Implemented uiWindowSetMargined() on GTK+.

This commit is contained in:
Pietro Gagliardi 2015-04-09 15:18:18 -04:00
parent 7c6beec879
commit d146167321
3 changed files with 26 additions and 2 deletions

View File

@ -55,14 +55,29 @@ static void uiContainer_remove(GtkContainer *container, GtkWidget *widget)
g_ptr_array_remove(c->children, widget);
}
#define gtkXMargin 12
#define gtkYMargin 12
static void uiContainer_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
uiContainer *c = uiContainer(widget);
uiSizing d;
intmax_t x, y, width, height;
gtk_widget_set_allocation(GTK_WIDGET(c), allocation);
if (c->child != NULL)
(*(c->child->resize))(c->child, allocation->x, allocation->y, allocation->width, allocation->height, &d);
if (c->child == NULL)
return;
x = allocation->x;
y = allocation->y;
width = allocation->width;
height = allocation->height;
if (c->margined) {
x += gtkXMargin;
y += gtkYMargin;
width -= 2 * gtkXMargin;
height -= 2 * gtkYMargin;
}
(*(c->child->resize))(c->child, x, y, width, height, &d);
}
struct forall {

View File

@ -26,6 +26,7 @@ struct uiContainer {
uiControl *child;
// these are the actual children widgets of the container as far as GTK+ is concerned
GPtrArray *children; // for forall()
gboolean margined;
};
struct uiContainerClass {
GtkContainerClass parent_class;

View File

@ -81,3 +81,11 @@ void uiWindowSetChild(uiWindow *w, uiControl *c)
uiContainer(w->container)->child = c;
(*(c->setParent))(c, (uintptr_t) (w->container));
}
// TODO margined
void uiWindowSetMargined(uiWindow *w, int margined)
{
uiContainer(w->container)->margined = margined;
updateParent((uintptr_t) (w->container));
}