Finished the new uiTab. That just leaves the new uiBox.
This commit is contained in:
parent
1f96ee9b54
commit
89425f0fa7
|
@ -23,6 +23,7 @@ static void uiGroupDestroy(uiControl *c)
|
||||||
removeConstraints(g);
|
removeConstraints(g);
|
||||||
if (g->child != NULL) {
|
if (g->child != NULL) {
|
||||||
uiControlSetParent(g->child, NULL);
|
uiControlSetParent(g->child, NULL);
|
||||||
|
uiDarwinControlSetSuperview(uiDarwinControl(g->child), nil);
|
||||||
uiControlDestroy(g->child);
|
uiControlDestroy(g->child);
|
||||||
}
|
}
|
||||||
[g->box release];
|
[g->box release];
|
||||||
|
@ -71,7 +72,7 @@ static void groupRelayout(uiGroup *g)
|
||||||
uiDarwinControlDefaultHugsTrailingEdge(uiGroup, box)
|
uiDarwinControlDefaultHugsTrailingEdge(uiGroup, box)
|
||||||
uiDarwinControlDefaultHugsBottom(uiGroup, box)
|
uiDarwinControlDefaultHugsBottom(uiGroup, box)
|
||||||
|
|
||||||
static void uiWindowChildEdgeHuggingChanged(uiDarwinControl *c)
|
static void uiGroupChildEdgeHuggingChanged(uiDarwinControl *c)
|
||||||
{
|
{
|
||||||
uiGroup *g = uiGroup(c);
|
uiGroup *g = uiGroup(c);
|
||||||
|
|
||||||
|
|
97
darwin/tab.m
97
darwin/tab.m
|
@ -49,7 +49,7 @@ struct uiTab {
|
||||||
|
|
||||||
- (void)establishChildConstraints
|
- (void)establishChildConstraints
|
||||||
{
|
{
|
||||||
[self removeChildConstraints]
|
[self removeChildConstraints];
|
||||||
if (self.c == NULL)
|
if (self.c == NULL)
|
||||||
return;
|
return;
|
||||||
singleChildConstraintsEstablish(&(self->constraints),
|
singleChildConstraintsEstablish(&(self->constraints),
|
||||||
|
@ -88,19 +88,14 @@ static void uiTabDestroy(uiControl *c)
|
||||||
while ([t->tabview numberOfTabViewItems] != 0)
|
while ([t->tabview numberOfTabViewItems] != 0)
|
||||||
[t->tabview removeTabViewItem:[t->tabview tabViewItemAtIndex:0]];
|
[t->tabview removeTabViewItem:[t->tabview tabViewItemAtIndex:0]];
|
||||||
// then destroy all the children
|
// then destroy all the children
|
||||||
[t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
|
for (page in t->pages) {
|
||||||
NSValue *v = (NSValue *) obj;
|
[page removeChildConstraints];
|
||||||
uiControl *c;
|
uiControlSetParent(page.c, NULL);
|
||||||
|
uiDarwinControlSetSuperview(uiDarwinControl(page.c), nil);
|
||||||
c = (uiControl *) [v pointerValue];
|
uiControlDestroy(page.c);
|
||||||
uiControlSetParent(c, NULL);
|
}
|
||||||
uiControlDestroy(c);
|
|
||||||
}];
|
|
||||||
// and finally destroy ourselves
|
// and finally destroy ourselves
|
||||||
[t->pageIDs release];
|
|
||||||
[t->pages release];
|
[t->pages release];
|
||||||
[t->views release];
|
|
||||||
[t->margined release];
|
|
||||||
[t->tabview release];
|
[t->tabview release];
|
||||||
uiFreeControl(uiControl(t));
|
uiFreeControl(uiControl(t));
|
||||||
}
|
}
|
||||||
|
@ -123,28 +118,20 @@ uiDarwinControlDefaultSetSuperview(uiTab, tabview)
|
||||||
|
|
||||||
static void tabRelayout(uiTab *t)
|
static void tabRelayout(uiTab *t)
|
||||||
{
|
{
|
||||||
NSUInteger i;
|
tabPage *page;
|
||||||
|
|
||||||
if ([t->pages count] == 0)
|
for (page in t->pages)
|
||||||
return;
|
[page establishChildConstraints];
|
||||||
for (i = 0; i < [t->pages count]; i++) {
|
}
|
||||||
NSValue *v;
|
|
||||||
uiControl *child;
|
|
||||||
uiDarwinControl *cc;
|
|
||||||
NSView *view, *childView;
|
|
||||||
NSNumber *margined;
|
|
||||||
|
|
||||||
v = (NSValue *) [t->pages objectAtIndex:i];
|
uiDarwinControlDefaultHugsTrailingEdge(uiTab, tabview)
|
||||||
child = (uiControl *) [v pointerValue];
|
uiDarwinControlDefaultHugsBottom(uiTab, tabview)
|
||||||
view = (NSView *) [t->views objectAtIndex:i];
|
|
||||||
childView = (NSView *) uiControlHandle(child);
|
static void uiTabChildEdgeHuggingChanged(uiDarwinControl *c)
|
||||||
margined = (NSNumber *) [t->margined objectAtIndex:i];
|
{
|
||||||
// first lay out the child
|
uiTab *t = uiTab(c);
|
||||||
cc = uiDarwinControl(child);
|
|
||||||
//TODO (*(cc->Relayout))(cc);
|
tabRelayout(t);
|
||||||
// then lay out the page
|
|
||||||
//TODO layoutSingleView(view, childView, [margined intValue], @"uiTab");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiTabAppend(uiTab *t, const char *name, uiControl *child)
|
void uiTabAppend(uiTab *t, const char *name, uiControl *child)
|
||||||
|
@ -154,51 +141,51 @@ void uiTabAppend(uiTab *t, const char *name, uiControl *child)
|
||||||
|
|
||||||
void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child)
|
void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child)
|
||||||
{
|
{
|
||||||
NSView *childView;
|
boxPage *page;
|
||||||
NSView *view;
|
NSView *view;
|
||||||
NSTabViewItem *i;
|
NSTabViewItem *i;
|
||||||
NSObject *pageID;
|
NSObject *pageID;
|
||||||
|
|
||||||
uiControlSetParent(child, uiControl(t));
|
uiControlSetParent(child, uiControl(t));
|
||||||
|
|
||||||
childView = (NSView *) uiControlHandle(child);
|
|
||||||
view = [[NSView alloc] initWithFrame:NSZeroRect];
|
view = [[NSView alloc] initWithFrame:NSZeroRect];
|
||||||
// TODO if we turn off the autoresizing mask, nothing shows up; didn't this get documented somewhere?
|
// TODO if we turn off the autoresizing mask, nothing shows up; didn't this get documented somewhere?
|
||||||
uiDarwinControlSetSuperview(uiDarwinControl(child), view);
|
uiDarwinControlSetSuperview(uiDarwinControl(child), view);
|
||||||
uiDarwinControlSyncEnableState(uiDarwinControl(child), uiControlEnabledToUser(uiControl(t)));
|
uiDarwinControlSyncEnableState(uiDarwinControl(child), uiControlEnabledToUser(uiControl(t)));
|
||||||
|
|
||||||
[t->pages insertObject:[NSValue valueWithPointer:child] atIndex:n];
|
|
||||||
[t->views insertObject:view atIndex:n];
|
|
||||||
[t->margined insertObject:[NSNumber numberWithInt:0] atIndex:n];
|
|
||||||
|
|
||||||
// the documentation says these can be nil but the headers say these must not be; let's be safe and make them non-nil anyway
|
// the documentation says these can be nil but the headers say these must not be; let's be safe and make them non-nil anyway
|
||||||
pageID = [NSObject new];
|
pageID = [NSObject new];
|
||||||
[t->pageIDs insertObject:pageID atIndex:n];
|
page = [[tabPage alloc] initWithView:view pageID:pageID];
|
||||||
|
page.c = child;
|
||||||
|
[t->pages insertObject:page atIndex:n];
|
||||||
|
[page release]; // no need for initial reference
|
||||||
|
|
||||||
i = [[NSTabViewItem alloc] initWithIdentifier:pageID];
|
i = [[NSTabViewItem alloc] initWithIdentifier:pageID];
|
||||||
[i setLabel:toNSString(name)];
|
[i setLabel:toNSString(name)];
|
||||||
[i setView:view];
|
[i setView:view];
|
||||||
[t->tabview insertTabViewItem:i atIndex:n];
|
[t->tabview insertTabViewItem:i atIndex:n];
|
||||||
|
// TODO release i?
|
||||||
|
|
||||||
|
[pageID release]; // no need for initial reference
|
||||||
|
[view release];
|
||||||
|
|
||||||
tabRelayout(t);
|
tabRelayout(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiTabDelete(uiTab *t, uintmax_t n)
|
void uiTabDelete(uiTab *t, uintmax_t n)
|
||||||
{
|
{
|
||||||
NSValue *v;
|
tabPage *page;
|
||||||
uiControl *child;
|
uiControl *child;
|
||||||
NSView *childView;
|
NSView *childView;
|
||||||
NSTabViewItem *i;
|
NSTabViewItem *i;
|
||||||
|
|
||||||
v = (NSValue *) [t->pages objectAtIndex:n];
|
page = (tabPage *) [t->pages objectAtIndex:n];
|
||||||
child = (uiControl *) [v pointerValue];
|
child = page.c;
|
||||||
|
[page removeChildConstraints];
|
||||||
[t->pages removeObjectAtIndex:n];
|
[t->pages removeObjectAtIndex:n];
|
||||||
[t->views removeObjectAtIndex:n];
|
|
||||||
[t->margined removeObjectAtIndex:n];
|
|
||||||
|
|
||||||
childView = (NSView *) uiControlHandle(child);
|
|
||||||
[childView removeFromSuperview];
|
|
||||||
uiControlSetParent(child, NULL);
|
uiControlSetParent(child, NULL);
|
||||||
|
uiDarwinControlSetSuperview(uiDarwinControl(child), nil);
|
||||||
|
|
||||||
i = [t->tabview tabViewItemAtIndex:n];
|
i = [t->tabview tabViewItemAtIndex:n];
|
||||||
[t->tabview removeTabViewItem:i];
|
[t->tabview removeTabViewItem:i];
|
||||||
|
@ -213,19 +200,18 @@ uintmax_t uiTabNumPages(uiTab *t)
|
||||||
|
|
||||||
int uiTabMargined(uiTab *t, uintmax_t n)
|
int uiTabMargined(uiTab *t, uintmax_t n)
|
||||||
{
|
{
|
||||||
NSNumber *v;
|
tabPage *page;
|
||||||
|
|
||||||
v = (NSNumber *) [t->margined objectAtIndex:n];
|
page = (tabPage *) [t->pages objectAtIndex:n];
|
||||||
return [v intValue];
|
return [page isMargined];
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiTabSetMargined(uiTab *t, uintmax_t n, int margined)
|
void uiTabSetMargined(uiTab *t, uintmax_t n, int margined)
|
||||||
{
|
{
|
||||||
NSNumber *v;
|
tabPage *page;
|
||||||
|
|
||||||
v = [NSNumber numberWithInt:margined];
|
page = (tabPage *) [t->pages objectAtIndex:n];
|
||||||
[t->margined replaceObjectAtIndex:n withObject:v];
|
[page setMargined:margined];
|
||||||
tabRelayout(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uiTab *uiNewTab(void)
|
uiTab *uiNewTab(void)
|
||||||
|
@ -239,9 +225,6 @@ uiTab *uiNewTab(void)
|
||||||
uiDarwinSetControlFont((NSControl *) (t->tabview), NSRegularControlSize);
|
uiDarwinSetControlFont((NSControl *) (t->tabview), NSRegularControlSize);
|
||||||
|
|
||||||
t->pages = [NSMutableArray new];
|
t->pages = [NSMutableArray new];
|
||||||
t->views = [NSMutableArray new];
|
|
||||||
t->margined = [NSMutableArray new];
|
|
||||||
t->pageIDs = [NSMutableArray new];
|
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,15 +83,13 @@ static void removeConstraints(uiWindow *w)
|
||||||
static void uiWindowDestroy(uiControl *c)
|
static void uiWindowDestroy(uiControl *c)
|
||||||
{
|
{
|
||||||
uiWindow *w = uiWindow(c);
|
uiWindow *w = uiWindow(c);
|
||||||
NSView *childView;
|
|
||||||
|
|
||||||
// hide the window
|
// hide the window
|
||||||
[w->window orderOut:w->window];
|
[w->window orderOut:w->window];
|
||||||
removeConstraints(w);
|
removeConstraints(w);
|
||||||
if (w->child != NULL) {
|
if (w->child != NULL) {
|
||||||
childView = (NSView *) uiControlHandle(w->child);
|
|
||||||
[childView removeFromSuperview];
|
|
||||||
uiControlSetParent(w->child, NULL);
|
uiControlSetParent(w->child, NULL);
|
||||||
|
uiDarwinControlSetSuperview(uiDarwinControl(w->child), nil);
|
||||||
uiControlDestroy(w->child);
|
uiControlDestroy(w->child);
|
||||||
}
|
}
|
||||||
[windowDelegate unregisterWindow:w];
|
[windowDelegate unregisterWindow:w];
|
||||||
|
|
Loading…
Reference in New Issue