aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/gwin/gwin.h22
-rw-r--r--src/gwin/gwin.c25
2 files changed, 43 insertions, 4 deletions
diff --git a/include/gwin/gwin.h b/include/gwin/gwin.h
index e5eb2e0b..194173e0 100644
--- a/include/gwin/gwin.h
+++ b/include/gwin/gwin.h
@@ -396,6 +396,28 @@ extern "C" {
* @api
*/
void gwinAddChild(GHandle parent, GHandle child, bool_t last);
+
+ /**
+ * @brief Get first child of a widget
+ *
+ * @return The first child or NULL if the widget has no children
+ *
+ * @param[in] gh The parent widget
+ *
+ * @api
+ */
+ GHandle gwinGetFirstChild(GHandle gh);
+
+ /**
+ * @brief Get the next child of a widget
+ *
+ * @return The next child or NULL if no more childs
+ *
+ * @param[in] gh The parent widget
+ *
+ * @api
+ */
+ GHandle gwinGetNextChild(GHandle gh);
#endif
#if GWIN_NEED_WINDOWMANAGER || defined (__DOXYGEN__)
diff --git a/src/gwin/gwin.c b/src/gwin/gwin.c
index 5d3da7cb..f226294d 100644
--- a/src/gwin/gwin.c
+++ b/src/gwin/gwin.c
@@ -180,6 +180,15 @@ GHandle gwinGWindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pI
}
void gwinDestroy(GHandle gh) {
+ #if GWIN_NEED_HIERARCHY
+ // kill your children as long as you have any
+ while (gh->child) {
+ GHandle tmp = gh->child;
+ gh->child = gh->child->sibling;
+ gwinDestroy(tmp);
+ }
+ #endif
+
// Make the window invisible
gwinSetVisible(gh, FALSE);
@@ -285,12 +294,12 @@ void gwinRedraw(GHandle gh) {
child->sibling = NULL;
child->child = NULL;
- if(!parent)
+ if (!parent)
return;
- if(last && parent->child) {
+ if (last && parent->child) {
GHandle s = parent->child;
- while(s->sibling)
+ while (s->sibling)
s = s->sibling;
s->sibling = child;
} else {
@@ -298,12 +307,20 @@ void gwinRedraw(GHandle gh) {
parent->child = child;
}
}
+
+ GHandle gwinGetFirstChild(GHandle gh) {
+ return gh->child;
+ }
+
+ GHandle gwinGetNextChild(GHandle gh) {
+ return gh->sibling;
+ }
#endif
void gwinClear(GHandle gh) {
/*
* Don't render anything when the window is not visible but
- * still call the AfterClear() routine as some widgets will
+ * still call return gh->child->sibling;the AfterClear() routine as some widgets will
* need this to clear internal buffers or similar
*/
if (!((gh->flags & GWIN_FLG_VISIBLE))) {