2015-04-29 12:38:38 -05:00
|
|
|
// 29 april 2015
|
|
|
|
#include "test.h"
|
|
|
|
|
|
|
|
static uiEntry *entry;
|
|
|
|
static uiCheckbox *spaced;
|
|
|
|
|
2015-04-29 12:47:50 -05:00
|
|
|
#define TEXT(name, type, getter, setter) \
|
|
|
|
static void get ## name ## Text(uiButton *b, void *data) \
|
|
|
|
{ \
|
|
|
|
char *text; \
|
|
|
|
text = getter(type(data)); \
|
|
|
|
uiEntrySetText(entry, text); \
|
|
|
|
uiFreeText(text); \
|
|
|
|
} \
|
|
|
|
static void set ## name ## Text(uiButton *b, void *data) \
|
|
|
|
{ \
|
|
|
|
char *text; \
|
|
|
|
text = uiEntryText(entry); \
|
|
|
|
setter(type(data), text); \
|
|
|
|
uiFreeText(text); \
|
|
|
|
}
|
|
|
|
TEXT(Window, uiWindow, uiWindowTitle, uiWindowSetTitle)
|
|
|
|
TEXT(Button, uiButton, uiButtonText, uiButtonSetText)
|
|
|
|
TEXT(Checkbox, uiCheckbox, uiCheckboxText, uiCheckboxSetText)
|
|
|
|
TEXT(Label, uiLabel, uiLabelText, uiLabelSetText)
|
|
|
|
|
2015-05-09 20:01:32 -05:00
|
|
|
static void onChanged(uiEntry *e, void *data)
|
|
|
|
{
|
|
|
|
printf("onChanged()\n");
|
|
|
|
}
|
|
|
|
|
2015-04-29 13:03:17 -05:00
|
|
|
static void toggleSpaced(uiCheckbox *c, void *data)
|
|
|
|
{
|
|
|
|
setSpaced(uiCheckboxChecked(spaced));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void forceSpaced(uiButton *b, void *data)
|
|
|
|
{
|
|
|
|
uiCheckboxSetChecked(spaced, data != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void showSpaced(uiButton *b, void *data)
|
|
|
|
{
|
|
|
|
char s[12];
|
|
|
|
|
|
|
|
querySpaced(s);
|
|
|
|
uiEntrySetText(entry, s);
|
|
|
|
}
|
|
|
|
|
2015-04-29 13:10:00 -05:00
|
|
|
#define SHED(method, Method) \
|
|
|
|
static void method ## Control(uiButton *b, void *data) \
|
|
|
|
{ \
|
|
|
|
uiControl ## Method(uiControl(data)); \
|
|
|
|
}
|
|
|
|
SHED(show, Show)
|
|
|
|
SHED(hide, Hide)
|
|
|
|
SHED(enable, Enable)
|
|
|
|
SHED(disable, Disable)
|
|
|
|
|
2015-04-29 19:23:38 -05:00
|
|
|
uiBox *page1;
|
|
|
|
|
|
|
|
void makePage1(uiWindow *w)
|
2015-04-29 12:38:38 -05:00
|
|
|
{
|
|
|
|
uiButton *getButton, *setButton;
|
|
|
|
uiBox *hbox;
|
|
|
|
uiBox *testBox;
|
|
|
|
uiLabel *label;
|
|
|
|
|
|
|
|
page1 = newVerticalBox();
|
|
|
|
|
|
|
|
entry = uiNewEntry();
|
2015-05-09 20:01:32 -05:00
|
|
|
uiEntryOnChanged(entry, onChanged, NULL);
|
2015-04-29 12:38:38 -05:00
|
|
|
uiBoxAppend(page1, uiControl(entry), 0);
|
|
|
|
|
|
|
|
spaced = uiNewCheckbox("Spaced");
|
2015-04-29 13:03:17 -05:00
|
|
|
uiCheckboxOnToggled(spaced, toggleSpaced, NULL);
|
2015-04-29 12:38:38 -05:00
|
|
|
label = uiNewLabel("Label");
|
|
|
|
|
|
|
|
hbox = newHorizontalBox();
|
|
|
|
getButton = uiNewButton("Get Window Text");
|
2015-04-29 12:47:50 -05:00
|
|
|
uiButtonOnClicked(getButton, getWindowText, w);
|
2015-04-29 12:38:38 -05:00
|
|
|
setButton = uiNewButton("Set Window Text");
|
2015-04-29 12:47:50 -05:00
|
|
|
uiButtonOnClicked(setButton, setWindowText, w);
|
2015-04-29 12:38:38 -05:00
|
|
|
uiBoxAppend(hbox, uiControl(getButton), 1);
|
|
|
|
uiBoxAppend(hbox, uiControl(setButton), 1);
|
|
|
|
uiBoxAppend(page1, uiControl(hbox), 0);
|
|
|
|
|
|
|
|
hbox = newHorizontalBox();
|
|
|
|
getButton = uiNewButton("Get Button Text");
|
2015-04-29 12:47:50 -05:00
|
|
|
uiButtonOnClicked(getButton, getButtonText, getButton);
|
2015-04-29 12:38:38 -05:00
|
|
|
setButton = uiNewButton("Set Button Text");
|
2015-04-29 12:47:50 -05:00
|
|
|
uiButtonOnClicked(setButton, setButtonText, getButton);
|
2015-04-29 12:38:38 -05:00
|
|
|
uiBoxAppend(hbox, uiControl(getButton), 1);
|
|
|
|
uiBoxAppend(hbox, uiControl(setButton), 1);
|
|
|
|
uiBoxAppend(page1, uiControl(hbox), 0);
|
|
|
|
|
|
|
|
hbox = newHorizontalBox();
|
|
|
|
getButton = uiNewButton("Get Checkbox Text");
|
2015-04-29 12:47:50 -05:00
|
|
|
uiButtonOnClicked(getButton, getCheckboxText, spaced);
|
2015-04-29 12:38:38 -05:00
|
|
|
setButton = uiNewButton("Set Checkbox Text");
|
2015-04-29 12:47:50 -05:00
|
|
|
uiButtonOnClicked(setButton, setCheckboxText, spaced);
|
2015-04-29 12:38:38 -05:00
|
|
|
uiBoxAppend(hbox, uiControl(getButton), 1);
|
|
|
|
uiBoxAppend(hbox, uiControl(setButton), 1);
|
|
|
|
uiBoxAppend(page1, uiControl(hbox), 0);
|
|
|
|
|
|
|
|
hbox = newHorizontalBox();
|
|
|
|
getButton = uiNewButton("Get Label Text");
|
2015-04-29 12:47:50 -05:00
|
|
|
uiButtonOnClicked(getButton, getLabelText, label);
|
2015-04-29 12:38:38 -05:00
|
|
|
setButton = uiNewButton("Set Label Text");
|
2015-04-29 12:47:50 -05:00
|
|
|
uiButtonOnClicked(setButton, setLabelText, label);
|
2015-04-29 12:38:38 -05:00
|
|
|
uiBoxAppend(hbox, uiControl(getButton), 1);
|
|
|
|
uiBoxAppend(hbox, uiControl(setButton), 1);
|
|
|
|
uiBoxAppend(page1, uiControl(hbox), 0);
|
|
|
|
|
|
|
|
hbox = newHorizontalBox();
|
|
|
|
uiBoxAppend(hbox, uiControl(spaced), 1);
|
|
|
|
getButton = uiNewButton("On");
|
2015-04-29 13:03:17 -05:00
|
|
|
uiButtonOnClicked(getButton, forceSpaced, getButton);
|
2015-04-29 12:38:38 -05:00
|
|
|
uiBoxAppend(hbox, uiControl(getButton), 0);
|
|
|
|
getButton = uiNewButton("Off");
|
2015-04-29 13:03:17 -05:00
|
|
|
uiButtonOnClicked(getButton, forceSpaced, NULL);
|
2015-04-29 12:38:38 -05:00
|
|
|
uiBoxAppend(hbox, uiControl(getButton), 0);
|
|
|
|
getButton = uiNewButton("Show");
|
2015-04-29 13:03:17 -05:00
|
|
|
uiButtonOnClicked(getButton, showSpaced, NULL);
|
2015-04-29 12:38:38 -05:00
|
|
|
uiBoxAppend(hbox, uiControl(getButton), 0);
|
|
|
|
uiBoxAppend(page1, uiControl(hbox), 0);
|
|
|
|
|
|
|
|
testBox = newHorizontalBox();
|
|
|
|
setButton = uiNewButton("Button");
|
|
|
|
uiBoxAppend(testBox, uiControl(setButton), 1);
|
|
|
|
getButton = uiNewButton("Show");
|
2015-04-29 13:10:00 -05:00
|
|
|
uiButtonOnClicked(getButton, showControl, setButton);
|
2015-04-29 12:38:38 -05:00
|
|
|
uiBoxAppend(testBox, uiControl(getButton), 0);
|
|
|
|
getButton = uiNewButton("Hide");
|
2015-04-29 13:10:00 -05:00
|
|
|
uiButtonOnClicked(getButton, hideControl, setButton);
|
2015-04-29 12:38:38 -05:00
|
|
|
uiBoxAppend(testBox, uiControl(getButton), 0);
|
|
|
|
getButton = uiNewButton("Enable");
|
2015-04-29 13:10:00 -05:00
|
|
|
uiButtonOnClicked(getButton, enableControl, setButton);
|
2015-04-29 12:38:38 -05:00
|
|
|
uiBoxAppend(testBox, uiControl(getButton), 0);
|
|
|
|
getButton = uiNewButton("Disable");
|
2015-04-29 13:10:00 -05:00
|
|
|
uiButtonOnClicked(getButton, disableControl, setButton);
|
2015-04-29 12:38:38 -05:00
|
|
|
uiBoxAppend(testBox, uiControl(getButton), 0);
|
|
|
|
uiBoxAppend(page1, uiControl(testBox), 0);
|
|
|
|
|
|
|
|
hbox = newHorizontalBox();
|
|
|
|
getButton = uiNewButton("Show Box");
|
2015-04-29 13:10:00 -05:00
|
|
|
uiButtonOnClicked(getButton, showControl, testBox);
|
2015-04-29 12:38:38 -05:00
|
|
|
uiBoxAppend(hbox, uiControl(getButton), 1);
|
|
|
|
getButton = uiNewButton("Hide Box");
|
2015-04-29 13:10:00 -05:00
|
|
|
uiButtonOnClicked(getButton, hideControl, testBox);
|
2015-04-29 12:38:38 -05:00
|
|
|
uiBoxAppend(hbox, uiControl(getButton), 1);
|
|
|
|
getButton = uiNewButton("Enable Box");
|
2015-04-29 13:10:00 -05:00
|
|
|
uiButtonOnClicked(getButton, enableControl, testBox);
|
2015-04-29 12:38:38 -05:00
|
|
|
uiBoxAppend(hbox, uiControl(getButton), 1);
|
|
|
|
getButton = uiNewButton("Disable Box");
|
2015-04-29 13:10:00 -05:00
|
|
|
uiButtonOnClicked(getButton, disableControl, testBox);
|
2015-04-29 12:38:38 -05:00
|
|
|
uiBoxAppend(hbox, uiControl(getButton), 1);
|
|
|
|
uiBoxAppend(page1, uiControl(hbox), 0);
|
|
|
|
|
|
|
|
uiBoxAppend(page1, uiControl(label), 0);
|
|
|
|
}
|