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 // 9 september 2015
#import "uipriv_darwin.h" #import "uipriv_darwin.h"
// TODO implement setEnabled:
@interface areaView : NSView { @interface areaView : NSView {
uiArea *libui_a; uiArea *libui_a;
NSTrackingArea *libui_ta; NSTrackingArea *libui_ta;

View File

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

View File

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