2015-07-11 15:56:37 -05:00
|
|
|
// 11 june 2015
|
2015-07-11 16:02:01 -05:00
|
|
|
#include "uipriv_darwin.h"
|
2015-07-11 15:56:37 -05:00
|
|
|
|
|
|
|
struct datetimepicker {
|
|
|
|
uiDateTimePicker d;
|
2015-07-28 10:47:05 -05:00
|
|
|
NSDatePicker *dp;
|
2015-07-11 15:56:37 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
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-11 15:56:37 -05:00
|
|
|
}
|
|
|
|
|
2015-07-28 10:47:05 -05:00
|
|
|
uiDateTimePicker *finishNewDateTimePicker(NSDatePickerElementFlags elements)
|
2015-07-11 15:56:37 -05:00
|
|
|
{
|
|
|
|
struct datetimepicker *d;
|
|
|
|
|
2015-07-28 10:47:05 -05:00
|
|
|
d = (struct datetimepicker *) uiNewControl(uiTypeDateTimePicker());
|
2015-07-11 15:56:37 -05:00
|
|
|
|
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);
|
2015-07-11 15:56:37 -05:00
|
|
|
|
|
|
|
uiControl(d)->Handle = datetimepickerHandle;
|
|
|
|
|
|
|
|
return uiDateTimePicker(d);
|
|
|
|
}
|
|
|
|
|
|
|
|
uiDateTimePicker *uiNewDateTimePicker(void)
|
|
|
|
{
|
2015-07-28 10:47:05 -05:00
|
|
|
return finishNewDateTimePicker(NSYearMonthDayDatePickerElementFlag | NSHourMinuteSecondDatePickerElementFlag);
|
2015-07-11 15:56:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uiDateTimePicker *uiNewDatePicker(void)
|
|
|
|
{
|
2015-07-28 10:47:05 -05:00
|
|
|
return finishNewDateTimePicker(NSYearMonthDayDatePickerElementFlag);
|
2015-07-11 15:56:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uiDateTimePicker *uiNewTimePicker(void)
|
|
|
|
{
|
2015-07-28 10:47:05 -05:00
|
|
|
return finishNewDateTimePicker(NSHourMinuteSecondDatePickerElementFlag);
|
2015-07-11 15:56:37 -05:00
|
|
|
}
|