aboutsummaryrefslogtreecommitdiffstats
path: root/src/gwin
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-12-16 23:01:55 +1000
committerinmarket <andrewh@inmarket.com.au>2014-12-16 23:01:55 +1000
commit16ebf86013db7d9b3f15ee2338734795c9e83bdf (patch)
treebe1f294b45dd7e1f68b352724f608ad1adcdd60e /src/gwin
parentecc6201c7403225228242a3525d568f1d269f749 (diff)
downloaduGFX-16ebf86013db7d9b3f15ee2338734795c9e83bdf.tar.gz
uGFX-16ebf86013db7d9b3f15ee2338734795c9e83bdf.tar.bz2
uGFX-16ebf86013db7d9b3f15ee2338734795c9e83bdf.zip
Fix 1 pixel display error in checkbox for text on left rendering.
Also add better comments to code.
Diffstat (limited to 'src/gwin')
-rw-r--r--src/gwin/gwin_checkbox.c14
1 files changed, 13 insertions, 1 deletions
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
}