libui/redo/test/page4.c

121 lines
3.2 KiB
C
Raw Normal View History

// 19 may 2015
#include "test.h"
static uiSpinbox *spinbox;
2015-05-20 09:29:57 -05:00
static uiSlider *slider;
2015-05-19 20:05:18 -05:00
static uiProgressBar *pbar;
2015-05-19 17:17:30 -05:00
#define CHANGED(what) \
static void on ## what ## Changed(ui ## what *this, void *data) \
{ \
2015-05-19 20:05:18 -05:00
uintmax_t value; \
2015-05-19 17:17:30 -05:00
printf("on %s changed\n", #what); \
2015-05-19 20:05:18 -05:00
value = ui ## what ## Value(this); \
2015-05-20 11:24:06 -05:00
uiSpinboxSetValue(spinbox, value); \
uiSliderSetValue(slider, value); \
2015-05-19 20:05:18 -05:00
uiProgressBarSetValue(pbar, value); \
2015-05-19 17:17:30 -05:00
}
CHANGED(Spinbox)
2015-05-20 09:29:57 -05:00
CHANGED(Slider)
2015-05-19 17:17:30 -05:00
2015-05-20 12:25:45 -05:00
#define SETTOO(what, name, n) \
static void set ## what ## Too ## name(uiButton *this, void *data) \
{ \
ui ## what ## SetValue(ui ## what(data), n); \
}
SETTOO(Spinbox, Low, -80)
SETTOO(Spinbox, High, 80)
SETTOO(Slider, Low, -80)
SETTOO(Slider, High, 80)
static uiCombobox *cbox;
static uiCombobox *editable;
static uiRadioButtons *rb;
2015-05-20 16:09:58 -05:00
static void appendCBRB(uiButton *b, void *data)
{
uiComboboxAppend(cbox, "New Item");
uiComboboxAppend(editable, "New Item");
uiRadioButtonsAppend(rb, "New Item");
}
uiBox *makePage4(void)
{
uiBox *page4;
2015-05-20 12:25:45 -05:00
uiBox *hbox;
uiSpinbox *xsb;
uiButton *b;
uiSlider *xsl;
page4 = newVerticalBox();
2015-05-20 12:25:45 -05:00
spinbox = uiNewSpinbox(0, 100);
2015-05-19 17:17:30 -05:00
uiSpinboxOnChanged(spinbox, onSpinboxChanged, NULL);
uiBoxAppend(page4, uiControl(spinbox), 0);
2015-05-20 12:25:45 -05:00
slider = uiNewSlider(0, 100);
2015-05-20 09:29:57 -05:00
uiSliderOnChanged(slider, onSliderChanged, NULL);
uiBoxAppend(page4, uiControl(slider), 0);
2015-05-19 20:05:18 -05:00
pbar = uiNewProgressBar();
uiBoxAppend(page4, uiControl(pbar), 0);
2015-05-20 13:08:34 -05:00
uiBoxAppend(page4, uiControl(uiNewHorizontalSeparator()), 0);
2015-05-20 12:25:45 -05:00
hbox = newHorizontalBox();
xsb = uiNewSpinbox(-40, 40);
uiBoxAppend(hbox, uiControl(xsb), 0);
b = uiNewButton("Bad Low");
uiButtonOnClicked(b, setSpinboxTooLow, xsb);
uiBoxAppend(hbox, uiControl(b), 0);
b = uiNewButton("Bad High");
uiButtonOnClicked(b, setSpinboxTooHigh, xsb);
uiBoxAppend(hbox, uiControl(b), 0);
uiBoxAppend(page4, uiControl(hbox), 0);
hbox = newHorizontalBox();
xsl = uiNewSlider(-40, 40);
uiBoxAppend(hbox, uiControl(xsl), 0);
b = uiNewButton("Bad Low");
uiButtonOnClicked(b, setSliderTooLow, xsl);
uiBoxAppend(hbox, uiControl(b), 0);
b = uiNewButton("Bad High");
uiButtonOnClicked(b, setSliderTooHigh, xsl);
uiBoxAppend(hbox, uiControl(b), 0);
uiBoxAppend(page4, uiControl(hbox), 0);
2015-05-20 16:09:58 -05:00
uiBoxAppend(page4, uiControl(uiNewHorizontalSeparator()), 0);
cbox = uiNewCombobox();
uiComboboxAppend(cbox, "Item 1");
uiComboboxAppend(cbox, "Item 2");
uiComboboxAppend(cbox, "Item 3");
uiBoxAppend(page4, uiControl(cbox), 0);
editable = uiNewEditableCombobox();
uiComboboxAppend(editable, "Editable Item 1");
uiComboboxAppend(editable, "Editable Item 2");
uiComboboxAppend(editable, "Editable Item 3");
uiBoxAppend(page4, uiControl(editable), 0);
rb = uiNewRadioButtons();
uiRadioButtonsAppend(rb, "Item 1");
uiRadioButtonsAppend(rb, "Item 2");
uiRadioButtonsAppend(rb, "Item 3");
uiBoxAppend(page4, uiControl(rb), 0);
hbox = newHorizontalBox();
b = uiNewButton("Append");
uiButtonOnClicked(b, appendCBRB, NULL);
uiBoxAppend(hbox, uiControl(b), 0);
uiBoxAppend(page4, uiControl(hbox), 0);
2015-05-22 09:36:24 -05:00
uiBoxAppend(page4, uiControl(uiNewHorizontalSeparator()), 0);
uiBoxAppend(page4, uiControl(uiNewDateTimePicker()), 0);
uiBoxAppend(page4, uiControl(uiNewDatePicker()), 0);
uiBoxAppend(page4, uiControl(uiNewTimePicker()), 0);
return page4;
}