aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@seriouslyembedded.com>2015-12-19 00:51:18 +0100
committerJoel Bodenmann <joel@seriouslyembedded.com>2015-12-19 00:51:18 +0100
commita1c81e3449d95d7e1723f4ee9d900c1b3937cfff (patch)
tree0961e7b23624223810bfe00a63369fb9e7308f38
parent1e775353178984af3172d7d2b58a31761596dcae (diff)
downloaduGFX-a1c81e3449d95d7e1723f4ee9d900c1b3937cfff.tar.gz
uGFX-a1c81e3449d95d7e1723f4ee9d900c1b3937cfff.tar.bz2
uGFX-a1c81e3449d95d7e1723f4ee9d900c1b3937cfff.zip
Fixing textedit widget rendering
-rw-r--r--src/gwin/gwin_textedit.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/gwin/gwin_textedit.c b/src/gwin/gwin_textedit.c
index 8c60ddd2..2dbe58bc 100644
--- a/src/gwin/gwin_textedit.c
+++ b/src/gwin/gwin_textedit.c
@@ -221,9 +221,10 @@ GHandle gwinGTexteditCreate(GDisplay* g, GTexteditObject* wt, GWidgetInit* pInit
void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param)
{
- const char *p;
- coord_t cpos, tpos;
- color_t ccol, tcol;
+ const char* p;
+ coord_t cpos, tpos;
+ const GColorSet* pcol;
+
(void)param;
// Is it a valid handle?
@@ -231,8 +232,10 @@ void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param)
return;
// Retrieve colors
- tcol = (gw->g.flags & GWIN_FLG_SYSENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text;
- ccol = (gw->g.flags & GWIN_FLG_SYSENABLED) ? gw->pstyle->enabled.edge : gw->pstyle->disabled.edge;
+ if ((gw->g.flags & GWIN_FLG_SYSENABLED))
+ pcol = &gw->pstyle->enabled;
+ else
+ pcol = &gw->pstyle->disabled;
// Adjust the text position so the cursor fits in the window
p = gw->text;
@@ -248,9 +251,9 @@ void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param)
// Render background and string
#if TEXT_PADDING_LEFT
- gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, TEXT_PADDING_LEFT, gw->g.height, gw->pstyle->background);
+ gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, TEXT_PADDING_LEFT, gw->g.height, pcol->fill);
#endif
- gdispGFillStringBox(gw->g.display, gw->g.x + TEXT_PADDING_LEFT, gw->g.y, gw->g.width-TEXT_PADDING_LEFT, gw->g.height, p, gw->g.font, tcol, gw->pstyle->background, justifyLeft);
+ gdispGFillStringBox(gw->g.display, gw->g.x + TEXT_PADDING_LEFT, gw->g.y, gw->g.width-TEXT_PADDING_LEFT, gw->g.height, p, gw->g.font, pcol->text, pcol->fill, justifyLeft);
// Render cursor (if focused)
if (gwinGetFocus() == (GHandle)gw) {
@@ -259,14 +262,15 @@ void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param)
// Draw cursor
tpos += gw->g.x + CURSOR_PADDING_LEFT + TEXT_PADDING_LEFT + gdispGetFontMetric(gw->g.font, fontBaselineX)/2;
cpos = (gw->g.height - gdispGetFontMetric(gw->g.font, fontHeight))/2 - CURSOR_EXTRA_HEIGHT;
- gdispGDrawLine(gw->g.display, tpos, gw->g.y + cpos, tpos, gw->g.y + gw->g.height - cpos, ccol);
+ gdispGDrawLine(gw->g.display, tpos, gw->g.y + cpos, tpos, gw->g.y + gw->g.height - cpos, pcol->edge);
}
// Render border
- gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, ccol);
+ gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, pcol->edge);
// Render highlighted border if focused
- _gwidgetDrawFocusRect(gw, 1, 1, gw->g.width-2, gw->g.height-2);
+ //_gwidgetDrawFocusRect(gw, 1, 1, gw->g.width-2, gw->g.height-2);
+ _gwidgetDrawFocusRect(gw, 0, 0, gw->g.width, gw->g.height);
}