Migrated darwin/box.m.

This commit is contained in:
Pietro Gagliardi 2016-04-25 12:35:01 -04:00
parent 6e584f26d3
commit f0ca2dcee5
2 changed files with 23 additions and 21 deletions

View File

@ -23,14 +23,6 @@ struct uiBox {
NSLayoutConstraintOrientation secondaryOrientation; NSLayoutConstraintOrientation secondaryOrientation;
}; };
static void onDestroy(uiBox *);
uiDarwinDefineControlWithOnDestroy(
uiBox, // type name
view, // handle
onDestroy(this); // on destroy
)
static uiControl *childAt(uiBox *b, uintmax_t n) static uiControl *childAt(uiBox *b, uintmax_t n)
{ {
NSValue *v; NSValue *v;
@ -39,8 +31,9 @@ static uiControl *childAt(uiBox *b, uintmax_t n)
return (uiControl *) [v pointerValue]; return (uiControl *) [v pointerValue];
} }
static void onDestroy(uiBox *b) static void uiBoxDestroy(uiControl *c)
{ {
uiBox *b = uiBox(c);
uintmax_t i; uintmax_t i;
uiControl *child; uiControl *child;
NSView *childView; NSView *childView;
@ -57,9 +50,22 @@ static void onDestroy(uiBox *b)
[b->noStretchyView release]; [b->noStretchyView release];
[b->children release]; [b->children release];
[b->stretchy release]; [b->stretchy release];
[b->view release];
uiFreeControl(uiControl(b));
} }
static void boxContainerUpdateState(uiControl *c) uiDarwinControlDefaultHandle(uiBox, view)
uiDarwinControlDefaultParent(uiBox, view)
uiDarwinControlDefaultSetParent(uiBox, view)
uiDarwinControlDefaultToplevel(uiBox, view)
uiDarwinControlDefaultVisible(uiBox, view)
uiDarwinControlDefaultShow(uiBox, view)
uiDarwinControlDefaultHide(uiBox, view)
uiDarwinControlDefaultEnabled(uiBox, view)
uiDarwinControlDefaultEnable(uiBox, view)
uiDarwinControlDefaultDisable(uiBox, view)
static void uiBoxSyncEnableState(uiControl *c, int enabled)
{ {
uiBox *b = uiBox(c); uiBox *b = uiBox(c);
NSUInteger i; NSUInteger i;
@ -71,10 +77,12 @@ static void boxContainerUpdateState(uiControl *c)
v = (NSValue *) [b->children objectAtIndex:i]; v = (NSValue *) [b->children objectAtIndex:i];
// TODO change all these other instances of casts to conversions // TODO change all these other instances of casts to conversions
child = uiControl([v pointerValue]); child = uiControl([v pointerValue]);
controlUpdateState(child); uiControlSyncEnableState(child, enabled);
} }
} }
uiDarwinControlDefaultSetSuperview(uiBox, view)
static NSString *viewName(uintmax_t n) static NSString *viewName(uintmax_t n)
{ {
return [NSString stringWithFormat:@"view%ju", n]; return [NSString stringWithFormat:@"view%ju", n];
@ -211,11 +219,6 @@ static void relayout(uiBox *b)
[views release]; [views release];
} }
static void boxRelayout(uiDarwinControl *c)
{
relayout(uiBox(c));
}
void uiBoxAppend(uiBox *b, uiControl *c, int stretchy) void uiBoxAppend(uiBox *b, uiControl *c, int stretchy)
{ {
NSView *childView; NSView *childView;
@ -272,7 +275,7 @@ static uiBox *finishNewBox(BOOL vertical)
{ {
uiBox *b; uiBox *b;
b = (uiBox *) uiNewControl(uiBox); uiDarwinNewControl(uiBox, b);
b->view = [[NSView alloc] initWithFrame:NSZeroRect]; b->view = [[NSView alloc] initWithFrame:NSZeroRect];
@ -297,10 +300,6 @@ static uiBox *finishNewBox(BOOL vertical)
setHuggingPri(b->noStretchyView, NSLayoutPriorityDefaultLow, NSLayoutConstraintOrientationHorizontal); setHuggingPri(b->noStretchyView, NSLayoutPriorityDefaultLow, NSLayoutConstraintOrientationHorizontal);
setHuggingPri(b->noStretchyView, NSLayoutPriorityDefaultLow, NSLayoutConstraintOrientationVertical); setHuggingPri(b->noStretchyView, NSLayoutPriorityDefaultLow, NSLayoutConstraintOrientationVertical);
uiDarwinFinishNewControl(b, uiBox);
uiControl(b)->ContainerUpdateState = boxContainerUpdateState;
uiDarwinControl(b)->Relayout = boxRelayout;
return b; return b;
} }

View File

@ -85,6 +85,9 @@ static void uiWindowDestroy(uiControl *c)
uiControlDestroy(w->child); uiControlDestroy(w->child);
} }
[windowDelegate unregisterWindow:w]; [windowDelegate unregisterWindow:w];
// TODO make sure this next line is right
[w->window release];
uiFreeControl(uiControl(w));
} }
uiDarwinControlDefaultHandle(uiWindow, window) uiDarwinControlDefaultHandle(uiWindow, window)