diff --git a/redo/windows/checkbox.c b/redo/windows/checkbox.c index 1009c914..9d4f7b80 100644 --- a/redo/windows/checkbox.c +++ b/redo/windows/checkbox.c @@ -22,7 +22,7 @@ static BOOL onWM_COMMAND(uiControl *cc, HWND hwnd, WORD code, LRESULT *lResult) if (code != BN_CLICKED) return FALSE; - // we didn't use BS_AUTOCHECKBOX (TODO get link) so we have to manage the check state ourselves + // we didn't use BS_AUTOCHECKBOX (http://blogs.msdn.com/b/oldnewthing/archive/2014/05/22/10527522.aspx) so we have to manage the check state ourselves check = BST_CHECKED; if (SendMessage(c->hwnd, BM_GETCHECK, 0, 0) == BST_CHECKED) check = BST_UNCHECKED; diff --git a/redo/windows/group.c b/redo/windows/group.c index 4299c95b..d80f5a3e 100644 --- a/redo/windows/group.c +++ b/redo/windows/group.c @@ -117,6 +117,21 @@ void uiGroupSetMargined(uiGroup *g, int margined) uiWindowsControlQueueRelayout(uiWindowsControl(g)); } +static LRESULT CALLBACK groupSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) +{ + LRESULT lResult; + + if (handleParentMessages(hwnd, uMsg, wParam, lParam, &lResult) != FALSE) + return lResult; + switch (uMsg) { + case WM_NCDESTROY: + if (RemoveWindowSubclass(hwnd, groupSubProc, uIdSubclass) == FALSE) + logLastError("error removing groupbox subclass in groupSubProc()"); + break; + } + return DefSubclassProc(hwnd, uMsg, wParam, lParam); +} + uiGroup *uiNewGroup(const char *text) { uiGroup *g; @@ -132,7 +147,8 @@ uiGroup *uiNewGroup(const char *text) TRUE); uiFree(wtext); - // TODO subclass uiGroup to call parent.c functions + if (SetWindowSubclass(g->hwnd, groupSubProc, 0, (DWORD_PTR) g) == FALSE) + logLastError("error subclassing groupbox to handle parent messages in uiNewGroup()"); uiWindowsFinishNewControl(g, uiGroup); uiControl(g)->ContainerUpdateState = groupContainerUpdateState; diff --git a/redo/windows/radiobuttons.c b/redo/windows/radiobuttons.c index 2f3a2a8d..546d408d 100644 --- a/redo/windows/radiobuttons.c +++ b/redo/windows/radiobuttons.c @@ -78,31 +78,34 @@ static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width static void radiobuttonsRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height) { -/* TODO - struct radiobuttons *r = (struct radiobuttons *) c; + uiRadioButtons *r = uiRadioButtons(c); + uiWindowsSizing *d; intmax_t height1; intmax_t h; uintmax_t i; HWND hwnd; - // TODO resize the main hwnd + uiWindowsEnsureMoveWindow(r->hwnd, x, y, width, height); - height1 = uiWindowsDlgUnitsToY(radiobuttonHeight, d->Sys->BaseY); + x = 0; + y = 0; + d = uiWindowsNewSizing(r->hwnd); + height1 = uiWindowsDlgUnitsToY(radiobuttonHeight, d->BaseY); + uiWindowsFreeSizing(d); for (i = 0; i < r->hwnds->len; i++) { hwnd = ptrArrayIndex(r->hwnds, HWND, i); h = height1; if (h > height) // clip to height h = height; - moveWindow(hwnd, x, y, width, h, d); + uiWindowsEnsureMoveWindow(hwnd, x, y, width, h); y += height1; height -= height1; if (height <= 0) // clip to height break; } -*/ } -// TODO container update state +// TODO commit enable/disable /* TODO static uintptr_t radiobuttonsStartZOrder(uiControl *c) @@ -137,10 +140,9 @@ static int radiobuttonsHasTabStops(uiControl *c) void uiRadioButtonsAppend(uiRadioButtons *r, const char *text) { -/* TODO HWND hwnd; WCHAR *wtext; - HWND after; +//TODO HWND after; wtext = toUTF16(text); hwnd = uiWindowsEnsureCreateControlHWND(0, @@ -149,9 +151,10 @@ void uiRadioButtonsAppend(uiRadioButtons *r, const char *text) hInstance, NULL, TRUE); uiFree(wtext); - uiWindowsUtilSetParent(hwnd, r->parent); + uiWindowsEnsureSetParent(hwnd, r->hwnd); uiWindowsRegisterWM_COMMANDHandler(hwnd, onWM_COMMAND, uiControl(r)); +/* TODO // maintain z-order if (r->hwnds->len == 0) // first item uiWindowsUtilSetZOrder(hwnd, r->insertAfter); @@ -159,10 +162,10 @@ void uiRadioButtonsAppend(uiRadioButtons *r, const char *text) after = ptrArrayIndex(r->hwnds, HWND, r->hwnds->len - 1); uiWindowsUtilSetZOrder(hwnd, (uintptr_t) after); } +*/ ptrArrayAppend(r->hwnds, hwnd); - uiControlQueueResize(uiControl(r)); -*/ + uiWindowsControlQueueRelayout(uiWindowsControl(r)); } uiRadioButtons *uiNewRadioButtons(void)