From bad22f5feea49a7417237aa70e2f6b9e349d91c2 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sat, 4 Jan 2014 15:51:18 +0100 Subject: [PATCH] working gwinGetVisible() and gwinGetEnabled() --- include/gwin/gwin.h | 6 +++--- src/gwin/gwin.c | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/include/gwin/gwin.h b/include/gwin/gwin.h index b9d4f966..e5eb2e0b 100644 --- a/include/gwin/gwin.h +++ b/include/gwin/gwin.h @@ -50,9 +50,9 @@ typedef struct GWindowObject { font_t font; // @< The current font #endif #if GWIN_NEED_HIERARCHY - GHandle *parent; // @< The pointer to the parent (or NULL) - GHandle *sibling; // @< The pointer to a widgets brother - GHandle *child; // @< The pointer to a widgets child + GHandle parent; // @< The parent widget + GHandle sibling; // @< The widget to its left (add right later as well) + GHandle child; // @< The child widget #endif } GWindowObject, * GHandle; /* @} */ diff --git a/src/gwin/gwin.c b/src/gwin/gwin.c index 057fd6e0..6d47f3b5 100644 --- a/src/gwin/gwin.c +++ b/src/gwin/gwin.c @@ -219,7 +219,18 @@ void gwinSetVisible(GHandle gh, bool_t visible) { } bool_t gwinGetVisible(GHandle gh) { - return (gh->flags & GWIN_FLG_VISIBLE) ? TRUE : FALSE; + #if GWIN_NEED_HIERARCHY + // return TRUE if all widgets (itself + parents) are visble, false otherwise + GHandle e = gh; + while (e) { + if (!(e->flags & GWIN_FLG_VISIBLE)) + return FALSE; + e = e->parent; + }; + return TRUE; + #else + return (gh->flags & GWIN_FLG_VISIBLE) ? TRUE : FALSE; + #endif } void gwinSetEnabled(GHandle gh, bool_t enabled) { @@ -238,13 +249,14 @@ void gwinSetEnabled(GHandle gh, bool_t enabled) { bool_t gwinGetEnabled(GHandle gh) { #if GWIN_NEED_HIERARCHY + // return TRUE if all widgets (itself + parents) are enabled, false otherwise GHandle e = gh; while (e) { - if ( e->flags & GWIN_FLG_ENABLED); - return TRUE; + if (!(e->flags & GWIN_FLG_ENABLED)) + return FALSE; e = e->parent; }; - return FALSE; + return TRUE; #else return (gh->flags & GWIN_FLG_ENABLED) ? TRUE : FALSE; #endif