Finished rewriting ui_unix.h. Now to rewrite all the controls. Yay?
This commit is contained in:
parent
12e519f928
commit
6d655cde45
51
ui_unix.h
51
ui_unix.h
|
@ -14,6 +14,8 @@ extern "C" {
|
||||||
typedef struct uiUnixControl uiUnixControl;
|
typedef struct uiUnixControl uiUnixControl;
|
||||||
struct uiUnixControl {
|
struct uiUnixControl {
|
||||||
uiControl c;
|
uiControl c;
|
||||||
|
uiControl *parent;
|
||||||
|
gboolean addedBefore;
|
||||||
void (*SetContainer)(uiUnixControl *, GtkContainer *, gboolean);
|
void (*SetContainer)(uiUnixControl *, GtkContainer *, gboolean);
|
||||||
};
|
};
|
||||||
#define uiUnixControl(this) ((uiUnixControl *) (this))
|
#define uiUnixControl(this) ((uiUnixControl *) (this))
|
||||||
|
@ -24,7 +26,8 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool
|
||||||
static void type ## Destroy(uiControl *c) \
|
static void type ## Destroy(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
uiControlVerifyDestroy(c); \
|
uiControlVerifyDestroy(c); \
|
||||||
[type(c)->handlefield release]; \
|
/* TODO is this safe on floating refs? */ \
|
||||||
|
g_object_unref(type(c)->handlefield); \
|
||||||
uiFreeControl(c); \
|
uiFreeControl(c); \
|
||||||
}
|
}
|
||||||
#define uiUnixControlDefaultHandle(type, handlefield) \
|
#define uiUnixControlDefaultHandle(type, handlefield) \
|
||||||
|
@ -51,51 +54,45 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool
|
||||||
#define uiUnixControlDefaultVisible(type, handlefield) \
|
#define uiUnixControlDefaultVisible(type, handlefield) \
|
||||||
static int type ## Visible(uiControl *c) \
|
static int type ## Visible(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
return uiUnixControl(c)->visible; \
|
return gtk_widget_get_visible(type(c)->handlefield); \
|
||||||
}
|
}
|
||||||
#define uiUnixControlDefaultShow(type, handlefield) \
|
#define uiUnixControlDefaultShow(type, handlefield) \
|
||||||
static void type ## Show(uiControl *c) \
|
static void type ## Show(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
uiUnixControl(c)->visible = YES; \
|
gtk_widget_show(type(c)->handlefield); \
|
||||||
[type(c)->handlefield setHidden:NO]; \
|
|
||||||
}
|
}
|
||||||
#define uiUnixControlDefaultHide(type, handlefield) \
|
#define uiUnixControlDefaultHide(type, handlefield) \
|
||||||
static void type ## Hide(uiControl *c) \
|
static void type ## Hide(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
uiUnixControl(c)->visible = NO; \
|
gtk_widget_hide(type(c)->handlefield); \
|
||||||
[type(c)->handlefield setHidden:YES]; \
|
|
||||||
}
|
}
|
||||||
#define uiUnixControlDefaultEnabled(type, handlefield) \
|
#define uiUnixControlDefaultEnabled(type, handlefield) \
|
||||||
static int type ## Enabled(uiControl *c) \
|
static int type ## Enabled(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
return uiUnixControl(c)->enabled; \
|
return gtk_widget_get_sensitive(type(c)->handlefield); \
|
||||||
}
|
}
|
||||||
#define uiUnixControlDefaultEnable(type, handlefield) \
|
#define uiUnixControlDefaultEnable(type, handlefield) \
|
||||||
static void type ## Enable(uiControl *c) \
|
static void type ## Enable(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
uiUnixControl(c)->enabled = YES; \
|
gtk_widget_set_sensitive(type(c)->handlefield, TRUE); \
|
||||||
uiControlSyncEnableState(c, uiControlEnabledToUser(c)); \
|
|
||||||
}
|
}
|
||||||
#define uiUnixControlDefaultDisable(type, handlefield) \
|
#define uiUnixControlDefaultDisable(type, handlefield) \
|
||||||
static void type ## Disable(uiControl *c) \
|
static void type ## Disable(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
uiUnixControl(c)->enabled = NO; \
|
gtk_widget_set_sensitive(type(c)->handlefield, FALSE); \
|
||||||
uiControlSyncEnableState(c, uiControlEnabledToUser(c)); \
|
|
||||||
}
|
}
|
||||||
#define uiUnixControlDefaultSyncEnableState(type, handlefield) \
|
#define uiUnixControlDefaultSetContainer(type, handlefield) \
|
||||||
static void type ## SyncEnableState(uiControl *c, int enabled) \
|
static void type ## SetContainer(uiUnixControl *c, GtkContainer *container, gboolean remove) \
|
||||||
{ \
|
{ \
|
||||||
if ([type(c)->handlefield respondsToSelector:@selector(setEnabled:)]) \
|
if (!uiUnixControl(c)->addedBefore) { \
|
||||||
[((id) type(c)->handlefield) setEnabled:enabled]; /* id cast to make compiler happy; thanks mikeash in irc.freenode.net/#macdev */ \
|
g_object_ref_sink(type(c)->handlefield); /* our own reference, which we release in Destroy() */ \
|
||||||
}
|
gtk_widget_show(type(c)->handlefield); \
|
||||||
#define uiUnixControlDefaultSetSuperview(type, handlefield) \
|
uiUnixControl(c)->addedBefore = TRUE; \
|
||||||
static void type ## SetSuperview(uiUnixControl *c, NSView *superview) \
|
} \
|
||||||
{ \
|
if (remove) \
|
||||||
[type(c)->handlefield setTranslatesAutoresizingMaskIntoConstraints:NO]; \
|
gtk_container_remove(container, type(c)->handlefield); \
|
||||||
if (superview == nil) \
|
|
||||||
[type(c)->handlefield removeFromSuperview]; \
|
|
||||||
else \
|
else \
|
||||||
[superview addSubview:type(c)->handlefield]; \
|
gtk_container_add(container, type(c)->handlefield); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define uiUnixControlAllDefaultsExceptDestroy(type, handlefield) \
|
#define uiUnixControlAllDefaultsExceptDestroy(type, handlefield) \
|
||||||
|
@ -109,8 +106,7 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool
|
||||||
uiUnixControlDefaultEnabled(type, handlefield) \
|
uiUnixControlDefaultEnabled(type, handlefield) \
|
||||||
uiUnixControlDefaultEnable(type, handlefield) \
|
uiUnixControlDefaultEnable(type, handlefield) \
|
||||||
uiUnixControlDefaultDisable(type, handlefield) \
|
uiUnixControlDefaultDisable(type, handlefield) \
|
||||||
uiUnixControlDefaultSyncEnableState(type, handlefield) \
|
uiUnixControlDefaultSetContainer(type, handlefield)
|
||||||
uiUnixControlDefaultSetSuperview(type, handlefield)
|
|
||||||
|
|
||||||
#define uiUnixControlAllDefaults(type, handlefield) \
|
#define uiUnixControlAllDefaults(type, handlefield) \
|
||||||
uiUnixControlDefaultDestroy(type, handlefield) \
|
uiUnixControlDefaultDestroy(type, handlefield) \
|
||||||
|
@ -130,10 +126,7 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool
|
||||||
uiControl(var)->Enabled = type ## Enabled; \
|
uiControl(var)->Enabled = type ## Enabled; \
|
||||||
uiControl(var)->Enable = type ## Enable; \
|
uiControl(var)->Enable = type ## Enable; \
|
||||||
uiControl(var)->Disable = type ## Disable; \
|
uiControl(var)->Disable = type ## Disable; \
|
||||||
uiControl(var)->SyncEnableState = type ## SyncEnableState; \
|
uiUnixControl(var)->SetContainer = type ## SetContainer;
|
||||||
uiUnixControl(var)->SetSuperview = type ## SetSuperview; \
|
|
||||||
uiUnixControl(var)->visible = YES; \
|
|
||||||
uiUnixControl(var)->enabled = YES;
|
|
||||||
// TODO document
|
// TODO document
|
||||||
_UI_EXTERN uiUnixControl *uiUnixAllocControl(size_t n, uint32_t typesig, const char *typenamestr);
|
_UI_EXTERN uiUnixControl *uiUnixAllocControl(size_t n, uint32_t typesig, const char *typenamestr);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue