working gwinGetVisible() and gwinGetEnabled()

This commit is contained in:
Joel Bodenmann 2014-01-04 15:51:18 +01:00
parent 12a7d7957b
commit bad22f5fee
2 changed files with 19 additions and 7 deletions

View File

@ -50,9 +50,9 @@ typedef struct GWindowObject {
font_t font; // @< The current font font_t font; // @< The current font
#endif #endif
#if GWIN_NEED_HIERARCHY #if GWIN_NEED_HIERARCHY
GHandle *parent; // @< The pointer to the parent (or NULL) GHandle parent; // @< The parent widget
GHandle *sibling; // @< The pointer to a widgets brother GHandle sibling; // @< The widget to its left (add right later as well)
GHandle *child; // @< The pointer to a widgets child GHandle child; // @< The child widget
#endif #endif
} GWindowObject, * GHandle; } GWindowObject, * GHandle;
/* @} */ /* @} */

View File

@ -219,7 +219,18 @@ void gwinSetVisible(GHandle gh, bool_t visible) {
} }
bool_t gwinGetVisible(GHandle gh) { bool_t gwinGetVisible(GHandle gh) {
#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; return (gh->flags & GWIN_FLG_VISIBLE) ? TRUE : FALSE;
#endif
} }
void gwinSetEnabled(GHandle gh, bool_t enabled) { void gwinSetEnabled(GHandle gh, bool_t enabled) {
@ -238,13 +249,14 @@ void gwinSetEnabled(GHandle gh, bool_t enabled) {
bool_t gwinGetEnabled(GHandle gh) { bool_t gwinGetEnabled(GHandle gh) {
#if GWIN_NEED_HIERARCHY #if GWIN_NEED_HIERARCHY
// return TRUE if all widgets (itself + parents) are enabled, false otherwise
GHandle e = gh; GHandle e = gh;
while (e) { while (e) {
if ( e->flags & GWIN_FLG_ENABLED); if (!(e->flags & GWIN_FLG_ENABLED))
return TRUE; return FALSE;
e = e->parent; e = e->parent;
}; };
return FALSE; return TRUE;
#else #else
return (gh->flags & GWIN_FLG_ENABLED) ? TRUE : FALSE; return (gh->flags & GWIN_FLG_ENABLED) ? TRUE : FALSE;
#endif #endif