Installed the Z-order stuff into box.c; tab order is now correct. There are some loose ends, though.

This commit is contained in:
Pietro Gagliardi 2015-06-02 17:42:51 -04:00
parent f26a3a18de
commit fd846cb01f
3 changed files with 30 additions and 2 deletions

View File

@ -233,6 +233,18 @@ static void boxAppend(uiBox *ss, uiControl *c, int stretchy)
{
struct box *b = (struct box *) ss;
struct boxControl *bc;
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 boxControl *, 0);
zorder = uiControlStartZOrder(bc->c);
}
bc = uiNew(struct boxControl);
bc->c = c;
@ -240,6 +252,13 @@ static void boxAppend(uiBox *ss, uiControl *c, int stretchy)
uiControlSetParent(bc->c, uiControl(b));
ptrArrayAppend(b->controls, bc);
uiControlQueueResize(uiControl(b));
// and now update the zorder for all controls
if (dozorder)
for (i = 0; i < b->controls->len; i++) {
bc = ptrArrayIndex(b->controls, struct boxControl *, i);
zorder = uiControlSetZOrder(bc->c, zorder);
}
}
static void boxDelete(uiBox *ss, uintmax_t index)

View File

@ -109,11 +109,19 @@ static void singleHWNDCommitDisable(uiControl *c)
uintptr_t uiWindowsUtilStartZOrder(HWND hwnd)
{
HWND insertAfter;
DWORD le;
// see http://stackoverflow.com/questions/30491418/
// also, the window at the beginning of the z-order has no previous window, so GetWindow() returns NULL
// we have to differentiate these error states
SetLastError(0);
insertAfter = GetWindow(hwnd, GW_HWNDPREV);
if (insertAfter == NULL)
logLastError("error getting insert after window in uiWindowsUtilStartZOrder()");
if (insertAfter == NULL) {
le = GetLastError();
SetLastError(le); // just in case
if (le != 0)
logLastError("error getting insert after window in uiWindowsUtilStartZOrder()");
}
return (uintptr_t) insertAfter;
}

View File

@ -3,6 +3,7 @@
// TODO
// - dialog doesn't respond to WM_PRINTCLIENT in Windows Classic
// - can't seem to tab away anymore
struct tab {
uiTab t;