Added uiControlHandle() implementations to the various controls.

This commit is contained in:
Pietro Gagliardi 2015-05-29 19:48:27 -04:00
parent 6dba84b99b
commit af4c9ae0c9
12 changed files with 99 additions and 0 deletions

View File

@ -30,6 +30,13 @@ static void buttonCommitDestroy(uiControl *c)
(*(b->baseCommitDestroy))(uiControl(b));
}
static uintptr_t buttonHandle(uiControl *c)
{
struct button *b = (struct button *) c;
return (uintptr_t) (b->hwnd);
}
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
#define buttonHeight 14
@ -96,6 +103,7 @@ uiButton *uiNewButton(const char *text)
b->onClicked = defaultOnClicked;
uiControl(b)->Handle = buttonHandle;
uiControl(b)->PreferredSize = buttonPreferredSize;
b->baseCommitDestroy = uiControl(b)->CommitDestroy;
uiControl(b)->CommitDestroy = buttonCommitDestroy;

View File

@ -38,6 +38,13 @@ static void checkboxCommitDestroy(uiControl *cc)
(*(c->baseCommitDestroy))(uiControl(c));
}
static uintptr_t checkboxHandle(uiControl *cc)
{
struct checkbox *c = (struct checkbox *) cc;
return (uintptr_t) (c->hwnd);
}
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
#define checkboxHeight 10
// from http://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx
@ -112,6 +119,7 @@ uiCheckbox *uiNewCheckbox(const char *text)
c->onToggled = defaultOnToggled;
uiControl(c)->Handle = checkboxHandle;
uiControl(c)->PreferredSize = checkboxPreferredSize;
c->baseCommitDestroy = uiControl(c)->CommitDestroy;
uiControl(c)->CommitDestroy = checkboxCommitDestroy;

View File

@ -10,6 +10,13 @@ struct combobox {
uiDefineControlType(uiCombobox, uiTypeCombobox, struct combobox)
static uintptr_t comboboxHandle(uiControl *cc)
{
struct combobox *c = (struct combobox *) cc;
return (uintptr_t) (c->hwnd);
}
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
#define comboboxWidth 107 /* this is actually the shorter progress bar width, but Microsoft only indicates as wide as necessary */
#define comboboxHeight 14
@ -49,6 +56,7 @@ static uiCombobox *finishNewCombobox(DWORD style)
hInstance, NULL,
TRUE);
uiControl(c)->Handle = comboboxHandle;
uiControl(c)->PreferredSize = comboboxPreferredSize;
uiCombobox(c)->Append = comboboxAppend;

View File

@ -10,6 +10,13 @@ struct datetimepicker {
uiDefineControlType(uiDateTimePicker, uiTypeDateTimePicker, struct datetimepicker)
static uintptr_t datetimepickerHandle(uiControl *c)
{
struct datetimepicker *d = (struct datetimepicker *) c;
return (uintptr_t) (d->hwnd);
}
// TODO
// TODO use DTM_GETIDEALSIZE when making Vista-only
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
@ -39,6 +46,7 @@ uiDateTimePicker *finishNewDateTimePicker(DWORD style, WCHAR *format)
if (SendMessageW(d->hwnd, DTM_SETFORMAT, 0, (LPARAM) format) == 0)
logLastError("error applying format string to date/time picker in finishNewDateTimePicker()");
uiControl(d)->Handle = datetimepickerHandle;
uiControl(d)->PreferredSize = datetimepickerPreferredSize;
return uiDateTimePicker(d);

View File

@ -33,6 +33,13 @@ static void entryCommitDestroy(uiControl *c)
(*(e->baseCommitDestroy))(uiControl(e));
}
static uintptr_t entryHandle(uiControl *c)
{
struct entry *e = (struct entry *) c;
return (uintptr_t) (e->hwnd);
}
// 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
@ -106,6 +113,7 @@ uiEntry *uiNewEntry(void)
e->onChanged = defaultOnChanged;
uiControl(e)->Handle = entryHandle;
uiControl(e)->PreferredSize = entryPreferredSize;
e->baseCommitDestroy = uiControl(e)->CommitDestroy;
uiControl(e)->CommitDestroy = entryCommitDestroy;

View File

