2015-04-22 16:40:58 -05:00
|
|
|
// 22 april 2015
|
|
|
|
#include "test.h"
|
|
|
|
|
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-04-22 18:23:34 -05:00
|
|
|
printf("in onClosing()\n");
|
|
|
|
uiQuit();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-05-09 09:12:02 -05:00
|
|
|
int onShouldQuit(void *data)
|
|
|
|
{
|
|
|
|
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-04-22 18:23:34 -05:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
uiInitOptions o;
|
|
|
|
int i;
|
|
|
|
const char *err;
|
|
|
|
uiWindow *w;
|
2015-05-07 16:13:16 -05:00
|
|
|
uiBox *page2, *page3;
|
2015-05-03 15:46:50 -05:00
|
|
|
int nomenus = 0;
|
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;
|
|
|
|
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);
|
2015-05-03 20:22:00 -05:00
|
|
|
printf("main window %p\n", 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();
|
|
|
|
uiWindowSetChild(w, uiControl(mainBox));
|
|
|
|
|
2015-04-29 20:09:16 -05:00
|
|
|
mainTab = newTab();
|
|
|
|
uiBoxAppend(mainBox, uiControl(mainTab), 1);
|
2015-04-28 20:47:18 -05:00
|
|
|
|
2015-04-29 19:23:38 -05:00
|
|
|
makePage1(w);
|
2015-04-29 20:09:16 -05:00
|
|
|
uiTabAppendPage(mainTab, "Page 1", uiControl(page1));
|
2015-04-29 09:23:45 -05:00
|
|
|
|
2015-04-29 19:15:29 -05:00
|
|
|
page2 = makePage2();
|
2015-04-29 20:09:16 -05:00
|
|
|
uiTabAppendPage(mainTab, "Page 2", uiControl(page2));
|
2015-04-29 19:15:29 -05:00
|
|
|
|
2015-05-06 15:00:49 -05:00
|
|
|
uiTabAppendPage(mainTab, "Empty Page", uiControl(uiNewHorizontalBox()));
|
|
|
|
|
2015-05-07 16:13:16 -05:00
|
|
|
page3 = makePage3();
|
|
|
|
uiTabAppendPage(mainTab, "Page 3", uiControl(page3));
|
|
|
|
|
2015-04-27 21:27:50 -05:00
|
|
|
uiControlShow(uiControl(w));
|
2015-04-28 16:48:56 -05:00
|
|
|
uiMain();
|
2015-04-22 18:23:34 -05:00
|
|
|
printf("after uiMain()\n");
|
2015-05-07 21:28:18 -05:00
|
|
|
uiUninit();
|
2015-05-09 12:29:39 -05:00
|
|
|
printf("after uiUninit()\n");
|
2015-04-22 16:40:58 -05:00
|
|
|
return 0;
|
|
|
|
}
|