2015-04-22 16:40:58 -05:00
|
|
|
// 22 april 2015
|
|
|
|
#include "test.h"
|
|
|
|
|
2015-10-09 10:49:57 -05:00
|
|
|
// TODOs
|
|
|
|
// - blank page affects menus negatively on Windows
|
|
|
|
|
2015-04-22 16:54:05 -05:00
|
|
|
void die(const char *fmt, ...)
|
|
|
|
{
|
2015-05-03 15:44:13 -05:00
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
fprintf(stderr, "[test program] ");
|
|
|
|
vfprintf(stderr, fmt, ap);
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
va_end(ap);
|
2015-04-22 16:54:05 -05:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2015-04-22 18:23:34 -05:00
|
|
|
int onClosing(uiWindow *w, void *data)
|
2015-04-22 16:40:58 -05:00
|
|
|
{
|
2015-06-08 18:09:57 -05:00
|
|
|
printf("in onClosing()\n");
|
2015-04-22 18:23:34 -05:00
|
|
|
uiQuit();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-05-09 09:12:02 -05:00
|
|
|
int onShouldQuit(void *data)
|
|
|
|
{
|
2015-06-08 18:09:57 -05:00
|
|
|
printf("in onShouldQuit()\n");
|
2015-05-09 09:50:03 -05:00
|
|
|
if (uiMenuItemChecked(shouldQuitItem)) {
|
|
|
|
uiControlDestroy(uiControl(data));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2015-05-09 09:12:02 -05:00
|
|
|
}
|
|
|
|
|
2015-04-29 18:55:42 -05:00
|
|
|
uiBox *mainBox;
|
2015-04-29 20:09:16 -05:00
|
|
|
uiTab *mainTab;
|
2015-04-29 18:55:42 -05:00
|
|
|
|
2015-06-03 23:51:41 -05:00
|
|
|
uiBox *(*newhbox)(void);
|
|
|
|
uiBox *(*newvbox)(void);
|
|
|
|
|
2015-04-22 18:23:34 -05:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
uiInitOptions o;
|
|
|
|
int i;
|
|
|
|
const char *err;
|
|
|
|
uiWindow *w;
|
2016-05-14 20:53:24 -05:00
|
|
|
uiBox *page2, *page3, *page4, *page5;
|
|
|
|
uiBox *page6, *page7, *page8, *page9, *page10;
|
2016-05-28 20:29:00 -05:00
|
|
|
uiBox *page11, *page12, *page13;
|
2016-06-09 16:15:59 -05:00
|
|
|
uiTab *page14;
|
2016-06-15 12:21:07 -05:00
|
|
|
uiBox *page15;
|
2016-06-21 21:22:13 -05:00
|
|
|
uiBox *page16;
|
2015-11-02 09:49:04 -06:00
|
|
|
uiTab *outerTab;
|
2015-12-19 15:56:45 -06:00
|
|
|
uiTab *innerTab;
|
2015-05-03 15:46:50 -05:00
|
|
|
int nomenus = 0;
|
2015-09-01 10:24:16 -05:00
|
|
|
int startspaced = 0;
|
2016-06-16 12:41:13 -05:00
|
|
|
int steps = 0;
|
2015-04-22 18:23:34 -05:00
|
|
|
|
2015-06-03 23:51:41 -05:00
|
|
|
newhbox = uiNewHorizontalBox;
|
|
|
|
newvbox = uiNewVerticalBox;
|
|
|
|
|
2015-04-22 18:23:34 -05:00
|
|
|
memset(&o, 0, sizeof (uiInitOptions));
|
|
|
|
for (i = 1; i < argc; i++)
|
2015-05-03 15:46:50 -05:00
|
|
|
if (strcmp(argv[i], "nomenus") == 0)
|
|
|
|
nomenus = 1;
|
2015-09-01 10:24:16 -05:00
|
|
|
else if (strcmp(argv[i], "startspaced") == 0)
|
|
|
|
startspaced = 1;
|
2015-06-03 23:51:41 -05:00
|
|
|
else if (strcmp(argv[i], "swaphv") == 0) {
|
|
|
|
newhbox = uiNewVerticalBox;
|
|
|
|
newvbox = uiNewHorizontalBox;
|
2016-06-16 12:41:13 -05:00
|
|
|
} else if (strcmp(argv[i], "steps") == 0)
|
|
|
|
steps = 1;
|
|
|
|
else {
|
2015-04-22 18:23:34 -05:00
|
|
|
fprintf(stderr, "%s: unrecognized option %s\n", argv[0], argv[i]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = uiInit(&o);
|
|
|
|
if (err != NULL) {
|
|
|
|
fprintf(stderr, "error initializing ui: %s\n", err);
|
|
|
|
uiFreeInitError(err);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-05-03 15:46:50 -05:00
|
|
|
if (!nomenus)
|
|
|
|
initMenus();
|
2015-04-23 17:22:06 -05:00
|
|
|
|
2015-04-22 18:23:34 -05:00
|
|
|
w = newWindow("Main Window", 320, 240, 1);
|
|
|
|
uiWindowOnClosing(w, onClosing, NULL);
|
2016-06-21 11:45:04 -05:00
|
|
|
printf("main window %p\n", (void *) w);
|
2015-04-22 18:23:34 -05:00
|
|
|
|
2015-05-09 09:18:19 -05:00
|
|
|
uiOnShouldQuit(onShouldQuit, w);
|
|
|
|
|
2015-04-29 18:55:42 -05:00
|
|
|
mainBox = newHorizontalBox();
|
2015-05-18 09:36:24 -05:00
|
|
|
uiWindowSetChild(w, uiControl(mainBox));
|
2015-04-29 18:55:42 -05:00
|
|
|
|
2015-11-02 09:49:04 -06:00
|
|
|
outerTab = newTab();
|
|
|
|
uiBoxAppend(mainBox, uiControl(outerTab), 1);
|
|
|
|
|
2015-04-29 20:09:16 -05:00
|
|
|
mainTab = newTab();
|
2015-12-19 15:56:45 -06:00
|
|
|
uiTabAppend(outerTab, "Pages 1-5", uiControl(mainTab));
|
2015-04-28 20:47:18 -05:00
|
|
|
|
2015-06-05 16:31:15 -05:00
|
|
|
// page 1 uses page 2's uiGroup
|
|
|
|
page2 = makePage2();
|
|
|
|
|
2015-04-29 19:23:38 -05:00
|
|
|
makePage1(w);
|
2015-05-18 09:36:24 -05:00
|
|
|
uiTabAppend(mainTab, "Page 1", uiControl(page1));
|
2015-04-29 09:23:45 -05:00
|
|
|
|
2015-05-18 09:20:11 -05:00
|
|
|
uiTabAppend(mainTab, "Page 2", uiControl(page2));
|
2015-04-29 19:15:29 -05:00
|
|
|
|
2015-05-18 09:20:11 -05:00
|
|
|
uiTabAppend(mainTab, "Empty Page", uiControl(uiNewHorizontalBox()));
|
2015-05-06 15:00:49 -05:00
|
|
|
|
2015-05-07 16:13:16 -05:00
|
|
|
page3 = makePage3();
|
2015-05-18 09:20:11 -05:00
|
|
|
uiTabAppend(mainTab, "Page 3", uiControl(page3));
|
2015-05-07 16:13:16 -05:00
|
|
|
|
2015-05-19 17:07:34 -05:00
|
|
|
page4 = makePage4();
|
|
|
|
uiTabAppend(mainTab, "Page 4", uiControl(page4));
|
|
|
|
|
2015-11-27 22:23:54 -06:00
|
|
|
page5 = makePage5(w);
|
2015-05-22 18:14:25 -05:00
|
|
|
uiTabAppend(mainTab, "Page 5", uiControl(page5));
|
|
|
|
|
2015-12-19 15:56:45 -06:00
|
|
|
innerTab = newTab();
|
2016-04-18 16:14:33 -05:00
|
|
|
uiTabAppend(outerTab, "Pages 6-10", uiControl(innerTab));
|
2015-12-19 15:56:45 -06:00
|
|
|
|
2015-10-08 18:20:06 -05:00
|
|
|
page6 = makePage6();
|
2015-12-19 15:56:45 -06:00
|
|
|
uiTabAppend(innerTab, "Page 6", uiControl(page6));
|
2015-10-08 18:20:06 -05:00
|
|
|
|
2015-10-13 14:09:06 -05:00
|
|
|
page7 = makePage7();
|
2015-12-19 15:56:45 -06:00
|
|
|
uiTabAppend(innerTab, "Page 7", uiControl(page7));
|
2015-10-13 14:09:06 -05:00
|
|
|
|
2015-12-22 18:01:56 -06:00
|
|
|
page8 = makePage8();
|
|
|
|
uiTabAppend(innerTab, "Page 8", uiControl(page8));
|
2015-10-18 22:00:24 -05:00
|
|
|
|
2015-12-24 21:59:00 -06:00
|
|
|
page9 = makePage9();
|
|
|
|
uiTabAppend(innerTab, "Page 9", uiControl(page9));
|
|
|
|
|
2016-04-14 12:27:15 -05:00
|
|
|
page10 = makePage10();
|
2016-04-14 11:57:09 -05:00
|
|
|
uiTabAppend(innerTab, "Page 10", uiControl(page10));
|
|
|
|
|
2016-05-14 20:53:24 -05:00
|
|
|
innerTab = newTab();
|
2016-06-21 21:22:13 -05:00
|
|
|
uiTabAppend(outerTab, "Pages 11-15", uiControl(innerTab));
|
2016-05-14 20:53:24 -05:00
|
|
|
|
2016-05-15 15:34:14 -05:00
|
|
|
// page11 = makePage11();
|
|
|
|
// uiTabAppend(innerTab, "Page 11", uiControl(page11));
|
2016-05-14 20:53:24 -05:00
|
|
|
|
2016-05-22 12:56:36 -05:00
|
|
|
page12 = makePage12();
|
|
|
|
uiTabAppend(innerTab, "Page 12", uiControl(page12));
|
|
|
|
|
2016-05-28 20:29:00 -05:00
|
|
|
page13 = makePage13();
|
|
|
|
uiTabAppend(innerTab, "Page 13", uiControl(page13));
|
|
|
|
|
2016-06-09 16:15:59 -05:00
|
|
|
page14 = makePage14();
|
|
|
|
uiTabAppend(innerTab, "Page 14", uiControl(page14));
|
|
|
|
|
2016-06-15 12:21:07 -05:00
|
|
|
page15 = makePage15(w);
|
|
|
|
uiTabAppend(innerTab, "Page 15", uiControl(page15));
|
|
|
|
|
2016-06-21 21:22:13 -05:00
|
|
|
innerTab = newTab();
|
|
|
|
uiTabAppend(outerTab, "Pages 16-?", uiControl(innerTab));
|
|
|
|
|
|
|
|
page16 = makePage16();
|
|
|
|
uiTabAppend(innerTab, "Page 16", uiControl(page16));
|
|
|
|
|
2015-09-01 10:24:16 -05:00
|
|
|
if (startspaced)
|
|
|
|
setSpaced(1);
|
|
|
|
|
2015-04-27 21:27:50 -05:00
|
|
|
uiControlShow(uiControl(w));
|
2016-06-16 12:41:13 -05:00
|
|
|
if (!steps)
|
|
|
|
uiMain();
|
2016-06-17 08:16:30 -05:00
|
|
|
else {
|
2016-06-17 08:22:31 -05:00
|
|
|
uiMainSteps();
|
2016-06-17 08:16:30 -05:00
|
|
|
while (uiMainStep(1))
|
|
|
|
;
|
|
|
|
}
|
2015-06-08 18:09:57 -05:00
|
|
|
printf("after uiMain()\n");
|
2015-05-07 21:28:18 -05:00
|
|
|
uiUninit();
|
2015-06-08 18:09:57 -05:00
|
|
|
printf("after uiUninit()\n");
|
2015-04-22 16:40:58 -05:00
|
|
|
return 0;
|
|
|
|
}
|