Dropped Page from uiTab method names. This keeps things consistent and allows us to do a more important change: InsertBefore -> InsertAt.

This commit is contained in:
Pietro Gagliardi 2015-05-18 10:20:11 -04:00
parent 2a5cdb6662
commit ef794a6db5
6 changed files with 25 additions and 26 deletions

View File

@ -20,7 +20,6 @@ ultimately:
- Windows: requires getting current menu state when amending it in sync()
- figure out where we should return HRESULTs
- Windows: don't abort if a cleanup function fails?
- drop "Page" from uiTab method names? (uiTabAppendPage() -> uiTabAppend())
- make it so Windows API calls that do logLastError(), etc. abort whatever they're doing and not try to continue, just like wintable
- 32-bit Mac OS X support (requires lots of code changes)
- change the build system to be more receptive to arch changes

View File

@ -74,16 +74,16 @@ int main(int argc, char *argv[])
uiBoxAppend(mainBox, uiControl(mainTab), 1);
makePage1(w);
// uiTabAppendPage(mainTab, "Page 1", uiControl(page1));
// uiTabAppend(mainTab, "Page 1", uiControl(page1));
uiWindowSetChild(w, uiControl(page1));
page2 = makePage2();
uiTabAppendPage(mainTab, "Page 2", uiControl(page2));
uiTabAppend(mainTab, "Page 2", uiControl(page2));
uiTabAppendPage(mainTab, "Empty Page", uiControl(uiNewHorizontalBox()));
uiTabAppend(mainTab, "Empty Page", uiControl(uiNewHorizontalBox()));
page3 = makePage3();
uiTabAppendPage(mainTab, "Page 3", uiControl(page3));
uiTabAppend(mainTab, "Page 3", uiControl(page3));
uiControlShow(uiControl(w));
uiMain();

View File

@ -26,12 +26,12 @@ static void movePage1(uiButton *b, void *data)
{
if (moveBack) {
uiBoxDelete(mainBox, 1);
uiTabInsertPageBefore(mainTab, "Page 1", 0, uiControl(page1));
uiTabInsertBefore(mainTab, "Page 1", 0, uiControl(page1));
uiButtonSetText(b, moveOutText);
moveBack = 0;
return;
}
uiTabDeletePage(mainTab, 0);
uiTabDelete(mainTab, 0);
uiBoxAppend(mainBox, uiControl(page1), 1);
uiButtonSetText(b, moveBackText);
moveBack = 1;
@ -156,8 +156,8 @@ uiBox *makePage2(void)
uiBoxAppend(page2, uiControl(hbox), 0);
disabledTab = newTab();
uiTabAppendPage(disabledTab, "Disabled", uiControl(uiNewButton("Button")));
uiTabAppendPage(disabledTab, "Tab", uiControl(uiNewLabel("Label")));
uiTabAppend(disabledTab, "Disabled", uiControl(uiNewButton("Button")));
uiTabAppend(disabledTab, "Tab", uiControl(uiNewLabel("Label")));
uiControlDisable(uiControl(disabledTab));
uiBoxAppend(page2, uiControl(disabledTab), 1);

View File

@ -123,9 +123,9 @@ interface Label from Control {
func NewLabel(text *const char) *Label;
interface Tab from Control {
func AppendPage(name *const char, c *Control);
func InsertPageBefore(name *const char, before uintmax_t, c *Control);
func DeletePage(index uintmax_t);
func Append(name *const char, c *Control);
func InsertBefore(name *const char, before uintmax_t, c *Control);
func Delete(index uintmax_t);
func NumPages(void) uintmax_t;
func Margined(page uintmax_t) int;
func SetMargined(page uintmax_t, margined int);

View File

@ -219,7 +219,7 @@ static LRESULT CALLBACK tabSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
#define tabCapGrow 32
static void tabAppendPage(uiTab *tt, const char *name, uiControl *child)
static void tabAppend(uiTab *tt, const char *name, uiControl *child)
{
struct tab *t = (struct tab *) tt;
TCITEMW item;
@ -252,7 +252,7 @@ static void tabAppendPage(uiTab *tt, const char *name, uiControl *child)
uiControlQueueResize(page->control);
}
static void tabInsertPageBefore(uiTab *tt, const char *name, uintmax_t n, uiControl *child)
static void tabInsertBefore(uiTab *tt, const char *name, uintmax_t n, uiControl *child)
{
struct tab *t = (struct tab *) tt;
TCITEMW item;
@ -273,11 +273,11 @@ static void tabInsertPageBefore(uiTab *tt, const char *name, uintmax_t n, uiCont
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()");
logLastError("error adding tab to Tab in uiTabInsertBefore()");
uiFree(wname);
}
static void tabDeletePage(uiTab *tt, uintmax_t n)
static void tabDelete(uiTab *tt, uintmax_t n)
{
struct tab *t = (struct tab *) tt;
struct tabPage *page;
@ -285,7 +285,7 @@ static void tabDeletePage(uiTab *tt, uintmax_t n)
// first delete the tab from the tab control
// if this is the current tab, no tab will be selected, which is good
if (SendMessageW(t->hwnd, TCM_DELETEITEM, (WPARAM) n, 0) == FALSE)
logLastError("error deleting Tab page in tabDeletePage()");
logLastError("error deleting Tab page in tabDelete()");
// now delete the page itself
page = ptrArrayIndex(t->pages, struct tabPage *, n);
@ -362,9 +362,9 @@ uiTab *uiNewTab(void)
t->baseSysFunc = uiControl(t)->SysFunc;
uiControl(t)->SysFunc = tabSysFunc;
uiTab(t)->AppendPage = tabAppendPage;
uiTab(t)->InsertPageBefore = tabInsertPageBefore;
uiTab(t)->DeletePage = tabDeletePage;
uiTab(t)->Append = tabAppend;
uiTab(t)->InsertBefore = tabInsertBefore;
uiTab(t)->Delete = tabDelete;
uiTab(t)->NumPages = tabNumPages;
uiTab(t)->Margined = tabMargined;
uiTab(t)->SetMargined = tabSetMargined;

View File

@ -26,15 +26,15 @@ static void tabPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_
// TODO
}
static void tabAppendPage(uiTab *tt, const char *name, uiControl *child)
static void tabAppend(uiTab *tt, const char *name, uiControl *child)
{
}
static void tabInsertPageBefore(uiTab *tt, const char *name, uintmax_t n, uiControl *child)
static void tabInsertBefore(uiTab *tt, const char *name, uintmax_t n, uiControl *child)
{
}
static void tabDeletePage(uiTab *tt, uintmax_t n)
static void tabDelete(uiTab *tt, uintmax_t n)
{
}
@ -77,9 +77,9 @@ uiTab *uiNewTab(void)
uiControl(t)->PreferredSize = tabPreferredSize;
uiTab(t)->AppendPage = tabAppendPage;
uiTab(t)->InsertPageBefore = tabInsertPageBefore;
uiTab(t)->DeletePage = tabDeletePage;
uiTab(t)->Append = tabAppend;
uiTab(t)->InsertBefore = tabInsertBefore;
uiTab(t)->Delete = tabDelete;
uiTab(t)->NumPages = tabNumPages;
uiTab(t)->Margined = tabMargined;
uiTab(t)->SetMargined = tabSetMargined;