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