summaryrefslogtreecommitdiff
path: root/new/newcontrol_darwin.m
diff options
context:
space:
mode:
Diffstat (limited to 'new/newcontrol_darwin.m')
-rw-r--r--new/newcontrol_darwin.m17
1 files changed, 13 insertions, 4 deletions
diff --git a/new/newcontrol_darwin.m b/new/newcontrol_darwin.m
index 8b0bd48..77c23ca 100644
--- a/new/newcontrol_darwin.m
+++ b/new/newcontrol_darwin.m
@@ -13,6 +13,7 @@ struct uiSingleViewControl {
#define S(c) ((uiSingleViewControl *) (c))
+// TODO this will need to change if we want to provide removal
static void singleDestroy(uiControl *c)
{
[S(c)->view removeFromSuperview];
@@ -26,18 +27,25 @@ static uintptr_t singleHandle(uiControl *c)
static void singleSetParent(uiControl *c, uintptr_t parent)
{
uiSingleViewControl *s = S(c);
- uintptr_t oldparent;
NSView *parentView;
- oldparent = s->parent;
s->parent = parent;
parentView = (NSView *) (s->parent);
- // TODO will this change parents?
[parentView addSubview:s->immediate];
- updateParent(oldparent);
updateParent(s->parent);
}
+static void singleRemoveParent(uiControl *c)
+{
+ uiSingleViewControl *s = S(c);
+ uintptr_t oldparent;
+
+ oldparent = s->parent;
+ s->parent = 0;
+ [s->immediate removeFromSuperview];
+ updateParent(oldparent);
+}
+
// also good for NSBox and NSProgressIndicator
static uiSize singlePreferredSize(uiControl *c, uiSizing *d)
{
@@ -92,6 +100,7 @@ uiControl *uiDarwinNewControl(Class class, BOOL inScrollView, BOOL scrollViewHas
c->control.destroy = singleDestroy;
c->control.handle = singleHandle;
c->control.setParent = singleSetParent;
+ c->control.removeParent = singleRemoveParent;
c->control.preferredSize = singlePreferredSize;
c->control.resize = singleResize;