2015-04-06 11:20:51 -05:00
|
|
|
// 6 april 2015
|
|
|
|
#include "ui.h"
|
|
|
|
#include <stdio.h>
|
2015-04-09 21:38:11 -05:00
|
|
|
#include <string.h>
|
2015-04-06 11:20:51 -05:00
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
// TODO convert to using the new conversion macros
|
2015-04-20 17:56:42 -05:00
|
|
|
// TODO why can't these be const?
|
2015-04-15 21:56:03 -05:00
|
|
|
|
2015-04-21 17:58:29 -05:00
|
|
|
void noopMenu(void *source, void *data)
|
|
|
|
{
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
2015-04-20 22:35:26 -05:00
|
|
|
static const uiMenuItem fileMenu[] = {
|
2015-04-21 17:58:29 -05:00
|
|
|
{ uiMenuItemTypeCommand, "New", noopMenu, NULL },
|
|
|
|
{ uiMenuItemTypeCommand, "Open", noopMenu, NULL },
|
|
|
|
{ uiMenuItemTypeQuit, NULL, noopMenu, NULL },
|
|
|
|
{ 0, NULL, NULL, NULL },
|
2015-04-20 17:56:42 -05:00
|
|
|
};
|
|
|
|
|
2015-04-20 22:35:26 -05:00
|
|
|
static const uiMenuItem editMenu[] = {
|
2015-04-21 17:58:29 -05:00
|
|
|
{ uiMenuItemTypeCommand, "Undo", noopMenu, NULL },
|
|
|
|
{ uiMenuItemTypeSeparator, NULL, NULL, NULL },
|
|
|
|
{ uiMenuItemTypeCheckbox, "Check Me", noopMenu, NULL },
|
|
|
|
{ uiMenuItemTypeCommand, "A&ccelerator T_est\tTest", noopMenu, NULL },
|
|
|
|
{ uiMenuItemTypePreferences, NULL, noopMenu, NULL },
|
|
|
|
{ 0, NULL, NULL, NULL },
|
2015-04-20 17:56:42 -05:00
|
|
|
};
|
|
|
|
|
2015-04-20 22:35:26 -05:00
|
|
|
static const uiMenuItem helpMenu[] = {
|
2015-04-21 17:58:29 -05:00
|
|
|
{ uiMenuItemTypeCommand, "Help", noopMenu, NULL },
|
|
|
|
{ uiMenuItemTypeAbout, NULL, noopMenu, NULL },
|
|
|
|
{ 0, NULL, NULL, NULL },
|
2015-04-20 17:56:42 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
static uiMenu menu[] = {
|
|
|
|
{ "File", fileMenu },
|
|
|
|
{ "Edit", editMenu },
|
|
|
|
{ "Help", helpMenu },
|
2015-04-20 17:34:51 -05:00
|
|
|
{ NULL, NULL },
|
|
|
|
};
|
|
|
|
|
2015-04-06 11:20:51 -05:00
|
|
|
int onClosing(uiWindow *w, void *data)
|
|
|
|
{
|
|
|
|
printf("in closing!\n");
|
|
|
|
uiQuit();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
uiEntry *e;
|
2015-04-08 20:25:30 -05:00
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void getWindowText(uiButton *b, void *data)
|
2015-04-08 20:25:30 -05:00
|
|
|
{
|
|
|
|
char *text;
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
text = uiWindowTitle(uiWindow(data));
|
2015-04-08 20:25:30 -05:00
|
|
|
uiEntrySetText(e, text);
|
|
|
|
uiFreeText(text);
|
|
|
|
}
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void setWindowText(uiButton *b, void *data)
|
2015-04-08 20:25:30 -05:00
|
|
|
{
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
text = uiEntryText(e);
|
2015-04-15 21:56:03 -05:00
|
|
|
uiWindowSetTitle(uiWindow(data), text);
|
2015-04-08 20:25:30 -05:00
|
|
|
uiFreeText(text);
|
|
|
|
}
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void getButtonText(uiButton *b, void *data)
|
2015-04-07 18:11:21 -05:00
|
|
|
{
|
2015-04-08 20:25:30 -05:00
|
|
|
char *text;
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
text = uiButtonText(uiButton(data));
|
2015-04-08 20:25:30 -05:00
|
|
|
uiEntrySetText(e, text);
|
|
|
|
uiFreeText(text);
|
2015-04-07 18:11:21 -05:00
|
|
|
}
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void setButtonText(uiButton *b, void *data)
|
2015-04-07 03:02:21 -05:00
|
|
|
{
|
2015-04-08 20:25:30 -05:00
|
|
|
char *text;
|
|
|
|
|
|
|
|
text = uiEntryText(e);
|
2015-04-15 21:56:03 -05:00
|
|
|
uiButtonSetText(uiButton(data), text);
|
2015-04-08 20:25:30 -05:00
|
|
|
uiFreeText(text);
|
2015-04-07 03:02:21 -05:00
|
|
|
}
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void getCheckboxText(uiButton *b, void *data)
|
2015-04-09 11:14:18 -05:00
|
|
|
{
|
|
|
|
char *text;
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
text = uiCheckboxText(uiCheckbox(data));
|
2015-04-09 11:14:18 -05:00
|
|
|
uiEntrySetText(e, text);
|
|
|
|
uiFreeText(text);
|
|
|
|
}
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void setCheckboxText(uiButton *b, void *data)
|
2015-04-09 11:14:18 -05:00
|
|
|
{
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
text = uiEntryText(e);
|
2015-04-15 21:56:03 -05:00
|
|
|
uiCheckboxSetText(uiCheckbox(data), text);
|
2015-04-09 11:14:18 -05:00
|
|
|
uiFreeText(text);
|
|
|
|
}
|
|
|
|
|
2015-04-09 12:42:42 -05:00
|
|
|
uiWindow *w;
|
2015-04-20 09:19:25 -05:00
|
|
|
#define nBoxes 13
|
|
|
|
uiBox *boxes[nBoxes];
|
2015-04-15 21:56:03 -05:00
|
|
|
uiCheckbox *spaced;
|
2015-04-09 11:26:59 -05:00
|
|
|
|
2015-04-09 12:42:42 -05:00
|
|
|
static void setSpaced(int spaced)
|
2015-04-09 11:26:59 -05:00
|
|
|
{
|
2015-04-09 14:59:40 -05:00
|
|
|
int i;
|
|
|
|
|
2015-04-09 12:42:42 -05:00
|
|
|
uiWindowSetMargined(w, spaced);
|
2015-04-20 09:19:25 -05:00
|
|
|
for (i = 0; i < nBoxes; i++)
|
|
|
|
uiBoxSetPadded(boxes[i], spaced);
|
2015-04-09 12:42:42 -05:00
|
|
|
}
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void toggleSpaced(uiCheckbox *c, void *data)
|
2015-04-09 12:42:42 -05:00
|
|
|
{
|
2015-04-15 21:56:03 -05:00
|
|
|
int s;
|
2015-04-09 12:42:42 -05:00
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
s = uiCheckboxChecked(spaced);
|
2015-04-09 12:42:42 -05:00
|
|
|
printf("toggled %d\n", s);
|
|
|
|
setSpaced(s);
|
2015-04-09 11:52:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// these will also be used to test if setting checks will trigger events
|
2015-04-15 21:56:03 -05:00
|
|
|
static void forceSpacedOn(uiButton *b, void *data)
|
2015-04-09 11:52:34 -05:00
|
|
|
{
|
|
|
|
uiCheckboxSetChecked(spaced, 1);
|
|
|
|
}
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void forceSpacedOff(uiButton *b, void *data)
|
2015-04-09 11:52:34 -05:00
|
|
|
{
|
|
|
|
uiCheckboxSetChecked(spaced, 0);
|
2015-04-09 11:26:59 -05:00
|
|
|
}
|
2015-04-09 11:14:18 -05:00
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void showSpaced(uiButton *b, void *data)
|
2015-04-09 19:04:18 -05:00
|
|
|
{
|
|
|
|
char msg[] = { 'm', ' ', '0', ' ', 'p', ' ', '0', '\0' };
|
|
|
|
|
2015-04-09 20:11:56 -05:00
|
|
|
if (uiWindowMargined(w))
|
|
|
|
msg[2] = '1';
|
2015-04-20 09:19:25 -05:00
|
|
|
if (uiBoxPadded(boxes[0]))
|
2015-04-09 19:04:18 -05:00
|
|
|
msg[6] = '1';
|
|
|
|
uiEntrySetText(e, msg);
|
|
|
|
}
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void showControl(uiButton *b, void *data)
|
2015-04-11 13:12:12 -05:00
|
|
|
{
|
2015-04-15 21:56:03 -05:00
|
|
|
uiControlShow(uiControl(data));
|
2015-04-11 13:12:12 -05:00
|
|
|
}
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void hideControl(uiButton *b, void *data)
|
2015-04-11 13:12:12 -05:00
|
|
|
{
|
2015-04-15 21:56:03 -05:00
|
|
|
uiControlHide(uiControl(data));
|
2015-04-11 13:12:12 -05:00
|
|
|
}
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void enableControl(uiButton *b, void *data)
|
2015-04-11 13:12:12 -05:00
|
|
|
{
|
2015-04-15 21:56:03 -05:00
|
|
|
uiControlEnable(uiControl(data));
|
2015-04-11 13:12:12 -05:00
|
|
|
}
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void disableControl(uiButton *b, void *data)
|
2015-04-11 13:12:12 -05:00
|
|
|
{
|
2015-04-15 21:56:03 -05:00
|
|
|
uiControlDisable(uiControl(data));
|
2015-04-11 13:12:12 -05:00
|
|
|
}
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void getLabelText(uiButton *b, void *data)
|
2015-04-11 20:53:49 -05:00
|
|
|
{
|
|
|
|
char *text;
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
text = uiLabelText(uiLabel(data));
|
2015-04-11 20:53:49 -05:00
|
|
|
uiEntrySetText(e, text);
|
|
|
|
uiFreeText(text);
|
|
|
|
}
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void setLabelText(uiButton *b, void *data)
|
2015-04-11 20:53:49 -05:00
|
|
|
{
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
text = uiEntryText(e);
|
2015-04-15 21:56:03 -05:00
|
|
|
uiLabelSetText(uiLabel(data), text);
|
2015-04-11 20:53:49 -05:00
|
|
|
uiFreeText(text);
|
|
|
|
}
|
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBox *firstBox;
|
|
|
|
uiBox *secondBox;
|
2015-04-15 21:56:03 -05:00
|
|
|
uiLabel *movingLabel;
|
2015-04-13 12:43:29 -05:00
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void moveToFirst(uiButton *b, void *data)
|
2015-04-13 12:43:29 -05:00
|
|
|
{
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxDelete(secondBox, 1);
|
|
|
|
uiBoxAppend(firstBox, uiControl(movingLabel), 1);
|
2015-04-13 12:43:29 -05:00
|
|
|
}
|
|
|
|
|
2015-04-15 21:56:03 -05:00
|
|
|
static void moveToSecond(uiButton *b, void *data)
|
2015-04-13 12:43:29 -05:00
|
|
|
{
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxDelete(firstBox, 1);
|
|
|
|
uiBoxAppend(secondBox, uiControl(movingLabel), 1);
|
2015-04-13 12:43:29 -05:00
|
|
|
}
|
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBox *mainBox;
|
|
|
|
uiBox *page1box;
|
2015-04-17 21:08:13 -05:00
|
|
|
uiTab *tab;
|
|
|
|
|
|
|
|
void movePage1Out(uiButton *b, void *data)
|
|
|
|
{
|
2015-04-17 21:26:05 -05:00
|
|
|
uiTabDeletePage(tab, 0);
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxAppend(mainBox, uiControl(page1box), 1);
|
2015-04-17 21:08:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void addPage1Back(uiButton *b, void *data)
|
|
|
|
{
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxDelete(mainBox, 1);
|
|
|
|
uiTabAddPage(tab, "Page 1", uiControl(page1box));
|
2015-04-17 21:08:13 -05:00
|
|
|
}
|
|
|
|
|
2015-04-07 18:11:21 -05:00
|
|
|
int main(int argc, char *argv[])
|
2015-04-06 11:20:51 -05:00
|
|
|
{
|
2015-04-09 21:38:11 -05:00
|
|
|
uiInitOptions o;
|
|
|
|
int i;
|
2015-04-10 15:54:06 -05:00
|
|
|
const char *err;
|
2015-04-15 21:56:03 -05:00
|
|
|
uiButton *getButton, *setButton;
|
|
|
|
uiLabel *label;
|
2015-04-20 09:19:25 -05:00
|
|
|
int page2box;
|
2015-04-06 11:20:51 -05:00
|
|
|
|
2015-04-09 21:38:11 -05:00
|
|
|
memset(&o, 0, sizeof (uiInitOptions));
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
if (strcmp(argv[i], "leaks") == 0)
|
|
|
|
o.debugLogAllocations = 1;
|
|
|
|
else {
|
|
|
|
fprintf(stderr, "%s: unrecognized option %s\n", argv[0], argv[i]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-04-20 17:34:51 -05:00
|
|
|
o.Menu = menu;
|
2015-04-09 21:38:11 -05:00
|
|
|
err = uiInit(&o);
|
2015-04-06 11:20:51 -05:00
|
|
|
if (err != NULL) {
|
2015-04-10 15:54:06 -05:00
|
|
|
fprintf(stderr, "error initializing ui: %s\n", err);
|
|
|
|
uiFreeInitError(err);
|
2015-04-06 11:20:51 -05:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-04-20 17:34:51 -05:00
|
|
|
w = uiNewWindow("Hello", 320, 240, 1);
|
2015-04-06 11:20:51 -05:00
|
|
|
uiWindowOnClosing(w, onClosing, NULL);
|
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
boxes[0] = uiNewVerticalBox();
|
|
|
|
page1box = boxes[0];
|
2015-04-08 20:25:30 -05:00
|
|
|
|
2015-04-08 22:28:47 -05:00
|
|
|
e = uiNewEntry();
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[0], uiControl(e), 0);
|
2015-04-07 18:11:21 -05:00
|
|
|
|
2015-04-11 21:33:23 -05:00
|
|
|
i = 1;
|
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
boxes[i] = uiNewHorizontalBox();
|
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-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[i], uiControl(getButton), 1);
|
|
|
|
uiBoxAppend(boxes[i], uiControl(setButton), 1);
|
|
|
|
uiBoxAppend(boxes[0], uiControl(boxes[i]), 0);
|
2015-04-11 21:33:23 -05:00
|
|
|
i++;
|
2015-04-07 18:11:21 -05:00
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
boxes[i] = uiNewHorizontalBox();
|
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-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[i], uiControl(getButton), 1);
|
|
|
|
uiBoxAppend(boxes[i], uiControl(setButton), 1);
|
|
|
|
uiBoxAppend(boxes[0], uiControl(boxes[i]), 0);
|
2015-04-11 21:33:23 -05:00
|
|
|
i++;
|
2015-04-09 11:14:18 -05:00
|
|
|
|
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 12:42:42 -05:00
|
|
|
uiCheckboxOnToggled(spaced, toggleSpaced, NULL);
|
2015-04-09 11:14:18 -05:00
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
boxes[i] = uiNewHorizontalBox();
|
2015-04-09 11:14:18 -05:00
|
|
|
getButton = uiNewButton("Get Checkbox Text");
|
|
|
|
uiButtonOnClicked(getButton, getCheckboxText, spaced);
|
|
|
|
setButton = uiNewButton("Set Checkbox Text");
|
|
|
|
uiButtonOnClicked(setButton, setCheckboxText, spaced);
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[i], uiControl(getButton), 1);
|
|
|
|
uiBoxAppend(boxes[i], uiControl(setButton), 1);
|
|
|
|
uiBoxAppend(boxes[0], uiControl(boxes[i]), 0);
|
2015-04-11 21:33:23 -05:00
|
|
|
i++;
|
2015-04-09 11:14:18 -05:00
|
|
|
|
2015-04-11 20:53:49 -05:00
|
|
|
label = uiNewLabel("Label");
|
2015-04-11 21:33:23 -05:00
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
boxes[i] = uiNewHorizontalBox();
|
2015-04-11 20:53:49 -05:00
|
|
|
getButton = uiNewButton("Get Label Text");
|
|
|
|
uiButtonOnClicked(getButton, getLabelText, label);
|
|
|
|
setButton = uiNewButton("Set Label Text");
|
|
|
|
uiButtonOnClicked(setButton, setLabelText, label);
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[i], uiControl(getButton), 1);
|
|
|
|
uiBoxAppend(boxes[i], uiControl(setButton), 1);
|
|
|
|
uiBoxAppend(boxes[0], uiControl(boxes[i]), 0);
|
2015-04-11 20:53:49 -05:00
|
|
|
i++;
|
2015-04-11 21:33:23 -05:00
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
boxes[i] = uiNewHorizontalBox();
|
|
|
|
uiBoxAppend(boxes[i], uiControl(spaced), 1);
|
2015-04-09 11:52:34 -05:00
|
|
|
getButton = uiNewButton("On");
|
|
|
|
uiButtonOnClicked(getButton, forceSpacedOn, NULL);
|
|
|
|
setButton = uiNewButton("Off");
|
|
|
|
uiButtonOnClicked(setButton, forceSpacedOff, NULL);
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[i], uiControl(getButton), 0);
|
|
|
|
uiBoxAppend(boxes[i], uiControl(setButton), 0);
|
2015-04-09 19:04:18 -05:00
|
|
|
setButton = uiNewButton("Show");
|
|
|
|
uiButtonOnClicked(setButton, showSpaced, NULL);
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[i], uiControl(setButton), 0);
|
|
|
|
uiBoxAppend(boxes[0], uiControl(boxes[i]), 0);
|
2015-04-11 21:33:23 -05:00
|
|
|
i++;
|
2015-04-07 03:02:21 -05:00
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
boxes[i] = uiNewHorizontalBox();
|
2015-04-11 13:12:12 -05:00
|
|
|
getButton = uiNewButton("Button");
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[i], uiControl(getButton), 1);
|
2015-04-11 13:12:12 -05:00
|
|
|
setButton = uiNewButton("Show");
|
|
|
|
uiButtonOnClicked(setButton, showControl, getButton);
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[i], uiControl(setButton), 0);
|
2015-04-11 13:12:12 -05:00
|
|
|
setButton = uiNewButton("Hide");
|
|
|
|
uiButtonOnClicked(setButton, hideControl, getButton);
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[i], uiControl(setButton), 0);
|
2015-04-11 13:12:12 -05:00
|
|
|
setButton = uiNewButton("Enable");
|
|
|
|
uiButtonOnClicked(setButton, enableControl, getButton);
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[i], uiControl(setButton), 0);
|
2015-04-11 13:12:12 -05:00
|
|
|
setButton = uiNewButton("Disable");
|
|
|
|
uiButtonOnClicked(setButton, disableControl, getButton);
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[i], uiControl(setButton), 0);
|
|
|
|
uiBoxAppend(boxes[0], uiControl(boxes[i]), 0);
|
2015-04-11 21:33:23 -05:00
|
|
|
i++;
|
2015-04-11 13:12:12 -05:00
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
boxes[i] = uiNewHorizontalBox();
|
|
|
|
setButton = uiNewButton("Show Box");
|
|
|
|
uiButtonOnClicked(setButton, showControl, boxes[i - 1]);
|
|
|
|
uiBoxAppend(boxes[i], uiControl(setButton), 1);
|
|
|
|
setButton = uiNewButton("Hide Box");
|
|
|
|
uiButtonOnClicked(setButton, hideControl, boxes[i - 1]);
|
|
|
|
uiBoxAppend(boxes[i], uiControl(setButton), 1);
|
|
|
|
setButton = uiNewButton("Enable Box");
|
|
|
|
uiButtonOnClicked(setButton, enableControl, boxes[i - 1]);
|
|
|
|
uiBoxAppend(boxes[i], uiControl(setButton), 1);
|
|
|
|
setButton = uiNewButton("Disable Box");
|
|
|
|
uiButtonOnClicked(setButton, disableControl, boxes[i - 1]);
|
|
|
|
uiBoxAppend(boxes[i], uiControl(setButton), 1);
|
|
|
|
uiBoxAppend(boxes[0], uiControl(boxes[i]), 0);
|
2015-04-11 21:33:23 -05:00
|
|
|
i++;
|
2015-04-11 13:12:12 -05:00
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[0], uiControl(label), 0);
|
2015-04-11 20:53:49 -05:00
|
|
|
|
2015-04-11 23:30:44 -05:00
|
|
|
tab = uiNewTab();
|
2015-04-20 09:19:25 -05:00
|
|
|
uiTabAddPage(tab, "Page 1", uiControl(boxes[0]));
|
|
|
|
//TODO uiTabAddPage(tab, "Page 1", uiControl(uiNewVerticalBox()));
|
2015-04-11 23:30:44 -05:00
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
page2box = i;
|
|
|
|
boxes[i] = uiNewVerticalBox();
|
|
|
|
uiTabAddPage(tab, "Page 2", uiControl(boxes[i]));
|
2015-04-11 23:30:44 -05:00
|
|
|
i++;
|
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
boxes[i] = uiNewHorizontalBox();
|
|
|
|
firstBox = boxes[i];
|
2015-04-13 12:43:29 -05:00
|
|
|
getButton = uiNewButton("Move Here");
|
|
|
|
uiButtonOnClicked(getButton, moveToFirst, NULL);
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[i], uiControl(getButton), 0);
|
2015-04-13 12:43:29 -05:00
|
|
|
movingLabel = uiNewLabel("This label moves!");
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[i], uiControl(movingLabel), 1);
|
|
|
|
uiBoxAppend(boxes[page2box], uiControl(boxes[i]), 0);
|
2015-04-13 12:43:29 -05:00
|
|
|
i++;
|
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
boxes[i] = uiNewHorizontalBox();
|
|
|
|
secondBox = boxes[i];
|
2015-04-13 12:43:29 -05:00
|
|
|
getButton = uiNewButton("Move Here");
|
|
|
|
uiButtonOnClicked(getButton, moveToSecond, NULL);
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[i], uiControl(getButton), 0);
|
|
|
|
uiBoxAppend(boxes[page2box], uiControl(boxes[i]), 0);
|
2015-04-13 12:43:29 -05:00
|
|
|
i++;
|
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
boxes[i] = uiNewHorizontalBox();
|
2015-04-17 21:08:13 -05:00
|
|
|
getButton = uiNewButton("Move Page 1 Out");
|
|
|
|
uiButtonOnClicked(getButton, movePage1Out, NULL);
|
|
|
|
setButton = uiNewButton("Add Page 1 Back");
|
|
|
|
uiButtonOnClicked(setButton, addPage1Back, NULL);
|
2015-04-20 09:19:25 -05:00
|
|
|
uiBoxAppend(boxes[i], uiControl(getButton), 0);
|
|
|
|
uiBoxAppend(boxes[i], uiControl(setButton), 0);
|
|
|
|
uiBoxAppend(boxes[page2box], uiControl(boxes[i]), 0);
|
2015-04-17 21:08:13 -05:00
|
|
|
i++;
|
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
boxes[i] = uiNewHorizontalBox();
|
|
|
|
mainBox = boxes[i];
|
|
|
|
uiBoxAppend(boxes[i], uiControl(tab), 1);
|
|
|
|
uiWindowSetChild(w, uiControl(mainBox));
|
2015-04-17 21:08:13 -05:00
|
|
|
i++;
|
|
|
|
|
2015-04-20 09:19:25 -05:00
|
|
|
if (i != nBoxes) {
|
|
|
|
fprintf(stderr, "forgot to update nBoxes (expected %d)\n", i);
|
2015-04-11 21:33:23 -05:00
|
|
|
return 1;
|
|
|
|
}
|
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;
|
|
|
|
}
|