More new control structure work. This is turning into a disaster already.

This commit is contained in:
Pietro Gagliardi 2016-04-24 19:56:14 -04:00
parent dda30cdb3c
commit e643dc3693
1 changed files with 38 additions and 17 deletions

View File

@ -14,39 +14,60 @@ extern "C" {
typedef struct uiDarwinControl uiDarwinControl; typedef struct uiDarwinControl uiDarwinControl;
struct uiDarwinControl { struct uiDarwinControl {
uiControl c; uiControl c;
uiControl *parent;
BOOL enabled;
BOOL visible;
void (*Relayout)(uiDarwinControl *); void (*Relayout)(uiDarwinControl *);
}; };
#define uiDarwinControl(this) ((uiDarwinControl *) (this)) #define uiDarwinControl(this) ((uiDarwinControl *) (this))
// TODO document // TODO document
_UI_EXTERN void uiDarwinControlTriggerRelayout(uiDarwinControl *); _UI_EXTERN void uiDarwinControlTriggerRelayout(uiDarwinControl *);
// TODO document #define uiDarwinControlDefaultDestroy(type, handlefield) \
#define uiDarwinDefineControlWithOnDestroy(type, handlefield, onDestroy) \ static void type ## Destroy(uiControl *c) \
static void _ ## type ## CommitDestroy(uiControl *c) \
{ \ { \
type *this = type(c); \ uiControlVerifyDestroy(c); \
onDestroy; \ [type(c)->handlefield release]; \
[this->handlefield release]; \ }
} \ #define uiDarwinControlDefaultHandle(type, handlefield) \
static uintptr_t _ ## type ## Handle(uiControl *c) \ static uintptr_t type ## Handle(uiControl *c) \
{ \ { \
return (uintptr_t) (type(c)->handlefield); \ return (uintptr_t) (type(c)->handlefield); \
} \ }
static void _ ## type ## ContainerUpdateState(uiControl *c) \ #define uiDarwinControlDefaultParent(type) \
static uiControl *type ## Parent(uiControl *c) \
{ \ { \
/* do nothing */ \ return uiDarwinControl(c)->parent; \
} \ }
static void _ ## type ## Relayout(uiDarwinControl *c) \ #define uiDarwinControlDefaultSetParent(type, handlefield) \
static void type ## SetParent(uiControl *c, uiControl *parent) \
{ \
uiControlVerifySetParent(c, parent); \
uiDarwinControl(c)->parent = parent; \
if (uiDarwinControl(c)->parent == NULL) \
[type(c)->handlefield removeFromSuperview]; \
else { \
/* TODO */ \
if ([type(c)->handlefield respondsToSelector:@selector(setEnabled:)]) \
[type(c)->handlefield setEnabled:uiControlEnabledToUser(c)]; \
} \
}
#define uiDarwinControlDefaultRelayout(type) \
static void type ## Relayout(uiDarwinControl *c) \
{ \ { \
/* do nothing */ \ /* do nothing */ \
} }
#define uiDarwinDefineControl(type, handlefield) \ #define uiDarwinControlAllDefaults(type, handlefield) \
uiDarwinDefineControlWithOnDestroy(type, handlefield, (void) this;) uiDarwinControlDefaultDestroy(type, handlefield) \
uiDarwinControlDefaultHandle(type, handlefield) \
uiDarwinControlDefaultParent(type) \
xxxxx \
uiDarwinControlDefaultRelayout(type)
// TODO document // TODO document
#define uiNewControl(type) uiDarwinNewControl(sizeof (type), type ## Signature, #type) #define uiDarwinNewControl(type) type(uiDarwinNewControl(sizeof (type), type ## Signature, #type))
_UI_EXTERN uiDarwinControl *uiDarwinNewControl(size_t n, uint32_t typesig, const char *typenamestr); _UI_EXTERN uiDarwinControl *uiDarwinAllocControl(size_t n, uint32_t typesig, const char *typenamestr);
#define uiDarwinFinishNewControl(variable, type) \ #define uiDarwinFinishNewControl(variable, type) \
uiControl(variable)->CommitDestroy = _ ## type ## CommitDestroy; \ uiControl(variable)->CommitDestroy = _ ## type ## CommitDestroy; \