Finished the type system.
This commit is contained in:
parent
69e27488f7
commit
97cb70527e
|
@ -265,12 +265,12 @@ uiBox *uiNewHorizontalBox(void)
|
||||||
struct box *b;
|
struct box *b;
|
||||||
|
|
||||||
b = uiNew(struct box);
|
b = uiNew(struct box);
|
||||||
|
uiTyped(b)->Type = uiTypeBox();
|
||||||
|
|
||||||
uiMakeContainer(uiControl(b));
|
uiMakeContainer(uiControl(b));
|
||||||
|
|
||||||
b->controls = newPtrArray();
|
b->controls = newPtrArray();
|
||||||
|
|
||||||
uiControl(b)->Type = uiTypeBox();
|
|
||||||
b->baseDestroy = uiControl(b)->Destroy;
|
b->baseDestroy = uiControl(b)->Destroy;
|
||||||
uiControl(b)->Destroy = boxDestroy;
|
uiControl(b)->Destroy = boxDestroy;
|
||||||
b->baseSetParent = uiControl(b)->SetParent;
|
b->baseSetParent = uiControl(b)->SetParent;
|
||||||
|
|
|
@ -33,6 +33,7 @@ func IsA(p *void, type uintmax_t, fail int) *void;
|
||||||
struct Typed {
|
struct Typed {
|
||||||
field Type uintmax_t;
|
field Type uintmax_t;
|
||||||
};
|
};
|
||||||
|
raw "#define uiTyped(this) ((uiTyped *) (this))";
|
||||||
|
|
||||||
raw "typedef struct uiSizingSys uiSizingSys;";
|
raw "typedef struct uiSizingSys uiSizingSys;";
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,7 @@ uiGroup *uiNewGroup(const char *text)
|
||||||
WCHAR *wtext;
|
WCHAR *wtext;
|
||||||
|
|
||||||
g = uiNew(struct group);
|
g = uiNew(struct group);
|
||||||
|
uiTyped(g)->Type = uiTypeGroup();
|
||||||
|
|
||||||
p.dwExStyle = WS_EX_CONTROLPARENT;
|
p.dwExStyle = WS_EX_CONTROLPARENT;
|
||||||
p.lpClassName = L"button";
|
p.lpClassName = L"button";
|
||||||
|
@ -110,7 +111,6 @@ uiGroup *uiNewGroup(const char *text)
|
||||||
|
|
||||||
g->hwnd = (HWND) uiControlHandle(uiControl(g));
|
g->hwnd = (HWND) uiControlHandle(uiControl(g));
|
||||||
|
|
||||||
uiControl(g)->Type = uiTypeGroup();
|
|
||||||
uiControl(g)->PreferredSize = groupPreferredSize;
|
uiControl(g)->PreferredSize = groupPreferredSize;
|
||||||
g->baseResize = uiControl(g)->Resize;
|
g->baseResize = uiControl(g)->Resize;
|
||||||
uiControl(g)->Resize = groupResize;
|
uiControl(g)->Resize = groupResize;
|
||||||
|
|
|
@ -329,6 +329,7 @@ uiTab *uiNewTab(void)
|
||||||
uiWindowsMakeControlParams p;
|
uiWindowsMakeControlParams p;
|
||||||
|
|
||||||
t = uiNew(struct tab);
|
t = uiNew(struct tab);
|
||||||
|
uiTyped(t)->Type = uiTypeTab();
|
||||||
|
|
||||||
p.dwExStyle = 0; // don't set WS_EX_CONTROLPARENT yet; we do that dynamically in the message loop (see main_windows.c)
|
p.dwExStyle = 0; // don't set WS_EX_CONTROLPARENT yet; we do that dynamically in the message loop (see main_windows.c)
|
||||||
p.lpClassName = WC_TABCONTROLW;
|
p.lpClassName = WC_TABCONTROLW;
|
||||||
|
@ -349,7 +350,6 @@ uiTab *uiNewTab(void)
|
||||||
if (SetWindowSubclass(t->hwnd, tabSubProc, 0, (DWORD_PTR) t) == FALSE)
|
if (SetWindowSubclass(t->hwnd, tabSubProc, 0, (DWORD_PTR) t) == FALSE)
|
||||||
logLastError("error subclassing Tab to give it its own resize handler in uiNewTab()");
|
logLastError("error subclassing Tab to give it its own resize handler in uiNewTab()");
|
||||||
|
|
||||||
uiControl(t)->Type = uiTypeTab();
|
|
||||||
uiControl(t)->PreferredSize = tabPreferredSize;
|
uiControl(t)->PreferredSize = tabPreferredSize;
|
||||||
t->baseResize = uiControl(t)->Resize;
|
t->baseResize = uiControl(t)->Resize;
|
||||||
uiControl(t)->Resize = tabResize;
|
uiControl(t)->Resize = tabResize;
|
||||||
|
|
|
@ -85,6 +85,7 @@ uiButton *uiNewButton(const char *text)
|
||||||
WCHAR *wtext;
|
WCHAR *wtext;
|
||||||
|
|
||||||
b = uiNew(struct button);
|
b = uiNew(struct button);
|
||||||
|
uiTyped(b)->Type = uiTypeButton();
|
||||||
|
|
||||||
p.dwExStyle = 0;
|
p.dwExStyle = 0;
|
||||||
p.lpClassName = L"button";
|
p.lpClassName = L"button";
|
||||||
|
@ -105,7 +106,6 @@ uiButton *uiNewButton(const char *text)
|
||||||
|
|
||||||
b->onClicked = defaultOnClicked;
|
b->onClicked = defaultOnClicked;
|
||||||
|
|
||||||
uiControl(b)->Type = uiTypeButton();
|
|
||||||
uiControl(b)->PreferredSize = buttonPreferredSize;
|
uiControl(b)->PreferredSize = buttonPreferredSize;
|
||||||
|
|
||||||
uiButton(b)->Text = buttonText;
|
uiButton(b)->Text = buttonText;
|
||||||
|
|
|
@ -100,6 +100,7 @@ uiCheckbox *uiNewCheckbox(const char *text)
|
||||||
WCHAR *wtext;
|
WCHAR *wtext;
|
||||||
|
|
||||||
c = uiNew(struct checkbox);
|
c = uiNew(struct checkbox);
|
||||||
|
uiTyped(c)->Type = uiTypeCheckbox();
|
||||||
|
|
||||||
p.dwExStyle = 0;
|
p.dwExStyle = 0;
|
||||||
p.lpClassName = L"button";
|
p.lpClassName = L"button";
|
||||||
|
@ -120,7 +121,6 @@ uiCheckbox *uiNewCheckbox(const char *text)
|
||||||
|
|
||||||
c->onToggled = defaultOnToggled;
|
c->onToggled = defaultOnToggled;
|
||||||
|
|
||||||
uiControl(c)->Type = uiTypeCheckbox();
|
|
||||||
uiControl(c)->PreferredSize = checkboxPreferredSize;
|
uiControl(c)->PreferredSize = checkboxPreferredSize;
|
||||||
|
|
||||||
uiCheckbox(c)->Text = checkboxText;
|
uiCheckbox(c)->Text = checkboxText;
|
||||||
|
|
|
@ -97,6 +97,7 @@ uiEntry *uiNewEntry(void)
|
||||||
uiWindowsMakeControlParams p;
|
uiWindowsMakeControlParams p;
|
||||||
|
|
||||||
e = uiNew(struct entry);
|
e = uiNew(struct entry);
|
||||||
|
uiTyped(e)->Type = uiTypeEntry();
|
||||||
|
|
||||||
p.dwExStyle = WS_EX_CLIENTEDGE;
|
p.dwExStyle = WS_EX_CLIENTEDGE;
|
||||||
p.lpClassName = L"edit";
|
p.lpClassName = L"edit";
|
||||||
|
@ -115,7 +116,6 @@ uiEntry *uiNewEntry(void)
|
||||||
|
|
||||||
e->onChanged = defaultOnChanged;
|
e->onChanged = defaultOnChanged;
|
||||||
|
|
||||||
uiControl(e)->Type = uiTypeEntry();
|
|
||||||
uiControl(e)->PreferredSize = entryPreferredSize;
|
uiControl(e)->PreferredSize = entryPreferredSize;
|
||||||
|
|
||||||
uiEntry(e)->Text = entryText;
|
uiEntry(e)->Text = entryText;
|
||||||
|
|
|
@ -38,6 +38,7 @@ uiGroup *uiNewGroup(const char *text)
|
||||||
WCHAR *wtext;
|
WCHAR *wtext;
|
||||||
|
|
||||||
g = uiNew(struct group);
|
g = uiNew(struct group);
|
||||||
|
uiTyped(g)->Type = uiTypeGroup();
|
||||||
|
|
||||||
p.dwExStyle = WS_EX_CONTROLPARENT;
|
p.dwExStyle = WS_EX_CONTROLPARENT;
|
||||||
p.lpClassName = L"button";
|
p.lpClassName = L"button";
|
||||||
|
@ -56,7 +57,6 @@ uiGroup *uiNewGroup(const char *text)
|
||||||
|
|
||||||
g->hwnd = (HWND) uiControlHandle(uiControl(g));
|
g->hwnd = (HWND) uiControlHandle(uiControl(g));
|
||||||
|
|
||||||
uiControl(g)->Type = uiTypeGroup();
|
|
||||||
uiControl(g)->PreferredSize = groupPreferredSize;
|
uiControl(g)->PreferredSize = groupPreferredSize;
|
||||||
|
|
||||||
uiGroup(g)->SetChild = groupSetChild;
|
uiGroup(g)->SetChild = groupSetChild;
|
||||||
|
|
|
@ -51,6 +51,7 @@ uiLabel *uiNewLabel(const char *text)
|
||||||
WCHAR *wtext;
|
WCHAR *wtext;
|
||||||
|
|
||||||
l = uiNew(struct label);
|
l = uiNew(struct label);
|
||||||
|
uiTyped(l)->Type = uiTypeLabel();
|
||||||
|
|
||||||
p.dwExStyle = 0;
|
p.dwExStyle = 0;
|
||||||
p.lpClassName = L"static";
|
p.lpClassName = L"static";
|
||||||
|
@ -71,7 +72,6 @@ uiLabel *uiNewLabel(const char *text)
|
||||||
|
|
||||||
l->hwnd = (HWND) uiControlHandle(uiControl(l));
|
l->hwnd = (HWND) uiControlHandle(uiControl(l));
|
||||||
|
|
||||||
uiControl(l)->Type = uiTypeLabel();
|
|
||||||
uiControl(l)->PreferredSize = labelPreferredSize;
|
uiControl(l)->PreferredSize = labelPreferredSize;
|
||||||
|
|
||||||
uiLabel(l)->Text = labelText;
|
uiLabel(l)->Text = labelText;
|
||||||
|
|
|
@ -131,6 +131,8 @@ static uiMenuItem *newItem(struct menu *m, int type, const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
item = uiNew(struct menuItem);
|
item = uiNew(struct menuItem);
|
||||||
|
uiTyped(item)->Type = uiTypeMenuItem();
|
||||||
|
|
||||||
m->items[m->len] = item;
|
m->items[m->len] = item;
|
||||||
m->len++;
|
m->len++;
|
||||||
|
|
||||||
|
@ -161,7 +163,6 @@ static uiMenuItem *newItem(struct menu *m, int type, const char *name)
|
||||||
if (item->type == typeQuit)
|
if (item->type == typeQuit)
|
||||||
item->onClicked = onQuitClicked;
|
item->onClicked = onQuitClicked;
|
||||||
|
|
||||||
uiMenuItem(item)->Type = uiTypeMenuItem();
|
|
||||||
uiMenuItem(item)->Enable = menuItemEnable;
|
uiMenuItem(item)->Enable = menuItemEnable;
|
||||||
uiMenuItem(item)->Disable = menuItemDisable;
|
uiMenuItem(item)->Disable = menuItemDisable;
|
||||||
uiMenuItem(item)->OnClicked = menuItemOnClicked;
|
uiMenuItem(item)->OnClicked = menuItemOnClicked;
|
||||||
|
@ -225,12 +226,13 @@ uiMenu *uiNewMenu(const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
m = uiNew(struct menu);
|
m = uiNew(struct menu);
|
||||||
|
uiTyped(m)->Type = uiTypeMenu();
|
||||||
|
|
||||||
menus[len] = m;
|
menus[len] = m;
|
||||||
len++;
|
len++;
|
||||||
|
|
||||||
m->name = toUTF16(name);
|
m->name = toUTF16(name);
|
||||||
|
|
||||||
uiMenu(m)->Type = uiTypeMenu();
|
|
||||||
uiMenu(m)->AppendItem = menuAppendItem;
|
uiMenu(m)->AppendItem = menuAppendItem;
|
||||||
uiMenu(m)->AppendCheckItem = menuAppendCheckItem;
|
uiMenu(m)->AppendCheckItem = menuAppendCheckItem;
|
||||||
uiMenu(m)->AppendQuitItem = menuAppendQuitItem;
|
uiMenu(m)->AppendQuitItem = menuAppendQuitItem;
|
||||||
|
|
|
@ -58,6 +58,7 @@ uiTab *uiNewTab(void)
|
||||||
uiWindowsMakeControlParams p;
|
uiWindowsMakeControlParams p;
|
||||||
|
|
||||||
t = uiNew(struct tab);
|
t = uiNew(struct tab);
|
||||||
|
uiTyped(t)->Type = uiTypeTab();
|
||||||
|
|
||||||
p.dwExStyle = 0; // don't set WS_EX_CONTROLPARENT yet; we do that dynamically in the message loop (see main_windows.c)
|
p.dwExStyle = 0; // don't set WS_EX_CONTROLPARENT yet; we do that dynamically in the message loop (see main_windows.c)
|
||||||
p.lpClassName = WC_TABCONTROLW;
|
p.lpClassName = WC_TABCONTROLW;
|
||||||
|
@ -74,7 +75,6 @@ uiTab *uiNewTab(void)
|
||||||
|
|
||||||
t->hwnd = (HWND) uiControlHandle(uiControl(t));
|
t->hwnd = (HWND) uiControlHandle(uiControl(t));
|
||||||
|
|
||||||
uiControl(t)->Type = uiTypeTab();
|
|
||||||
uiControl(t)->PreferredSize = tabPreferredSize;
|
uiControl(t)->PreferredSize = tabPreferredSize;
|
||||||
|
|
||||||
uiTab(t)->AppendPage = tabAppendPage;
|
uiTab(t)->AppendPage = tabAppendPage;
|
||||||
|
|
|
@ -322,6 +322,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
||||||
BOOL hasMenubarBOOL;
|
BOOL hasMenubarBOOL;
|
||||||
|
|
||||||
w = uiNew(struct window);
|
w = uiNew(struct window);
|
||||||
|
uiTyped(w)->Type = uiTypeWindow();
|
||||||
|
|
||||||
hasMenubarBOOL = FALSE;
|
hasMenubarBOOL = FALSE;
|
||||||
if (hasMenubar)
|
if (hasMenubar)
|
||||||
|
@ -355,7 +356,6 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
||||||
|
|
||||||
w->onClosing = defaultOnClosing;
|
w->onClosing = defaultOnClosing;
|
||||||
|
|
||||||
uiControl(w)->Type = uiTypeWindow();
|
|
||||||
uiControl(w)->Destroy = windowDestroy;
|
uiControl(w)->Destroy = windowDestroy;
|
||||||
uiControl(w)->Handle = windowHandle;
|
uiControl(w)->Handle = windowHandle;
|
||||||
uiControl(w)->Parent = windowParent;
|
uiControl(w)->Parent = windowParent;
|
||||||
|
|
Loading…
Reference in New Issue