uiDateTimePicker Keep libui constructors at the end of the file

This commit is contained in:
cody271 2018-02-22 19:20:16 -08:00
parent cf671c1da5
commit 0baf2d2eb6
3 changed files with 74 additions and 74 deletions

View File

@ -80,6 +80,36 @@ static void defaultOnChanged(uiDateTimePicker *d, void *data)
// do nothing
}
void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time)
{
time_t t;
struct tm tmbuf;
NSDate *date;
date = [d->dp dateValue];
t = (time_t) [date timeIntervalSince1970];
tmbuf = *localtime(&t);
memcpy(time, &tmbuf, sizeof(struct tm));
}
void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time)
{
time_t t;
struct tm tmbuf;
memcpy(&tmbuf, time, sizeof(struct tm));
t = mktime(&tmbuf);
[d->dp setDateValue:[NSDate dateWithTimeIntervalSince1970:t]];
}
void uiDateTimePickerOnChanged(uiDateTimePicker *d, void (*f)(uiDateTimePicker *, void *), void *data)
{
d->onChanged = f;
d->onChangedData = data;
}
static uiDateTimePicker *finishNewDateTimePicker(NSDatePickerElementFlags elements)
{
uiDateTimePicker *d;
@ -120,33 +150,3 @@ uiDateTimePicker *uiNewTimePicker(void)
{
return finishNewDateTimePicker(NSHourMinuteSecondDatePickerElementFlag);
}
void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time)
{
time_t t;
struct tm tmbuf;
NSDate *date;
date = [d->dp dateValue];
t = (time_t) [date timeIntervalSince1970];
tmbuf = *localtime(&t);
memcpy(time, &tmbuf, sizeof(struct tm));
}
void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time)
{
time_t t;
struct tm tmbuf;
memcpy(&tmbuf, time, sizeof(struct tm));
t = mktime(&tmbuf);
[d->dp setDateValue:[NSDate dateWithTimeIntervalSince1970:t]];
}
void uiDateTimePickerOnChanged(uiDateTimePicker *d, void (*f)(uiDateTimePicker *, void *), void *data)
{
d->onChanged = f;
d->onChangedData = data;
}

View File

@ -560,6 +560,38 @@ static void defaultOnChanged(uiDateTimePicker *d, void *data)
// do nothing
}
void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time)
{
time_t t;
struct tm tmbuf;
GDateTime *dt;
dt = selected(d->d);
t = g_date_time_to_unix(dt);
g_date_time_unref(dt);
tmbuf = *localtime(&t);
memcpy(time, &tmbuf, sizeof(struct tm));
}
void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time)
{
time_t t;
struct tm tmbuf;
memcpy(&tmbuf, time, sizeof(struct tm));
t = mktime(&tmbuf);
dateTimePickerWidget_setTime(d->d, g_date_time_new_from_unix_local(t));
dateTimeChanged(d->d);
}
void uiDateTimePickerOnChanged(uiDateTimePicker *d, void (*f)(uiDateTimePicker *, void *), void *data)
{
d->onChanged = f;
d->onChangedData = data;
}
static GtkWidget *newDTP(void)
{
GtkWidget *w;
@ -617,35 +649,3 @@ uiDateTimePicker *uiNewTimePicker(void)
{
return finishNewDateTimePicker(newTP);
}
void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time)
{
time_t t;
struct tm tmbuf;
GDateTime *dt;
dt = selected(d->d);
t = g_date_time_to_unix(dt);
g_date_time_unref(dt);
tmbuf = *localtime(&t);
memcpy(time, &tmbuf, sizeof(struct tm));
}
void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time)
{
time_t t;
struct tm tmbuf;
memcpy(&tmbuf, time, sizeof(struct tm));
t = mktime(&tmbuf);
dateTimePickerWidget_setTime(d->d, g_date_time_new_from_unix_local(t));
dateTimeChanged(d->d);
}
void uiDateTimePickerOnChanged(uiDateTimePicker *d, void (*f)(uiDateTimePicker *, void *), void *data)
{
d->onChanged = f;
d->onChangedData = data;
}

View File

@ -168,6 +168,18 @@ static LRESULT CALLBACK datetimepickerSubProc(HWND hwnd, UINT uMsg, WPARAM wPara
return DefSubclassProc(hwnd, uMsg, wParam, lParam);
}
void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time)
{
}
void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time)
{
}
void uiDateTimePickerOnChanged(uiDateTimePicker *d, void (*f)(uiDateTimePicker *, void *), void *data)
{
}
uiDateTimePicker *uiNewDateTimePicker(void)
{
uiDateTimePicker *d;
@ -189,15 +201,3 @@ uiDateTimePicker *uiNewTimePicker(void)
{
return finishNewDateTimePicker(DTS_TIMEFORMAT);
}
void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time)
{
}
void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time)
{
}
void uiDateTimePickerOnChanged(uiDateTimePicker *d, void (*f)(uiDateTimePicker *, void *), void *data)
{
}