Separated tab page child assignment from the constructor to keep the vtable together.

This commit is contained in:
Pietro Gagliardi 2015-06-01 20:12:55 -04:00
parent 6d64922055
commit 993bc58691
3 changed files with 17 additions and 9 deletions

View File

@ -130,7 +130,8 @@ static void tabInsertAt(uiTab *tt, const char *name, uintmax_t n, uiControl *chi
// see below
hide = curpage(t);
page = newTabPage(child);
page = newTabPage();
tabPageSetChild(page, child);
uiControlSetParent(page, uiControl(t));
// and make it invisible at first; we show it later if needed
uiControlHide(page);

View File

@ -49,6 +49,9 @@ static void tabPageResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width,
(*(t->baseResize))(uiControl(t), x, y, width, height, d);
if (t->child == NULL)
return;
dchild = uiControlSizing(uiControl(t));
if (GetClientRect(t->hwnd, &r) == 0)
@ -90,7 +93,7 @@ static INT_PTR CALLBACK dlgproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
return FALSE;
}
uiControl *newTabPage(uiControl *child)
uiControl *newTabPage(void)
{
struct tabPage *t;
HRESULT hr;
@ -107,13 +110,7 @@ uiControl *newTabPage(uiControl *child)
if (hr != S_OK)
logHRESULT("error setting tab page background in newTabPage()", hr);
// needs to be done here, otherwise the uiControlSetParent() below will crash
// TODO split into separate functions
uiControl(t)->Handle = tabPageHandle;
t->child = child;
uiControlSetParent(t->child, uiControl(t));
uiControl(t)->PreferredSize = tabPagePreferredSize;
t->baseResize = uiControl(t)->Resize;
uiControl(t)->Resize = tabPageResize;
@ -144,3 +141,12 @@ void tabPageDestroyChild(uiControl *c)
uiControlDestroy(t->child);
t->child = NULL;
}
void tabPageSetChild(uiControl *c, uiControl *child)
{
struct tabPage *t = (struct tabPage *) c;
t->child = child;
t->child = child;
uiControlSetParent(t->child, uiControl(t));
}

View File

@ -115,7 +115,8 @@ extern void endDialogHelper(HWND);
extern void setSingleHWNDFuncs(uiControl *);
// tabpage.c
extern uiControl *newTabPage(uiControl *);
extern uiControl *newTabPage(void);
extern int tabPageMargined(uiControl *);
extern void tabPageSetMargined(uiControl *, int);
extern void tabPageDestroyChild(uiControl *);
extern void tabPageSetChild(uiControl *, uiControl *);