Added gwinLabelSetAttribute()
This commit is contained in:
parent
8b4ca72036
commit
135f8f5eca
4 changed files with 71 additions and 4 deletions
|
@ -24,6 +24,7 @@ FEATURE: Support for ChibiOS/RT 3.x
|
||||||
FEATURE: Added gwinProgressbarStop() and gwinProgressbarReset()
|
FEATURE: Added gwinProgressbarStop() and gwinProgressbarReset()
|
||||||
FEATURE: Added generic ILI93xx driver by xlh1460
|
FEATURE: Added generic ILI93xx driver by xlh1460
|
||||||
FEATURE: Added gwinListEnableRender()
|
FEATURE: Added gwinListEnableRender()
|
||||||
|
FEATURE: Added gwinLabelSetAttribute()
|
||||||
|
|
||||||
|
|
||||||
*** changes after 1.9 ***
|
*** changes after 1.9 ***
|
||||||
|
|
|
@ -135,7 +135,9 @@
|
||||||
#define GWIN_NEED_GRAPH FALSE
|
#define GWIN_NEED_GRAPH FALSE
|
||||||
|
|
||||||
#define GWIN_NEED_WIDGET FALSE
|
#define GWIN_NEED_WIDGET FALSE
|
||||||
|
#define GWIN_NEED_HIERARCHY FALSE
|
||||||
#define GWIN_NEED_LABEL FALSE
|
#define GWIN_NEED_LABEL FALSE
|
||||||
|
#define GWIN_LABEL_ATTRIBUTE FALSE
|
||||||
#define GWIN_NEED_BUTTON FALSE
|
#define GWIN_NEED_BUTTON FALSE
|
||||||
#define GWIN_BUTTON_LAZY_RELEASE FALSE
|
#define GWIN_BUTTON_LAZY_RELEASE FALSE
|
||||||
#define GWIN_NEED_SLIDER FALSE
|
#define GWIN_NEED_SLIDER FALSE
|
||||||
|
@ -146,6 +148,7 @@
|
||||||
#define GWIN_NEED_LIST FALSE
|
#define GWIN_NEED_LIST FALSE
|
||||||
#define GWIN_NEED_LIST_IMAGES FALSE
|
#define GWIN_NEED_LIST_IMAGES FALSE
|
||||||
#define GWIN_NEED_PROGRESSBAR FALSE
|
#define GWIN_NEED_PROGRESSBAR FALSE
|
||||||
|
#define GWIN_NEED_FRAME FALSE
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
// macros to assist in data type conversions
|
// macros to assist in data type conversions
|
||||||
#define gh2obj ((GLabelObject *)gh)
|
#define gh2obj ((GLabelObject *)gh)
|
||||||
|
#define gw2obj ((GLabelObject *)gw)
|
||||||
|
|
||||||
// flags for the GLabelObject
|
// flags for the GLabelObject
|
||||||
#define GLABEL_FLG_WAUTO (GWIN_FIRST_CONTROL_FLAG << 0)
|
#define GLABEL_FLG_WAUTO (GWIN_FIRST_CONTROL_FLAG << 0)
|
||||||
|
@ -57,11 +58,27 @@ static void gwinLabelDefaultDraw(GWidgetObject *gw, void *param) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// render the text
|
#if GWIN_LABEL_ATTRIBUTE
|
||||||
|
if (gw2obj->attr != 0) {
|
||||||
|
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw2obj->attr, gw->g.font,
|
||||||
|
(gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background,
|
||||||
|
justifyLeft);
|
||||||
|
|
||||||
|
gdispGFillStringBox(gw->g.display, gw->g.x + gw2obj->tab, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font,
|
||||||
|
(gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background,
|
||||||
|
justifyLeft);
|
||||||
|
} else {
|
||||||
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font,
|
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font,
|
||||||
(gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background,
|
(gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background,
|
||||||
justifyLeft);
|
justifyLeft);
|
||||||
|
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font,
|
||||||
|
(gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background,
|
||||||
|
justifyLeft);
|
||||||
|
#endif
|
||||||
|
|
||||||
// render the border (if any)
|
// render the border (if any)
|
||||||
if (gw->g.flags & GLABEL_FLG_BORDER)
|
if (gw->g.flags & GLABEL_FLG_BORDER)
|
||||||
gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, (gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.edge : gw->pstyle->disabled.edge);
|
gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, (gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.edge : gw->pstyle->disabled.edge);
|
||||||
|
@ -124,6 +141,11 @@ GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit)
|
||||||
// no borders by default
|
// no borders by default
|
||||||
flags &=~ GLABEL_FLG_BORDER;
|
flags &=~ GLABEL_FLG_BORDER;
|
||||||
|
|
||||||
|
#if GWIN_LABEL_ATTRIBUTE
|
||||||
|
widget->tab = 0;
|
||||||
|
widget->attr = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
widget->w.g.flags |= flags;
|
widget->w.g.flags |= flags;
|
||||||
gwinSetVisible(&widget->w.g, pInit->g.show);
|
gwinSetVisible(&widget->w.g, pInit->g.show);
|
||||||
|
|
||||||
|
@ -141,6 +163,19 @@ void gwinLabelSetBorder(GHandle gh, bool_t border) {
|
||||||
gh2obj->w.g.flags &=~ GLABEL_FLG_BORDER;
|
gh2obj->w.g.flags &=~ GLABEL_FLG_BORDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GWIN_LABEL_ATTRIBUTE
|
||||||
|
void gwinLabelSetAttribute(GHandle gh, coord_t tab, char* attr) {
|
||||||
|
// is it a valid handle?
|
||||||
|
if (gh->vmt != (gwinVMT *)&labelVMT)
|
||||||
|
return;
|
||||||
|
|
||||||
|
gh2obj->tab = tab;
|
||||||
|
gh2obj->attr = attr;
|
||||||
|
|
||||||
|
gwinRedraw(gh);
|
||||||
|
}
|
||||||
|
#endif // GWIN_LABEL_ATTRIBUTE
|
||||||
|
|
||||||
#endif // GFX_USE_GWIN && GFX_NEED_LABEL
|
#endif // GFX_USE_GWIN && GFX_NEED_LABEL
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,11 @@
|
||||||
// An label window
|
// An label window
|
||||||
typedef struct GLabelObject {
|
typedef struct GLabelObject {
|
||||||
GWidgetObject w;
|
GWidgetObject w;
|
||||||
|
|
||||||
|
#if GWIN_LABEL_ATTRIBUTE
|
||||||
|
coord_t tab;
|
||||||
|
char* attr;
|
||||||
|
#endif
|
||||||
} GLabelObject;
|
} GLabelObject;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -63,6 +68,29 @@ GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit);
|
||||||
*/
|
*/
|
||||||
void gwinLabelSetBorder(GHandle gh, bool_t border);
|
void gwinLabelSetBorder(GHandle gh, bool_t border);
|
||||||
|
|
||||||
|
#if GWIN_LABEL_ATTRIBUTE
|
||||||
|
/**
|
||||||
|
* @brief Add an attribute in front of the actualy label text
|
||||||
|
* @detail Often you want to display a text like this:
|
||||||
|
* Current IP: 192.168.1.42
|
||||||
|
* In that case, one the actual IP will be variable, the text in front of it
|
||||||
|
* always remains the same. The static text is called the attribute and can be
|
||||||
|
* set using this function.
|
||||||
|
* Furthermore, the tab can be set in order to vertically align multiple labels.
|
||||||
|
* Please check out the website for further explanation, illustraions and usage
|
||||||
|
* examples.
|
||||||
|
*
|
||||||
|
* @note The attribute text is currently not being allocated
|
||||||
|
*
|
||||||
|
* @param[in] gh The widget handle (must be a label handle)
|
||||||
|
* @param[in] tab The distance of the label text from the left widget edge
|
||||||
|
* @param[in] attr The attribute to be displayed
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
void gwinLabelSetAttribute(GHandle gh, coord_t tab, char* attr);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue