diff --git a/new/container_unix.c b/new/container_unix.c index d9d6996..d393273 100644 --- a/new/container_unix.c +++ b/new/container_unix.c @@ -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 { diff --git a/new/uipriv_unix.h b/new/uipriv_unix.h index 1ee2269..3187c45 100644 --- a/new/uipriv_unix.h +++ b/new/uipriv_unix.h @@ -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; diff --git a/new/window_unix.c b/new/window_unix.c index dca52e3..b778b26 100644 --- a/new/window_unix.c +++ b/new/window_unix.c @@ -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)); +}