Migrated darwin/tab.m and fixed up the other files. Now for darwin/control.m, then we can test...

This commit is contained in:
Pietro Gagliardi 2016-04-25 12:52:54 -04:00
parent b50eda0303
commit 189d661b7f
6 changed files with 50 additions and 21 deletions

View File

@ -59,9 +59,13 @@ static buttonDelegateClass *buttonDelegate = nil;
uiDarwinControlAllDefaultsExceptDestroy(uiButton, button) uiDarwinControlAllDefaultsExceptDestroy(uiButton, button)
static void uiButtonDestroy(uiControl *b) static void uiButtonDestroy(uiControl *c)
{ {
[buttonDelegate unregisterButton:uiButton(b)]; uiButton *b = uiButton(c);
[buttonDelegate unregisterButton:b];
[b->button release];
uiFreeControl(uiControl(b));
} }
char *uiButtonText(uiButton *b) char *uiButtonText(uiButton *b)

View File

@ -61,9 +61,13 @@ static checkboxDelegateClass *checkboxDelegate = nil;
uiDarwinControlAllDefaultsExceptDestroy(uiCheckbox, button) uiDarwinControlAllDefaultsExceptDestroy(uiCheckbox, button)
static void uiCheckboxDestroy(uiControl *c) static void uiCheckboxDestroy(uiControl *cc)
{ {
[checkboxDelegate unregisterCheckbox:uiCheckbox(c)]; uiCheckbox *c = uiCheckbox(cc);
[checkboxDelegate unregisterCheckbox:c];
[c->button release];
uiFreeControl(uiControl(c));
} }
char *uiCheckboxText(uiCheckbox *c) char *uiCheckboxText(uiCheckbox *c)

View File

@ -110,6 +110,8 @@ static void uiComboboxDestroy(uiControl *cc)
[c->pb unbind:@"selectedIndex"]; [c->pb unbind:@"selectedIndex"];
[c->pbac release]; [c->pbac release];
} }
[c->handle release];
uiFreeControl(uiControl(c));
} }
void uiComboboxAppend(uiCombobox *c, const char *text) void uiComboboxAppend(uiCombobox *c, const char *text)

View File

@ -79,7 +79,11 @@ uiDarwinControlAllDefaultsExceptDestroy(uiEntry, textfield)
static void uiEntryDestroy(uiControl *c) static void uiEntryDestroy(uiControl *c)
{ {
[entryDelegate unregisterEntry:uiEntry(c)]; uiEntry *e = uiEntry(c);
[entryDelegate unregisterEntry:e];
[e->textfield release];
uiFreeControl(e);
} }
char *uiEntryText(uiEntry *e) char *uiEntryText(uiEntry *e)

View File

@ -81,7 +81,11 @@ uiDarwinControlAllDefaultsExceptDestroy(uiSlider, slider)
static void uiSliderDestroy(uiControl *c) static void uiSliderDestroy(uiControl *c)
{ {
[sliderDelegate unregisterSlider:uiSlider(c)]; uiSlider *s = uiSlider(c);
[sliderDelegate unregisterSlider:s];
[s->slider release];
uiFreeControl(uiControl(s));
} }
intmax_t uiSliderValue(uiSlider *s) intmax_t uiSliderValue(uiSlider *s)

View File

