From 16ebf86013db7d9b3f15ee2338734795c9e83bdf Mon Sep 17 00:00:00 2001 From: inmarket Date: Tue, 16 Dec 2014 23:01:55 +1000 Subject: Fix 1 pixel display error in checkbox for text on left rendering. Also add better comments to code. --- src/gwin/gwin_checkbox.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/gwin') diff --git a/src/gwin/gwin_checkbox.c b/src/gwin/gwin_checkbox.c index dec085c3..72d8dbdf 100644 --- a/src/gwin/gwin_checkbox.c +++ b/src/gwin/gwin_checkbox.c @@ -158,14 +158,19 @@ void gwinCheckboxDraw_CheckOnLeft(GWidgetObject *gw, void *param) { if (gw->g.vmt != (gwinVMT *)&checkboxVMT) return; pcol = getDrawColors(gw); + // Get the dimension of the check box (sans text) ld = gw->g.width < gw->g.height ? gw->g.width : gw->g.height; + + // Draw the empty check box gdispGFillArea(gw->g.display, gw->g.x+1, gw->g.y+1, ld, ld-2, gw->pstyle->background); gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, ld, ld, pcol->edge); + // Draw the check df = ld < 4 ? 1 : 2; if (gw->g.flags & GCHECKBOX_FLG_CHECKED) gdispGFillArea(gw->g.display, gw->g.x+df, gw->g.y+df, ld-2*df, ld-2*df, pcol->fill); + // Draw the text gdispGFillStringBox(gw->g.display, gw->g.x+ld+1, gw->g.y, gw->g.width-ld-1, gw->g.height, gw->text, gw->g.font, pcol->text, gw->pstyle->background, justifyLeft); #undef gcw } @@ -179,15 +184,22 @@ void gwinCheckboxDraw_CheckOnRight(GWidgetObject *gw, void *param) { if (gw->g.vmt != (gwinVMT *)&checkboxVMT) return; pcol = getDrawColors(gw); + // Get the dimension of the check box (sans text) ld = gw->g.width < gw->g.height ? gw->g.width : gw->g.height; - ep = gw->g.width-ld-1; + + // Get the position of the check box + ep = gw->g.width-ld; + + // Draw the empty check box gdispGFillArea(gw->g.display, gw->g.x+ep-1, gw->g.y+1, ld, ld-2, gw->pstyle->background); gdispGDrawBox(gw->g.display, gw->g.x+ep, gw->g.y, ld, ld, pcol->edge); + // Draw the check df = ld < 4 ? 1 : 2; if (gw->g.flags & GCHECKBOX_FLG_CHECKED) gdispGFillArea(gw->g.display, gw->g.x+ep+df, gw->g.y+df, ld-2*df, ld-2*df, pcol->fill); + // Draw the text gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, ep-1, gw->g.height, gw->text, gw->g.font, pcol->text, gw->pstyle->background, justifyRight); #undef gcw } -- cgit v1.2.3