Added uiTab page tracking to the Mac OS X backend; necessary for tabDeletePage(). Fixed some small NULL pointer errors in some other files too.
This commit is contained in:
parent
8179d66ae6
commit
c99e8d4af4
|
@ -98,7 +98,7 @@ uiCheckbox *uiNewCheckbox(const char *text)
|
|||
|
||||
c = uiNew(struct checkbox);
|
||||
|
||||
uiDarwinNewControl(uiControl(c), [NSButton class], NO, NO, destroy, NULL);
|
||||
uiDarwinNewControl(uiControl(c), [NSButton class], NO, NO, destroy, c);
|
||||
|
||||
c->checkbox = (NSButton *) VIEW(c);
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ uiEntry *uiNewEntry(void)
|
|||
|
||||
e = uiNew(struct entry);
|
||||
|
||||
uiDarwinNewControl(uiControl(e), [NSTextField class], NO, NO, destroy, NULL);
|
||||
uiDarwinNewControl(uiControl(e), [NSTextField class], NO, NO, destroy, e);
|
||||
|
||||
e->textfield = (NSTextField *) VIEW(e);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ uiLabel *uiNewLabel(const char *text)
|
|||
|
||||
l = uiNew(struct label);
|
||||
|
||||
uiDarwinNewControl(uiControl(l), [NSTextField class], NO, NO, destroy, NULL);
|
||||
uiDarwinNewControl(uiControl(l), [NSTextField class], NO, NO, destroy, l);
|
||||
|
||||
l->label = (NSTextField *) VIEW(l);
|
||||
|
||||
|
|
21
darwin/tab.m
21
darwin/tab.m
|
@ -8,12 +8,21 @@
|
|||
struct tab {
|
||||
uiTab t;
|
||||
NSTabView *tabview;
|
||||
NSMutableArray *pages;
|
||||
};
|
||||
|
||||
static void destroy(void *data)
|
||||
{
|
||||
struct tab *t = (struct tab *) data;
|
||||
|
||||
[t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
|
||||
NSValue *v = (NSValue *) obj;
|
||||
uiParent *p;
|
||||
|
||||
p = (uiParent *) [v pointerValue];
|
||||
uiParentDestroy(p);
|
||||
}];
|
||||
[t->pages release];
|
||||
uiFree(t);
|
||||
}
|
||||
|
||||
|
@ -37,6 +46,7 @@ static void tabAddPage(uiTab *tt, const char *name, uiControl *child)
|
|||
|
||||
content = uiNewParent(0);
|
||||
uiParentSetMainControl(content, child);
|
||||
[t->pages addObject:[NSValue valueWithPointer:content]];
|
||||
|
||||
i = [[NSTabViewItem alloc] initWithIdentifier:nil];
|
||||
[i setLabel:toNSString(name)];
|
||||
|
@ -44,19 +54,28 @@ static void tabAddPage(uiTab *tt, const char *name, uiControl *child)
|
|||
[t->tabview addTabViewItem:i];
|
||||
}
|
||||
|
||||
static void tabDeletePage(uiTab *tt, uintmax_t n)
|
||||
{
|
||||
struct tab *t = (struct tab *) tt;
|
||||
|
||||
[t->pages removeObjectAtIndex:n];
|
||||
}
|
||||
|
||||
uiTab *uiNewTab(void)
|
||||
{
|
||||
struct tab *t;
|
||||
|
||||
t = uiNew(struct tab);
|
||||
|
||||
uiDarwinNewControl(uiControl(t), [NSTabView class], NO, NO, destroy, NULL);
|
||||
uiDarwinNewControl(uiControl(t), [NSTabView class], NO, NO, destroy, t);
|
||||
|
||||
t->tabview = (NSTabView *) VIEW(t);
|
||||
|
||||
// also good for NSTabView (same selector and everything)
|
||||
setStandardControlFont((NSControl *) (t->tabview));
|
||||
|
||||
t->pages = [NSMutableArray new];
|
||||
|
||||
uiControl(t)->PreferredSize = preferredSize;
|
||||
|
||||
uiTab(t)->AddPage = tabAddPage;
|
||||
|
|
Loading…
Reference in New Issue