Implemented tabPreferredSize(). This finally eliminates windows/OLDtab.c.
This commit is contained in:
parent
a48aa36251
commit
884bd5c862
|
@ -1,34 +0,0 @@
|
|||
// 12 april 2015
|
||||
#include "uipriv_windows.h"
|
||||
|
||||
// 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)
|
||||
{
|
||||
struct tab *t = (struct tab *) c;
|
||||
LRESULT current;
|
||||
struct tabPage *curpage;
|
||||
intmax_t curwid, curht;
|
||||
RECT r;
|
||||
|
||||
r.left = 0;
|
||||
r.top = 0;
|
||||
r.right = 0;
|
||||
r.bottom = 0;
|
||||
if (t->pages->len != 0) {
|
||||
current = SendMessageW(t->hwnd, TCM_GETCURSEL, 0, 0);
|
||||
if (current != (LRESULT) (-1)) {
|
||||
curpage = ptrArrayIndex(t->pages, struct tabPage *, current);
|
||||
uiControlPreferredSize(curpage->control, d, &curwid, &curht);
|
||||
r.right = curwid;
|
||||
r.bottom = curht;
|
||||
// TODO add margins
|
||||
}
|
||||
}
|
||||
// otherwise just use the rect [0 0 0 0]
|
||||
// the following will take the tabs themselves into account
|
||||
SendMessageW(t->hwnd, TCM_ADJUSTRECT, (WPARAM) TRUE, (LPARAM) (&r));
|
||||
*width = r.right - r.left;
|
||||
*height = r.bottom - r.top;
|
||||
}
|
|
@ -96,7 +96,32 @@ static uintptr_t tabHandle(uiControl *c)
|
|||
|
||||
static void tabPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
|
||||
{
|
||||
// TODO
|
||||
struct tab *t = (struct tab *) c;
|
||||
intmax_t maxwid, maxht;
|
||||
intmax_t pagewid, pageht;
|
||||
uiControl *page;
|
||||
uintmax_t i;
|
||||
RECT r;
|
||||
|
||||
maxwid = 0;
|
||||
maxht = 0;
|
||||
for (i = 0; i < t->pages->len; i++) {
|
||||
page = ptrArrayIndex(t->pages, uiControl *, i);
|
||||
uiControlPreferredSize(page, d, &pagewid, &pageht);
|
||||
if (maxwid < pagewid)
|
||||
maxwid = pagewid;
|
||||
if (maxht < pageht)
|
||||
maxht = pageht;
|
||||
}
|
||||
|
||||
r.left = 0;
|
||||
r.top = 0;
|
||||
r.right = maxwid;
|
||||
r.bottom = maxht;
|
||||
// this also includes the tabs themselves
|
||||
SendMessageW(t->hwnd, TCM_ADJUSTRECT, (WPARAM) TRUE, (LPARAM) (&r));
|
||||
*width = r.right - r.left;
|
||||
*height = r.bottom - r.top;
|
||||
}
|
||||
|
||||
static void tabResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d)
|
||||
|
|
Loading…
Reference in New Issue