From 1a39797a14965a275e638e624debd5474f7bf8ae Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 31 Aug 2015 12:33:44 -0400 Subject: [PATCH] More Windows control work. --- redo/windows/OLDradiobuttons.c | 2 +- redo/windows/OLDspinbox.c | 2 +- redo/windows/combobox.c | 2 +- redo/windows/container.c | 2 +- redo/windows/datetimepicker.c | 2 +- redo/windows/entry.c | 2 +- redo/windows/group.c | 2 +- redo/windows/label.c | 2 +- redo/windows/progressbar.c | 2 +- redo/windows/radiobuttons.c | 12 ++++++++---- redo/windows/separator.c | 2 +- redo/windows/slider.c | 2 +- redo/windows/spinbox.c | 11 +++++++---- redo/windows/tab.c | 11 +++++++---- 14 files changed, 33 insertions(+), 23 deletions(-) diff --git a/redo/windows/OLDradiobuttons.c b/redo/windows/OLDradiobuttons.c index ce450b92..7ab9f8d9 100644 --- a/redo/windows/OLDradiobuttons.c +++ b/redo/windows/OLDradiobuttons.c @@ -173,7 +173,7 @@ static void radiobuttonsAppend(uiRadioButtons *rr, const char *text) HWND after; wtext = toUTF16(text); - hwnd = uiWindowsUtilCreateControlHWND(0, + hwnd = uiWindowsEnsureCreateControlHWND(0, L"button", wtext, BS_RADIOBUTTON | WS_TABSTOP, hInstance, NULL, diff --git a/redo/windows/OLDspinbox.c b/redo/windows/OLDspinbox.c index bd19eed3..ac730a91 100644 --- a/redo/windows/OLDspinbox.c +++ b/redo/windows/OLDspinbox.c @@ -223,7 +223,7 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) s = (struct spinbox *) uiNewControl(uiTypeSpinbox()); - s->hwnd = uiWindowsUtilCreateControlHWND(WS_EX_CLIENTEDGE, + s->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE, L"edit", L"", // don't use ES_NUMBER; it doesn't allow typing in a leading - ES_AUTOHSCROLL | ES_LEFT | ES_NOHIDESEL | WS_TABSTOP, diff --git a/redo/windows/combobox.c b/redo/windows/combobox.c index 9d82b858..33ae1c2b 100644 --- a/redo/windows/combobox.c +++ b/redo/windows/combobox.c @@ -43,7 +43,7 @@ static uiCombobox *finishNewCombobox(DWORD style) c = (uiCombobox *) uiNewControl(uiComboboxType()); - c->hwnd = uiWindowsUtilCreateControlHWND(WS_EX_CLIENTEDGE, + c->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE, L"combobox", L"", style | WS_TABSTOP, hInstance, NULL, diff --git a/redo/windows/container.c b/redo/windows/container.c index 2ee104a1..57e4765c 100644 --- a/redo/windows/container.c +++ b/redo/windows/container.c @@ -59,7 +59,7 @@ void uninitContainer(void) HWND makeContainer(void) { - return uiWindowsUtilCreateControlHWND(WS_EX_CONTROLPARENT, + return uiWindowsEnsureCreateControlHWND(WS_EX_CONTROLPARENT, containerClass, L"", 0, hInstance, NULL, diff --git a/redo/windows/datetimepicker.c b/redo/windows/datetimepicker.c index 9cf7d9b8..33e5c5c4 100644 --- a/redo/windows/datetimepicker.c +++ b/redo/windows/datetimepicker.c @@ -128,7 +128,7 @@ static uiDateTimePicker *finishNewDateTimePicker(DWORD style) d = (uiDateTimePicker *) uiNewControl(uiDateTimePickerType()); - d->hwnd = uiWindowsUtilCreateControlHWND(WS_EX_CLIENTEDGE, + d->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE, DATETIMEPICK_CLASSW, L"", style | WS_TABSTOP, hInstance, NULL, diff --git a/redo/windows/entry.c b/redo/windows/entry.c index 9ccebe41..7341c429 100644 --- a/redo/windows/entry.c +++ b/redo/windows/entry.c @@ -85,7 +85,7 @@ uiEntry *uiNewEntry(void) e = (uiEntry *) uiWindowsNewSingleHWNDControl(uiNewControl()); - e->hwnd = uiWindowsUtilCreateControlHWND(WS_EX_CLIENTEDGE, + e->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE, L"edit", L"", ES_AUTOHSCROLL | ES_LEFT | ES_NOHIDESEL | WS_TABSTOP, hInstance, NULL, diff --git a/redo/windows/group.c b/redo/windows/group.c index 592b67ac..a2930c8c 100644 --- a/redo/windows/group.c +++ b/redo/windows/group.c @@ -126,7 +126,7 @@ uiGroup *uiNewGroup(const char *text) g = (uiGroup *) uiNewControl(uiGroupType()); wtext = toUTF16(text); - g->hwnd = uiWindowsUtilCreateControlHWND(WS_EX_CONTROLPARENT, + g->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CONTROLPARENT, L"button", wtext, BS_GROUPBOX, hInstance, NULL, diff --git a/redo/windows/label.c b/redo/windows/label.c index 17e9c70a..5c435594 100644 --- a/redo/windows/label.c +++ b/redo/windows/label.c @@ -42,7 +42,7 @@ uiLabel *uiNewLabel(const char *text) l = (uiLabel *) uiNewControl(uiLabelType()); wtext = toUTF16(text); - l->hwnd = uiWindowsUtilCreateControlHWND(0, + l->hwnd = uiWindowsEnsureCreateControlHWND(0, L"static", wtext, // SS_LEFTNOWORDWRAP clips text past the end; SS_NOPREFIX avoids accelerator translation // controls are vertically aligned to the top by default (thanks Xeek in irc.freenode.net/#winapi) diff --git a/redo/windows/progressbar.c b/redo/windows/progressbar.c index 983e2030..4f28c778 100644 --- a/redo/windows/progressbar.c +++ b/redo/windows/progressbar.c @@ -46,7 +46,7 @@ uiProgressBar *uiNewProgressBar(void) p = (uiProgressBar *) uiNewControl(uiProgressBarType()); - p->hwnd = uiWindowsUtilCreateControlHWND(0, + p->hwnd = uiWindowsEnsureCreateControlHWND(0, PROGRESS_CLASSW, L"", PBS_SMOOTH, hInstance, NULL, diff --git a/redo/windows/radiobuttons.c b/redo/windows/radiobuttons.c index 52396862..3eace2e0 100644 --- a/redo/windows/radiobuttons.c +++ b/redo/windows/radiobuttons.c @@ -13,8 +13,11 @@ struct uiRadioButtons { static void onDestroy(uiRadioButtons *); -// TODO -uiDefineControlType(uiRadioButtons, uiTypeRadioButtons, struct radiobuttons) +uiWindowsDefineControlWithOnDestroy( + uiRadioButtons, // type name + uiRadioButtonsType, // type function + onDestroy(this); // on destroy +) // TODO arrow keys don't work for changing items @@ -140,7 +143,7 @@ void uiRadioButtonsAppend(uiRadioButtons *r, const char *text) HWND after; wtext = toUTF16(text); - hwnd = uiWindowsUtilCreateControlHWND(0, + hwnd = uiWindowsEnsureCreateControlHWND(0, L"button", wtext, BS_RADIOBUTTON | WS_TABSTOP, hInstance, NULL, @@ -172,7 +175,8 @@ uiRadioButtons *uiNewRadioButtons(void) r->hwnds = newPtrArray(); - // TODO + uiWindowsFinishNewControl(r, uiRadioButtons); uiControl(r)->Relayout = radiobuttonsRelayout; + return r; } diff --git a/redo/windows/separator.c b/redo/windows/separator.c index 771201f6..77087570 100644 --- a/redo/windows/separator.c +++ b/redo/windows/separator.c @@ -30,7 +30,7 @@ uiSeparator *uiNewHorizontalSeparator(void) s = (uiSeparator *) uiNewControl(uiSeparatorType()); - s->hwnd = uiWindowsUtilCreateControlHWND(0, + s->hwnd = uiWindowsEnsureCreateControlHWND(0, L"static", L"", SS_ETCHEDHORZ, hInstance, NULL, diff --git a/redo/windows/slider.c b/redo/windows/slider.c index 299bd9a1..5aded7c4 100644 --- a/redo/windows/slider.c +++ b/redo/windows/slider.c @@ -61,7 +61,7 @@ uiSlider *uiNewSlider(intmax_t min, intmax_t max) s = (uiSlider *) uiNewControl(uiSliderType()); - s->hwnd = uiWindowsUtilCreateControlHWND(0, + s->hwnd = uiWindowsEnsureCreateControlHWND(0, TRACKBAR_CLASSW, L"", TBS_HORZ | TBS_TOOLTIPS | TBS_TRANSPARENTBKGND | WS_TABSTOP, hInstance, NULL, diff --git a/redo/windows/spinbox.c b/redo/windows/spinbox.c index 10760ba1..923cc6da 100644 --- a/redo/windows/spinbox.c +++ b/redo/windows/spinbox.c @@ -12,8 +12,11 @@ struct uiSpinbox { static void onDestroy(uiSpinbox *); -// TODO -uiDefineControlType(uiSpinbox, uiTypeSpinbox, struct spinbox) +uiWindowsDefineControlWithOnDestroy( + uiSpinbox, // type name + uiSpinboxType, // type function + onDestroy(this); // on destroy +) // utility functions @@ -190,7 +193,7 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) s = (uiSpinbox *) uiNewControl(uiSpinboxType()); - s->hwnd = uiWindowsUtilCreateControlHWND(WS_EX_CLIENTEDGE, + s->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE, L"edit", L"", // don't use ES_NUMBER; it doesn't allow typing in a leading - ES_AUTOHSCROLL | ES_LEFT | ES_NOHIDESEL | WS_TABSTOP, @@ -206,7 +209,7 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) SendMessageW(s->updown, UDM_SETPOS32, 0, (LPARAM) min); s->inhibitChanged = FALSE; - // TODO + uiWindowsFinishNewControl(s, uiSpinbox); return s; } diff --git a/redo/windows/tab.c b/redo/windows/tab.c index 80cf69cc..8ae74e10 100644 --- a/redo/windows/tab.c +++ b/redo/windows/tab.c @@ -13,8 +13,11 @@ struct uiTab { static void onDestroy(uiTab *); -// TODO -uiDefineControlType(uiTab, uiTypeTab, struct tab) +uiWindowsDefineControlWithOnDestroy( + uiTab, // type name + uiTabType, // type function + onDestroy(this); // on destroy +) // utility functions @@ -223,7 +226,7 @@ uiTab *uiNewTab(void) t = (struct tab *) uiWindowsNewSingleHWNDControl(uiTypeTab()); - t->hwnd = uiWindowsUtilCreateControlHWND(0, // don't set WS_EX_CONTROLPARENT yet; we do that dynamically in the message loop (see below) + t->hwnd = uiWindowsEnsureCreateControlHWND(0, // don't set WS_EX_CONTROLPARENT yet; we do that dynamically in the message loop (see below) WC_TABCONTROLW, L"", // don't give WS_TABSTOP here; we only apply WS_TABSTOP if there are tabs TCS_TOOLTIPS, @@ -234,7 +237,7 @@ uiTab *uiNewTab(void) t->pages = newPtrArray(); - // TODO + uiWindowsFinishNewControl(t, uiTab); uiControl(t)->ContainerUpdateState = tabContainerUpdateState; uiWindowsControl(t)->Relayout = tabRelayout;