2015-04-06 11:20:51 -05:00
|
|
|
// 6 april 2015
|
|
|
|
#include "ui.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int onClosing(uiWindow *w, void *data)
|
|
|
|
{
|
|
|
|
printf("in closing!\n");
|
|
|
|
uiQuit();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-04-07 03:02:21 -05:00
|
|
|
void onClicked(uiControl *b, void *data)
|
2015-04-07 18:11:21 -05:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
void onClicked2(uiControl *b, void *data)
|
2015-04-07 03:02:21 -05:00
|
|
|
{
|
|
|
|
printf("button clicked!\n");
|
|
|
|
}
|
|
|
|
|
2015-04-07 18:11:21 -05:00
|
|
|
int main(int argc, char *argv[])
|
2015-04-06 11:20:51 -05:00
|
|
|
{
|
|
|
|
uiInitError *err;
|
|
|
|
uiWindow *w;
|
2015-04-07 18:11:21 -05:00
|
|
|
uiControl *stack;
|
|
|
|
uiControl *button, *button2;
|
2015-04-06 11:20:51 -05:00
|
|
|
|
|
|
|
err = uiInit(NULL);
|
|
|
|
if (err != NULL) {
|
|
|
|
fprintf(stderr, "error initializing ui: %s\n", uiInitErrorMessage(err));
|
|
|
|
uiInitErrorFree(err);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
w = uiNewWindow("Hello", 320, 240);
|
|
|
|
uiWindowOnClosing(w, onClosing, NULL);
|
|
|
|
|
2015-04-07 18:11:21 -05:00
|
|
|
if (argc > 1)
|
|
|
|
stack = uiNewHorizontalStack();
|
|
|
|
else
|
|
|
|
stack = uiNewVerticalStack();
|
|
|
|
uiWindowSetChild(w, stack);
|
|
|
|
|
|
|
|
button2 = uiNewButton("Change Me");
|
|
|
|
uiButtonOnClicked(button, onClicked2, NULL);
|
|
|
|
|
2015-04-07 03:02:21 -05:00
|
|
|
button = uiNewButton("Click Me");
|
2015-04-07 18:11:21 -05:00
|
|
|
uiButtonOnClicked(button, onClicked, button2);
|
|
|
|
uiStackAdd(stack, button, 1);
|
|
|
|
uiStackAdd(stack, button2, 0);
|
2015-04-07 03:02:21 -05:00
|
|
|
|
2015-04-07 13:13:42 -05:00
|
|
|
uiWindowShow(w);
|
2015-04-06 11:20:51 -05:00
|
|
|
uiMain();
|
2015-04-06 19:01:14 -05:00
|
|
|
printf("after uiMain()\n");
|
2015-04-06 11:20:51 -05:00
|
|
|
return 0;
|
|
|
|
}
|