Tested everything by migrating darwin/combobox.m; fixed errors along the way. Also more TODOs.

This commit is contained in:
Pietro Gagliardi 2016-04-25 10:23:16 -04:00
parent a97171ed86
commit 639a010a56
3 changed files with 17 additions and 18 deletions

View File

@ -1,6 +1,8 @@
// 9 september 2015
#import "uipriv_darwin.h"
// TODO implement setEnabled:
@interface areaView : NSView {
uiArea *libui_a;
NSTrackingArea *libui_ta;

View File

@ -98,16 +98,12 @@ struct uiCombobox {
static comboboxDelegateClass *comboboxDelegate = nil;
static void onDestroy(uiCombobox *);
uiDarwinControlAllDefaultsExceptDestroy(uiCombobox, handle)
uiDarwinDefineControlWithOnDestroy(
uiCombobox, // type name
handle, // handle
onDestroy(this); // on destroy
)
static void onDestroy(uiCombobox *c)
static void uiComboboxDestroy(uiControl *cc)
{
uiCombobox *c = uiCombobox(cc);
[comboboxDelegate unregisterCombobox:c];
if (!c->editable) {
[c->pb unbind:@"contentObjects"];
@ -169,7 +165,7 @@ static uiCombobox *finishNewCombobox(BOOL editable)
{
uiCombobox *c;
c = (uiCombobox *) uiNewControl(uiCombobox);
uiDarwinNewControl(uiCombobox, c);
c->editable = editable;
if (c->editable) {
@ -214,8 +210,6 @@ static uiCombobox *finishNewCombobox(BOOL editable)
[comboboxDelegate registerCombobox:c];
uiComboboxOnSelected(c, defaultOnSelected, NULL);
uiDarwinFinishNewControl(c, uiCombobox);
return c;
}

View File

@ -45,7 +45,7 @@ _UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *);
uiControlVerifySetParent(c, parent); \
uiDarwinControl(c)->parent = parent; \
}
#define uiDarwinControlDefaultToplevel(type) \
#define uiDarwinControlDefaultToplevel(type, handlefield) \
static int type ## Toplevel(uiControl *c) \
{ \
return 0; \
@ -72,13 +72,13 @@ _UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *);
{ \
return uiDarwinControl(c)->enabled; \
}
#define uiDarwinControlDefaultEnabled(type, handlefield) \
#define uiDarwinControlDefaultEnable(type, handlefield) \
static void type ## Enable(uiControl *c) \
{ \
uiDarwinControl(c)->enabled = YES; \
uiControlSyncEnableState(c, uiControlEnabledToUser(c)); \
}
#define uiDarwinControlDefaultHide(type, handlefield) \
#define uiDarwinControlDefaultDisable(type, handlefield) \
static void type ## Disable(uiControl *c) \
{ \
uiDarwinControl(c)->enabled = NO; \
@ -99,8 +99,7 @@ _UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *);
[superview addSubview:type(c)->handlefield]; \
}
#define uiDarwinControlAllDefaults(type, handlefield) \
uiDarwinControlDefaultDestroy(type, handlefield) \
#define uiDarwinControlAllDefaultsExceptDestroy(type, handlefield) \
uiDarwinControlDefaultHandle(type, handlefield) \
uiDarwinControlDefaultParent(type, handlefield) \
uiDarwinControlDefaultSetParent(type, handlefield) \
@ -111,11 +110,15 @@ _UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *);
uiDarwinControlDefaultEnabled(type, handlefield) \
uiDarwinControlDefaultEnable(type, handlefield) \
uiDarwinControlDefaultDisable(type, handlefield) \
uiDarwinControlDefaultSetEnableState(type, handlefield) \
uiDarwinControlDefaultSyncEnableState(type, handlefield) \
uiDarwinControlDefaultSetSuperview(type, handlefield)
#define uiDarwinControlAllDefaults(type, handlefield) \
uiDarwinControlDefaultDestroy(type, handlefield) \
uiDarwinControlAllDefaultsExceptDestroy(type, handlefield)
// TODO document
#define uiDarwinNewControl(var, type) \
#define uiDarwinNewControl(type, var) \
var = type(uiDarwinNewControl(sizeof (type), type ## Signature, #type)) \
uiControl(var)->Destroy = type ## Destroy; \
uiControl(var)->Handle = type ## Handle; \