From 31679b4fa80a53141314672ee1b6453891826419 Mon Sep 17 00:00:00 2001 From: Bradley Smith Date: Sat, 2 Aug 2008 16:37:57 +0100 Subject: Add more uitest stuff. Signed-off-by: Bradley Smith --- ui/Makefile.am | 2 +- ui/ui-arena.c | 45 +++++++++++++++++++++++++++++++++++++++ ui/ui-arena.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ ui/ui-cmdwin.c | 45 +++++++++++++++++++++++++++++++++++++++ ui/ui-cmdwin.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ ui/ui-window-private.h | 3 ++- ui/ui-window.c | 46 ++++++++++++++++++++++++++++++--------- 7 files changed, 245 insertions(+), 12 deletions(-) create mode 100644 ui/ui-arena.c create mode 100644 ui/ui-arena.h create mode 100644 ui/ui-cmdwin.c create mode 100644 ui/ui-cmdwin.h diff --git a/ui/Makefile.am b/ui/Makefile.am index be2c4a5..cf01f1b 100644 --- a/ui/Makefile.am +++ b/ui/Makefile.am @@ -19,5 +19,5 @@ bin_PROGRAMS = uitest INCLUDES = $(GTK_CFLAGS) -I$(top_builddir)/ui/ -uitest_SOURCES = main.c ui-window.c +uitest_SOURCES = main.c ui-window.c ui-arena.c ui-cmdwin.c uitest_LDFLAGS = $(GTK_LIBS) diff --git a/ui/ui-arena.c b/ui/ui-arena.c new file mode 100644 index 0000000..06c7bcc --- /dev/null +++ b/ui/ui-arena.c @@ -0,0 +1,45 @@ +/* Copyright (C) 2008 Bradley Smith + * + * GNU Robots, ui-arena.c + * + * GNU Robots is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNU Robots is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Robots. If not, see . + */ + +#include "ui-arena.h" + +struct _UIArenaPrivate +{ + int dummy; +}; + +#define UI_ARENA_GET_PRIVATE(obj) \ + G_TYPE_INSTANCE_GET_PRIVATE(obj, UI_TYPE_ARENA, UIArenaPrivate) + +G_DEFINE_TYPE(UIArena, ui_arena, GTK_TYPE_DRAWING_AREA) + +GtkWidget *ui_arena_new(void) +{ + return GTK_WIDGET(g_object_new(UI_TYPE_ARENA, NULL)); +} + +static void ui_arena_init(UIArena *arena) +{ + gtk_widget_set_size_request(GTK_WIDGET(arena), 40*16,18*16); +} + +static void ui_arena_class_init(UIArenaClass *klass) +{ + g_type_class_add_private(G_OBJECT_CLASS(klass), + sizeof(UIArenaPrivate)); +} diff --git a/ui/ui-arena.h b/ui/ui-arena.h new file mode 100644 index 0000000..5277f54 --- /dev/null +++ b/ui/ui-arena.h @@ -0,0 +1,58 @@ +/* Copyright (C) 2008 Bradley Smith + * + * GNU Robots, ui-arena.h + * + * GNU Robots is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNU Robots is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Robots. If not, see . + */ + +#ifndef __UI_ARENA_H__ +#define __UI_ARENA_H__ + +#include + +G_BEGIN_DECLS + +#define UI_TYPE_ARENA \ + ui_arena_get_type() +#define UI_ARENA(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, UI_TYPE_ARENA, UIArena) +#define UI_ARENA_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, UI_ARENA_TYPE, UIArenaClass) +#define IS_UI_ARENA(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, UI_TYPE_ARENA) +#define IS_UI_ARENA_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, UI_TYPE_ARENA) + +typedef struct _UIArena UIArena; +typedef struct _UIArenaClass UIArenaClass; +typedef struct _UIArenaPrivate UIArenaPrivate; + +struct _UIArena +{ + GtkDrawingArea widget; + UIArenaPrivate* priv; +}; + +struct _UIArenaClass +{ + GtkDrawingAreaClass parent_class; +}; + +GType ui_arena_get_type(void) G_GNUC_CONST; + +GtkWidget *ui_arena_new(void); + +G_END_DECLS + +#endif diff --git a/ui/ui-cmdwin.c b/ui/ui-cmdwin.c new file mode 100644 index 0000000..b743687 --- /dev/null +++ b/ui/ui-cmdwin.c @@ -0,0 +1,45 @@ +/* Copyright (C) 2008 Bradley Smith + * + * GNU Robots, ui-cmdwin.c + * + * GNU Robots is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNU Robots is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Robots. If not, see . + */ + +#include "ui-cmdwin.h" + +struct _UICmdWinPrivate +{ + int dummy; +}; + +#define UI_CMDWIN_GET_PRIVATE(obj) \ + G_TYPE_INSTANCE_GET_PRIVATE(obj, UI_TYPE_CMDWIN, UICmdWinPrivate) + +G_DEFINE_TYPE(UICmdWin, ui_cmdwin, GTK_TYPE_VBOX) + +GtkWidget *ui_cmdwin_new(void) +{ + return GTK_WIDGET(g_object_new(UI_TYPE_CMDWIN, NULL)); +} + +static void ui_cmdwin_init(UICmdWin *cmdwin) +{ + gtk_widget_set_size_request(GTK_WIDGET(cmdwin), 40*16,200); +} + +static void ui_cmdwin_class_init(UICmdWinClass *klass) +{ + g_type_class_add_private(G_OBJECT_CLASS(klass), + sizeof(UICmdWinPrivate)); +} diff --git a/ui/ui-cmdwin.h b/ui/ui-cmdwin.h new file mode 100644 index 0000000..c3bcf8a --- /dev/null +++ b/ui/ui-cmdwin.h @@ -0,0 +1,58 @@ +/* Copyright (C) 2008 Bradley Smith + * + * GNU Robots, ui-cmdwin.h + * + * GNU Robots is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNU Robots is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Robots. If not, see . + */ + +#ifndef __UI_CMDWIN_H__ +#define __UI_CMDWIN_H__ + +#include + +G_BEGIN_DECLS + +#define UI_TYPE_CMDWIN \ + ui_cmdwin_get_type() +#define UI_CMDWIN(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, UI_TYPE_CMDWIN, UICmdWin) +#define UI_CMDWIN_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, UI_CMDWIN_TYPE, UICmdWinClass) +#define IS_UI_CMDWIN(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, UI_TYPE_CMDWIN) +#define IS_UI_CMDWIN_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, UI_TYPE_CMDWIN) + +typedef struct _UICmdWin UICmdWin; +typedef struct _UICmdWinClass UICmdWinClass; +typedef struct _UICmdWinPrivate UICmdWinPrivate; + +struct _UICmdWin +{ + GtkVBox widget; + UICmdWinPrivate* priv; +}; + +struct _UICmdWinClass +{ + GtkVBoxClass parent_class; +}; + +GType ui_cmdwin_get_type(void) G_GNUC_CONST; + +GtkWidget *ui_cmdwin_new(void); + +G_END_DECLS + +#endif diff --git a/ui/ui-window-private.h b/ui/ui-window-private.h index 34bca0e..cfb8b63 100644 --- a/ui/ui-window-private.h +++ b/ui/ui-window-private.h @@ -23,7 +23,8 @@ G_BEGIN_DECLS struct _UIWindowPrivate { - int dummy; + GtkWidget *cmdwin; + GtkWidget *arena; }; G_END_DECLS diff --git a/ui/ui-window.c b/ui/ui-window.c index fe0cd07..27c49e9 100644 --- a/ui/ui-window.c +++ b/ui/ui-window.c @@ -19,6 +19,9 @@ #include "ui-window.h" #include "ui-window-private.h" +#include "ui-cmdwin.h" +#include "ui-arena.h" + #include #define UI_WINDOW_GET_PRIVATE(obj) \ @@ -30,25 +33,48 @@ static void on_ui_window_destroy(GtkWidget *widget, gpointer data); GtkWidget *ui_window_new(void) { - return GTK_WIDGET(g_object_new(UI_TYPE_WINDOW, NULL)); + return GTK_WIDGET(g_object_new(UI_TYPE_WINDOW, NULL)); } static void on_ui_window_destroy(GtkWidget *widget, gpointer data) { - gtk_widget_hide(widget); - gtk_main_quit(); + gtk_widget_hide(widget); + gtk_main_quit(); } -static void ui_window_init(UIWindow* window) +static void ui_window_init(UIWindow *window) { - g_signal_connect(G_OBJECT(window), "destroy", - G_CALLBACK(on_ui_window_destroy), NULL); + GtkWidget *vbox; + GtkWidget *vpaned; + + window->priv = UI_WINDOW_GET_PRIVATE(window); + + vbox = gtk_vbox_new(FALSE, 0); + vpaned = gtk_vpaned_new(); + window->priv->cmdwin = ui_cmdwin_new(); + window->priv->arena = ui_arena_new(); + + gtk_paned_add1(GTK_PANED(vpaned), window->priv->arena); + gtk_paned_add2(GTK_PANED(vpaned), window->priv->cmdwin); + + /* TODO: Add menu first etc */ + gtk_box_pack_start(GTK_BOX(vbox), vpaned, TRUE, TRUE, 0); + + gtk_container_add(GTK_CONTAINER(window), vbox); + + g_signal_connect(G_OBJECT(window), "destroy", + G_CALLBACK(on_ui_window_destroy), NULL); - gtk_window_set_title(GTK_WINDOW(window), "UI Test"); - gtk_widget_show(GTK_WIDGET(window)); + gtk_window_set_title(GTK_WINDOW(window), "UI Test"); + gtk_widget_show(window->priv->cmdwin); + gtk_widget_show(window->priv->arena); + gtk_widget_show(vpaned); + gtk_widget_show(vbox); + gtk_widget_show(GTK_WIDGET(window)); } -static void ui_window_class_init(UIWindowClass* klass) +static void ui_window_class_init(UIWindowClass *klass) { - g_type_class_add_private(G_OBJECT_CLASS(klass), sizeof(UIWindowPrivate)); + g_type_class_add_private(G_OBJECT_CLASS(klass), + sizeof(UIWindowPrivate)); } -- cgit v1.1