Fixing textedit widget rendering

ugfx_release_2.6
Joel Bodenmann 2015-12-19 00:51:18 +01:00
parent 1e77535317
commit a1c81e3449
1 changed files with 14 additions and 10 deletions

View File

@ -221,9 +221,10 @@ GHandle gwinGTexteditCreate(GDisplay* g, GTexteditObject* wt, GWidgetInit* pInit
void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param) void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param)
{ {
const char *p; const char* p;
coord_t cpos, tpos; coord_t cpos, tpos;
color_t ccol, tcol; const GColorSet* pcol;
(void)param; (void)param;
// Is it a valid handle? // Is it a valid handle?
@ -231,8 +232,10 @@ void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param)
return; return;
// Retrieve colors // Retrieve colors
tcol = (gw->g.flags & GWIN_FLG_SYSENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text; if ((gw->g.flags & GWIN_FLG_SYSENABLED))
ccol = (gw->g.flags & GWIN_FLG_SYSENABLED) ? gw->pstyle->enabled.edge : gw->pstyle->disabled.edge; pcol = &gw->pstyle->enabled;
else
pcol = &gw->pstyle->disabled;
// Adjust the text position so the cursor fits in the window // Adjust the text position so the cursor fits in the window
p = gw->text; p = gw->text;
@ -248,9 +251,9 @@ void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param)
// Render background and string // Render background and string
#if TEXT_PADDING_LEFT #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 #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) // Render cursor (if focused)
if (gwinGetFocus() == (GHandle)gw) { if (gwinGetFocus() == (GHandle)gw) {
@ -259,14 +262,15 @@ void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param)
// Draw cursor // Draw cursor
tpos += gw->g.x + CURSOR_PADDING_LEFT + TEXT_PADDING_LEFT + gdispGetFontMetric(gw->g.font, fontBaselineX)/2; 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; 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 // 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 // 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);
} }