Added a basic date/time picker.
This commit is contained in:
parent
677048222e
commit
d5e956e254
|
@ -97,5 +97,11 @@ uiBox *makePage4(void)
|
||||||
uiRadioButtonsAppend(rb, "Item 3");
|
uiRadioButtonsAppend(rb, "Item 3");
|
||||||
uiBoxAppend(page4, uiControl(rb), 0);
|
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;
|
return page4;
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,6 +181,12 @@ interface RadioButtons from Control {
|
||||||
};
|
};
|
||||||
func NewRadioButtons(void) *RadioButtons;
|
func NewRadioButtons(void) *RadioButtons;
|
||||||
|
|
||||||
|
interface DateTimePicker from Control {
|
||||||
|
};
|
||||||
|
func NewDateTimePicker(void) *DateTimePicker;
|
||||||
|
func NewDatePicker(void) *DateTimePicker;
|
||||||
|
func NewTimePicker(void) *DateTimePicker;
|
||||||
|
|
||||||
interface Menu {
|
interface Menu {
|
||||||
func AppendItem(name *const char) *MenuItem;
|
func AppendItem(name *const char) *MenuItem;
|
||||||
func AppendCheckItem(name *const char) *MenuItem;
|
func AppendCheckItem(name *const char) *MenuItem;
|
||||||
|
|
|
@ -7,6 +7,7 @@ osCFILES = \
|
||||||
windows/combobox.c \
|
windows/combobox.c \
|
||||||
windows/container.c \
|
windows/container.c \
|
||||||
windows/control.c \
|
windows/control.c \
|
||||||
|
windows/datetimepicker.c \
|
||||||
windows/debug.c \
|
windows/debug.c \
|
||||||
windows/entry.c \
|
windows/entry.c \
|
||||||
windows/events.c \
|
windows/events.c \
|
||||||
|
|
|
@ -48,6 +48,7 @@ static uiCombobox *finishNewCombobox(DWORD style)
|
||||||
c = uiNew(struct combobox);
|
c = uiNew(struct combobox);
|
||||||
uiTyped(c)->Type = uiTypeCombobox();
|
uiTyped(c)->Type = uiTypeCombobox();
|
||||||
|
|
||||||
|
// TODO client edge?
|
||||||
p.dwExStyle = WS_EX_CLIENTEDGE;
|
p.dwExStyle = WS_EX_CLIENTEDGE;
|
||||||
p.lpClassName = L"combobox";
|
p.lpClassName = L"combobox";
|
||||||
p.lpWindowName = L"";
|
p.lpWindowName = L"";
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -79,6 +79,7 @@ uiInitOptions options;
|
||||||
ICC_LISTVIEW_CLASSES | /* table headers */ \
|
ICC_LISTVIEW_CLASSES | /* table headers */ \
|
||||||
ICC_UPDOWN_CLASS | /* spinboxes */ \
|
ICC_UPDOWN_CLASS | /* spinboxes */ \
|
||||||
ICC_BAR_CLASSES | /* trackbar */ \
|
ICC_BAR_CLASSES | /* trackbar */ \
|
||||||
|
ICC_DATE_CLASSES | /* date/time picker */ \
|
||||||
0)
|
0)
|
||||||
|
|
||||||
const char *uiInit(uiInitOptions *o)
|
const char *uiInit(uiInitOptions *o)
|
||||||
|
|
Loading…
Reference in New Issue