From aa568e51cf5c98f833c4b0937db0f472c079bd5b Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 3 May 2015 17:13:40 -0400 Subject: [PATCH] Implemented uiControlPreferredSize() on Windows uiTabs. --- windows/tab.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/windows/tab.c b/windows/tab.c index f89d6462..d15ded78 100644 --- a/windows/tab.c +++ b/windows/tab.c @@ -61,7 +61,30 @@ static void onDestroy(void *data) static void preferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height) { - // TODO + struct tab *t = (struct tab *) c; + LRESULT current; + uiContainer *curpage; + intmax_t curwid, curht; + RECT r; + + r.left = 0; + r.top = 0; + r.right = 0; + r.bottom = 0; + if (t->len != 0) { + current = SendMessageW(t->hwnd, TCM_GETCURSEL, 0, 0); + if (current != (LRESULT) (-1)) { + curpage = t->pages[current]; + uiControlPreferredSize(uiControl(curpage), d, &curwid, &curht); + r.right = curwid; + r.bottom = curht; + } + } + // otherwise just use the rect [0 0 0 0] + SendMessageW(t->hwnd, TCM_ADJUSTRECT, (WPARAM) TRUE, (LPARAM) (&r)); + *width = r.right - r.left; + *height = r.bottom - r.top; + // TODO does ths include the tabs themselves on windows? they do on wine } // common code for resizes