Separated tab page child assignment from the constructor to keep the vtable together.
This commit is contained in:
parent
6d64922055
commit
993bc58691
|
@ -130,7 +130,8 @@ static void tabInsertAt(uiTab *tt, const char *name, uintmax_t n, uiControl *chi
|
||||||
// see below
|
// see below
|
||||||
hide = curpage(t);
|
hide = curpage(t);
|
||||||
|
|
||||||
page = newTabPage(child);
|
page = newTabPage();
|
||||||
|
tabPageSetChild(page, child);
|
||||||
uiControlSetParent(page, uiControl(t));
|
uiControlSetParent(page, uiControl(t));
|
||||||
// and make it invisible at first; we show it later if needed
|
// and make it invisible at first; we show it later if needed
|
||||||
uiControlHide(page);
|
uiControlHide(page);
|
||||||
|
|
|
@ -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);
|
(*(t->baseResize))(uiControl(t), x, y, width, height, d);
|
||||||
|
|
||||||
|
if (t->child == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
dchild = uiControlSizing(uiControl(t));
|
dchild = uiControlSizing(uiControl(t));
|
||||||
|
|
||||||
if (GetClientRect(t->hwnd, &r) == 0)
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
uiControl *newTabPage(uiControl *child)
|
uiControl *newTabPage(void)
|
||||||
{
|
{
|
||||||
struct tabPage *t;
|
struct tabPage *t;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
@ -107,13 +110,7 @@ uiControl *newTabPage(uiControl *child)
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
logHRESULT("error setting tab page background in newTabPage()", hr);
|
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;
|
uiControl(t)->Handle = tabPageHandle;
|
||||||
|
|
||||||
t->child = child;
|
|
||||||
uiControlSetParent(t->child, uiControl(t));
|
|
||||||
|
|
||||||
uiControl(t)->PreferredSize = tabPagePreferredSize;
|
uiControl(t)->PreferredSize = tabPagePreferredSize;
|
||||||
t->baseResize = uiControl(t)->Resize;
|
t->baseResize = uiControl(t)->Resize;
|
||||||
uiControl(t)->Resize = tabPageResize;
|
uiControl(t)->Resize = tabPageResize;
|
||||||
|
@ -144,3 +141,12 @@ void tabPageDestroyChild(uiControl *c)
|
||||||
uiControlDestroy(t->child);
|
uiControlDestroy(t->child);
|
||||||
t->child = NULL;
|
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));
|
||||||
|
}
|
||||||
|
|
|
@ -115,7 +115,8 @@ extern void endDialogHelper(HWND);
|
||||||
extern void setSingleHWNDFuncs(uiControl *);
|
extern void setSingleHWNDFuncs(uiControl *);
|
||||||
|
|
||||||
// tabpage.c
|
// tabpage.c
|
||||||
extern uiControl *newTabPage(uiControl *);
|
extern uiControl *newTabPage(void);
|
||||||
extern int tabPageMargined(uiControl *);
|
extern int tabPageMargined(uiControl *);
|
||||||
extern void tabPageSetMargined(uiControl *, int);
|
extern void tabPageSetMargined(uiControl *, int);
|
||||||
extern void tabPageDestroyChild(uiControl *);
|
extern void tabPageDestroyChild(uiControl *);
|
||||||
|
extern void tabPageSetChild(uiControl *, uiControl *);
|
||||||
|
|
Loading…
Reference in New Issue