Started rewriting window.c. More TODOs.

This commit is contained in:
Pietro Gagliardi 2015-04-22 23:03:32 -04:00
parent 78ae87409e
commit f90c15fef1
2 changed files with 68 additions and 0 deletions

View File

@ -2,6 +2,7 @@
#include "ui.h"
#include "uipriv.h"
// TODO remove these
typedef struct box box;
typedef struct boxControl boxControl;

67
new/unix/window.c Normal file
View File

@ -0,0 +1,67 @@
// 22 april 2015
#include "uipriv_unix.h"
struct window {
uiWindow w;
// the window itself, preconverted to the various GTK+ types
GtkWidget *widget;
GtkContainer *container;
GtkWindow *window;
// the main content widget of the GtkWindow
GtkWidget *vboxwidget;
GtkContainer *vboxcontainer;
GtkBox *vbox;
// the OS container for the uiWindow
uiOSContainer *content;
int margined;
};
uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubars)
{
struct window *w;
w = uiNew(struct window);
w->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
w->container = GTK_CONTAINER(w->widget);
w->window = GTK_WINDOW(w->widget);
w->vboxwidget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
w->vboxcontainer = GTK_CONTAINER(w->vboxwidget);
w->vbox = GTK_BOX(w->vboxwidget);
// set the vbox as the GtkWindow child
gtk_container_add(w->container, w->vboxwidget);
// TODO menus
// and add the OS container
w->content = uiNewOSContainer((uintptr_t) (w->vboxcontainer));
gtk_widget_set_hexpand(GTK_WIDGET(w->content), TRUE);
gtk_widget_set_halign(GTK_WIDGET(w->content), GTK_ALIGN_FILL);
gtk_widget_set_vexpand(GTK_WIDGET(w->content), TRUE);
gtk_widget_set_valign(GTK_WIDGET(w->content), GTK_ALL_FILL);
// show everything in the vbox, but not the GtkWindow itself
gtk_widget_show_all(w->vboxwidget);
// and connect our OnClosing() event
g_signal_connect(w->TODO
uiWindow(w)->Destroy = windowDestroy;
uiWindow(w)->Handle = windowHandle;
uiWindow(w)->Title = windowTitle;
uiWindow(w)->SetTitle = windowSetTitle;
uiWindow(w)->Show = windowShow;
uiWindow(w)->Hide = windowHide;
uiWindow(w)->OnClosing = windowOnClosing;
uiWindow(w)->SetChild = windowSetChild;
uiWindow(w)->Margined = windowMargined;
uiWindow(w)->SetMargined = windowSetMargined;
return uiWindow(w);
}