@ -8,6 +8,13 @@ struct group {
uiDefineControlType(uiGroup, uiTypeGroup, struct group)
static uintptr_t groupHandle(uiControl *c)
{
struct group *g = (struct group *) c;
return (uintptr_t) (g->hwnd);
}
static void groupPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
{
// TODO
@ -35,6 +42,7 @@ uiGroup *uiNewGroup(const char *text)
TRUE);
uiFree(wtext);
uiControl(g)->Handle = groupHandle;
uiControl(g)->PreferredSize = groupPreferredSize;
uiGroup(g)->SetChild = groupSetChild;

View File

@ -8,6 +8,13 @@ struct label {
uiDefineControlType(uiLabel, uiTypeLabel, struct label)
static uintptr_t labelHandle(uiControl *c)
{
struct label *l = (struct label *) c;
return (uintptr_t) (l->hwnd);
}
// via http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
#define labelHeight 8
@ -46,6 +53,7 @@ uiLabel *uiNewLabel(const char *text)
TRUE);
uiFree(wtext);
uiControl(l)->Handle = labelHandle;
uiControl(l)->PreferredSize = labelPreferredSize;
uiLabel(l)->Text = labelText;

View File

@ -8,6 +8,13 @@ struct progressbar {
uiDefineControlType(uiProgressBar, uiTypeProgressBar, struct progressbar)
static uintptr_t progressbarHandle(uiControl *c)
{
struct progressbar *p = (struct progressbar *) c;
return (uintptr_t) (p->hwnd);
}
// via http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
#define pbarWidth 237
#define pbarHeight 8
@ -40,6 +47,7 @@ uiProgressBar *uiNewProgressBar(void)
hInstance, NULL,
FALSE);
uiControl(p)->Handle = progressbarHandle;
uiControl(p)->PreferredSize = progressbarPreferredSize;
uiProgressBar(p)->SetValue = progressbarSetValue;

View File

@ -16,6 +16,13 @@ uiDefineControlType(uiSeparator, uiTypeSeparator, struct separator)
// TODO
// TODO DPI independence?
static uintptr_t separatorHandle(uiControl *c)
{
struct separator *s = (struct separator *) c;
return s->hwnd;
}
static void separatorPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
{
*width = 1; // TODO
@ -34,6 +41,7 @@ uiSeparator *uiNewHorizontalSeparator(void)
hInstance, NULL,
TRUE);
uiControl(s)->Handle = separatorHandle;
uiControl(s)->PreferredSize = separatorPreferredSize;
return uiSeparator(s);

View File

@ -33,6 +33,13 @@ static void sliderCommitDestroy(uiControl *c)
(*(s->baseCommitDestroy))(uiControl(s));
}
static uintptr_t sliderHandle(uiControl *c)
{
struct slider *s = (struct slider *) c;
return (uintptr_t) (s->hwnd);
}
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
#define sliderWidth 107 /* this is actually the shorter progress bar width, but Microsoft doesn't indicate a width */
#define sliderHeight 15
@ -93,6 +100,7 @@ uiSlider *uiNewSlider(intmax_t min, intmax_t max)
s->onChanged = defaultOnChanged;
uiControl(s)->Handle = sliderHandle;
uiControl(s)->PreferredSize = sliderPreferredSize;
s->baseCommitDestroy = uiControl(s)->CommitDestroy;
uiControl(s)->CommitDestroy = sliderCommitDestroy;

View File

@ -59,6 +59,15 @@ static void spinboxCommitDestroy(uiControl *c)
(*(s->baseCommitDestroy))(uiControl(s));
}
// the edit control is the one to return here
// we can't return the updown because it gets recreated on resize
static uintptr_t spinboxHandle(uiControl *c)
{
struct spinbox *s = (struct spinbox *) c;
return (uintptr_t) (s->hwnd);
}
// 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
@ -157,6 +166,7 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max)
s->hwnd = uiWindowsNewSingleHWNDControl(WS_EX_CLIENTEDGE,
L"edit", L"",
// TODO ES_NUMBER doesn't allow typing in a leading -
ES_AUTOHSCROLL | ES_LEFT | ES_NOHIDESEL | ES_NUMBER | WS_TABSTOP,
hInstance, NULL,
TRUE);
@ -171,6 +181,7 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max)
s->onChanged = defaultOnChanged;
uiControl(s)->Handle = spinboxHandle;
uiControl(s)->PreferredSize = spinboxPreferredSize;
s->baseResize = uiControl(s)->Resize;
uiControl(s)->Resize = spinboxResize;

View File

@ -66,6 +66,13 @@ static void tabCommitDestroy(uiControl *c)
(*(t->baseCommitDestroy))(uiControl(t));
}
static uintptr_t tabHandle(uiControl *c)
{
struct tab *t = (struct tab *) c;
return (uintptr_t) (t->hwnd);
}
// from http://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx
#define tabMargin 7
@ -217,6 +224,7 @@ uiTab *uiNewTab(void)
t->pages = newPtrArray();
uiControl(t)->Handle = tabHandle;
uiControl(t)->PreferredSize = tabPreferredSize;
t->baseResize = uiControl(t)->Resize;
uiControl(t)->Resize = tabResize;