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)
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)

View File

@ -61,9 +61,13 @@ static checkboxDelegateClass *checkboxDelegate = nil;
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)

View File

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

View File

@ -79,7 +79,11 @@ uiDarwinControlAllDefaultsExceptDestroy(uiEntry, textfield)
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)

View File

@ -81,7 +81,11 @@ uiDarwinControlAllDefaultsExceptDestroy(uiSlider, slider)
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)

View File

@ -1,6 +1,8 @@
// 15 august 2015
#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 {
uiDarwinControl c;
NSTabView *tabview;
@ -12,16 +14,10 @@ struct uiTab {
NSMutableArray *margined; // []NSNumber
};
static void onDestroy(uiTab *);
uiDarwinDefineControlWithOnDestroy(
uiTab, // type name
tabview, // handle
onDestroy(this); // on destroy
)
static void onDestroy(uiTab *t)
static void uiTabDestroy(uiControl *c)
{
uiTab *t = uiTab(c);
// first remove all tab pages so we can destroy all the children
while ([t->tabview numberOfTabViewItems] != 0)
[t->tabview removeTabViewItem:[t->tabview tabViewItemAtIndex:0]];
@ -38,9 +34,25 @@ static void onDestroy(uiTab *t)
[t->pages release];
[t->views 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
uiDarwinControlDefaultSyncEnableState(uiTab, tabview)
uiDarwinControlDefaultSetSuperview(uiTab, tabview)
static void tabRelayout(uiDarwinControl *c)
{
@ -97,7 +109,7 @@ void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child)
[i setView:view];
[t->tabview insertTabViewItem:i atIndex:n];
uiDarwinControlTriggerRelayout(uiDarwinControl(t));
tabRelayout(t);
}
void uiTabDelete(uiTab *t, uintmax_t n)
@ -120,6 +132,8 @@ void uiTabDelete(uiTab *t, uintmax_t n)
i = [t->tabview tabViewItemAtIndex:n];
[t->tabview removeTabViewItem:i];
tabRelayout(t);
}
uintmax_t uiTabNumPages(uiTab *t)
@ -141,14 +155,14 @@ void uiTabSetMargined(uiTab *t, uintmax_t n, int margined)
v = [NSNumber numberWithInt:margined];
[t->margined replaceObjectAtIndex:n withObject:v];
uiDarwinControlTriggerRelayout(uiDarwinControl(t));
tabRelayout(t);
}
uiTab *uiNewTab(void)
{
uiTab *t;
t = (uiTab *) uiNewControl(uiTab);
uiDarwinNewControl(uiTab, t);
t->tabview = [[NSTabView alloc] initWithFrame:NSZeroRect];
// also good for NSTabView (same selector and everything)
@ -158,8 +172,5 @@ uiTab *uiNewTab(void)
t->views = [NSMutableArray new];
t->margined = [NSMutableArray new];
uiDarwinFinishNewControl(t, uiTab);
uiDarwinControl(t)->Relayout = tabRelayout;
return t;
}