Started migrating the GTK+ container.
This commit is contained in:
parent
58a4b5d2da
commit
10e8d3203f
|
@ -13,10 +13,9 @@ typedef struct containerWidgetClass containerWidgetClass;
|
||||||
|
|
||||||
struct containerWidget {
|
struct containerWidget {
|
||||||
GtkContainer parent_instance;
|
GtkContainer parent_instance;
|
||||||
uiContainer *c;
|
uiControl *main;
|
||||||
GPtrArray *widgets; // for for_each()/for_all()
|
GPtrArray *widgets; // for for_each()/for_all()
|
||||||
uiContainer *parent;
|
int margined;
|
||||||
int hidden;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct containerWidgetClass {
|
struct containerWidgetClass {
|
||||||
|
@ -64,23 +63,34 @@ static void containerWidget_remove(GtkContainer *container, GtkWidget *widget)
|
||||||
static void containerWidget_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
|
static void containerWidget_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
|
||||||
{
|
{
|
||||||
containerWidget *c = containerWidget(widget);
|
containerWidget *c = containerWidget(widget);
|
||||||
uiSizing d;
|
uiSizing *d;
|
||||||
|
intmax_t x, y, width, height;
|
||||||
|
|
||||||
gtk_widget_set_allocation(GTK_WIDGET(c), allocation);
|
gtk_widget_set_allocation(GTK_WIDGET(c), allocation);
|
||||||
d.XPadding = gtkXPadding;
|
x = allocation->x;
|
||||||
d.YPadding = gtkYPadding;
|
y = allocation->y;
|
||||||
uiContainerResizeChildren(c->c, allocation->x, allocation->y, allocation->width, allocation->height, &d);
|
width = allocation->width;
|
||||||
|
height = allocation->height;
|
||||||
|
if (c->margined) {
|
||||||
|
x += gtkXMargin;
|
||||||
|
y += gtkYMargin;
|
||||||
|
width -= 2 * gtkXMargin;
|
||||||
|
height -= 2 * gtkYMargin;
|
||||||
|
}
|
||||||
|
d = uiUnixNewSizing();
|
||||||
|
uiControlResize(c->c, x, y, width, height, d);
|
||||||
|
uiFreeSizing(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void containerWidget_get_preferred_height(GtkWidget *widget, gint *minimum, gint *natural)
|
static void containerWidget_get_preferred_height(GtkWidget *widget, gint *minimum, gint *natural)
|
||||||
{
|
{
|
||||||
containerWidget *c = containerWidget(widget);
|
containerWidget *c = containerWidget(widget);
|
||||||
intmax_t width, height;
|
intmax_t width, height;
|
||||||
uiSizing d;
|
uiSizing *d;
|
||||||
|
|
||||||
d.XPadding = gtkXPadding;
|
d = uiUnixNewSizing();
|
||||||
d.YPadding = gtkYPadding;
|
|
||||||
uiControlPreferredSize(uiControl(c->c), &d, &width, &height);
|
uiControlPreferredSize(uiControl(c->c), &d, &width, &height);
|
||||||
|
uiFreeSizing(d);
|
||||||
*minimum = 0; // allow arbitrary resize
|
*minimum = 0; // allow arbitrary resize
|
||||||
*natural = height;
|
*natural = height;
|
||||||
}
|
}
|
||||||
|
@ -89,11 +99,11 @@ static void containerWidget_get_preferred_width(GtkWidget *widget, gint *minimum
|
||||||
{
|
{
|
||||||
containerWidget *c = containerWidget(widget);
|
containerWidget *c = containerWidget(widget);
|
||||||
intmax_t width, height;
|
intmax_t width, height;
|
||||||
uiSizing d;
|
uiSizing *d;
|
||||||
|
|
||||||
d.XPadding = gtkXPadding;
|
d = uiUnixNewSizing();
|
||||||
d.YPadding = gtkYPadding;
|
|
||||||
uiControlPreferredSize(uiControl(c->c), &d, &width, &height);
|
uiControlPreferredSize(uiControl(c->c), &d, &width, &height);
|
||||||
|
uiFreeSizing(d);
|
||||||
*minimum = 0; // allow arbitrary resize
|
*minimum = 0; // allow arbitrary resize
|
||||||
*natural = width;
|
*natural = width;
|
||||||
}
|
}
|
||||||
|
@ -132,15 +142,7 @@ static void containerWidget_class_init(containerWidgetClass *class)
|
||||||
GTK_CONTAINER_CLASS(class)->forall = containerWidget_forall;
|
GTK_CONTAINER_CLASS(class)->forall = containerWidget_forall;
|
||||||
}
|
}
|
||||||
|
|
||||||
// subclasses override this and call back here when all children are destroyed
|
////////////////////////// CONTINUE HERE
|
||||||
static void containerDestroy(uiControl *cc)
|
|
||||||
{
|
|
||||||
containerWidget *c = containerWidget(cc->Internal);
|
|
||||||
|
|
||||||
if (c->parent != NULL)
|
|
||||||
complain("attempt to destroy uiContainer %p while it has a parent", cc);
|
|
||||||
g_object_unref(c); // release our initial reference, which destroys the widget
|
|
||||||
}
|
|
||||||
|
|
||||||
static uintptr_t containerHandle(uiControl *cc)
|
static uintptr_t containerHandle(uiControl *cc)
|
||||||
{
|
{
|
Loading…
Reference in New Issue