libui/redo/darwin/datetimepicker.m

51 lines
1.3 KiB
Mathematica
Raw Normal View History

// 11 june 2015
2015-07-11 16:02:01 -05:00
#include "uipriv_darwin.h"
struct datetimepicker {
uiDateTimePicker d;
2015-07-28 10:47:05 -05:00
NSDatePicker *dp;
};
uiDefineControlType(uiDateTimePicker, uiTypeDateTimePicker, struct datetimepicker)
static uintptr_t datetimepickerHandle(uiControl *c)
{
struct datetimepicker *d = (struct datetimepicker *) c;
2015-07-28 10:47:05 -05:00
return (uintptr_t) (d->dp);
}
2015-07-28 10:47:05 -05:00
uiDateTimePicker *finishNewDateTimePicker(NSDatePickerElementFlags elements)
{
struct datetimepicker *d;
2015-07-28 10:47:05 -05:00
d = (struct datetimepicker *) uiNewControl(uiTypeDateTimePicker());
2015-07-28 10:47:05 -05:00
d->dp = [[NSDatePicker alloc] initWithFrame:NSZeroRect];
// TODO text field stuff
[d->dp setDatePickerStyle:NSTextFieldAndStepperDatePickerStyle];
[d->dp setDatePickerElements:elements];
[d->dp setDatePickerMode:NSSingleDateMode];
// TODO get date picker font
2015-07-29 12:43:54 -05:00
uiDarwinMakeSingleViewControl(uiControl(d), d->dp, YES);
uiControl(d)->Handle = datetimepickerHandle;
return uiDateTimePicker(d);
}
uiDateTimePicker *uiNewDateTimePicker(void)
{
2015-07-28 10:47:05 -05:00
return finishNewDateTimePicker(NSYearMonthDayDatePickerElementFlag | NSHourMinuteSecondDatePickerElementFlag);
}
uiDateTimePicker *uiNewDatePicker(void)
{
2015-07-28 10:47:05 -05:00
return finishNewDateTimePicker(NSYearMonthDayDatePickerElementFlag);
}
uiDateTimePicker *uiNewTimePicker(void)
{
2015-07-28 10:47:05 -05:00
return finishNewDateTimePicker(NSHourMinuteSecondDatePickerElementFlag);
}