Started migrating ui_unix.h. SyncEnableState can be dropped from the GTK+ port, so let's do that next.
This commit is contained in:
parent
98e7afc5de
commit
a651caac89
138
ui_unix.h
138
ui_unix.h
|
@ -14,42 +14,128 @@ extern "C" {
|
||||||
typedef struct uiUnixControl uiUnixControl;
|
typedef struct uiUnixControl uiUnixControl;
|
||||||
struct uiUnixControl {
|
struct uiUnixControl {
|
||||||
uiControl c;
|
uiControl c;
|
||||||
|
void (*SetContainer)(uiUnixControl *, GtkContainer *, gboolean);
|
||||||
};
|
};
|
||||||
#define uiUnixControl(this) ((uiUnixControl *) (this))
|
#define uiUnixControl(this) ((uiUnixControl *) (this))
|
||||||
|
|
||||||
// TODO document
|
// TODO document
|
||||||
#define uiUnixDefineControlWithOnDestroy(type, onDestroy) \
|
_UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gboolean);
|
||||||
static void _ ## type ## CommitDestroy(uiControl *c) \
|
|
||||||
|
#define uiUnixControlDefaultDestroy(type, handlefield) \
|
||||||
|
static void type ## Destroy(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
type *this = type(c); \
|
uiControlVerifyDestroy(c); \
|
||||||
onDestroy; \
|
[type(c)->handlefield release]; \
|
||||||
g_object_unref(this->widget); \
|
uiFreeControl(c); \
|
||||||
} \
|
}
|
||||||
static uintptr_t _ ## type ## Handle(uiControl *c) \
|
#define uiUnixControlDefaultHandle(type, handlefield) \
|
||||||
|
static uintptr_t type ## Handle(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
return (uintptr_t) (type(c)->widget); \
|
return (uintptr_t) (type(c)->handlefield); \
|
||||||
} \
|
}
|
||||||
static void _ ## type ## ContainerUpdateState(uiControl *c) \
|
#define uiUnixControlDefaultParent(type, handlefield) \
|
||||||
|
static uiControl *type ## Parent(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
/* do nothing */ \
|
return uiUnixControl(c)->parent; \
|
||||||
|
}
|
||||||
|
#define uiUnixControlDefaultSetParent(type, handlefield) \
|
||||||
|
static void type ## SetParent(uiControl *c, uiControl *parent) \
|
||||||
|
{ \
|
||||||
|
uiControlVerifySetParent(c, parent); \
|
||||||
|
uiUnixControl(c)->parent = parent; \
|
||||||
|
}
|
||||||
|
#define uiUnixControlDefaultToplevel(type, handlefield) \
|
||||||
|
static int type ## Toplevel(uiControl *c) \
|
||||||
|
{ \
|
||||||
|
return 0; \
|
||||||
|
}
|
||||||
|
#define uiUnixControlDefaultVisible(type, handlefield) \
|
||||||
|
static int type ## Visible(uiControl *c) \
|
||||||
|
{ \
|
||||||
|
return uiUnixControl(c)->visible; \
|
||||||
|
}
|
||||||
|
#define uiUnixControlDefaultShow(type, handlefield) \
|
||||||
|
static void type ## Show(uiControl *c) \
|
||||||
|
{ \
|
||||||
|
uiUnixControl(c)->visible = YES; \
|
||||||
|
[type(c)->handlefield setHidden:NO]; \
|
||||||
|
}
|
||||||
|
#define uiUnixControlDefaultHide(type, handlefield) \
|
||||||
|
static void type ## Hide(uiControl *c) \
|
||||||
|
{ \
|
||||||
|
uiUnixControl(c)->visible = NO; \
|
||||||
|
[type(c)->handlefield setHidden:YES]; \
|
||||||
|
}
|
||||||
|
#define uiUnixControlDefaultEnabled(type, handlefield) \
|
||||||
|
static int type ## Enabled(uiControl *c) \
|
||||||
|
{ \
|
||||||
|
return uiUnixControl(c)->enabled; \
|
||||||
|
}
|
||||||
|
#define uiUnixControlDefaultEnable(type, handlefield) \
|
||||||
|
static void type ## Enable(uiControl *c) \
|
||||||
|
{ \
|
||||||
|
uiUnixControl(c)->enabled = YES; \
|
||||||
|
uiControlSyncEnableState(c, uiControlEnabledToUser(c)); \
|
||||||
|
}
|
||||||
|
#define uiUnixControlDefaultDisable(type, handlefield) \
|
||||||
|
static void type ## Disable(uiControl *c) \
|
||||||
|
{ \
|
||||||
|
uiUnixControl(c)->enabled = NO; \
|
||||||
|
uiControlSyncEnableState(c, uiControlEnabledToUser(c)); \
|
||||||
|
}
|
||||||
|
#define uiUnixControlDefaultSyncEnableState(type, handlefield) \
|
||||||
|
static void type ## SyncEnableState(uiControl *c, int enabled) \
|
||||||
|
{ \
|
||||||
|
if ([type(c)->handlefield respondsToSelector:@selector(setEnabled:)]) \
|
||||||
|
[((id) type(c)->handlefield) setEnabled:enabled]; /* id cast to make compiler happy; thanks mikeash in irc.freenode.net/#macdev */ \
|
||||||
|
}
|
||||||
|
#define uiUnixControlDefaultSetSuperview(type, handlefield) \
|
||||||
|
static void type ## SetSuperview(uiUnixControl *c, NSView *superview) \
|
||||||
|
{ \
|
||||||
|
[type(c)->handlefield setTranslatesAutoresizingMaskIntoConstraints:NO]; \
|
||||||
|
if (superview == nil) \
|
||||||
|
[type(c)->handlefield removeFromSuperview]; \
|
||||||
|
else \
|
||||||
|
[superview addSubview:type(c)->handlefield]; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define uiUnixDefineControl(type) \
|
#define uiUnixControlAllDefaultsExceptDestroy(type, handlefield) \
|
||||||
uiUnixDefineControlWithOnDestroy(type, (void) this;)
|
uiUnixControlDefaultHandle(type, handlefield) \
|
||||||
|
uiUnixControlDefaultParent(type, handlefield) \
|
||||||
|
uiUnixControlDefaultSetParent(type, handlefield) \
|
||||||
|
uiUnixControlDefaultToplevel(type, handlefield) \
|
||||||
|
uiUnixControlDefaultVisible(type, handlefield) \
|
||||||
|
uiUnixControlDefaultShow(type, handlefield) \
|
||||||
|
uiUnixControlDefaultHide(type, handlefield) \
|
||||||
|
uiUnixControlDefaultEnabled(type, handlefield) \
|
||||||
|
uiUnixControlDefaultEnable(type, handlefield) \
|
||||||
|
uiUnixControlDefaultDisable(type, handlefield) \
|
||||||
|
uiUnixControlDefaultSyncEnableState(type, handlefield) \
|
||||||
|
uiUnixControlDefaultSetSuperview(type, handlefield)
|
||||||
|
|
||||||
|
#define uiUnixControlAllDefaults(type, handlefield) \
|
||||||
|
uiUnixControlDefaultDestroy(type, handlefield) \
|
||||||
|
uiUnixControlAllDefaultsExceptDestroy(type, handlefield)
|
||||||
|
|
||||||
// TODO document
|
// TODO document
|
||||||
#define uiNewControl(type) uiUnixNewControl(sizeof (type), type ## Signature, #type)
|
#define uiUnixNewControl(type, var) \
|
||||||
_UI_EXTERN uiUnixControl *uiUnixNewControl(size_t n, uint32_t typesig, const char *typenamestr);
|
var = type(uiUnixAllocControl(sizeof (type), type ## Signature, #type)); \
|
||||||
|
uiControl(var)->Destroy = type ## Destroy; \
|
||||||
#define uiUnixFinishNewControl(variable, type) \
|
uiControl(var)->Handle = type ## Handle; \
|
||||||
uiControl(variable)->CommitDestroy = _ ## type ## CommitDestroy; \
|
uiControl(var)->Parent = type ## Parent; \
|
||||||
uiControl(variable)->Handle = _ ## type ## Handle; \
|
uiControl(var)->SetParent = type ## SetParent; \
|
||||||
uiControl(variable)->ContainerUpdateState = _ ## type ## ContainerUpdateState; \
|
uiControl(var)->Toplevel = type ## Toplevel; \
|
||||||
uiUnixFinishControl(uiControl(variable));
|
uiControl(var)->Visible = type ## Visible; \
|
||||||
|
uiControl(var)->Show = type ## Show; \
|
||||||
// This is a function used to set up a control.
|
uiControl(var)->Hide = type ## Hide; \
|
||||||
// Don't call it directly; use uiUnixFinishNewControl() instead.
|
uiControl(var)->Enabled = type ## Enabled; \
|
||||||
_UI_EXTERN void uiUnixFinishControl(uiControl *c);
|
uiControl(var)->Enable = type ## Enable; \
|
||||||
|
uiControl(var)->Disable = type ## Disable; \
|
||||||
|
uiControl(var)->SyncEnableState = type ## SyncEnableState; \
|
||||||
|
uiUnixControl(var)->SetSuperview = type ## SetSuperview; \
|
||||||
|
uiUnixControl(var)->visible = YES; \
|
||||||
|
uiUnixControl(var)->enabled = YES;
|
||||||
|
// TODO document
|
||||||
|
_UI_EXTERN uiUnixControl *uiUnixAllocControl(size_t n, uint32_t typesig, const char *typenamestr);
|
||||||
|
|
||||||
// uiUnixStrdupText() takes the given string and produces a copy of it suitable for being freed by uiFreeText().
|
// uiUnixStrdupText() takes the given string and produces a copy of it suitable for being freed by uiFreeText().
|
||||||
_UI_EXTERN char *uiUnixStrdupText(const char *);
|
_UI_EXTERN char *uiUnixStrdupText(const char *);
|
||||||
|
|
Loading…
Reference in New Issue