Implemented uiTabInsertPageBefore() on Windows.
This commit is contained in:
parent
84114f4913
commit
d247e76866
4
TODO.md
4
TODO.md
|
@ -71,3 +71,7 @@ notes to self
|
||||||
- explicitly document label position at top-left corner
|
- explicitly document label position at top-left corner
|
||||||
- mark that uiControlShow() on a uiWindow() will bring to front and give keyboard focus because of OS X
|
- mark that uiControlShow() on a uiWindow() will bring to front and give keyboard focus because of OS X
|
||||||
- make sure ShowWindow() is sufficient for zorder on Windows
|
- make sure ShowWindow() is sufficient for zorder on Windows
|
||||||
|
- document that you can't use InsertBefore functions to insert before a nonexistent index (that includes if an array is empty)
|
||||||
|
- reconsider this, as the pointer array code does work with the first invalid index...
|
||||||
|
- we would need to test everything else with it
|
||||||
|
- note that uiTabInsertPageBefore() does NOT change the current tab page (it may change its index if inserting before the current page)
|
||||||
|
|
|
@ -26,8 +26,9 @@ static void movePage1(uiButton *b, void *data)
|
||||||
{
|
{
|
||||||
if (moveBack) {
|
if (moveBack) {
|
||||||
uiBoxDelete(mainBox, 1);
|
uiBoxDelete(mainBox, 1);
|
||||||
uiTabInsertPageBefore(mainTab, 0, uiControl(page1));
|
uiTabInsertPageBefore(mainTab, "Page 1", 0, uiControl(page1));
|
||||||
uiButtonSetText(b, moveOutText);
|
uiButtonSetText(b, moveOutText);
|
||||||
|
moveBack = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uiTabDeletePage(mainTab, 0);
|
uiTabDeletePage(mainTab, 0);
|
||||||
|
|
|
@ -233,6 +233,32 @@ static void tabAppendPage(uiTab *tt, const char *name, uiControl *child)
|
||||||
SendMessageW(t->hwnd, msgUpdateChild, 0, 0);
|
SendMessageW(t->hwnd, msgUpdateChild, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tabInsertPageBefore(uiTab *tt, const char *name, uintmax_t n, uiControl *child)
|
||||||
|
{
|
||||||
|
struct tab *t = (struct tab *) tt;
|
||||||
|
TCITEMW item;
|
||||||
|
struct tabPage *page;
|
||||||
|
WCHAR *wname;
|
||||||
|
|
||||||
|
page = uiNew(struct tabPage);
|
||||||
|
|
||||||
|
page->bin = newBin();
|
||||||
|
binSetMainControl(page->bin, child);
|
||||||
|
binSetParent(page->bin, (uintptr_t) (t->hwnd));
|
||||||
|
// always hide; the current tab doesn't change
|
||||||
|
uiControlHide(uiControl(page->bin));
|
||||||
|
|
||||||
|
ptrArrayInsertBefore(t->pages, n, page);
|
||||||
|
|
||||||
|
ZeroMemory(&item, sizeof (TCITEMW));
|
||||||
|
item.mask = TCIF_TEXT;
|
||||||
|
wname = toUTF16(name);
|
||||||
|
item.pszText = wname;
|
||||||
|
if (SendMessageW(t->hwnd, TCM_INSERTITEM, (WPARAM) n, (LPARAM) (&item)) == (LRESULT) -1)
|
||||||
|
logLastError("error adding tab to Tab in uiTabInsertPageBefore()");
|
||||||
|
uiFree(wname);
|
||||||
|
}
|
||||||
|
|
||||||
static void tabDeletePage(uiTab *tt, uintmax_t n)
|
static void tabDeletePage(uiTab *tt, uintmax_t n)
|
||||||
{
|
{
|
||||||
struct tab *t = (struct tab *) tt;
|
struct tab *t = (struct tab *) tt;
|
||||||
|
@ -322,6 +348,7 @@ uiTab *uiNewTab(void)
|
||||||
uiControl(t)->SysFunc = tabSysFunc;
|
uiControl(t)->SysFunc = tabSysFunc;
|
||||||
|
|
||||||
uiTab(t)->AppendPage = tabAppendPage;
|
uiTab(t)->AppendPage = tabAppendPage;
|
||||||
|
uiTab(t)->InsertPageBefore = tabInsertPageBefore;
|
||||||
uiTab(t)->DeletePage = tabDeletePage;
|
uiTab(t)->DeletePage = tabDeletePage;
|
||||||
uiTab(t)->NumPages = tabNumPages;
|
uiTab(t)->NumPages = tabNumPages;
|
||||||
uiTab(t)->Margined = tabMargined;
|
uiTab(t)->Margined = tabMargined;
|
||||||
|
|
Loading…
Reference in New Issue