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-08 20:25:30 -05:00
|
|
|
uiControl *e;
|
|
|
|
|
|
|
|
static void getWindowText(uiControl *b, void *data)
|
|
|
|
{
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
text = uiWindowTitle((uiWindow *) data);
|
|
|
|
uiEntrySetText(e, text);
|
|
|
|
uiFreeText(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setWindowText(uiControl *b, void *data)
|
|
|
|
{
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
text = uiEntryText(e);
|
|
|
|
uiWindowSetTitle((uiWindow *) data, text);
|
|
|
|
uiFreeText(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void getButtonText(uiControl *b, void *data)
|
2015-04-07 18:11:21 -05:00
|
|
|
{
|
2015-04-08 20:25:30 -05:00
|
|
|
char *text;
|
|
|
|
|
|
|
|
text = uiButtonText((uiControl *) data);
|
|
|
|
uiEntrySetText(e, text);
|
|
|
|
uiFreeText(text);
|
2015-04-07 18:11:21 -05:00
|
|
|
}
|
|
|
|
|
2015-04-08 20:25:30 -05:00
|
|
|
static void setButtonText(uiControl *b, void *data)
|
2015-04-07 03:02:21 -05:00
|
|
|
{
|
2015-04-08 20:25:30 -05:00
|
|
|
char *text;
|
|
|
|
|
|
|
|
text = uiEntryText(e);
|
|
|
|
uiButtonSetText((uiControl *) data, text);
|
|
|
|
uiFreeText(text);
|
2015-04-07 03:02:21 -05:00
|
|
|
}
|
|
|
|
|
2015-04-09 11:14:18 -05:00
|
|
|
static void getCheckboxText(uiControl *b, void *data)
|
|
|
|
{
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
text = uiCheckboxText((uiControl *) data);
|
|
|
|
uiEntrySetText(e, text);
|
|
|
|
uiFreeText(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setCheckboxText(uiControl *b, void *data)
|
|
|
|
{
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
text = uiEntryText(e);
|
|
|
|
uiCheckboxSetText((uiControl *) data, text);
|
|
|
|
uiFreeText(text);
|
|
|
|
}
|
|
|
|
|
2015-04-09 11:26:59 -05:00
|
|
|
uiControl *stacks[4];
|
|
|
|
uiControl *spaced;
|
|
|
|
|
|
|
|
static void setSpaced(uiControl *c, void *data)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
printf("toggled\n");
|
|
|
|
}
|
2015-04-09 11:14:18 -05:00
|
|
|
|
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-08 20:25:30 -05:00
|
|
|
uiControl *getButton, *setButton;
|
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-09 11:14:18 -05:00
|
|
|
stacks[0] = uiNewVerticalStack();
|
2015-04-09 11:32:59 -05:00
|
|
|
uiWindowSetChild(w, stacks[0]);
|
2015-04-08 20:25:30 -05:00
|
|
|
|
2015-04-08 22:28:47 -05:00
|
|
|
e = uiNewEntry();
|
2015-04-09 11:14:18 -05:00
|
|
|
uiStackAdd(stacks[0], e, 0);
|
2015-04-07 18:11:21 -05:00
|
|
|
|
2015-04-09 11:14:18 -05:00
|
|
|
stacks[1] = uiNewHorizontalStack();
|
2015-04-08 20:25:30 -05:00
|
|
|
getButton = uiNewButton("Get Window Text");
|
2015-04-09 01:43:49 -05:00
|
|
|
uiButtonOnClicked(getButton, getWindowText, w);
|
2015-04-08 20:25:30 -05:00
|
|
|
setButton = uiNewButton("Set Window Text");
|
2015-04-09 01:43:49 -05:00
|
|
|
uiButtonOnClicked(setButton, setWindowText, w);
|
2015-04-09 11:14:18 -05:00
|
|
|
uiStackAdd(stacks[1], getButton, 1);
|
|
|
|
uiStackAdd(stacks[1], setButton, 1);
|
|
|
|
uiStackAdd(stacks[0], stacks[1], 0);
|
2015-04-07 18:11:21 -05:00
|
|
|
|
2015-04-09 11:14:18 -05:00
|
|
|
stacks[2] = uiNewHorizontalStack();
|
2015-04-08 22:28:47 -05:00
|
|
|
getButton = uiNewButton("Get Button Text");
|
2015-04-09 01:43:49 -05:00
|
|
|
uiButtonOnClicked(getButton, getButtonText, getButton);
|
2015-04-08 22:28:47 -05:00
|
|
|
setButton = uiNewButton("Set Button Text");
|
2015-04-09 01:43:49 -05:00
|
|
|
uiButtonOnClicked(setButton, setButtonText, getButton);
|
2015-04-09 11:14:18 -05:00
|
|
|
uiStackAdd(stacks[2], getButton, 1);
|
|
|
|
uiStackAdd(stacks[2], setButton, 1);
|
|
|
|
uiStackAdd(stacks[0], stacks[2], 0);
|
|
|
|
|
2015-04-09 11:26:59 -05:00
|
|
|
// this will also be used to make sure tab stops work properly when inserted out of creation order, especially on Windows
|
2015-04-09 11:14:18 -05:00
|
|
|
spaced = uiNewCheckbox("Spaced");
|
2015-04-09 11:32:59 -05:00
|
|
|
uiCheckboxOnToggled(spaced, setSpaced, NULL);
|
2015-04-09 11:14:18 -05:00
|
|
|
|
|
|
|
stacks[3] = uiNewHorizontalStack();
|
|
|
|
getButton = uiNewButton("Get Checkbox Text");
|
|
|
|
uiButtonOnClicked(getButton, getCheckboxText, spaced);
|
|
|
|
setButton = uiNewButton("Set Checkbox Text");
|
|
|
|
uiButtonOnClicked(setButton, setCheckboxText, spaced);
|
|
|
|
uiStackAdd(stacks[3], getButton, 1);
|
|
|
|
uiStackAdd(stacks[3], setButton, 1);
|
|
|
|
uiStackAdd(stacks[0], stacks[3], 0);
|
|
|
|
|
|
|
|
uiStackAdd(stacks[0], spaced, 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;
|
|
|
|
}
|