More new Darwin controls.

This commit is contained in:
Pietro Gagliardi 2015-08-14 23:50:38 -04:00
parent 60856a59b7
commit a931957f4e
5 changed files with 218 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}