Set up tabs in the test program and renamed uiAddTab() to uiAppendTab().

This commit is contained in:
Pietro Gagliardi 2015-04-28 21:47:18 -04:00
parent da2ad417a0
commit ca1103e347
4 changed files with 20 additions and 2 deletions

View File

@ -20,6 +20,7 @@ int main(int argc, char *argv[])
int i; int i;
const char *err; const char *err;
uiWindow *w; uiWindow *w;
uiTab *tab;
memset(&o, 0, sizeof (uiInitOptions)); memset(&o, 0, sizeof (uiInitOptions));
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
@ -42,6 +43,10 @@ int main(int argc, char *argv[])
w = newWindow("Main Window", 320, 240, 1); w = newWindow("Main Window", 320, 240, 1);
uiWindowOnClosing(w, onClosing, NULL); uiWindowOnClosing(w, onClosing, NULL);
tab = newTab();
uiTabAppendPage(tab, "Page 1", newVerticalBox());
uiWindowSetChild(w, uiControl(tab));
uiControlShow(uiControl(newWindow("Second Window", 320, 240, 1))); uiControlShow(uiControl(newWindow("Second Window", 320, 240, 1)));
uiControlShow(uiControl(w)); uiControlShow(uiControl(w));

View File

@ -29,6 +29,7 @@ static void *append(void *thing, int type)
enum types { enum types {
window, window,
box, box,
tab,
}; };
void setSpaced(int spaced) void setSpaced(int spaced)
@ -45,6 +46,9 @@ void setSpaced(int spaced)
case box: case box:
uiBoxSetPadded(uiBox(p), spaced); uiBoxSetPadded(uiBox(p), spaced);
break; break;
case tab:
// TODO
break;
} }
} }
} }
@ -75,3 +79,12 @@ uiBox *newVerticalBox(void)
append(b, box); append(b, box);
return b; return b;
} }
uiTab *newTab(void)
{
uiTab *t;
t = uiNewTab();
append(t, tab);
return t;
}

View File

@ -14,6 +14,7 @@ extern void setSpaced(int);
extern uiWindow *newWindow(const char *title, int width, int height, int hasMenubar); extern uiWindow *newWindow(const char *title, int width, int height, int hasMenubar);
extern uiBox *newHorizontalBox(void); extern uiBox *newHorizontalBox(void);
extern uiBox *newVerticalBox(void); extern uiBox *newVerticalBox(void);
extern uiTab *newTab(void);
// menus.c // menus.c
extern void initMenus(void); extern void initMenus(void);

View File

@ -112,8 +112,7 @@ interface Label from Control {
func NewLabel(text *const char) *Label; func NewLabel(text *const char) *Label;
interface Tab from Control { interface Tab from Control {
// TODO rename to AppendPage() func AppendPage(name *const char, c *Control);
func AddPage(name *const char, c *Control);
func DeletePage(index uintmax_t); func DeletePage(index uintmax_t);
}; };
func NewTab(void) *Tab; func NewTab(void) *Tab;