diff --git a/redo/reredo/darwin/progressbar.m b/redo/reredo/darwin/progressbar.m new file mode 100644 index 00000000..d069d70b --- /dev/null +++ b/redo/reredo/darwin/progressbar.m @@ -0,0 +1,37 @@ +// 14 august 2015 +#import "uipriv_darwin.h" + +struct uiProgressBar { + uiDarwinControl c; + NSProgressIndicator *pi; +}; + +uiDarwinDefineControl( + uiProgressBar, // type name + uiProgressBarType, // type function + pi // handle +) + +void uiProgressbarSetValue(uiProgressBar *p, int value) +{ + if (value < 0 || value > 100) + complain("value %d out of range in progressbarSetValue()", value); + // TODO +} + +uiProgressBar *uiNewProgressBar(void) +{ + uiProgressBar *p; + + p = (uiProgressBar *) uiNewControl(uiProgressBarType()); + + p->pi = [[NSProgressIndicator alloc] initWithFrame:NSZeroRect]; + [p->pi setControlSize:NSRegularControlSize]; + [p->pi setBezeled:YES]; + [p->pi setStyle:NSProgressIndicatorBarStyle]; + [p->pi setIndeterminate:NO]; + + uiDarwinFinishNewControl(p, uiProgressBar); + + return p; +} diff --git a/redo/reredo/darwin/radiobuttons.m b/redo/reredo/darwin/radiobuttons.m new file mode 100644 index 00000000..0b07bb94 --- /dev/null +++ b/redo/reredo/darwin/radiobuttons.m @@ -0,0 +1,33 @@ +// 14 august 2015 +#import "uipriv_darwin.h" + +struct uiRadioButtons { + uiDarwinControl c; + NSTextField *dummy; +}; + +uiDarwinDefineControl( + uiRadioButtons, // type name + uiRadioButtonsType, // type function + dummy // handle +) + +void uiRadioButtonsAppend(uiRadioButtons *r, const char *text) +{ + // TODO + uiControlQueueResize(uiControl(r)); +} + +uiRadioButtons *uiNewRadioButtons(void) +{ + uiRadioButtons *r; + + r = (uiRadioButtons *) uiNewControl(uiRadioButtonsType()); + + r->dummy = [[NSTextField alloc] initWithFrame:NSZeroRect]; + [r->dummy setStringValue:@"TODO uiRadioButtons not implemented"]; + + uiDarwinFinishNewControl(r, uiRadioButtons); + + return r; +} diff --git a/redo/reredo/darwin/separator.m b/redo/reredo/darwin/separator.m new file mode 100644 index 00000000..3042f998 --- /dev/null +++ b/redo/reredo/darwin/separator.m @@ -0,0 +1,33 @@ +// 14 august 2015 +#import "uipriv_darwin.h" + +// TODO sizing +// namely, figure out how horizontal and vertical work + +struct uiSeparator { + uiDarwinControl c; + NSBox *box; +}; + +uiDarwinDefineControl( + uiSeparator, // type name + uiSeparatorType, // type function + box // handle +) + +uiSeparator *uiNewHorizontalSeparator(void) +{ + uiSeparator *s; + + s = (uiSeparator *) uiNewControl(uiSeparatorType()); + + s->box = [[NSBox alloc] initWithFrame:NSZeroRect]; + [s->box setBoxType:NSBoxSeparator]; +//TODO [s->box setBorderType:TODO]; + [s->box setTransparent:NO]; + [s->box setTitlePosition:NSNoTitle]; + + uiDarwinFinishNewControl(s, uiSeparator); + + return s; +} diff --git a/redo/reredo/darwin/slider.m b/redo/reredo/darwin/slider.m new file mode 100644 index 00000000..b31ff724 --- /dev/null +++ b/redo/reredo/darwin/slider.m @@ -0,0 +1,63 @@ +// 14 august 2015 +#import "uipriv_darwin.h" + +// TODO events + +type uiSlider { + uiDarwinControl c; + NSSlider *slider; + void (*onChanged)(uiSlider *, void *); + void *onChangedData; +}; + +uiDarwinDefineControl( + uiSlider, // type name + uiSliderType, // type function + slider // handle +) + +intmax_t uiSliderValue(uiSlider *s) +{ + return PUT_CODE_HERE; +} + +void uiSliderSetValue(uiSlider *s, intmax_t value) +{ + // TODO +} + +void uiSliderOnChanged(uiSlider *s, void (*f)(uiSlider *, void *), void *data) +{ + s->onChanged = f; + s->onChangedData = data; +} + +static void defaultOnChanged(uiSlider *s, void *data) +{ + // do nothing +} + +uiSlider *uiNewSlider(intmax_t min, intmax_t max) +{ + uiSlider *s; + NSSliderCell *cell; + + s = (uiSlider *) uiNewControl(uiSliderType()); + + s->slider = [[NSSlider alloc] initWithFrame:NSZeroRect]; + // TODO vertical is defined by wider than tall + [s->slider setMinValue:min]; + [s->slider setMaxValue:max]; + [s->slider setAllowsTickMarkValuesOnly:NO]; + [s->slider setNumberOfTickMarks:0]; + [s->slider setTickMarkPosition:NSTickMarkAbove]; + + cell = (NSSliderCell *) [s->slider cell]; + [cell setSliderType:NSLinearSlider]; + + uiSliderOnChanged(s, defaultOnChanged, NULL); + + uiDarwinFinishNewControl(s, uiSlider); + + return s; +} diff --git a/redo/reredo/darwin/spinbox.m b/redo/reredo/darwin/spinbox.m new file mode 100644 index 00000000..b6555766 --- /dev/null +++ b/redo/reredo/darwin/spinbox.m @@ -0,0 +1,52 @@ +// 14 august 2015 +#import "uipriv_darwin.h" + +struct uiSpinbox { + uiDarwinControl c; + NSTextField *dummy; + void (*onChanged)(uiSpinbox *, void *); + void *onChangedData; +}; + +uiDarwinDefineControl( + uiSpinbox, // type name + uiSpinboxType, // type function + dummy // handle +) + +intmax_t uiSpinboxValue(uiSpinbox *s) +{ + return PUT_CODE_HERE; +} + +void uiSpinboxSetValue(uiSpinbox *s, intmax_t value) +{ + // TODO +} + +void uiSpinboxOnChanged(uiSpinbox *s, void (*f)(uiSpinbox *, void *), void *data) +{ + s->onChanged = f; + s->onChangedData = data; +} + +static void defaultOnChanged(uiSpinbox *s, void *data) +{ + // do nothing +} + +uiSpinbox *uiNewSpinbox(void) +{ + uiSpinbox *s; + + s = (uiSpinbox *) uiNewControl(uiSpinboxType()); + + s->dummy = [[NSTextField alloc] initWithFrame:NSZeroRect]; + [s->dummy setStringValue:@"TODO uiSpinbox not implemented"]; + + uiSpinboxSetOnChanged(s, defaultOnChanged, NULL); + + uiDarwinFinishNewControl(s, uiSpinbox); + + return s; +}