Added a basic date/time picker.

This commit is contained in:
Pietro Gagliardi 2015-05-22 10:36:24 -04:00
parent 677048222e
commit d5e956e254
6 changed files with 83 additions and 0 deletions

View File

@ -97,5 +97,11 @@ uiBox *makePage4(void)
uiRadioButtonsAppend(rb, "Item 3");
uiBoxAppend(page4, uiControl(rb), 0);
uiBoxAppend(page4, uiControl(uiNewHorizontalSeparator()), 0);
uiBoxAppend(page4, uiControl(uiNewDateTimePicker()), 0);
uiBoxAppend(page4, uiControl(uiNewDatePicker()), 0);
uiBoxAppend(page4, uiControl(uiNewTimePicker()), 0);
return page4;
}

View File

@ -181,6 +181,12 @@ interface RadioButtons from Control {
};
func NewRadioButtons(void) *RadioButtons;
interface DateTimePicker from Control {
};
func NewDateTimePicker(void) *DateTimePicker;
func NewDatePicker(void) *DateTimePicker;
func NewTimePicker(void) *DateTimePicker;
interface Menu {
func AppendItem(name *const char) *MenuItem;
func AppendCheckItem(name *const char) *MenuItem;

View File

@ -7,6 +7,7 @@ osCFILES = \
windows/combobox.c \
windows/container.c \
windows/control.c \
windows/datetimepicker.c \
windows/debug.c \
windows/entry.c \
windows/events.c \

View File

@ -48,6 +48,7 @@ static uiCombobox *finishNewCombobox(DWORD style)
c = uiNew(struct combobox);
uiTyped(c)->Type = uiTypeCombobox();
// TODO client edge?
p.dwExStyle = WS_EX_CLIENTEDGE;
p.lpClassName = L"combobox";
p.lpWindowName = L"";

View File

@ -0,0 +1,68 @@
// 22 may 2015
#include "uipriv_windows.h"
struct datetimepicker {
uiDateTimePicker d;
HWND hwnd;
};
static void onDestroy(void *data)
{
struct datetimepicker *d = (struct datetimepicker *) data;
uiFree(d);
}
// TODO
// TODO use DTM_GETIDEALSIZE when making Vista-only
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
#define entryWidth 107 /* this is actually the shorter progress bar width, but Microsoft only indicates as wide as necessary */
#define entryHeight 14
static void datetimepickerPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
{
*width = uiWindowsDlgUnitsToX(entryWidth, d->Sys->BaseX);
*height = uiWindowsDlgUnitsToY(entryHeight, d->Sys->BaseY);
}
uiDateTimePicker *finishNewDateTimePicker(DWORD style)
{
struct datetimepicker *d;
uiWindowsMakeControlParams p;
d = uiNew(struct datetimepicker);
uiTyped(d)->Type = uiTypeDateTimePicker();
p.dwExStyle = 0; // TODO client edge?
p.lpClassName = DATETIMEPICK_CLASSW;
p.lpWindowName = L"";
p.dwStyle = style | WS_TABSTOP;
p.hInstance = hInstance;
p.lpParam = NULL;
p.useStandardControlFont = TRUE;
p.onDestroy = onDestroy;
p.onDestroyData = d;
uiWindowsMakeControl(uiControl(d), &p);
d->hwnd = (HWND) uiControlHandle(uiControl(d));
uiControl(d)->PreferredSize = datetimepickerPreferredSize;
return uiDateTimePicker(d);
}
// TODO
uiDateTimePicker *uiNewDateTimePicker(void)
{
return finishNewDateTimePicker(0);
}
uiDateTimePicker *uiNewDatePicker(void)
{
return finishNewDateTimePicker(DTS_SHORTDATECENTURYFORMAT);
}
uiDateTimePicker *uiNewTimePicker(void)
{
return finishNewDateTimePicker(DTS_TIMEFORMAT);
}

View File

@ -79,6 +79,7 @@ uiInitOptions options;
ICC_LISTVIEW_CLASSES | /* table headers */ \
ICC_UPDOWN_CLASS | /* spinboxes */ \
ICC_BAR_CLASSES | /* trackbar */ \
ICC_DATE_CLASSES | /* date/time picker */ \
0)
const char *uiInit(uiInitOptions *o)