aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/gwin/gwin.h13
-rw-r--r--src/gwin/checkbox.c32
-rw-r--r--src/gwin/gwin.c30
3 files changed, 20 insertions, 55 deletions
diff --git a/include/gwin/gwin.h b/include/gwin/gwin.h
index 9d3d1dbc..ded401d0 100644
--- a/include/gwin/gwin.h
+++ b/include/gwin/gwin.h
@@ -42,7 +42,7 @@ typedef struct GWindowObject {
#endif
const struct gwinVMT *vmt; // @< The VMT for this GWIN
GDisplay * display; // @< The display this window is on.
- coord_t x, y; // @< Screen relative position
+ coord_t x, y; // @< Position relative to parent
coord_t width, height; // @< Dimensions of this window
color_t color, bgcolor; // @< The current drawing colors
uint16_t flags; // @< Window flags (the meaning is private to the GWIN class)
@@ -337,17 +337,6 @@ extern "C" {
bool_t gwinGetEnabled(GHandle gh);
/**
- * @brief Get absolute coordinates of a window
- *
- * @param[in] gh The window
- * @param[out] x The absolut x coordinate
- * @param[out] y The absolut y coordinate
- *
- * @api
- */
- void gwinGetAbsoluteCoordinates(GHandle gh, coord_t *x, coord_t *y);
-
- /**
* @brief Move a window
*
* @param[in] gh The window
diff --git a/src/gwin/checkbox.c b/src/gwin/checkbox.c
index 4e487196..13730d50 100644
--- a/src/gwin/checkbox.c
+++ b/src/gwin/checkbox.c
@@ -153,52 +153,44 @@ static const GColorSet *getDrawColors(GWidgetObject *gw) {
void gwinCheckboxDraw_CheckOnLeft(GWidgetObject *gw, void *param) {
#define gcw ((GCheckboxObject *)gw)
- coord_t ld, df, abs_x, abs_y;
+ coord_t ld, df;
const GColorSet * pcol;
(void) param;
- if (gw->g.vmt != (gwinVMT *)&checkboxVMT)
- return;
-
- gwinGetAbsoluteCoordinates((GHandle)gw, &abs_x, &abs_y);
-
+ if (gw->g.vmt != (gwinVMT *)&checkboxVMT) return;
pcol = getDrawColors(gw);
ld = gw->g.width < gw->g.height ? gw->g.width : gw->g.height;
- gdispGFillArea(gw->g.display, abs_x+1, abs_y+1, ld, ld-2, gw->pstyle->background);
- gdispGDrawBox(gw->g.display, abs_x, abs_y, ld, ld, pcol->edge);
+ 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);
df = ld < 4 ? 1 : 2;
if (gw->g.flags & GCHECKBOX_FLG_CHECKED)
- gdispGFillArea(gw->g.display, abs_x+df, abs_y+df, ld-2*df, ld-2*df, pcol->fill);
+ gdispGFillArea(gw->g.display, gw->g.x+df, gw->g.y+df, ld-2*df, ld-2*df, pcol->fill);
- gdispGFillStringBox(gw->g.display, abs_x+ld+1, abs_y, gw->g.width-ld-1, gw->g.height, gw->text, gw->g.font, pcol->text, gw->pstyle->background, justifyLeft);
+ 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
}
void gwinCheckboxDraw_CheckOnRight(GWidgetObject *gw, void *param) {
#define gcw ((GCheckboxObject *)gw)
- coord_t ep, ld, df, abs_x, abs_y;
+ coord_t ep, ld, df;
const GColorSet * pcol;
(void) param;
- if (gw->g.vmt != (gwinVMT *)&checkboxVMT)
- return;
-
- gwinGetAbsoluteCoordinates((GHandle)gw, &abs_x, &abs_y);
-
+ if (gw->g.vmt != (gwinVMT *)&checkboxVMT) return;
pcol = getDrawColors(gw);
ld = gw->g.width < gw->g.height ? gw->g.width : gw->g.height;
ep = gw->g.width-ld-1;
- gdispGFillArea(gw->g.display, abs_x+ep-1, abs_y+1, ld, ld-2, gw->pstyle->background);
- gdispGDrawBox(gw->g.display, abs_x+ep, abs_y, ld, ld, pcol->edge);
+ 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);
df = ld < 4 ? 1 : 2;
if (gw->g.flags & GCHECKBOX_FLG_CHECKED)
- gdispGFillArea(gw->g.display, abs_x+ep+df, abs_y+df, ld-2*df, ld-2*df, pcol->fill);
+ gdispGFillArea(gw->g.display, gw->g.x+ep+df, gw->g.y+df, ld-2*df, ld-2*df, pcol->fill);
- gdispGFillStringBox(gw->g.display, abs_x, abs_y, ep-1, gw->g.height, gw->text, gw->g.font, pcol->text, gw->pstyle->background, justifyRight);
+ 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
}
diff --git a/src/gwin/gwin.c b/src/gwin/gwin.c
index 27f893a8..79a52a62 100644
--- a/src/gwin/gwin.c
+++ b/src/gwin/gwin.c
@@ -274,22 +274,6 @@ bool_t gwinGetEnabled(GHandle gh) {
#endif
}
-void gwinGetAbsoluteCoordinates(GHandle gh, coord_t *x, coord_t *y) {
- #if GWIN_NEED_HIERARCHY
- GHandle tmp;
-
- // sum up all relative coordinates up to the root parent
- for (*x = 0, *y = 0, tmp = gh; tmp; tmp = tmp->parent) {
- *x += tmp->x;
- *y += tmp->y;
- }
-
- #else
- *x = gh->x;
- *y = gh->y;
- #endif
-}
-
void gwinMove(GHandle gh, coord_t x, coord_t y) {
_gwm_redim(gh, x, y, gh->width, gh->height);
}
@@ -335,14 +319,14 @@ void gwinRedraw(GHandle gh) {
parent->child = child;
}
- #if GDISP_NEED_CLIP
- gdispGSetClip(child->display, child->x, child->y, child->width, child->height);
- #endif
- gdispGFillArea(child->display, child->x, child->y, child->width, child->height, child->bgcolor);
- #if GDISP_NEED_CLIP
- gdispGUnsetClip(child->display);
- #endif
+ // clear the area of the current child position as it will be moved
+ gwinClear(child);
+
+ // window coordinates until now are relative, make them absolute now.
+ child->x += parent->x;
+ child->y += parent->y;
+ // redraw the window
gwinClear(parent);
gwinRedraw(parent);
}