Handled uiGroup parenting and destruction.
This commit is contained in:
parent
678ddbedf3
commit
fb10d65249
|
@ -8,26 +8,6 @@ struct group {
|
||||||
void (*baseResize)(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *);
|
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
|
// TODO get source
|
||||||
#define groupXMargin 6
|
#define groupXMargin 6
|
||||||
|
@ -76,15 +56,6 @@ static void groupComputeChildSize(uiControl *c, intmax_t *x, intmax_t *y, intmax
|
||||||
*height = r.bottom - r.top;
|
*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)
|
uiGroup *uiNewGroup(const char *text)
|
||||||
{
|
{
|
||||||
struct group *g;
|
struct group *g;
|
||||||
|
|
|
@ -4,10 +4,23 @@
|
||||||
struct group {
|
struct group {
|
||||||
uiGroup g;
|
uiGroup g;
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
|
uiControl *child;
|
||||||
|
void (*baseCommitDestroy)(uiControl *);
|
||||||
};
|
};
|
||||||
|
|
||||||
uiDefineControlType(uiGroup, uiTypeGroup, struct group)
|
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)
|
static uintptr_t groupHandle(uiControl *c)
|
||||||
{
|
{
|
||||||
struct group *g = (struct group *) c;
|
struct group *g = (struct group *) c;
|
||||||
|
@ -22,9 +35,25 @@ static void groupPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intma
|
||||||
*height = 0;
|
*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)
|
uiGroup *uiNewGroup(const char *text)
|
||||||
|
@ -44,6 +73,9 @@ uiGroup *uiNewGroup(const char *text)
|
||||||
|
|
||||||
uiControl(g)->Handle = groupHandle;
|
uiControl(g)->Handle = groupHandle;
|
||||||
uiControl(g)->PreferredSize = groupPreferredSize;
|
uiControl(g)->PreferredSize = groupPreferredSize;
|
||||||
|
g->baseCommitDestroy = uiControl(g)->CommitDestroy;
|
||||||
|
uiControl(g)->CommitDestroy = groupCommitDestroy;
|
||||||
|
uiControl(g)->ContainerUpdateState = groupContainerUpdateState;
|
||||||
|
|
||||||
uiGroup(g)->SetChild = groupSetChild;
|
uiGroup(g)->SetChild = groupSetChild;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue