35 lines
971 B
C
35 lines
971 B
C
|
// 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;
|
||
|
}
|