wip
This commit is contained in:
parent
931c465265
commit
ad57ab7967
2 changed files with 45 additions and 6 deletions
|
@ -19,7 +19,7 @@
|
||||||
* @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
|
* @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
|
||||||
* @pre GDISP_NEED_TEXT must be set to TRUE in your gfxconf.h
|
* @pre GDISP_NEED_TEXT must be set to TRUE in your gfxconf.h
|
||||||
* @pre GWIN_NEED_LABEL must be set to TRUE in your gfxconf.h
|
* @pre GWIN_NEED_LABEL must be set to TRUE in your gfxconf.h
|
||||||
* @pre The font you want to use must be enabled in your gfxconf.h
|
* @pre The fonts you want to use must be enabled in your gfxconf.h
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
@ -33,17 +33,29 @@
|
||||||
typedef struct GLabelWidget_t {
|
typedef struct GLabelWidget_t {
|
||||||
GWindowObject g;
|
GWindowObject g;
|
||||||
|
|
||||||
char* text;
|
const char* text;
|
||||||
} GLabelWidget;
|
} GLabelWidget;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create a label widget.
|
||||||
|
* @details A label widget is a simple window which has a static text.
|
||||||
|
*
|
||||||
|
* @param[in] widget The label structure to initialise. If this is NULL, the structure is dynamically allocated.
|
||||||
|
* @param[in] pinit The initialisation parameters to use.
|
||||||
|
*
|
||||||
|
* @return NULL if there is no resultat drawing area, otherwise the widget handle.
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
GHandle gwinLabelCreate(GLabelWidget *widget, GWindowInit *pInit);
|
GHandle gwinLabelCreate(GLabelWidget *widget, GWindowInit *pInit);
|
||||||
void gwinLabelSetColor(GHandle gh, color_t color);
|
void gwinLabelSetColor(GHandle gh, color_t color);
|
||||||
void gwinLabelSetBgColor(GHandle gh, color_t bgColor);
|
void gwinLabelSetBgColor(GHandle gh, color_t bgColor);
|
||||||
void gwinLabelSetText(GHandle gh, char* text);
|
void gwinLabelSetFont(GHandle gh, font_t font);
|
||||||
|
void gwinLabelSetText(GHandle gh, const char* text);
|
||||||
void gwinLabelDraw(GHandle gh);
|
void gwinLabelDraw(GHandle gh);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -41,8 +41,25 @@ static void _afterClear(GWindowObject *gh) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GHandle gwinLabelCreate(GLabelWidget *widget, GWindowInit *pInit) {
|
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
|
||||||
|
};
|
||||||
|
|
||||||
|
GHandle gwinLabelCreate(GLabelWidget *widget, GWindowInit *pInit) {
|
||||||
|
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);
|
||||||
|
|
||||||
|
return (GHandle)widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gwinLabelSetColor(GHandle gh, color_t color) {
|
void gwinLabelSetColor(GHandle gh, color_t color) {
|
||||||
|
@ -53,14 +70,24 @@ void gwinLabelSetBgColor(GHandle gh, color_t bgColor) {
|
||||||
widget(gh)->g.bgcolor = bgColor;
|
widget(gh)->g.bgcolor = bgColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gwinLabelSetText(GHandle gh, char* text) {
|
void gwinLabelSetFont(GHandle gh, font_t font) {
|
||||||
|
widget(gh)->g.font = font;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gwinLabelSetText(GHandle gh, const char* text) {
|
||||||
widget(gh)->text = text;
|
widget(gh)->text = text;
|
||||||
|
|
||||||
gwinLabelDraw(gh);
|
gwinLabelDraw(gh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gwinLabelDraw(GHandle gh) {
|
void gwinLabelDraw(GHandle gh) {
|
||||||
|
gdispFillString( widget(gh)->g.x,
|
||||||
|
widget(gh)->g.y,
|
||||||
|
widget(gh)->text,
|
||||||
|
widget(gh)->g.font,
|
||||||
|
widget(gh)->g.color,
|
||||||
|
widget(gh)->g.bgcolor
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // GFX_USE_GWIN && GFX_NEED_LABEL
|
#endif // GFX_USE_GWIN && GFX_NEED_LABEL
|
||||||
|
|
Loading…
Add table
Reference in a new issue