Switched the GTK+ implementation to use this new uiBox, completed the implementation a bit more, and fixed some other build errors.

This commit is contained in:
Pietro Gagliardi 2015-07-30 12:43:40 -04:00
parent d4d30285ff
commit 43341f51e9
4 changed files with 24 additions and 13 deletions

View File

@ -26,7 +26,6 @@ baseHFILES = \
$(osHFILES) $(osHFILES)
baseCFILES = \ baseCFILES = \
box.c \
control.c \ control.c \
menu.c \ menu.c \
ptrarray.c \ ptrarray.c \

View File

@ -3,6 +3,7 @@
osCFILES = \ osCFILES = \
unix/alloc.c \ unix/alloc.c \
unix/bin.c \ unix/bin.c \
unix/box.c \
unix/button.c \ unix/button.c \
unix/checkbox.c \ unix/checkbox.c \
unix/combobox.c \ unix/combobox.c \

View File

@ -1,6 +1,7 @@
// 7 april 2015 // 7 april 2015
#include "out/ui.h" #include "uipriv_unix.h"
#include "uipriv.h"
// TODO clean this up
struct box { struct box {
uiBox b; uiBox b;
@ -64,14 +65,28 @@ static void boxAppend(uiBox *ss, uiControl *c, int stretchy)
{ {
struct box *b = (struct box *) ss; struct box *b = (struct box *) ss;
struct boxControl *bc; struct boxControl *bc;
uintmax_t i; GtkWidget *widget;
bc = uiNew(struct boxControl); bc = uiNew(struct boxControl);
bc->c = c; bc->c = c;
bc->stretchy = stretchy; bc->stretchy = stretchy;
uiControlSetParent(bc->c, uiControl(b)); uiControlSetParent(bc->c, uiControl(b));
if (bc->stretchy) widget = GTK_WIDGET(uiControlHandle(bc->c));
gtk_size_group_add_widget(b->stretchygroup, GTK_WIDGET(uiControlHandle(bc->c))); if (bc->stretchy) {
if (b->vertical) {
gtk_widget_set_vexpand(widget, TRUE);
gtk_widget_set_valign(widget, GTK_ALIGN_FILL);
} else {
gtk_widget_set_hexpand(widget, TRUE);
gtk_widget_set_halign(widget, GTK_ALIGN_FILL);
}
gtk_size_group_add_widget(b->stretchygroup, widget);
} else // TODO undo this all in delete
if (b->vertical)
gtk_widget_set_vexpand(widget, FALSE);
else
gtk_widget_set_hexpand(widget, FALSE);
// TODO make the other dimension fill
ptrArrayAppend(b->controls, bc); ptrArrayAppend(b->controls, bc);
uiControlQueueResize(uiControl(b)); uiControlQueueResize(uiControl(b));
} }
@ -112,7 +127,7 @@ static void boxSetPadded(uiBox *ss, int padded)
uiControlQueueResize(uiControl(b)); uiControlQueueResize(uiControl(b));
} }
static uiBox *finishNewBox(GtkOrientationType orientation) static uiBox *finishNewBox(GtkOrientation orientation)
{ {
struct box *b; struct box *b;
@ -131,11 +146,9 @@ static uiBox *finishNewBox(GtkOrientationType orientation)
b->controls = newPtrArray(); b->controls = newPtrArray();
uiUnixMakeSingleWidgetControl(uiControl(b), b->widget);
uiControl(b)->Handle = boxHandle; uiControl(b)->Handle = boxHandle;
uiControl(b)->PreferredSize = boxPreferredSize;
b->baseResize = uiControl(b)->Resize;
uiControl(b)->Resize = boxResize;
uiControl(b)->HasTabStops = boxHasTabStops;
b->baseCommitDestroy = uiControl(b)->CommitDestroy; b->baseCommitDestroy = uiControl(b)->CommitDestroy;
uiControl(b)->CommitDestroy = boxCommitDestroy; uiControl(b)->CommitDestroy = boxCommitDestroy;
uiControl(b)->ContainerUpdateState = boxContainerUpdateState; uiControl(b)->ContainerUpdateState = boxContainerUpdateState;

View File

@ -144,8 +144,6 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
{ {
struct window *w; struct window *w;
finalizeMenus();
w = (struct window *) uiNewControl(uiTypeWindow()); w = (struct window *) uiNewControl(uiTypeWindow());
w->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); w->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);