Added a checkbox to the test program. It won't do anything just yet...

This commit is contained in:
Pietro Gagliardi 2015-04-09 12:14:18 -04:00
parent 67bfe61c93
commit 2917d568d2
2 changed files with 49 additions and 13 deletions

View File

@ -47,13 +47,32 @@ static void setButtonText(uiControl *b, void *data)
uiFreeText(text); uiFreeText(text);
} }
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);
}
uiControl *stacks[3];
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
uiInitError *err; uiInitError *err;
uiWindow *w; uiWindow *w;
uiControl *mainStack;
uiControl *buttonStack;
uiControl *getButton, *setButton; uiControl *getButton, *setButton;
uiControl *spaced;
err = uiInit(NULL); err = uiInit(NULL);
if (err != NULL) { if (err != NULL) {
@ -65,29 +84,42 @@ int main(int argc, char *argv[])
w = uiNewWindow("Hello", 320, 240); w = uiNewWindow("Hello", 320, 240);
uiWindowOnClosing(w, onClosing, NULL); uiWindowOnClosing(w, onClosing, NULL);
mainStack = uiNewVerticalStack(); stacks[0] = uiNewVerticalStack();
uiWindowSetChild(w, mainStack); uiWindowSetChild(w, staacks[0]);
e = uiNewEntry(); e = uiNewEntry();
uiStackAdd(mainStack, e, 0); uiStackAdd(stacks[0], e, 0);
buttonStack = uiNewHorizontalStack(); stacks[1] = uiNewHorizontalStack();
getButton = uiNewButton("Get Window Text"); getButton = uiNewButton("Get Window Text");
uiButtonOnClicked(getButton, getWindowText, w); uiButtonOnClicked(getButton, getWindowText, w);
setButton = uiNewButton("Set Window Text"); setButton = uiNewButton("Set Window Text");
uiButtonOnClicked(setButton, setWindowText, w); uiButtonOnClicked(setButton, setWindowText, w);
uiStackAdd(buttonStack, getButton, 1); uiStackAdd(stacks[1], getButton, 1);
uiStackAdd(buttonStack, setButton, 1); uiStackAdd(stacks[1], setButton, 1);
uiStackAdd(mainStack, buttonStack, 0); uiStackAdd(stacks[0], stacks[1], 0);
buttonStack = uiNewHorizontalStack(); stacks[2] = uiNewHorizontalStack();
getButton = uiNewButton("Get Button Text"); getButton = uiNewButton("Get Button Text");
uiButtonOnClicked(getButton, getButtonText, getButton); uiButtonOnClicked(getButton, getButtonText, getButton);
setButton = uiNewButton("Set Button Text"); setButton = uiNewButton("Set Button Text");
uiButtonOnClicked(setButton, setButtonText, getButton); uiButtonOnClicked(setButton, setButtonText, getButton);
uiStackAdd(buttonStack, getButton, 1); uiStackAdd(stacks[2], getButton, 1);
uiStackAdd(buttonStack, setButton, 1); uiStackAdd(stacks[2], setButton, 1);
uiStackAdd(mainStack, buttonStack, 0); uiStackAdd(stacks[0], stacks[2], 0);
spaced = uiNewCheckbox("Spaced");
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);
uiWindowShow(w); uiWindowShow(w);
uiMain(); uiMain();

View File

@ -45,4 +45,8 @@ uiControl *uiNewEntry(void);
char *uiEntryText(uiControl *); char *uiEntryText(uiControl *);
void uiEntrySetText(uiControl *, const char *); void uiEntrySetText(uiControl *, const char *);
uiControl *uiNewCheckbox(const char *);
char *uiCheckboxText(void);
void uiCheckboxSetText(uiControl *, const char *);
#endif #endif