From 3a6dd294de7a41988aca7d396a9dae5e2042bc26 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sat, 4 Jan 2014 21:10:10 +0100 Subject: gwinDestroy(), gwinGetFirstChild() and gwinGetNextChild() --- src/gwin/gwin.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/gwin/gwin.c') 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))) { -- cgit v1.2.3