2015-04-29 19:15:29 -05:00
|
|
|
// 29 april 2015
|
|
|
|
#include "test.h"
|
|
|
|
|
2015-06-05 16:31:15 -05:00
|
|
|
uiGroup *page2group;
|
|
|
|
|
2015-04-29 19:15:29 -05:00
|
|
|
static uiLabel *movingLabel;
|
|
|
|
static uiBox *movingBoxes[2];
|
|
|
|
static int movingCurrent;
|
|
|
|
|
|
|
|
static void moveLabel(uiButton *b, void *data)
|
|
|
|
{
|
|
|
|
int from, to;
|
|
|
|
|
|
|
|
from = movingCurrent;
|
|
|
|
to = 0;
|
|
|
|
if (from == 0)
|
|
|
|
to = 1;
|
|
|
|
uiBoxDelete(movingBoxes[from], 0);
|
|
|
|
uiBoxAppend(movingBoxes[to], uiControl(movingLabel), 0);
|
|
|
|
movingCurrent = to;
|
|
|
|
}
|
|
|
|
|
2015-04-29 20:09:16 -05:00
|
|
|
static int moveBack;
|
|
|
|
#define moveOutText "Move Page 1 Out"
|
|
|
|
#define moveBackText "Move Page 1 Back"
|
|
|
|
|
|
|
|
static void movePage1(uiButton *b, void *data)
|
|
|
|
{
|
|
|
|
if (moveBack) {
|
2015-05-06 12:58:03 -05:00
|
|
|
uiBoxDelete(mainBox, 1);
|
2015-05-18 09:32:08 -05:00
|
|
|
uiTabInsertAt(mainTab, "Page 1", 0, uiControl(page1));
|
2015-05-06 12:58:03 -05:00
|
|
|
uiButtonSetText(b, moveOutText);
|
2015-05-06 13:09:20 -05:00
|
|
|
moveBack = 0;
|
2015-04-29 20:09:16 -05:00
|
|
|
return;
|
|
|
|
}
|
2015-05-18 09:20:11 -05:00
|
|
|
uiTabDelete(mainTab, 0);
|
2015-04-29 20:09:16 -05:00
|
|
|
uiBoxAppend(mainBox, uiControl(page1), 1);
|
|
|
|
uiButtonSetText(b, moveBackText);
|
|
|
|
moveBack = 1;
|
|
|
|
}
|
2015-04-29 19:15:29 -05:00
|
|
|
|
2015-11-27 12:01:12 -06:00
|
|
|
static void openAnotherWindow(uiButton *bb, void *data)
|
2015-04-30 11:00:21 -05:00
|
|
|
{
|
2015-11-27 12:01:12 -06:00
|
|
|
uiWindow *w;
|
|
|
|
uiBox *b;
|
|
|
|
|
|
|
|
w = uiNewWindow("Another Window", 100, 100, data != NULL);
|
|
|
|
b = uiNewVerticalBox();
|
|
|
|
uiBoxAppend(b, uiControl(uiNewEntry()), 0);
|
|
|
|
uiBoxAppend(b, uiControl(uiNewButton("Button")), 0);
|
|
|
|
uiBoxSetPadded(b, 1);
|
|
|
|
uiWindowSetChild(w, uiControl(b));
|
|
|
|
uiWindowSetMargined(w, 1);
|
|
|
|
uiControlShow(uiControl(w));
|
2015-04-30 11:00:21 -05:00
|
|
|
}
|
|
|
|
|
2015-06-05 16:12:51 -05:00
|
|
|
static void openAnotherDisabledWindow(uiButton *b, void *data)
|
|
|
|
{
|
|
|
|
uiWindow *w;
|
|
|
|
|
|
|
|
w = uiNewWindow("Another Window", 100, 100, data != NULL);
|
|
|
|
uiControlDisable(uiControl(w));
|
|
|
|
uiControlShow(uiControl(w));
|
|
|
|
}
|
|
|
|
|
2015-05-04 09:34:16 -05:00
|
|
|
#define SHED(method, Method) \
|
|
|
|
static void method ## Control(uiButton *b, void *data) \
|
|
|
|
{ \
|
|
|
|
uiControl ## Method(uiControl(data)); \
|
|
|
|
}
|
2015-05-07 15:33:33 -05:00
|
|
|
SHED(show, Show)
|
2015-05-04 09:34:16 -05:00
|
|
|
SHED(enable, Enable)
|
|
|
|
SHED(disable, Disable)
|
|
|
|
|
2015-05-06 21:09:10 -05:00
|
|
|
static void echoReadOnlyText(uiEntry *e, void *data)
|
2015-05-06 18:54:42 -05:00
|
|
|
{
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
text = uiEntryText(e);
|
2015-05-06 21:09:10 -05:00
|
|
|
uiEntrySetText(uiEntry(data), text);
|
2015-05-06 18:54:42 -05:00
|
|
|
uiFreeText(text);
|
|
|
|
}
|
|
|
|
|
2015-04-29 19:15:29 -05:00
|
|
|
uiBox *makePage2(void)
|
|
|
|
{
|
|
|
|
uiBox *page2;
|
|
|
|
uiBox *hbox;
|
2015-05-11 21:35:16 -05:00
|
|
|
uiGroup *group;
|
|
|
|
uiBox *vbox;
|
2015-04-29 19:15:29 -05:00
|
|
|
uiButton *button;
|
2015-05-04 10:07:23 -05:00
|
|
|
uiBox *nestedBox;
|
2015-05-04 09:34:16 -05:00
|
|
|
uiBox *innerhbox;
|
|
|
|
uiBox *innerhbox2;
|
|
|
|
uiBox *innerhbox3;
|
2015-05-04 13:14:12 -05:00
|
|
|
uiTab *disabledTab;
|
2015-05-06 18:54:42 -05:00
|
|
|
uiEntry *entry;
|
2015-05-06 21:09:10 -05:00
|
|
|
uiEntry *readonly;
|
2015-05-07 15:33:33 -05:00
|
|
|
uiButton *button2;
|
2015-04-29 19:15:29 -05:00
|
|
|
|
|
|
|
page2 = newVerticalBox();
|
|
|
|
|
2015-05-11 21:35:16 -05:00
|
|
|
group = newGroup("Moving Label");
|
2015-06-05 16:31:15 -05:00
|
|
|
page2group = group;
|
2015-05-11 21:35:16 -05:00
|
|
|
uiBoxAppend(page2, uiControl(group), 0);
|
|
|
|
vbox = newVerticalBox();
|
|
|
|
uiGroupSetChild(group, uiControl(vbox));
|
|
|
|
|
2015-04-29 19:15:29 -05:00
|
|
|
hbox = newHorizontalBox();
|
|
|
|
button = uiNewButton("Move the Label!");
|
|
|
|
uiButtonOnClicked(button, moveLabel, NULL);
|
|
|
|
uiBoxAppend(hbox, uiControl(button), 1);
|
|
|
|
// have a blank label for space
|
|
|
|
uiBoxAppend(hbox, uiControl(uiNewLabel("")), 1);
|
2015-05-11 21:35:16 -05:00
|
|
|
uiBoxAppend(vbox, uiControl(hbox), 0);
|
2015-04-29 19:15:29 -05:00
|
|
|
|
|
|
|
hbox = newHorizontalBox();
|
|
|
|
movingBoxes[0] = newVerticalBox();
|
|
|
|
uiBoxAppend(hbox, uiControl(movingBoxes[0]), 1);
|
|
|
|
movingBoxes[1] = newVerticalBox();
|
|
|
|
uiBoxAppend(hbox, uiControl(movingBoxes[1]), 1);
|
2015-05-11 21:35:16 -05:00
|
|
|
uiBoxAppend(vbox, uiControl(hbox), 0);
|
2015-04-29 19:15:29 -05:00
|
|
|
|
|
|
|
movingCurrent = 0;
|
|
|
|
movingLabel = uiNewLabel("This label moves!");
|
|
|
|
uiBoxAppend(movingBoxes[movingCurrent], uiControl(movingLabel), 0);
|
|
|
|
|
2015-04-29 20:09:16 -05:00
|
|
|
hbox = newHorizontalBox();
|
|
|
|
button = uiNewButton(moveOutText);
|
|
|
|
uiButtonOnClicked(button, movePage1, NULL);
|
|
|
|
uiBoxAppend(hbox, uiControl(button), 0);
|
|
|
|
uiBoxAppend(page2, uiControl(hbox), 0);
|
|
|
|
moveBack = 0;
|
|
|
|
|
2015-04-30 11:00:21 -05:00
|
|
|
hbox = newHorizontalBox();
|
|
|
|
uiBoxAppend(hbox, uiControl(uiNewLabel("Label Alignment Test")), 0);
|
|
|
|
button = uiNewButton("Open Menued Window");
|
|
|
|
uiButtonOnClicked(button, openAnotherWindow, button);
|
|
|
|
uiBoxAppend(hbox, uiControl(button), 0);
|
|
|
|
button = uiNewButton("Open Menuless Window");
|
|
|
|
uiButtonOnClicked(button, openAnotherWindow, NULL);
|
|
|
|
uiBoxAppend(hbox, uiControl(button), 0);
|
2015-06-05 16:12:51 -05:00
|
|
|
button = uiNewButton("Disabled Menued");
|
|
|
|
uiButtonOnClicked(button, openAnotherDisabledWindow, button);
|
|
|
|
uiBoxAppend(hbox, uiControl(button), 0);
|
|
|
|
button = uiNewButton("Disabled Menuless");
|
|
|
|
uiButtonOnClicked(button, openAnotherDisabledWindow, NULL);
|
|
|
|
uiBoxAppend(hbox, uiControl(button), 0);
|
2015-04-30 11:00:21 -05:00
|
|
|
uiBoxAppend(page2, uiControl(hbox), 0);
|
|
|
|
|
2015-05-04 10:07:23 -05:00
|
|
|
nestedBox = newHorizontalBox();
|
2015-05-04 09:34:16 -05:00
|
|
|
innerhbox = newHorizontalBox();
|
|
|
|
uiBoxAppend(innerhbox, uiControl(uiNewButton("These")), 0);
|
2015-05-04 12:55:57 -05:00
|
|
|
button = uiNewButton("buttons");
|
|
|
|
uiControlDisable(uiControl(button));
|
|
|
|
uiBoxAppend(innerhbox, uiControl(button), 0);
|
2015-05-04 10:07:23 -05:00
|
|
|
uiBoxAppend(nestedBox, uiControl(innerhbox), 0);
|
2015-05-04 09:34:16 -05:00
|
|
|
innerhbox = newHorizontalBox();
|
|
|
|
uiBoxAppend(innerhbox, uiControl(uiNewButton("are")), 0);
|
|
|
|
innerhbox2 = newHorizontalBox();
|
|
|
|
button = uiNewButton("in");
|
|
|
|
uiControlDisable(uiControl(button));
|
|
|
|
uiBoxAppend(innerhbox2, uiControl(button), 0);
|
|
|
|
uiBoxAppend(innerhbox, uiControl(innerhbox2), 0);
|
2015-05-04 10:07:23 -05:00
|
|
|
uiBoxAppend(nestedBox, uiControl(innerhbox), 0);
|
2015-05-04 09:34:16 -05:00
|
|
|
innerhbox = newHorizontalBox();
|
|
|
|
innerhbox2 = newHorizontalBox();
|
|
|
|
uiBoxAppend(innerhbox2, uiControl(uiNewButton("nested")), 0);
|
|
|
|
innerhbox3 = newHorizontalBox();
|
2015-05-04 12:55:57 -05:00
|
|
|
button = uiNewButton("boxes");
|
|
|
|
uiControlDisable(uiControl(button));
|
|
|
|
uiBoxAppend(innerhbox3, uiControl(button), 0);
|
2015-05-04 09:34:16 -05:00
|
|
|
uiBoxAppend(innerhbox2, uiControl(innerhbox3), 0);
|
|
|
|
uiBoxAppend(innerhbox, uiControl(innerhbox2), 0);
|
2015-05-04 10:07:23 -05:00
|
|
|
uiBoxAppend(nestedBox, uiControl(innerhbox), 0);
|
|
|
|
uiBoxAppend(page2, uiControl(nestedBox), 0);
|
|
|
|
|
|
|
|
hbox = newHorizontalBox();
|
|
|
|
button = uiNewButton("Enable Nested Box");
|
|
|
|
uiButtonOnClicked(button, enableControl, nestedBox);
|
|
|
|
uiBoxAppend(hbox, uiControl(button), 0);
|
|
|
|
button = uiNewButton("Disable Nested Box");
|
|
|
|
uiButtonOnClicked(button, disableControl, nestedBox);
|
|
|
|
uiBoxAppend(hbox, uiControl(button), 0);
|
2015-05-04 09:34:16 -05:00
|
|
|
uiBoxAppend(page2, uiControl(hbox), 0);
|
|
|
|
|
2015-05-04 13:14:12 -05:00
|
|
|
disabledTab = newTab();
|
2015-05-18 09:20:11 -05:00
|
|
|
uiTabAppend(disabledTab, "Disabled", uiControl(uiNewButton("Button")));
|
|
|
|
uiTabAppend(disabledTab, "Tab", uiControl(uiNewLabel("Label")));
|
2015-05-04 13:14:12 -05:00
|
|
|
uiControlDisable(uiControl(disabledTab));
|
|
|
|
uiBoxAppend(page2, uiControl(disabledTab), 1);
|
|
|
|
|
2015-05-06 18:54:42 -05:00
|
|
|
entry = uiNewEntry();
|
2015-05-06 21:09:10 -05:00
|
|
|
readonly = uiNewEntry();
|
|
|
|
uiEntryOnChanged(entry, echoReadOnlyText, readonly);
|
|
|
|
uiEntrySetText(readonly, "If you can see this, uiEntryReadOnly() isn't working properly.");
|
2015-05-06 21:21:11 -05:00
|
|
|
uiEntrySetReadOnly(readonly, 1);
|
2015-05-06 21:09:10 -05:00
|
|
|
if (uiEntryReadOnly(readonly))
|
|
|
|
uiEntrySetText(readonly, "");
|
2015-05-06 18:54:42 -05:00
|
|
|
uiBoxAppend(page2, uiControl(entry), 0);
|
2015-05-06 21:09:10 -05:00
|
|
|
uiBoxAppend(page2, uiControl(readonly), 0);
|
2015-05-06 18:54:42 -05:00
|
|
|
|
2015-05-07 15:33:33 -05:00
|
|
|
hbox = newHorizontalBox();
|
|
|
|
button = uiNewButton("Show Button 2");
|
|
|
|
button2 = uiNewButton("Button 2");
|
|
|
|
uiButtonOnClicked(button, showControl, button2);
|
|
|
|
uiControlHide(uiControl(button2));
|
|
|
|
uiBoxAppend(hbox, uiControl(button), 1);
|
|
|
|
uiBoxAppend(hbox, uiControl(button2), 0);
|
|
|
|
uiBoxAppend(page2, uiControl(hbox), 0);
|
|
|
|
|
2015-04-29 19:15:29 -05:00
|
|
|
return page2;
|
|
|
|
}
|