diff --git a/new/container_unix.c b/new/container_unix.c index f008878..ab0298f 100644 --- a/new/container_unix.c +++ b/new/container_unix.c @@ -34,8 +34,12 @@ static void uiContainer_remove(GtkContainer *container, GtkWidget *widget) static void uiContainer_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { + uiControl *c; + uiSizing d; + gtk_widget_set_allocation(widget, allocation); - // TODO resize child + c = uiContainer(widget)->child; + (*(c->resize))(widget, allocation.x, allocation.y, allocation.width, allocation.height, &d); } struct forall { diff --git a/new/main_unix.c b/new/main_unix.c index 90374c7..aae049b 100644 --- a/new/main_unix.c +++ b/new/main_unix.c @@ -12,3 +12,9 @@ void uiQuit(void) { gtk_main_quit(); } + +// TODO move somewhere else +uintptr_t uiControlHandle(uiControl *c) +{ + return (*(c->handle))(c); +} diff --git a/new/uipriv_unix.h b/new/uipriv_unix.h index 5cf2bff..95b2468 100644 --- a/new/uipriv_unix.h +++ b/new/uipriv_unix.h @@ -18,7 +18,9 @@ typedef struct uiContainer uiContainer; typedef struct uiContainerClass uiContainerClass; struct uiContainer { GtkContainer parent_instance; - // TODO + // this is what triggers the resizing of all the children + uiControl *child; + // these are the actual children widgets of the container as far as GTK+ is concerned GPtrArray *children; // for forall() }; struct uiContainerClass { diff --git a/new/window_unix.c b/new/window_unix.c index 3a145ac..ecc520c 100644 --- a/new/window_unix.c +++ b/new/window_unix.c @@ -3,6 +3,7 @@ struct uiWindow { GtkWidget *widget; + GtkWidget *container; int (*onClosing)(uiWindow *, void *); void *onClosingData; }; @@ -15,6 +16,8 @@ uiWindow *uiNewWindow(char *title, int width, int height) w->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(w->widget), title); gtk_window_resize(GTK_WINDOW(w->widget), width, height); + w->container = newContainer(); + gtk_container_add(GTK_CONTAINER(w->widget), w->container); return w; } @@ -58,3 +61,9 @@ void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *, void *), void *data) w->onClosingData = data; g_signal_connect(w->widget, "delete-event", G_CALLBACK(onClosing), w); } + +void uiWindowSetChild(uiWindow *w, uiControl *c) +{ + uiContainer(w->container)->child = c; + (*(c->setParent))(c, (uintptr_t) (w->container)); +}