From af4c9ae0c98de8554afc72590036592775e448b6 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 29 May 2015 19:48:27 -0400 Subject: [PATCH] Added uiControlHandle() implementations to the various controls. --- redo/windows/button.c | 8 ++++++++ redo/windows/checkbox.c | 8 ++++++++ redo/windows/combobox.c | 8 ++++++++ redo/windows/datetimepicker.c | 8 ++++++++ redo/windows/entry.c | 8 ++++++++ redo/windows/group.c | 8 ++++++++ redo/windows/label.c | 8 ++++++++ redo/windows/progressbar.c | 8 ++++++++ redo/windows/separator.c | 8 ++++++++ redo/windows/slider.c | 8 ++++++++ redo/windows/spinbox.c | 11 +++++++++++ redo/windows/tab.c | 8 ++++++++ 12 files changed, 99 insertions(+) diff --git a/redo/windows/button.c b/redo/windows/button.c index 919bdd12..40156f03 100644 --- a/redo/windows/button.c +++ b/redo/windows/button.c @@ -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; diff --git a/redo/windows/checkbox.c b/redo/windows/checkbox.c index 47ac7b1f..8395ec25 100644 --- a/redo/windows/checkbox.c +++ b/redo/windows/checkbox.c @@ -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; diff --git a/redo/windows/combobox.c b/redo/windows/combobox.c index efc5824f..bfe7bfac 100644 --- a/redo/windows/combobox.c +++ b/redo/windows/combobox.c @@ -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; diff --git a/redo/windows/datetimepicker.c b/redo/windows/datetimepicker.c index 2c649be6..4b028600 100644 --- a/redo/windows/datetimepicker.c +++ b/redo/windows/datetimepicker.c @@ -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); diff --git a/redo/windows/entry.c b/redo/windows/entry.c index 9b66ffd0..fdbd7aa9 100644 --- a/redo/windows/entry.c +++ b/redo/windows/entry.c @@ -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; diff --git a/redo/windows/group.c b/redo/windows/group.c index e2fdd458..c853cf86 100644 --- a/redo/windows/group.c +++ b/redo/windows/group.c @@ -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; diff --git a/redo/windows/label.c b/redo/windows/label.c index a1b97840..6abd4d59 100644 --- a/redo/windows/label.c +++ b/redo/windows/label.c @@ -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; diff --git a/redo/windows/progressbar.c b/redo/windows/progressbar.c index 4f4bc668..f2f78c12 100644 --- a/redo/windows/progressbar.c +++ b/redo/windows/progressbar.c @@ -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; diff --git a/redo/windows/separator.c b/redo/windows/separator.c index 2029ceb4..5363387d 100644 --- a/redo/windows/separator.c +++ b/redo/windows/separator.c @@ -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); diff --git a/redo/windows/slider.c b/redo/windows/slider.c index d1678722..cf8e1ff8 100644 --- a/redo/windows/slider.c +++ b/redo/windows/slider.c @@ -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; diff --git a/redo/windows/spinbox.c b/redo/windows/spinbox.c index 3ad4902f..5a564507 100644 --- a/redo/windows/spinbox.c +++ b/redo/windows/spinbox.c @@ -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; diff --git a/redo/windows/tab.c b/redo/windows/tab.c index b648a7bd..87ee1f6f 100644 --- a/redo/windows/tab.c +++ b/redo/windows/tab.c @@ -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;