From be747af77c659dfc755645db3100f0a1395832bc Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 3 Jun 2015 15:58:47 -0400 Subject: [PATCH] Settled Z-ordering for spinboxes. --- redo/windows/spinbox.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/redo/windows/spinbox.c b/redo/windows/spinbox.c index c6165f18..a41933ab 100644 --- a/redo/windows/spinbox.c +++ b/redo/windows/spinbox.c @@ -103,7 +103,6 @@ static void recreateUpDown(struct spinbox *s) UPDOWN_CLASSW, L"", // no WS_VISIBLE; we set visibility ourselves // TODO tab stop? - // TODO maintain Z-order WS_CHILD | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_HOTTRACK | UDS_NOTHOUSANDS | UDS_SETBUDDYINT, // this is important; it's necessary for autosizing to work 0, 0, 0, 0, @@ -115,6 +114,8 @@ static void recreateUpDown(struct spinbox *s) SendMessageW(s->updown, UDM_SETRANGE32, (WPARAM) min, (LPARAM) max); SendMessageW(s->updown, UDM_SETPOS32, 0, (LPARAM) current); } + // preserve the z-order + uiWindowsUtilSetZOrder(s->updown, (uintptr_t) (s->hwnd)); if (uiControlContainerVisible(uiControl(s))) uiWindowsUtilShow(s->updown); s->inhibitChanged = FALSE; @@ -140,6 +141,18 @@ COMMIT(Hide, uiWindowsUtilHide) COMMIT(Enable, uiWindowsUtilEnable) COMMIT(Disable, uiWindowsUtilDisable) +// StartZOrder() is fine (the edit is the first control, and that's satisfied by the singleHWND interface) +// SetZOrder() is not +// TODO don't even bother with singleHWND at all +static uintptr_t spinboxSetZOrder(uiControl *c, uintptr_t insertAfter) +{ + struct spinbox *s = (struct spinbox *) c; + + uiWindowsUtilSetZOrder(s->hwnd, insertAfter); + uiWindowsUtilSetZOrder(s->updown, (uintptr_t) (s->hwnd)); + return (uintptr_t) (s->updown); +} + static void defaultOnChanged(uiSpinbox *s, void *data) { // do nothing @@ -202,6 +215,7 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) uiControl(s)->CommitHide = spinboxCommitHide; uiControl(s)->CommitEnable = spinboxCommitEnable; uiControl(s)->CommitDisable = spinboxCommitDisable; + uiControl(s)->SetZOrder = spinboxSetZOrder; uiSpinbox(s)->Value = spinboxValue; uiSpinbox(s)->SetValue = spinboxSetValue;