From f6d9e1ea1e39a9b2cbf69e23d1ee2519b71ab752 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 30 May 2015 13:15:43 -0400 Subject: [PATCH] More work trying to get tab pages to work. There's something up with boxes, but there's also something up with theme dialog textures... --- redo/windows/tab.c | 11 ----------- redo/windows/tabpage.c | 32 +++++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/redo/windows/tab.c b/redo/windows/tab.c index 41d320b2..5cc47a57 100644 --- a/redo/windows/tab.c +++ b/redo/windows/tab.c @@ -68,9 +68,6 @@ static uintptr_t tabHandle(uiControl *c) return (uintptr_t) (t->hwnd); } -// from http://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx -#define tabMargin 7 - static void tabPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height) { // TODO @@ -102,14 +99,6 @@ static void tabResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intm SendMessageW(t->hwnd, TCM_ADJUSTRECT, (WPARAM) FALSE, (LPARAM) (&r)); mapWindowRect(NULL, dchild->Sys->CoordFrom, &r); -/*TODO - if (page->margined) { - r.left += uiWindowsDlgUnitsToX(tabMargin, d->Sys->BaseX); - r.top += uiWindowsDlgUnitsToY(tabMargin, d->Sys->BaseY); - r.right -= uiWindowsDlgUnitsToX(tabMargin, d->Sys->BaseX); - r.bottom -= uiWindowsDlgUnitsToY(tabMargin, d->Sys->BaseY); - } -*/ uiControlResize(page, r.left, r.top, r.right - r.left, r.bottom - r.top, dchild); uiFreeSizing(dchild); diff --git a/redo/windows/tabpage.c b/redo/windows/tabpage.c index 98f75483..774e6472 100644 --- a/redo/windows/tabpage.c +++ b/redo/windows/tabpage.c @@ -9,8 +9,9 @@ struct tabPage { uiControl c; HWND hwnd; - uiControl *control; + uiControl *control; // TODO rename child int margined; + void (*baseResize)(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *); }; uiDefineControlType(tabPage, tabPageType, struct tabPage) @@ -25,6 +26,31 @@ static uintptr_t tabPageHandle(uiControl *c) return (uintptr_t) (t->hwnd); } +// from http://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx +#define tabMargin 7 + +static void tabPageResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d) +{ + struct tabPage *t = (struct tabPage *) c; + RECT r; + uiSizing *dchild; + + (*(t->baseResize))(uiControl(t), x, y, width, height, d); + + if (GetClientRect(t->hwnd, &r) == 0) + logLastError("error getting tab page client rect in tabPageResize()"); + if (t->margined) { + r.left += uiWindowsDlgUnitsToX(tabMargin, d->Sys->BaseX); + r.top += uiWindowsDlgUnitsToY(tabMargin, d->Sys->BaseY); + r.right -= uiWindowsDlgUnitsToX(tabMargin, d->Sys->BaseX); + r.bottom -= uiWindowsDlgUnitsToY(tabMargin, d->Sys->BaseY); + } + + dchild = uiControlSizing(uiControl(t)); +//TODO uiControlResize(t->control, r.left, r.top, r.right - r.left, r.bottom - r.top, dchild); + uiFreeSizing(dchild); +} + uiControl *newTabPage(uiControl *child) { struct tabPage *t; @@ -38,6 +64,7 @@ uiControl *newTabPage(uiControl *child) hInstance, NULL, FALSE); + // TODO figure out why this is not working hr = EnableThemeDialogTexture(t->hwnd, ETDT_ENABLE | ETDT_USETABTEXTURE | ETDT_ENABLETAB); if (hr != S_OK) logHRESULT("error setting tab page background in newTabPage()", hr); @@ -51,5 +78,8 @@ uiControl *newTabPage(uiControl *child) t->control = child; uiControlSetParent(t->control, uiControl(t)); + t->baseResize = uiControl(t)->Resize; + uiControl(t)->Resize = tabPageResize; + return uiControl(t); }