From f2e30548fc700239a71ce5ee6fce37245831f110 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 17 Aug 2015 17:27:27 -0400 Subject: [PATCH] Attempted to fill in uiGroup; also fixed uiUninit() bugs. --- redo/reredo/darwin/group.m | 33 ++++++++++++++++++++++++++------- redo/reredo/darwin/main.m | 1 + redo/reredo/darwin/tab.m | 1 + 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/redo/reredo/darwin/group.m b/redo/reredo/darwin/group.m index 7589336c..a9f522c4 100644 --- a/redo/reredo/darwin/group.m +++ b/redo/reredo/darwin/group.m @@ -8,13 +8,23 @@ struct uiGroup { int margined; }; +static void onDestroy(uiGroup *); + uiDarwinDefineControlWithOnDestroy( uiGroup, // type name uiGroupType, // type function box, // handle - /* TODO */; // on destroy + onDestroy(this); // on destroy ) +static void onDestroy(uiGroup *g) +{ + if (g->child != NULL) { + uiControlSetParent(g->child, NULL); + uiControlDestroy(g->child); + } +} + // TODO group container update char *uiGroupTitle(uiGroup *g) @@ -31,15 +41,20 @@ void uiGroupSetTitle(uiGroup *g, const char *text) void uiGroupSetChild(uiGroup *g, uiControl *child) { -/* TODO - if (g->child != NULL) + NSView *childView; + + if (g->child != NULL) { + childView = (NSView *) uiControlHandle(g->child); + [childView removeFromSuperview]; uiControlSetParent(g->child, NULL); + } g->child = child; if (g->child != NULL) { + childView = (NSView *) uiControlHandle(g->child); uiControlSetParent(g->child, uiControl(g)); -//TODO uiControlQueueResize(g->child); + [g->box addSubview:childView]; + layoutSingleView(g->box, childView, g->margined); } -*/ } int uiGroupMargined(uiGroup *g) @@ -49,9 +64,13 @@ int uiGroupMargined(uiGroup *g) void uiGroupSetMargined(uiGroup *g, int margined) { + NSView *childView; + g->margined = margined; - // TODO -//TODO uiControlQueueResize(uiControl(g)); + if (g->child != NULL) { + childView = (NSView *) uiControlHandle(g->child); + layoutSingleView(g->box, childView, g->margined); + } } uiGroup *uiNewGroup(const char *title) diff --git a/redo/reredo/darwin/main.m b/redo/reredo/darwin/main.m index 172e5844..b80dc9eb 100644 --- a/redo/reredo/darwin/main.m +++ b/redo/reredo/darwin/main.m @@ -91,6 +91,7 @@ void uiUninit(void) uninitMenus(); // TODO free application delegate // TODO free NSApplication resources (main menu, etc.) + uninitTypes(); uninitAlloc(); } diff --git a/redo/reredo/darwin/tab.m b/redo/reredo/darwin/tab.m index dfb59efa..31ba6f06 100644 --- a/redo/reredo/darwin/tab.m +++ b/redo/reredo/darwin/tab.m @@ -32,6 +32,7 @@ static void onDestroy(uiTab *t) uiControl *c; c = (uiControl *) [v pointerValue]; + uiControlSetParent(c, NULL); uiControlDestroy(c); }]; // and finally destroy ourselves