aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@seriouslyembedded.com>2015-11-06 22:47:42 +0100
committerJoel Bodenmann <joel@seriouslyembedded.com>2015-11-06 22:47:42 +0100
commite8a769c3823eef72a9e064d3bf992152ed261ad2 (patch)
tree4372d4c8dfee34bca27e691906a46a713479fcb3 /src
parentc2b7e1bd4176795c83c4c6edb5ee94705ef27712 (diff)
downloaduGFX-e8a769c3823eef72a9e064d3bf992152ed261ad2.tar.gz
uGFX-e8a769c3823eef72a9e064d3bf992152ed261ad2.tar.bz2
uGFX-e8a769c3823eef72a9e064d3bf992152ed261ad2.zip
Adding justification parameter to gwinLabelCreate()
Diffstat (limited to 'src')
-rw-r--r--src/gwin/gwin_label.c17
-rw-r--r--src/gwin/gwin_label.h7
2 files changed, 15 insertions, 9 deletions
diff --git a/src/gwin/gwin_label.c b/src/gwin/gwin_label.c
index 9b62679f..c8a9a0f0 100644
--- a/src/gwin/gwin_label.c
+++ b/src/gwin/gwin_label.c
@@ -80,7 +80,7 @@ static const gwidgetVMT labelVMT = {
#endif
};
-GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit) {
+GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit, justify_t justify) {
uint16_t flags = 0;
// auto assign width
@@ -89,7 +89,7 @@ GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit)
flags |= GLABEL_FLG_WAUTO;
pInit->g.width = getwidth(pInit->text, gwinGetDefaultFont(), gdispGGetWidth(g) - pInit->g.x);
}
-
+
// auto assign height
if (pInit->g.height <= 0) {
flags |= GLABEL_FLG_HAUTO;
@@ -99,6 +99,8 @@ GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit)
if (!(widget = (GLabelObject *)_gwidgetCreate(g, &widget->w, pInit, &labelVMT)))
return 0;
+ widget->justify = justify;
+
#if GWIN_LABEL_ATTRIBUTE
widget->tab = 0;
widget->attr = 0;
@@ -163,12 +165,13 @@ void gwinLabelDefaultDraw(GWidgetObject *gw, void *param) {
#if GWIN_LABEL_ATTRIBUTE
if (gw2obj->attr) {
- gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw2obj->tab, h, gw2obj->attr, gw->g.font, c, gw->pstyle->background, justifyLeft);
- gdispGFillStringBox(gw->g.display, gw->g.x + gw2obj->tab, gw->g.y, w-gw2obj->tab, h, gw->text, gw->g.font, c, gw->pstyle->background, justifyLeft);
- } else
- gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, w, h, gw->text, gw->g.font, c, gw->pstyle->background, justifyLeft);
+ gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw2obj->tab, h, gw2obj->attr, gw->g.font, c, gw->pstyle->background, gw2obj->justify);
+ gdispGFillStringBox(gw->g.display, gw->g.x + gw2obj->tab, gw->g.y, w-gw2obj->tab, h, gw->text, gw->g.font, c, gw->pstyle->background, gw2obj->justify);
+ } else {
+ gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, w, h, gw->text, gw->g.font, c, gw->pstyle->background, gw2obj->justify);
+ }
#else
- gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, w, h, gw->text, gw->g.font, c, gw->pstyle->background, justifyLeft);
+ gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, w, h, gw->text, gw->g.font, c, gw->pstyle->background, gw2obj->justify);
#endif
// render the border (if any)
diff --git a/src/gwin/gwin_label.h b/src/gwin/gwin_label.h
index 84836bf2..8c7c9fd5 100644
--- a/src/gwin/gwin_label.h
+++ b/src/gwin/gwin_label.h
@@ -38,6 +38,8 @@
typedef struct GLabelObject {
GWidgetObject w;
+ justify_t justify;
+
#if GWIN_LABEL_ATTRIBUTE
coord_t tab;
const char* attr;
@@ -55,13 +57,14 @@ extern "C" {
* @param[in] g The GDisplay to display this window on
* @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.
+ * @param[in] justify The justification.
*
* @return NULL if there is no resultat drawing area, otherwise the widget handle.
*
* @api
*/
-GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit);
-#define gwinLabelCreate(w, pInit) gwinGLabelCreate(GDISP, w, pInit)
+GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit, justify_t justify);
+#define gwinLabelCreate(w, pInit, justify) gwinGLabelCreate(GDISP, w, pInit, justify)
/**
* @brief Border settings for the default rendering routine