summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-04-09 15:18:18 -0400
committerPietro Gagliardi <[email protected]>2015-04-09 15:18:18 -0400
commitd1461673210f8616bba6fe3a586148aa44696edd (patch)
tree88e613399af846af817dc64d30ae8d7266c4a99f
parent7c6beec879fcea66361b677eb752477f01f65b98 (diff)
Implemented uiWindowSetMargined() on GTK+.
-rw-r--r--new/container_unix.c19
-rw-r--r--new/uipriv_unix.h1
-rw-r--r--new/window_unix.c8
3 files changed, 26 insertions, 2 deletions
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));
+}