Migrated darwin/tab.m. Now to test...
This commit is contained in:
parent
14d8a0e563
commit
9f59c0059c
|
@ -16,10 +16,11 @@ static void destroy(void *data)
|
||||||
|
|
||||||
[t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
|
[t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
|
||||||
NSValue *v = (NSValue *) obj;
|
NSValue *v = (NSValue *) obj;
|
||||||
uiParent *p;
|
uiContainer *p;
|
||||||
|
|
||||||
p = (uiParent *) [v pointerValue];
|
// TODO this is definitely wrong but
|
||||||
uiParentDestroy(p);
|
p = (uiContainer *) [v pointerValue];
|
||||||
|
uiControlDestroy(uiControl(p));
|
||||||
}];
|
}];
|
||||||
[t->pages release];
|
[t->pages release];
|
||||||
uiFree(t);
|
uiFree(t);
|
||||||
|
@ -37,19 +38,19 @@ static void preferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *
|
||||||
*height = (intmax_t) (s.height);
|
*height = (intmax_t) (s.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tabAddPage(uiTab *tt, const char *name, uiControl *child)
|
static void tabAppendPage(uiTab *tt, const char *name, uiControl *child)
|
||||||
{
|
{
|
||||||
struct tab *t = (struct tab *) tt;
|
struct tab *t = (struct tab *) tt;
|
||||||
uiParent *content;
|
uiContainer *page;
|
||||||
NSTabViewItem *i;
|
NSTabViewItem *i;
|
||||||
|
|
||||||
content = uiNewParent(0);
|
page = newBin();
|
||||||
uiParentSetMainControl(content, child);
|
binSetMainConotrol(page, child);
|
||||||
[t->pages addObject:[NSValue valueWithPointer:content]];
|
[t->pages addObject:[NSValue valueWithPointer:page]];
|
||||||
|
|
||||||
i = [[NSTabViewItem alloc] initWithIdentifier:nil];
|
i = [[NSTabViewItem alloc] initWithIdentifier:nil];
|
||||||
[i setLabel:toNSString(name)];
|
[i setLabel:toNSString(name)];
|
||||||
[i setView:((NSView *) uiParentHandle(content))];
|
[i setView:((NSView *) uiContainerHandle(content))];
|
||||||
[t->tabview addTabViewItem:i];
|
[t->tabview addTabViewItem:i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,14 +58,15 @@ static void tabDeletePage(uiTab *tt, uintmax_t n)
|
||||||
{
|
{
|
||||||
struct tab *t = (struct tab *) tt;
|
struct tab *t = (struct tab *) tt;
|
||||||
NSValue *v;
|
NSValue *v;
|
||||||
uiParent *p;
|
uiContainer *p;
|
||||||
NSTabViewItem *i;
|
NSTabViewItem *i;
|
||||||
|
|
||||||
v = (NSValue *) [t->pages objectAtIndex:n];
|
v = (NSValue *) [t->pages objectAtIndex:n];
|
||||||
p = (uiParent *) [v pointerValue];
|
p = (uiContainer *) [v pointerValue];
|
||||||
[t->pages removeObjectAtIndex:n];
|
[t->pages removeObjectAtIndex:n];
|
||||||
|
|
||||||
// make sure the children of the tab aren't destroyed
|
// make sure the children of the tab aren't destroyed
|
||||||
uiParentSetMainControl(p, NULL);
|
binSetMainControl(p, NULL);
|
||||||
|
|
||||||
// TODO negotiate lifetimes better
|
// TODO negotiate lifetimes better
|
||||||
i = [t->tabview tabViewItemAtIndex:n];
|
i = [t->tabview tabViewItemAtIndex:n];
|
||||||
|
@ -79,7 +81,7 @@ uiTab *uiNewTab(void)
|
||||||
|
|
||||||
uiDarwinNewControl(uiControl(t), [NSTabView class], NO, NO, destroy, t);
|
uiDarwinNewControl(uiControl(t), [NSTabView class], NO, NO, destroy, t);
|
||||||
|
|
||||||
t->tabview = (NSTabView *) VIEW(t);
|
t->tabview = (NSTabView *) uiControlHandle(uiControl(t));
|
||||||
|
|
||||||
// also good for NSTabView (same selector and everything)
|
// also good for NSTabView (same selector and everything)
|
||||||
setStandardControlFont((NSControl *) (t->tabview));
|
setStandardControlFont((NSControl *) (t->tabview));
|
||||||
|
@ -88,7 +90,7 @@ uiTab *uiNewTab(void)
|
||||||
|
|
||||||
uiControl(t)->PreferredSize = preferredSize;
|
uiControl(t)->PreferredSize = preferredSize;
|
||||||
|
|
||||||
uiTab(t)->AddPage = tabAddPage;
|
uiTab(t)->AppendPage = tabAppendPage;
|
||||||
uiTab(t)->DeletePage = tabDeletePage;
|
uiTab(t)->DeletePage = tabDeletePage;
|
||||||
|
|
||||||
return uiTab(t);
|
return uiTab(t);
|
Loading…
Reference in New Issue