Handled uiGroup parenting and destruction.

This commit is contained in:
Pietro Gagliardi 2015-06-01 18:00:20 -04:00
parent 678ddbedf3
commit fb10d65249
2 changed files with 34 additions and 31 deletions

View File

@ -8,26 +8,6 @@ struct group {
void (*baseResize)(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *);
};
static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult)
{
return FALSE;
}
static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult)
{
return FALSE;
}
static void onDestroy(void *data)
{
struct group *g = (struct group *) data;
if (g->child != NULL) {
uiControlSetParent(g->child, NULL);
uiControlDestroy(g->child);
}
uiFree(g);
}
// TODO get source
#define groupXMargin 6
@ -76,15 +56,6 @@ static void groupComputeChildSize(uiControl *c, intmax_t *x, intmax_t *y, intmax
*height = r.bottom - r.top;
}
static void groupSetChild(uiGroup *gg, uiControl *c)
{
struct group *g = (struct group *) gg;
g->child = c;
if (g->child != NULL)
uiControlQueueResize(g->child);
}
uiGroup *uiNewGroup(const char *text)
{
struct group *g;

View File

@ -4,10 +4,23 @@
struct group {
uiGroup g;
HWND hwnd;
uiControl *child;
void (*baseCommitDestroy)(uiControl *);
};
uiDefineControlType(uiGroup, uiTypeGroup, struct group)
static void groupCommitDestroy(uiControl *c)
{
struct group *g = (struct group *) c;
if (g->child != NULL) {
uiControlSetParent(g->child, NULL);
uiControlDestroy(g->child);
}
(*(g->baseCommitDestroy))(uiControl(g));
}
static uintptr_t groupHandle(uiControl *c)
{
struct group *g = (struct group *) c;
@ -22,9 +35,25 @@ static void groupPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intma
*height = 0;
}
static void groupSetChild(uiGroup *gg, uiControl *c)
static void groupContainerUpdateState(uiControl *c)
{
// TODO
struct group *g = (struct group *) c;
if (g->child != NULL)
uiControlUpdateState(g->child);
}
static void groupSetChild(uiGroup *gg, uiControl *child)
{
struct group *g = (struct group *) gg;
if (g->child != NULL)
uiControlSetParent(g->child, NULL);
g->child = child;
if (g->child != NULL) {
uiControlSetParent(g->child, uiControl(g));
uiControlQueueResize(g->child);
}
}
uiGroup *uiNewGroup(const char *text)
@ -44,6 +73,9 @@ uiGroup *uiNewGroup(const char *text)
uiControl(g)->Handle = groupHandle;
uiControl(g)->PreferredSize = groupPreferredSize;
g->baseCommitDestroy = uiControl(g)->CommitDestroy;
uiControl(g)->CommitDestroy = groupCommitDestroy;
uiControl(g)->ContainerUpdateState = groupContainerUpdateState;
uiGroup(g)->SetChild = groupSetChild;