Applied the new type system to the Windows backend and fixed some more C++ stupidity related to it.
This commit is contained in:
parent
96e8f1f8ea
commit
bc0a1d43c9
|
@ -149,11 +149,11 @@ void controlUpdateState(uiControl *c)
|
|||
#define uiControlSignature 0x7569436F
|
||||
|
||||
// TODO should this be public?
|
||||
uiControl *newControl(size_t size, uint32_t OSsig, uint32_t typesig, const char *typename)
|
||||
uiControl *newControl(size_t size, uint32_t OSsig, uint32_t typesig, const char *typenamestr)
|
||||
{
|
||||
uiControl *c;
|
||||
|
||||
c = (uiControl *) uiAlloc(size, typename);
|
||||
c = (uiControl *) uiAlloc(size, typenamestr);
|
||||
c->Signature = uiControlSignature;
|
||||
c->OSSignature = OSsig;
|
||||
c->TypeSignature = typesig;
|
||||
|
|
|
@ -25,7 +25,7 @@ extern void osCommitEnable(uiControl *);
|
|||
extern void osCommitDisable(uiControl *);
|
||||
|
||||
// control.c
|
||||
extern uiControl *newControl(size_t size, uint32_t OSsig, uint32_t typesig, const char *typename);
|
||||
extern uiControl *newControl(size_t size, uint32_t OSsig, uint32_t typesig, const char *typenamestr);
|
||||
|
||||
// ptrarray.c
|
||||
struct ptrArray {
|
||||
|
|
|
@ -65,7 +65,7 @@ void uiDarwinSetControlFont(NSControl *c, NSControlSize size)
|
|||
|
||||
#define uiDarwinControlSignature 0x44617277
|
||||
|
||||
uiDarwinControl *uiDarwinNewControl(size_t n, uint32_t typesig, const char *typename)
|
||||
uiDarwinControl *uiDarwinNewControl(size_t n, uint32_t typesig, const char *typenamestr)
|
||||
{
|
||||
return uiDarwinControl(newControl(n, uiDarwinControlSignature, typesig, typename));
|
||||
return uiDarwinControl(newControl(n, uiDarwinControlSignature, typesig, typenamestr));
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ _UI_EXTERN void uiDarwinControlTriggerRelayout(uiDarwinControl *);
|
|||
|
||||
// TODO document
|
||||
#define uiNewControl(type) uiDarwinNewControl(sizeof (type), type ## Signature, #type)
|
||||
_UI_EXTERN uiDarwinControl *uiDarwinNewControl(size_t n, uint32_t typesig, const char *typename);
|
||||
_UI_EXTERN uiDarwinControl *uiDarwinNewControl(size_t n, uint32_t typesig, const char *typenamestr);
|
||||
|
||||
#define uiDarwinFinishNewControl(variable, type) \
|
||||
uiControl(variable)->CommitDestroy = _ ## type ## CommitDestroy; \
|
||||
|
|
|
@ -39,7 +39,7 @@ struct uiUnixControl {
|
|||
|
||||
// TODO document
|
||||
#define uiNewControl(type) uiUnixNewControl(sizeof (type), type ## Signature, #type)
|
||||
_UI_EXTERN uiUnixControl *uiUnixNewControl(size_t n, uint32_t typesig, const char *typename);
|
||||
_UI_EXTERN uiUnixControl *uiUnixNewControl(size_t n, uint32_t typesig, const char *typenamestr);
|
||||
|
||||
#define uiUnixFinishNewControl(variable, type) \
|
||||
uiControl(variable)->CommitDestroy = _ ## type ## CommitDestroy; \
|
||||
|
|
|
@ -65,6 +65,11 @@ _UI_EXTERN void uiWindowsControlQueueRelayout(uiWindowsControl *);
|
|||
#define uiWindowsDefineControl(type) \
|
||||
uiWindowsDefineControlWithOnDestroy(type, (void) me;)
|
||||
|
||||
// TODO document
|
||||
// TODO rename the macro?
|
||||
#define uiNewControl(type) uiWindowsNewControl(sizeof (type), type ## Signature, #type)
|
||||
_UI_EXTERN uiWindowsControl *uiWindowsNewControl(size_t n, uint32_t typesig, const char *typenamestr);
|
||||
|
||||
#define uiWindowsFinishNewControl(variable, type) \
|
||||
uiControl(variable)->CommitDestroy = _ ## type ## CommitDestroy; \
|
||||
uiControl(variable)->Handle = _ ## type ## Handle; \
|
||||
|
|
|
@ -32,7 +32,7 @@ void uiUnixFinishControl(uiControl *c)
|
|||
|
||||
#define uiUnixControlSignature 0x556E6978
|
||||
|
||||
uiUnixControl *uiUnixNewControl(size_t n, uint32_t typesig, const char *typename)
|
||||
uiUnixControl *uiUnixNewControl(size_t n, uint32_t typesig, const char *typenamestr)
|
||||
{
|
||||
return uiUnixControl(newControl(n, uiUnixControlSignature, typesig, typename));
|
||||
return uiUnixControl(newControl(n, uiUnixControlSignature, typesig, typenamestr));
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ uiArea *uiNewArea(uiAreaHandler *ah)
|
|||
{
|
||||
uiArea *a;
|
||||
|
||||
a = (uiArea *) uiNewControl(uiAreaType());
|
||||
a = (uiArea *) uiNewControl(uiArea);
|
||||
|
||||
a->ah = ah;
|
||||
a->scrolling = FALSE;
|
||||
|
@ -127,7 +127,7 @@ uiArea *uiNewScrollingArea(uiAreaHandler *ah, intmax_t width, intmax_t height)
|
|||
{
|
||||
uiArea *a;
|
||||
|
||||
a = (uiArea *) uiNewControl(uiAreaType());
|
||||
a = (uiArea *) uiNewControl(uiArea);
|
||||
|
||||
a->ah = ah;
|
||||
a->scrolling = TRUE;
|
||||
|
|
|
@ -275,7 +275,7 @@ static uiBox *finishNewBox(int vertical)
|
|||
{
|
||||
uiBox *b;
|
||||
|
||||
b = (uiBox *) uiNewControl(uiBoxType());
|
||||
b = (uiBox *) uiNewControl(uiBox);
|
||||
|
||||
b->hwnd = newContainer();
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ uiButton *uiNewButton(const char *text)
|
|||
uiButton *b;
|
||||
WCHAR *wtext;
|
||||
|
||||
b = (uiButton *) uiNewControl(uiButtonType());
|
||||
b = (uiButton *) uiNewControl(uiButton);
|
||||
|
||||
wtext = toUTF16(text);
|
||||
b->hwnd = uiWindowsEnsureCreateControlHWND(0,
|
||||
|
|
|
@ -88,7 +88,7 @@ uiCheckbox *uiNewCheckbox(const char *text)
|
|||
uiCheckbox *c;
|
||||
WCHAR *wtext;
|
||||
|
||||
c = (uiCheckbox *) uiNewControl(uiCheckboxType());
|
||||
c = (uiCheckbox *) uiNewControl(uiCheckbox);
|
||||
|
||||
wtext = toUTF16(text);
|
||||
c->hwnd = uiWindowsEnsureCreateControlHWND(0,
|
||||
|
|
|
@ -85,7 +85,7 @@ static uiCombobox *finishNewCombobox(DWORD style)
|
|||
{
|
||||
uiCombobox *c;
|
||||
|
||||
c = (uiCombobox *) uiNewControl(uiComboboxType());
|
||||
c = (uiCombobox *) uiNewControl(uiCombobox);
|
||||
|
||||
c->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE,
|
||||
L"combobox", L"",
|
||||
|
|
|
@ -24,16 +24,6 @@ HWND uiWindowsEnsureCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCW
|
|||
return hwnd;
|
||||
}
|
||||
|
||||
// TODO make this unnecessary
|
||||
static uintmax_t type_uiWindowsControl = 0;
|
||||
|
||||
uintmax_t uiWindowsControlType(void)
|
||||
{
|
||||
if (type_uiWindowsControl == 0)
|
||||
type_uiWindowsControl = uiRegisterType("uiWindowsControl", uiControlType(), sizeof (uiWindowsControl));
|
||||
return type_uiWindowsControl;
|
||||
}
|
||||
|
||||
static void defaultCommitShow(uiControl *c)
|
||||
{
|
||||
ShowWindow((HWND) uiControlHandle(c), SW_SHOW);
|
||||
|
@ -70,3 +60,11 @@ void uiWindowsRearrangeControlIDsZOrder(uiControl *c)
|
|||
wc = uiWindowsControl(c);
|
||||
(*(wc->ArrangeChildrenControlIDsZOrder))(wc);
|
||||
}
|
||||
|
||||
// choose a value distinct from uiWindowSignature
|
||||
#define uiWindowsControlSignature 0x4D53576E
|
||||
|
||||
uiWindowsControl *uiWindowsNewControl(size_t n, uint32_t typesig, const char *typenamestr)
|
||||
{
|
||||
return uiWindowsControl(newControl(n, uiWindowsControlSignature, typesig, typenamestr));
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ static uiDateTimePicker *finishNewDateTimePicker(DWORD style)
|
|||
{
|
||||
uiDateTimePicker *d;
|
||||
|
||||
d = (uiDateTimePicker *) uiNewControl(uiDateTimePickerType());
|
||||
d = (uiDateTimePicker *) uiNewControl(uiDateTimePicker);
|
||||
|
||||
d->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE,
|
||||
DATETIMEPICK_CLASSW, L"",
|
||||
|
|
|
@ -82,7 +82,7 @@ uiEntry *uiNewEntry(void)
|
|||
{
|
||||
uiEntry *e;
|
||||
|
||||
e = (uiEntry *) uiNewControl(uiEntryType());
|
||||
e = (uiEntry *) uiNewControl(uiEntry);
|
||||
|
||||
e->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE,
|
||||
L"edit", L"",
|
||||
|
|
|
@ -102,7 +102,7 @@ uiFontButton *uiNewFontButton(void)
|
|||
{
|
||||
uiFontButton *b;
|
||||
|
||||
b = (uiFontButton *) uiNewControl(uiFontButtonType());
|
||||
b = (uiFontButton *) uiNewControl(uiFontButton);
|
||||
|
||||
b->hwnd = uiWindowsEnsureCreateControlHWND(0,
|
||||
L"button", L"you should not be seeing this",
|
||||
|
|
|
@ -148,7 +148,7 @@ uiGroup *uiNewGroup(const char *text)
|
|||
uiGroup *g;
|
||||
WCHAR *wtext;
|
||||
|
||||
g = (uiGroup *) uiNewControl(uiGroupType());
|
||||
g = (uiGroup *) uiNewControl(uiGroup);
|
||||
|
||||
wtext = toUTF16(text);
|
||||
g->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CONTROLPARENT,
|
||||
|
|
|
@ -38,7 +38,7 @@ uiLabel *uiNewLabel(const char *text)
|
|||
uiLabel *l;
|
||||
WCHAR *wtext;
|
||||
|
||||
l = (uiLabel *) uiNewControl(uiLabelType());
|
||||
l = (uiLabel *) uiNewControl(uiLabel);
|
||||
|
||||
wtext = toUTF16(text);
|
||||
l->hwnd = uiWindowsEnsureCreateControlHWND(0,
|
||||
|
|
|
@ -13,7 +13,6 @@ static BOOL hasPreferences = FALSE;
|
|||
static BOOL hasAbout = FALSE;
|
||||
|
||||
struct uiMenu {
|
||||
uiTyped t;
|
||||
WCHAR *name;
|
||||
uiMenuItem **items;
|
||||
uintmax_t len;
|
||||
|
@ -21,7 +20,6 @@ struct uiMenu {
|
|||
};
|
||||
|
||||
struct uiMenuItem {
|
||||
uiTyped t;
|
||||
WCHAR *name;
|
||||
int type;
|
||||
WORD id;
|
||||
|
@ -121,7 +119,6 @@ static uiMenuItem *newItem(uiMenu *m, int type, const char *name)
|
|||
}
|
||||
|
||||
item = uiNew(uiMenuItem);
|
||||
uiTyped(item)->Type = uiMenuItemType();
|
||||
|
||||
m->items[m->len] = item;
|
||||
m->len++;
|
||||
|
@ -211,7 +208,6 @@ uiMenu *uiNewMenu(const char *name)
|
|||
}
|
||||
|
||||
m = uiNew(uiMenu);
|
||||
uiTyped(m)->Type = uiMenuType();
|
||||
|
||||
menus[len] = m;
|
||||
len++;
|
||||
|
|
|
@ -101,7 +101,7 @@ uiMultilineEntry *uiNewMultilineEntry(void)
|
|||
{
|
||||
uiMultilineEntry *e;
|
||||
|
||||
e = (uiMultilineEntry *) uiNewControl(uiMultilineEntryType());
|
||||
e = (uiMultilineEntry *) uiNewControl(uiMultilineEntry);
|
||||
|
||||
e->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE,
|
||||
L"edit", L"",
|
||||
|
|
|
@ -43,7 +43,7 @@ uiProgressBar *uiNewProgressBar(void)
|
|||
{
|
||||
uiProgressBar *p;
|
||||
|
||||
p = (uiProgressBar *) uiNewControl(uiProgressBarType());
|
||||
p = (uiProgressBar *) uiNewControl(uiProgressBar);
|
||||
|
||||
p->hwnd = uiWindowsEnsureCreateControlHWND(0,
|
||||
PROGRESS_CLASSW, L"",
|
||||
|
|
|
@ -142,7 +142,7 @@ uiRadioButtons *uiNewRadioButtons(void)
|
|||
{
|
||||
uiRadioButtons *r;
|
||||
|
||||
r = (uiRadioButtons *) uiNewControl(uiRadioButtonsType());
|
||||
r = (uiRadioButtons *) uiNewControl(uiRadioButtons);
|
||||
|
||||
r->hwnd = newContainer();
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ uiSeparator *uiNewHorizontalSeparator(void)
|
|||
{
|
||||
uiSeparator *s;
|
||||
|
||||
s = (uiSeparator *) uiNewControl(uiSeparatorType());
|
||||
s = (uiSeparator *) uiNewControl(uiSeparator);
|
||||
|
||||
s->hwnd = uiWindowsEnsureCreateControlHWND(0,
|
||||
L"static", L"",
|
||||
|
|
|
@ -58,7 +58,7 @@ uiSlider *uiNewSlider(intmax_t min, intmax_t max)
|
|||
{
|
||||
uiSlider *s;
|
||||
|
||||
s = (uiSlider *) uiNewControl(uiSliderType());
|
||||
s = (uiSlider *) uiNewControl(uiSlider);
|
||||
|
||||
s->hwnd = uiWindowsEnsureCreateControlHWND(0,
|
||||
TRACKBAR_CLASSW, L"",
|
||||
|
|
|
@ -176,7 +176,7 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max)
|
|||
if (min >= max)
|
||||
complain("error: min >= max in uiNewSpinbox()");
|
||||
|
||||
s = (uiSpinbox *) uiNewControl(uiSpinboxType());
|
||||
s = (uiSpinbox *) uiNewControl(uiSpinbox);
|
||||
|
||||
s->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE,
|
||||
L"edit", L"",
|
||||
|
|
|
@ -241,7 +241,7 @@ uiTab *uiNewTab(void)
|
|||
{
|
||||
uiTab *t;
|
||||
|
||||
t = (uiTab *) uiNewControl(uiTabType());
|
||||
t = (uiTab *) uiNewControl(uiTab);
|
||||
|
||||
t->hwnd = uiWindowsEnsureCreateControlHWND(0,
|
||||
WC_TABCONTROLW, L"",
|
||||
|
|
|
@ -261,7 +261,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
|||
WCHAR *wtitle;
|
||||
BOOL hasMenubarBOOL;
|
||||
|
||||
w = (uiWindow *) uiNewControl(uiWindowType());
|
||||
w = (uiWindow *) uiNewControl(uiWindow);
|
||||
|
||||
hasMenubarBOOL = FALSE;
|
||||
if (hasMenubar)
|
||||
|
|
Loading…
Reference in New Issue