Finished the new ui_darwin.h.
This commit is contained in:
parent
31dee85b5e
commit
a6b324a33c
|
@ -0,0 +1,4 @@
|
||||||
|
every rule in ui_darwin.h
|
||||||
|
SetParent must be followed by SetSuperview
|
||||||
|
TODO can child cache it?
|
||||||
|
adding a child must be followed by a call to SyncEnableState
|
100
ui_darwin.h
100
ui_darwin.h
|
@ -17,13 +17,11 @@ struct uiDarwinControl {
|
||||||
uiControl *parent;
|
uiControl *parent;
|
||||||
BOOL enabled;
|
BOOL enabled;
|
||||||
BOOL visible;
|
BOOL visible;
|
||||||
void (*AddSubview)(uiDarwinControl *, NSView *);
|
void (*SetSuperview)(uiDarwinControl *, NSView *);
|
||||||
void (*Relayout)(uiDarwinControl *);
|
|
||||||
};
|
};
|
||||||
#define uiDarwinControl(this) ((uiDarwinControl *) (this))
|
#define uiDarwinControl(this) ((uiDarwinControl *) (this))
|
||||||
// TODO document
|
// TODO document
|
||||||
_UI_EXTERN void uiDarwinControlAddSubview(uiDarwinControl *, NSView *);
|
_UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *);
|
||||||
_UI_EXTERN void uiDarwinControlTriggerRelayout(uiDarwinControl *);
|
|
||||||
|
|
||||||
#define uiDarwinControlDefaultDestroy(type, handlefield) \
|
#define uiDarwinControlDefaultDestroy(type, handlefield) \
|
||||||
static void type ## Destroy(uiControl *c) \
|
static void type ## Destroy(uiControl *c) \
|
||||||
|
@ -36,7 +34,7 @@ _UI_EXTERN void uiDarwinControlTriggerRelayout(uiDarwinControl *);
|
||||||
{ \
|
{ \
|
||||||
return (uintptr_t) (type(c)->handlefield); \
|
return (uintptr_t) (type(c)->handlefield); \
|
||||||
}
|
}
|
||||||
#define uiDarwinControlDefaultParent(type) \
|
#define uiDarwinControlDefaultParent(type, handlefield) \
|
||||||
static uiControl *type ## Parent(uiControl *c) \
|
static uiControl *type ## Parent(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
return uiDarwinControl(c)->parent; \
|
return uiDarwinControl(c)->parent; \
|
||||||
|
@ -56,51 +54,89 @@ _UI_EXTERN void uiDarwinControlTriggerRelayout(uiDarwinControl *);
|
||||||
{ \
|
{ \
|
||||||
return 0; \
|
return 0; \
|
||||||
}
|
}
|
||||||
#define uiDarwinControlDefaultVisible(type) \
|
#define uiDarwinControlDefaultVisible(type, handlefield) \
|
||||||
static int type ## Visible(uiDarwinControl *c) \
|
static int type ## Visible(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
/* TODO */ \
|
|
||||||
return uiDarwinControl(c)->visible; \
|
return uiDarwinControl(c)->visible; \
|
||||||
}
|
}
|
||||||
// TODO others here
|
#define uiDarwinControlDefaultShow(type, handlefield) \
|
||||||
#define uiDarwinControlDefaultAddSubview(type) \
|
static void type ## Show(uiControl *c) \
|
||||||
static void type ## AddSubview(uiDarwinControl *c, NSView *subview) \
|
|
||||||
{ \
|
{ \
|
||||||
/* TODO do nothing or log? one of the two */ \
|
uiDarwinControl(c)->visible = YES; \
|
||||||
|
[type(c)->handlefield setHidden:NO]; \
|
||||||
}
|
}
|
||||||
#define uiDarwinControlDefaultRelayout(type) \
|
#define uiDarwinControlDefaultHide(type, handlefield) \
|
||||||
static void type ## Relayout(uiDarwinControl *c) \
|
static void type ## Hide(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
/* do nothing */ \
|
uiDarwinControl(c)->visible = NO; \
|
||||||
|
[type(c)->handlefield setHidden:YES]; \
|
||||||
|
}
|
||||||
|
#define uiDarwinControlDefaultEnabled(type, handlefield) \
|
||||||
|
static int type ## Visible(uiControl *c) \
|
||||||
|
{ \
|
||||||
|
return uiDarwinControl(c)->enabled; \
|
||||||
|
}
|
||||||
|
#define uiDarwinControlDefaultEnabled(type, handlefield) \
|
||||||
|
static void type ## Enable(uiControl *c) \
|
||||||
|
{ \
|
||||||
|
uiDarwinControl(c)->enabled = YES; \
|
||||||
|
uiControlSyncEnableState(c, uiControlEnabledToUser(c)); \
|
||||||
|
}
|
||||||
|
#define uiDarwinControlDefaultHide(type, handlefield) \
|
||||||
|
static void type ## Disable(uiControl *c) \
|
||||||
|
{ \
|
||||||
|
uiDarwinControl(c)->enabled = NO; \
|
||||||
|
uiControlSyncEnableState(c, uiControlEnabledToUser(c)); \
|
||||||
|
}
|
||||||
|
#define uiDarwinControlDefaultSyncEnableState(type, handlefield) \
|
||||||
|
static void type ## SyncEnableState(uiControl *c, int enabled) \
|
||||||
|
{ \
|
||||||
|
if ([type(e)->handlefield respondsToSelector:@selector(setEnabled:)]) \
|
||||||
|
[type(e)->handlefield setEnabled:enabled]; \
|
||||||
|
}
|
||||||
|
#define uiDarwinControlDefaultSetSuperview(type, handlefield) \
|
||||||
|
static void type ## AddSubview(uiDarwinControl *c, NSView *superview) \
|
||||||
|
{ \
|
||||||
|
if (superview == nil) \
|
||||||
|
[type(c)->handlefield removeFromSuperview]; \
|
||||||
|
else \
|
||||||
|
[superview addSubview:type(c)->handlefield]; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define uiDarwinControlAllDefaults(type, handlefield) \
|
#define uiDarwinControlAllDefaults(type, handlefield) \
|
||||||
uiDarwinControlDefaultDestroy(type, handlefield) \
|
uiDarwinControlDefaultDestroy(type, handlefield) \
|
||||||
uiDarwinControlDefaultHandle(type, handlefield) \
|
uiDarwinControlDefaultHandle(type, handlefield) \
|
||||||
uiDarwinControlDefaultParent(type) \
|
uiDarwinControlDefaultParent(type, handlefield) \
|
||||||
uiDarwinControlDefaultSetParent(type, handlefield) \
|
uiDarwinControlDefaultSetParent(type, handlefield) \
|
||||||
uiDarwinControlDefaultToplevel(type) \
|
uiDarwinControlDefaultToplevel(type, handlefield) \
|
||||||
xxxxx \
|
uiDarwinControlDefaultVisible(type, handlefield) \
|
||||||
uiDarwinControlDefaultAddSubview(type) \
|
uiDarwinControlDefaultShow(type, handlefield) \
|
||||||
uiDarwinControlDefaultRelayout(type)
|
uiDarwinControlDefaultHide(type, handlefield) \
|
||||||
|
uiDarwinControlDefaultEnabled(type, handlefield) \
|
||||||
|
uiDarwinControlDefaultEnable(type, handlefield) \
|
||||||
|
uiDarwinControlDefaultDisable(type, handlefield) \
|
||||||
|
uiDarwinControlDefaultSetEnableState(type, handlefield) \
|
||||||
|
uiDarwinControlDefaultSetSuperview(type, handlefield)
|
||||||
|
|
||||||
// TODO document
|
// TODO document
|
||||||
#define uiDarwinNewControl(var, type) \
|
#define uiDarwinNewControl(var, type) \
|
||||||
var = type(uiDarwinNewControl(sizeof (type), type ## Signature, #type)) \
|
var = type(uiDarwinNewControl(sizeof (type), type ## Signature, #type)) \
|
||||||
TODO
|
uiControl(var)->Destroy = type ## Destroy; \
|
||||||
|
uiControl(var)->Handle = type ## Handle; \
|
||||||
|
uiControl(var)->Parent = type ## Parent; \
|
||||||
|
uiControl(var)->SetParent = type ## SetParent; \
|
||||||
|
uiControl(var)->Toplevel = type ## Toplevel; \
|
||||||
|
uiControl(var)->Visible = type ## Visible; \
|
||||||
|
uiControl(var)->Show = type ## Show; \
|
||||||
|
uiControl(var)->Hide = type ## Hide; \
|
||||||
|
uiControl(var)->Enabled = type ## Enabled; \
|
||||||
|
uiControl(var)->Enable = type ## Enable; \
|
||||||
|
uiControl(var)->Disable = type ## Disable; \
|
||||||
|
uiControl(var)->SyncEnableState = type ## SyncEnableState; \
|
||||||
|
uiDarwinControl(var)->SetSuperview = type ## SetSuperview;
|
||||||
|
// TODO document
|
||||||
_UI_EXTERN uiDarwinControl *uiDarwinAllocControl(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) \
|
|
||||||
uiControl(variable)->CommitDestroy = _ ## type ## CommitDestroy; \
|
|
||||||
uiControl(variable)->Handle = _ ## type ## Handle; \
|
|
||||||
uiControl(variable)->ContainerUpdateState = _ ## type ## ContainerUpdateState; \
|
|
||||||
uiDarwinControl(variable)->Relayout = _ ## type ## Relayout; \
|
|
||||||
uiDarwinFinishControl(uiControl(variable));
|
|
||||||
|
|
||||||
// This is a function used to set up a control.
|
|
||||||
// Don't call it directly; use uiDarwinFinishNewControl() instead.
|
|
||||||
_UI_EXTERN void uiDarwinFinishControl(uiControl *c);
|
|
||||||
|
|
||||||
// Use this function as a shorthand for setting control fonts.
|
// Use this function as a shorthand for setting control fonts.
|
||||||
_UI_EXTERN void uiDarwinSetControlFont(NSControl *c, NSControlSize size);
|
_UI_EXTERN void uiDarwinSetControlFont(NSControl *c, NSControlSize size);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue