ugfx/src/gwin/label.c

95 lines
1.8 KiB
C
Raw Normal View History

2013-07-01 17:53:58 +00:00
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://chibios-gfx.com/license.html
*/
/**
* @file include/gwin/label.h
* @brief GWIN label widget header file.
*
* @defgroup Label Label
* @ingroup GWIN
*
* @{
*/
#include "gfx.h"
#if GFX_USE_GWIN && GWIN_NEED_LABEL
#include "gwin/class_gwin.h"
#define widget(gh) ((GLabelWidget*)gh)
static void _destroy(GWindowObject *gh) {
(void)gh;
return;
}
static void _redraw(GWindowObject *gh) {
(void)gh;
return;
}
static void _afterClear(GWindowObject *gh) {
(void)gh;
return;
}
2013-07-02 06:29:38 +00:00
static const gwinVMT labelVMT = {
"Label", // The class name
sizeof(GLabelWidget), // The object size
_destroy, // The destroy routine
0, // The redraw routine
_afterClear // The after-clear routine
};
2013-07-01 17:53:58 +00:00
GHandle gwinLabelCreate(GLabelWidget *widget, GWindowInit *pInit) {
2013-07-02 06:29:38 +00:00
if (!(widget = (GLabelWidget *)_gwindowCreate(&widget->g, pInit, &labelVMT, 0)))
return 0;
widget->g.x = pInit->x;
widget->g.y = pInit->y;
widget->g.width = pInit->width;
widget->g.height = pInit->height;
gwinSetVisible((GHandle)widget, pInit->show);
2013-07-01 17:53:58 +00:00
2013-07-02 06:29:38 +00:00
return (GHandle)widget;
2013-07-01 17:53:58 +00:00
}
void gwinLabelSetColor(GHandle gh, color_t color) {
widget(gh)->g.color = color;
}
void gwinLabelSetBgColor(GHandle gh, color_t bgColor) {
widget(gh)->g.bgcolor = bgColor;
}
2013-07-02 06:29:38 +00:00
void gwinLabelSetFont(GHandle gh, font_t font) {
widget(gh)->g.font = font;
}
void gwinLabelSetText(GHandle gh, const char* text) {
2013-07-01 17:53:58 +00:00
widget(gh)->text = text;
gwinLabelDraw(gh);
}
void gwinLabelDraw(GHandle gh) {
2013-07-02 06:29:38 +00:00
gdispFillString( widget(gh)->g.x,
widget(gh)->g.y,
widget(gh)->text,
widget(gh)->g.font,
widget(gh)->g.color,
widget(gh)->g.bgcolor
);
2013-07-01 17:53:58 +00:00
}
#endif // GFX_USE_GWIN && GFX_NEED_LABEL