More spinbox and slider work.
This commit is contained in:
parent
7a86dc92cb
commit
ea4017f29d
|
@ -18,22 +18,60 @@ static uiProgressBar *pbar;
|
||||||
CHANGED(Spinbox)
|
CHANGED(Spinbox)
|
||||||
CHANGED(Slider)
|
CHANGED(Slider)
|
||||||
|
|
||||||
|
#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)
|
||||||
|
|
||||||
uiBox *makePage4(void)
|
uiBox *makePage4(void)
|
||||||
{
|
{
|
||||||
uiBox *page4;
|
uiBox *page4;
|
||||||
|
uiBox *hbox;
|
||||||
|
uiSpinbox *xsb;
|
||||||
|
uiButton *b;
|
||||||
|
uiSlider *xsl;
|
||||||
|
|
||||||
page4 = newVerticalBox();
|
page4 = newVerticalBox();
|
||||||
|
|
||||||
spinbox = uiNewSpinbox();
|
spinbox = uiNewSpinbox(0, 100);
|
||||||
uiSpinboxOnChanged(spinbox, onSpinboxChanged, NULL);
|
uiSpinboxOnChanged(spinbox, onSpinboxChanged, NULL);
|
||||||
uiBoxAppend(page4, uiControl(spinbox), 0);
|
uiBoxAppend(page4, uiControl(spinbox), 0);
|
||||||
|
|
||||||
slider = uiNewSlider();
|
slider = uiNewSlider(0, 100);
|
||||||
uiSliderOnChanged(slider, onSliderChanged, NULL);
|
uiSliderOnChanged(slider, onSliderChanged, NULL);
|
||||||
uiBoxAppend(page4, uiControl(slider), 0);
|
uiBoxAppend(page4, uiControl(slider), 0);
|
||||||
|
|
||||||
pbar = uiNewProgressBar();
|
pbar = uiNewProgressBar();
|
||||||
uiBoxAppend(page4, uiControl(pbar), 0);
|
uiBoxAppend(page4, uiControl(pbar), 0);
|
||||||
|
|
||||||
|
// TODO separator
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
return page4;
|
return page4;
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,13 +143,15 @@ func NewGroup(text *const char) *Group;
|
||||||
|
|
||||||
// spinbox/slider rules:
|
// spinbox/slider rules:
|
||||||
// setting value outside of range will automatically clamp
|
// setting value outside of range will automatically clamp
|
||||||
|
// initial value is minimum
|
||||||
|
// TODO what happens if max > min? max == min?
|
||||||
|
|
||||||
interface Spinbox from Control {
|
interface Spinbox from Control {
|
||||||
func Value(void) intmax_t;
|
func Value(void) intmax_t;
|
||||||
func SetValue(value intmax_t);
|
func SetValue(value intmax_t);
|
||||||
func OnChanged(f *func(s *Spinbox, data *void), data *void);
|
func OnChanged(f *func(s *Spinbox, data *void), data *void);
|
||||||
};
|
};
|
||||||
func NewSpinbox(void) *Spinbox;
|
func NewSpinbox(min intmax_t, max intmax_t) *Spinbox;
|
||||||
|
|
||||||
interface ProgressBar from Control {
|
interface ProgressBar from Control {
|
||||||
// TODO Value()
|
// TODO Value()
|
||||||
|
@ -162,7 +164,7 @@ interface Slider from Control {
|
||||||
func SetValue(value intmax_t);
|
func SetValue(value intmax_t);
|
||||||
func OnChanged(f *func(s *Slider, data *void), data *void);
|
func OnChanged(f *func(s *Slider, data *void), data *void);
|
||||||
};
|
};
|
||||||
func NewSlider(void) *Slider;
|
func NewSlider(min intmax_t, max intmax_t) *Slider;
|
||||||
|
|
||||||
interface Menu {
|
interface Menu {
|
||||||
func AppendItem(name *const char) *MenuItem;
|
func AppendItem(name *const char) *MenuItem;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
// TODOs
|
// TODOs
|
||||||
// - investigate overriding WM_ERASEBKGND to simulate TBS_TRANSPARENTBKGND
|
// - investigate overriding WM_ERASEBKGND to simulate TBS_TRANSPARENTBKGND
|
||||||
|
// - wine does not clamp TBM_SETPOS
|
||||||
|
|
||||||
struct slider {
|
struct slider {
|
||||||
uiSlider s;
|
uiSlider s;
|
||||||
|
@ -78,7 +79,7 @@ static void sliderOnChanged(uiSlider *ss, void (*f)(uiSlider *, void *), void *d
|
||||||
s->onChangedData = data;
|
s->onChangedData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
uiSlider *uiNewSlider(void)
|
uiSlider *uiNewSlider(intmax_t min, intmax_t max)
|
||||||
{
|
{
|
||||||
struct slider *s;
|
struct slider *s;
|
||||||
uiWindowsMakeControlParams p;
|
uiWindowsMakeControlParams p;
|
||||||
|
@ -103,8 +104,9 @@ uiSlider *uiNewSlider(void)
|
||||||
|
|
||||||
s->hwnd = (HWND) uiControlHandle(uiControl(s));
|
s->hwnd = (HWND) uiControlHandle(uiControl(s));
|
||||||
|
|
||||||
SendMessageW(s->hwnd, TBM_SETRANGEMIN, (WPARAM) TRUE, (LPARAM) 0);
|
SendMessageW(s->hwnd, TBM_SETRANGEMIN, (WPARAM) TRUE, (LPARAM) min);
|
||||||
SendMessageW(s->hwnd, TBM_SETRANGEMAX, (WPARAM) TRUE, (LPARAM) 100);
|
SendMessageW(s->hwnd, TBM_SETRANGEMAX, (WPARAM) TRUE, (LPARAM) max);
|
||||||
|
SendMessageW(s->hwnd, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) min);
|
||||||
|
|
||||||
s->onChanged = defaultOnChanged;
|
s->onChanged = defaultOnChanged;
|
||||||
|
|
||||||
|
|
|
@ -110,10 +110,6 @@ static void recreateUpDown(struct spinbox *s)
|
||||||
if (preserve) {
|
if (preserve) {
|
||||||
SendMessageW(s->updown, UDM_SETRANGE32, (WPARAM) min, (LPARAM) max);
|
SendMessageW(s->updown, UDM_SETRANGE32, (WPARAM) min, (LPARAM) max);
|
||||||
SendMessageW(s->updown, UDM_SETPOS32, 0, (LPARAM) current);
|
SendMessageW(s->updown, UDM_SETPOS32, 0, (LPARAM) current);
|
||||||
} else {
|
|
||||||
// TODO
|
|
||||||
SendMessageW(s->updown, UDM_SETRANGE32, 0, 100);
|
|
||||||
SendMessageW(s->updown, UDM_SETPOS32, 0, 0);
|
|
||||||
}
|
}
|
||||||
if (uiControlContainerVisible(uiControl(s)))
|
if (uiControlContainerVisible(uiControl(s)))
|
||||||
ShowWindow(s->updown, SW_SHOW);
|
ShowWindow(s->updown, SW_SHOW);
|
||||||
|
@ -158,7 +154,7 @@ static void spinboxOnChanged(uiSpinbox *ss, void (*f)(uiSpinbox *, void *), void
|
||||||
s->onChangedData = data;
|
s->onChangedData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
uiSpinbox *uiNewSpinbox(void)
|
uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max)
|
||||||
{
|
{
|
||||||
struct spinbox *s;
|
struct spinbox *s;
|
||||||
uiWindowsMakeControlParams p;
|
uiWindowsMakeControlParams p;
|
||||||
|
@ -183,6 +179,10 @@ uiSpinbox *uiNewSpinbox(void)
|
||||||
s->hwnd = (HWND) uiControlHandle(uiControl(s));
|
s->hwnd = (HWND) uiControlHandle(uiControl(s));
|
||||||
|
|
||||||
recreateUpDown(s);
|
recreateUpDown(s);
|
||||||
|
s->inhibitChanged = TRUE;
|
||||||
|
SendMessageW(s->updown, UDM_SETRANGE32, (WPARAM) min, (LPARAM) max);
|
||||||
|
SendMessageW(s->updown, UDM_SETPOS32, 0, (LPARAM) min);
|
||||||
|
s->inhibitChanged = FALSE;
|
||||||
|
|
||||||
s->onChanged = defaultOnChanged;
|
s->onChanged = defaultOnChanged;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue