diff --git a/redo/windows/box.c b/redo/windows/box.c index 3d45414a..9809981e 100644 --- a/redo/windows/box.c +++ b/redo/windows/box.c @@ -231,37 +231,30 @@ static void boxContainerUpdateState(uiControl *c) } } +static void redoControlIDsZOrder(uiBox *b) +{ + struct child *bc; + LONG_PTR controlID; + HWND insertAfter; + uintmax_t i; + + controlID = 100; + insertAfter = NULL; + for (i = 0; i < b->controls->len; i++) { + bc = ptrArrayIndex(b->controls, struct child *, i); + childAssignControlIDZOrder(bc, &controlID, &insertAfter); + } +} + void uiBoxAppend(uiBox *b, uiControl *c, int stretchy) { struct child *bc; -/* TODO - uintptr_t zorder; - int dozorder; - uintmax_t i; - - // start the zorder with the *CURRENT* first child - // this is in case we're adding a new first child - dozorder = 0; - if (b->controls->len != 0) { - dozorder = 1; - bc = ptrArrayIndex(b->controls, struct child *, 0); - zorder = uiControlStartZOrder(bc->c); - } -*/ bc = newChild(c, uiControl(b), b->hwnd); ctrlSetStretchy(bc, stretchy); ptrArrayAppend(b->controls, bc); + redoControlIDsZOrder(b); uiWindowsControlQueueRelayout(uiWindowsControl(b)); - -/* TODO - // and now update the zorder for all controls - if (dozorder) - for (i = 0; i < b->controls->len; i++) { - bc = ptrArrayIndex(b->controls, struct child *, i); - zorder = uiControlSetZOrder(bc->c, zorder); - } -*/ } void uiBoxDelete(uiBox *b, uintmax_t index) @@ -271,6 +264,7 @@ void uiBoxDelete(uiBox *b, uintmax_t index) bc = ptrArrayIndex(b->controls, struct child *, index); ptrArrayDelete(b->controls, index); childRemove(bc); + redoControlIDsZOrder(b); uiWindowsControlQueueRelayout(uiWindowsControl(b)); } diff --git a/redo/windows/child.c b/redo/windows/child.c index 49ea1b76..ec2f5c28 100644 --- a/redo/windows/child.c +++ b/redo/windows/child.c @@ -123,6 +123,14 @@ void childUpdateState(struct child *c) controlUpdateState(c->c); } +void childAssignControlIDZOrder(struct child *c, LONG_PTR *controlID, HWND *insertAfter) +{ + uiWindowsControl *wc; + + wc = uiWindowsControl(c->c); + (*(wc->AssignControlIDZOrder))(wc, controlID, insertAfter); +} + void childSetSoleControlID(struct child *c) { uiWindowsEnsureAssignControlIDZOrder(c->hwnd, 100, NULL); diff --git a/redo/windows/uipriv_windows.h b/redo/windows/uipriv_windows.h index 9207fd46..a1f37866 100644 --- a/redo/windows/uipriv_windows.h +++ b/redo/windows/uipriv_windows.h @@ -106,6 +106,7 @@ extern void childRelayout(struct child *c, intmax_t x, intmax_t y, intmax_t widt extern void childQueueRelayout(struct child *c); extern int childVisible(struct child *c); extern void childUpdateState(struct child *c); +extern void childAssignControlIDZOrder(struct child *c, LONG_PTR *controlID, HWND *insertAfter); extern void childSetSoleControlID(struct child *c); extern HWND childTabPage(struct child *c); extern int childMargined(struct child *c);