libui/test/page13.c

158 lines
3.4 KiB
C
Raw Normal View History

// 28 may 2016
#include "test.h"
2016-05-28 21:49:27 -05:00
static int winClose(uiWindow *w, void *data)
{
return 1;
}
static void openTestWindow(uiBox *(*mkf)(void))
{
uiWindow *w;
uiBox *b;
uiCombobox *c;
uiEditableCombobox *e;
uiRadioButtons *r;
w = uiNewWindow("Test", 100, 100, 0);
uiWindowOnClosing(w, winClose, NULL);
uiWindowSetMargined(w, 1);
b = (*mkf)();
uiWindowSetChild(w, uiControl(b));
#define BA(x) uiBoxAppend(b, uiControl(x), 0)
BA(uiNewButton(""));
BA(uiNewCheckbox(""));
BA(uiNewEntry());
BA(uiNewLabel(""));
BA(uiNewSpinbox(0, 100));
BA(uiNewProgressBar());
BA(uiNewSlider(0, 100));
BA(uiNewHorizontalSeparator());
c = uiNewCombobox();
uiComboboxAppend(c, "");
BA(c);
e = uiNewEditableCombobox();
uiEditableComboboxAppend(e, "");
BA(e);
r = uiNewRadioButtons();
uiRadioButtonsAppend(r, "");
BA(r);
BA(uiNewDateTimePicker());
BA(uiNewDatePicker());
BA(uiNewTimePicker());
BA(uiNewMultilineEntry());
// TODO nonscrolling and scrolling areas?
BA(uiNewFontButton());
BA(uiNewColorButton());
BA(uiNewPasswordEntry());
BA(uiNewSearchEntry());
2016-06-17 10:02:17 -05:00
BA(uiNewVerticalSeparator());
2016-05-28 21:49:27 -05:00
uiControlShow(uiControl(w));
}
static void buttonClicked(uiButton *b, void *data)
{
openTestWindow((uiBox *(*)(void)) data);
}
static void entryChanged(uiEntry *e, void *data)
{
char *text;
text = uiEntryText(e);
printf("%s entry changed: %s\n", (const char *) data, text);
uiFreeText(text);
}
static void showHide(uiButton *b, void *data)
{
uiControl *c = uiControl(data);
if (uiControlVisible(c))
uiControlHide(c);
else
uiControlShow(c);
}
static void setIndeterminate(uiButton *b, void *data)
{
uiProgressBar *p = uiProgressBar(data);
2016-06-16 16:43:04 -05:00
int value;
2016-06-16 16:43:04 -05:00
value = uiProgressBarValue(p);
if (value == -1)
value = 50;
else
value = -1;
uiProgressBarSetValue(p, value);
}
2016-06-15 11:06:19 -05:00
static void deleteFirst(uiButton *b, void *data)
{
uiForm *f = uiForm(data);
uiFormDelete(f, 0);
}
uiBox *makePage13(void)
{
uiBox *page13;
uiRadioButtons *rb;
uiButton *b;
uiForm *f;
uiEntry *e;
uiProgressBar *p;
page13 = newVerticalBox();
rb = uiNewRadioButtons();
uiRadioButtonsAppend(rb, "Item 1");
uiRadioButtonsAppend(rb, "Item 2");
uiRadioButtonsAppend(rb, "Item 3");
uiBoxAppend(page13, uiControl(rb), 0);
rb = uiNewRadioButtons();
uiRadioButtonsAppend(rb, "Item A");
uiRadioButtonsAppend(rb, "Item B");
uiBoxAppend(page13, uiControl(rb), 0);
b = uiNewButton("Horizontal");
2016-05-28 21:49:27 -05:00
uiButtonOnClicked(b, buttonClicked, uiNewHorizontalBox);
uiBoxAppend(page13, uiControl(b), 0);
b = uiNewButton("Vertical");
2016-05-28 21:49:27 -05:00
uiButtonOnClicked(b, buttonClicked, uiNewVerticalBox);
uiBoxAppend(page13, uiControl(b), 0);
f = newForm();
e = uiNewPasswordEntry();
uiEntryOnChanged(e, entryChanged, "password");
uiFormAppend(f, "Password Entry", uiControl(e), 0);
e = uiNewSearchEntry();
uiEntryOnChanged(e, entryChanged, "search");
uiFormAppend(f, "Search Box", uiControl(e), 0);
uiFormAppend(f, "MLE", uiControl(uiNewMultilineEntry()), 1);
p = uiNewProgressBar();
2016-06-16 16:43:04 -05:00
uiProgressBarSetValue(p, 50);
uiBoxAppend(page13, uiControl(p), 0);
2016-06-16 16:43:04 -05:00
b = uiNewButton("Toggle Indeterminate");
uiButtonOnClicked(b, setIndeterminate, p);
uiBoxAppend(page13, uiControl(b), 0);
b = uiNewButton("Show/Hide");
uiButtonOnClicked(b, showHide, e);
uiBoxAppend(page13, uiControl(b), 0);
2016-06-15 11:06:19 -05:00
b = uiNewButton("Delete First");
uiButtonOnClicked(b, deleteFirst, f);
uiBoxAppend(page13, uiControl(b), 0);
uiBoxAppend(page13, uiControl(f), 1);
return page13;
}