Finished ui_windows.h. Now we have to actually write all this. Yay...

This commit is contained in:
Pietro Gagliardi 2016-04-26 19:07:56 -04:00
parent 25b9231ff8
commit dab10d13d2
1 changed files with 131 additions and 1 deletions

View File

@ -19,6 +19,7 @@ struct uiWindowsControl {
uiControl *parent;
BOOL enabled;
BOOL visible;
void (*SyncEnableState)(uiWindowsControl *, int);
void (*SetParentHWND)(uiWindowsControl *, HWND);
void (*MinimumSize)(uiWindowsControl *, intmax_t *, intmax_t *);
void (*ChildMinimumSizeChanged)(uiWIndowsControl *);
@ -26,13 +27,142 @@ struct uiWindowsControl {
};
#define uiWindowsControl(this) ((uiWindowsControl *) (this))
// TODO document
_UI_EXTERN void uiWindowsControlSyncEnableState(uiWindowsControl *, int);
_UI_EXTERN void uiWindowsControlSetParentHWND(uiWindowsControl *, HWND);
_UI_EXTERN void uiWindowsControlMinimumSize(uiWindowsControl *, intmax_t *, intmax_t *);
_UI_EXTERN void uiWindowsControlChildMinimumSizeChanged(uiWindowsControl *);
_UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_PTR *, HWND *);
// TODO document
xxxx
#define uiWindowsControlDefaultDestroy(type) \
static void type ## Destroy(uiControl *c) \
{ \
uiControlVerifyDestroy(c); \
uiWindowsEnsureDestroyWindow(type(c)->hwnd); \
uiFreeControl(c); \
}
#define uiWindowsControlDefaultHandle(type) \
static uintptr_t type ## Handle(uiControl *c) \
{ \
return (uintptr_t) (type(c)->hwnd); \
}
#define uiWindowsControlDefaultParent(type) \
static uiControl *type ## Parent(uiControl *c) \
{ \
return uiWindowsControl(c)->parent; \
}
#define uiWindowsControlDefaultSetParent(type) \
static void type ## SetParent(uiControl *c, uiControl *parent) \
{ \
uiControlVerifySetParent(c, parent); \
uiWindowsControl(c)->parent = parent; \
}
#define uiWindowsControlDefaultToplevel(type) \
static int type ## Toplevel(uiControl *c) \
{ \
return 0; \
}
#define uiWindowsControlDefaultVisible(type) \
static int type ## Visible(uiControl *c) \
{ \
return uiWindowsControl(c)->visible; \
}
#define uiWindowsControlDefaultShow(type) \
static void type ## Show(uiControl *c) \
{ \
uiWindowsControl(c)->visible = YES; \
ShowWindow(type(c)->hwnd, SW_SHOW); \
}
#define uiWindowsControlDefaultHide(type) \
static void type ## Hide(uiControl *c) \
{ \
uiWindowsControl(c)->visible = NO; \
ShowWindow(type(c)->hwnd, SW_HIDE); \
}
#define uiWindowsControlDefaultEnabled(type) \
static int type ## Enabled(uiControl *c) \
{ \
return uiWindowsControl(c)->enabled; \
}
#define uiWindowsControlDefaultEnable(type) \
static void type ## Enable(uiControl *c) \
{ \
uiWindowsControl(c)->enabled = YES; \
uiWindowsControlSyncEnableState(uiWindowsControl(c), uiControlEnabledToUser(c)); \
}
#define uiWindowsControlDefaultDisable(type) \
static void type ## Disable(uiControl *c) \
{ \
uiWindowsControl(c)->enabled = NO; \
uiWindowsControlSyncEnableState(uiWindowsControl(c), uiControlEnabledToUser(c)); \
}
#define uiWindowsControlDefaultSyncEnableState(type) \
static void type ## SyncEnableState(uiWindowsControl *c, int enabled) \
{ \
if (uiWindowsShouldStopSyncEnableState(c, enabled)) \
return; \
EnableWindow(type(c)->hwnd, enabled); \
}
#define uiWindowsControlDefaultSetParentHWND(type) \
static void type ## SetParentHWND(uiWindowsControl *c, HWND parent) \
{ \
uiWindowsEnsureSetParent(type(c)->hwnd, parent); \
}
// note that there is no uiWindowsControlDefaultMinimumSize(); you MUST define this yourself!
#define uiWindowsDefaultChildMinimumSizeChanged(type) \
static void type ## ChildMinimumSizeChanged)(uiWIndowsControl *c) \
{ \
/* do nothing; default has no children */ \
}
#define uiWindowsDefaultAssignControlIDZorder(type) \
static void type ## AssignControlIDZOrder)(uiWindowsControl *c, LONG_PTR *cID, HWND *zorder) \
{ \
uiWindowsEnsureAssignControlIDZOrder(c, cID, zorder); \
}
#define uiWindowsControlAllDefaultsExceptDestroy(type) \
uiWindowsControlDefaultHandle(type) \
uiWindowsControlDefaultParent(type) \
uiWindowsControlDefaultSetParent(type) \
uiWindowsControlDefaultToplevel(type) \
uiWindowsControlDefaultVisible(type) \
uiWindowsControlDefaultShow(type) \
uiWindowsControlDefaultHide(type) \
uiWindowsControlDefaultEnabled(type) \
uiWindowsControlDefaultEnable(type) \
uiWindowsControlDefaultDisable(type) \
uiWindowsControlDefaultSyncEnableState(type) \
uiWindowsControlDefaultSetParentHWND(type) \
uiWindowsDefaultChildMinimumSizeChanged(type) \
uiWindowsDefaultAssignControlIDZorder(type)
#define uiWindowsControlAllDefaults(type) \
uiWindowsControlDefaultDestroy(type) \
uiWindowsControlAllDefaultsExceptDestroy(type)
// TODO document
#define uiWindowsNewControl(type, var) \
var = type(uiWindowsAllocControl(sizeof (type), type ## Signature, #type)); \
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; \
uiWindowsControl(var)->SyncEnableState = type ## SyncEnableState; \
uiWindowsControl(var)->SetParentHWND = type ## SetParentHWND; \
uiWindowsControl(var)->MinimumSize = type ## MinimumSize; \
uiWindowsControl(var)->ChildMinimumSizeChanged = type ## ChildMinimumSizeChanged; \
uiWindowsControl(var)->AssignControlIDZOrder = type ## AssignControlIDZorder; \
uiWindowsControl(var)->visible = YES; \
uiWindowsControl(var)->enabled = YES;
// TODO document
_UI_EXTERN uiWindowsControl *uiWindowsAllocControl(size_t n, uint32_t typesig, const char *typenamestr);
// TODO document
_UI_EXTERN HWND uiWindowsEnsureCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, HINSTANCE hInstance, LPVOID lpParam, BOOL useStandardControlFont);