From 639a010a56d7af147122551adcd8d65c2bb46142 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 25 Apr 2016 10:23:16 -0400 Subject: [PATCH] Tested everything by migrating darwin/combobox.m; fixed errors along the way. Also more TODOs. --- darwin/area.m | 2 ++ darwin/combobox.m | 16 +++++----------- ui_darwin.h | 17 ++++++++++------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/darwin/area.m b/darwin/area.m index 540157fc..74179e21 100644 --- a/darwin/area.m +++ b/darwin/area.m @@ -1,6 +1,8 @@ // 9 september 2015 #import "uipriv_darwin.h" +// TODO implement setEnabled: + @interface areaView : NSView { uiArea *libui_a; NSTrackingArea *libui_ta; diff --git a/darwin/combobox.m b/darwin/combobox.m index 2bbdf4a2..93089f76 100644 --- a/darwin/combobox.m +++ b/darwin/combobox.m @@ -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; } diff --git a/ui_darwin.h b/ui_darwin.h index 7f5ed4af..9b07d6cc 100644 --- a/ui_darwin.h +++ b/ui_darwin.h @@ -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; \