Wrote up a new test program that will feature uiEntry when I write it (next).
This commit is contained in:
parent
c6d7e33121
commit
d3f602f64a
75
new/test.c
75
new/test.c
|
@ -9,22 +9,53 @@ int onClosing(uiWindow *w, void *data)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onClicked(uiControl *b, void *data)
|
uiControl *e;
|
||||||
|
|
||||||
|
/*TODO
|
||||||
|
static void getWindowText(uiControl *b, void *data)
|
||||||
{
|
{
|
||||||
// TODO
|
char *text;
|
||||||
|
|
||||||
|
text = uiWindowTitle((uiWindow *) data);
|
||||||
|
uiEntrySetText(e, text);
|
||||||
|
uiFreeText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onClicked2(uiControl *b, void *data)
|
static void setWindowText(uiControl *b, void *data)
|
||||||
{
|
{
|
||||||
printf("button clicked!\n");
|
char *text;
|
||||||
|
|
||||||
|
text = uiEntryText(e);
|
||||||
|
uiWindowSetTitle((uiWindow *) data, text);
|
||||||
|
uiFreeText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void getButtonText(uiControl *b, void *data)
|
||||||
|
{
|
||||||
|
char *text;
|
||||||
|
|
||||||
|
text = uiButtonText((uiControl *) data);
|
||||||
|
uiEntrySetText(e, text);
|
||||||
|
uiFreeText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setButtonText(uiControl *b, void *data)
|
||||||
|
{
|
||||||
|
char *text;
|
||||||
|
|
||||||
|
text = uiEntryText(e);
|
||||||
|
uiButtonSetText((uiControl *) data, text);
|
||||||
|
uiFreeText(text);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
uiInitError *err;
|
uiInitError *err;
|
||||||
uiWindow *w;
|
uiWindow *w;
|
||||||
uiControl *stack;
|
uiControl *mainStack;
|
||||||
uiControl *button, *button2;
|
uiControl *buttonStack;
|
||||||
|
uiControl *getButton, *setButton;
|
||||||
|
|
||||||
err = uiInit(NULL);
|
err = uiInit(NULL);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
|
@ -36,19 +67,29 @@ int main(int argc, char *argv[])
|
||||||
w = uiNewWindow("Hello", 320, 240);
|
w = uiNewWindow("Hello", 320, 240);
|
||||||
uiWindowOnClosing(w, onClosing, NULL);
|
uiWindowOnClosing(w, onClosing, NULL);
|
||||||
|
|
||||||
if (argc > 1)
|
mainStack = uiNewVerticalStack();
|
||||||
stack = uiNewHorizontalStack();
|
uiWindowSetChild(w, mainStack);
|
||||||
else
|
|
||||||
stack = uiNewVerticalStack();
|
|
||||||
uiWindowSetChild(w, stack);
|
|
||||||
|
|
||||||
button2 = uiNewButton("Change Me");
|
e = uiTextEntryNew();
|
||||||
uiButtonOnClicked(button2, onClicked2, NULL);
|
uiStackAdd(mainStack, e, 0);
|
||||||
|
|
||||||
button = uiNewButton("Click Me");
|
buttonStack = uiNewHorizontalStack();
|
||||||
uiButtonOnClicked(button, onClicked, button2);
|
getButton = uiNewButton("Get Window Text");
|
||||||
uiStackAdd(stack, button, 1);
|
//TODO uiButtonOnClicked(getButton, getWindowText, w);
|
||||||
uiStackAdd(stack, button2, 0);
|
setButton = uiNewButton("Set Window Text");
|
||||||
|
//TODO uiButtonOnClicked(setButton, setWindowText, w);
|
||||||
|
uiStackAdd(buttonStack, getButton, 1);
|
||||||
|
uiStackAdd(buttonStack, setButton, 1);
|
||||||
|
uiStackAdd(mainStack, buttonStack, 0);
|
||||||
|
|
||||||
|
buttonStack = uiNewHorizontalStack();
|
||||||
|
//TODO getButton = uiNewButton("Get Button Text");
|
||||||
|
uiButtonOnClicked(getButton, getButtonText, getButton);
|
||||||
|
//TODO setButton = uiNewButton("Set Button Text");
|
||||||
|
uiButtonOnClicked(setButton, setButtonText, getButton);
|
||||||
|
uiStackAdd(buttonStack, getButton, 1);
|
||||||
|
uiStackAdd(buttonStack, setButton, 1);
|
||||||
|
uiStackAdd(mainStack, buttonStack, 0);
|
||||||
|
|
||||||
uiWindowShow(w);
|
uiWindowShow(w);
|
||||||
uiMain();
|
uiMain();
|
||||||
|
|
Loading…
Reference in New Issue