@ -1,6 +1,8 @@
// 15 august 2015 // 15 august 2015
#import "uipriv_darwin.h" #import "uipriv_darwin.h"
// TODO for this and group, make sure simply relaying ourselves out is enough (are the buttons and title, respectively, intrinsic?)
struct uiTab { struct uiTab {
uiDarwinControl c; uiDarwinControl c;
NSTabView *tabview; NSTabView *tabview;
@ -12,16 +14,10 @@ struct uiTab {
NSMutableArray *margined; // []NSNumber NSMutableArray *margined; // []NSNumber
}; };
static void onDestroy(uiTab *); static void uiTabDestroy(uiControl *c)
uiDarwinDefineControlWithOnDestroy(
uiTab, // type name
tabview, // handle
onDestroy(this); // on destroy
)
static void onDestroy(uiTab *t)
{ {
uiTab *t = uiTab(c);
// first remove all tab pages so we can destroy all the children // first remove all tab pages so we can destroy all the children
while ([t->tabview numberOfTabViewItems] != 0) while ([t->tabview numberOfTabViewItems] != 0)
[t->tabview removeTabViewItem:[t->tabview tabViewItemAtIndex:0]]; [t->tabview removeTabViewItem:[t->tabview tabViewItemAtIndex:0]];
@ -38,9 +34,25 @@ static void onDestroy(uiTab *t)
[t->pages release]; [t->pages release];
[t->views release]; [t->views release];
[t->margined release]; [t->margined release];
[t->tabview release];
uiFreeControl(uiControl(t));
} }
uiDarwinControlDefaultHandle(uiTab, tabview)
uiDarwinControlDefaultParent(uiTab, tabview)
uiDarwinControlDefaultSetParent(uiTab, tabview)
uiDarwinControlDefaultToplevel(uiTab, tabview)
uiDarwinControlDefaultVisible(uiTab, tabview)
uiDarwinControlDefaultShow(uiTab, tabview)
uiDarwinControlDefaultHide(uiTab, tabview)
uiDarwinControlDefaultEnabled(uiTab, tabview)
uiDarwinControlDefaultEnable(uiTab, tabview)
uiDarwinControlDefaultDisable(uiTab, tabview)
// TODO container update // TODO container update
uiDarwinControlDefaultSyncEnableState(uiTab, tabview)
uiDarwinControlDefaultSetSuperview(uiTab, tabview)
static void tabRelayout(uiDarwinControl *c) static void tabRelayout(uiDarwinControl *c)
{ {
@ -97,7 +109,7 @@ void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child)
[i setView:view]; [i setView:view];
[t->tabview insertTabViewItem:i atIndex:n]; [t->tabview insertTabViewItem:i atIndex:n];
uiDarwinControlTriggerRelayout(uiDarwinControl(t)); tabRelayout(t);
} }
void uiTabDelete(uiTab *t, uintmax_t n) void uiTabDelete(uiTab *t, uintmax_t n)
@ -120,6 +132,8 @@ void uiTabDelete(uiTab *t, uintmax_t n)
i = [t->tabview tabViewItemAtIndex:n]; i = [t->tabview tabViewItemAtIndex:n];
[t->tabview removeTabViewItem:i]; [t->tabview removeTabViewItem:i];
tabRelayout(t);
} }
uintmax_t uiTabNumPages(uiTab *t) uintmax_t uiTabNumPages(uiTab *t)
@ -141,14 +155,14 @@ void uiTabSetMargined(uiTab *t, uintmax_t n, int margined)
v = [NSNumber numberWithInt:margined]; v = [NSNumber numberWithInt:margined];
[t->margined replaceObjectAtIndex:n withObject:v]; [t->margined replaceObjectAtIndex:n withObject:v];
uiDarwinControlTriggerRelayout(uiDarwinControl(t)); tabRelayout(t);
} }
uiTab *uiNewTab(void) uiTab *uiNewTab(void)
{ {
uiTab *t; uiTab *t;
t = (uiTab *) uiNewControl(uiTab); uiDarwinNewControl(uiTab, t);
t->tabview = [[NSTabView alloc] initWithFrame:NSZeroRect]; t->tabview = [[NSTabView alloc] initWithFrame:NSZeroRect];
// also good for NSTabView (same selector and everything) // also good for NSTabView (same selector and everything)
@ -158,8 +172,5 @@ uiTab *uiNewTab(void)
t->views = [NSMutableArray new]; t->views = [NSMutableArray new];
t->margined = [NSMutableArray new]; t->margined = [NSMutableArray new];
uiDarwinFinishNewControl(t, uiTab);
uiDarwinControl(t)->Relayout = tabRelayout;
return t; return t;
} }