Added a system for holding a uiControl in a single GtkWidget.

This commit is contained in:
Pietro Gagliardi 2015-06-29 11:18:39 -04:00
parent 2ca99e3ffe
commit c0bb1ff7a8
2 changed files with 47 additions and 0 deletions

View File

@ -153,3 +153,46 @@ uintptr_t uiMakeContainer(uiControl *c)
containerWidget(widget)->c = c;
return (uintptr_t) widget;
}
// A holder wraps a uiControl in a single GtkWidget.
// It is used for things like GtkWindow, GtkNotebook, etc..
// The containerWidget's c is the wrapped uiControl.
// TODO what happens when destroying these and regular containerWidgets?
struct holder {
uiControl c;
containerWidget *cw;
};
uiDefineControlType(holder, holderType, struct holder)
static uintptr_t holderHandle(uiControl *c)
{
struct holder *h = (struct holder *) c;
return (uintptr_t) (h->cw);
}
uiControl *newHolder(void)
{
struct holder *h;
h = (struct holder *) uiNewControl(holderType());
h->cw = containerWidget(uiMakeContainer(uiControl(h)));
uiControl(h)->Handle = holderHandle;
return uiControl(h);
}
void holderSetChild(uiControl *hh, uiControl *c)
{
struct holder *h = (struct holder *) hh;
if (h->cw->c != NULL)
uiControlSetParent(h->cw->c, NULL);
h->cw->c = c;
if (c != NULL)
uiControlSetParent(h->cw->c, uiControl(h));
}

View File

@ -20,5 +20,9 @@ extern void uninitMenus(void);
extern void initAlloc(void);
extern void uninitAlloc(void);
// container.c
extern uiControl *newHolder(void);
extern void holderSetChild(uiControl *, uiControl *);
// TODO
#define PUT_CODE_HERE 0