1 | #include "orxonox_gui.h" |
---|
2 | |
---|
3 | int main( int argc, char *argv[] ) |
---|
4 | { |
---|
5 | gtk_init (&argc, &argv); |
---|
6 | Window* orxonoxGUI = new Window("Graphical Orxonox Launcher"); |
---|
7 | orxonoxGUI->connectSignal ("destroy", orxonoxGUI->orxonox_gui_quit); |
---|
8 | orxonoxGUI->connectSignal ("delete_event", orxonoxGUI->orxonox_gui_quit); |
---|
9 | |
---|
10 | Frame* Frametest = new Frame ("Test"); |
---|
11 | orxonoxGUI->fill((Frame*) Frametest); |
---|
12 | Frame* test = (Frame*) orxonoxGUI->down; |
---|
13 | test->setTitle("shit"); |
---|
14 | orxonoxGUI->showall (); |
---|
15 | |
---|
16 | gtk_main(); |
---|
17 | return 0; |
---|
18 | } |
---|
19 | |
---|
20 | |
---|
21 | /* WIDGET */ |
---|
22 | void Widget::show() |
---|
23 | { |
---|
24 | gtk_widget_show (widget); |
---|
25 | } |
---|
26 | |
---|
27 | void Widget::connectSignal (char* event, gint ( *signal)( GtkWidget*, GdkEvent*, void *)) |
---|
28 | { |
---|
29 | g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), NULL); |
---|
30 | } |
---|
31 | |
---|
32 | /* CONTAINERS*/ |
---|
33 | |
---|
34 | void Container::fill (Widget *lowerWidget) |
---|
35 | { |
---|
36 | gtk_container_add (GTK_CONTAINER(this->widget), lowerWidget->widget); |
---|
37 | this->down = lowerWidget; |
---|
38 | } |
---|
39 | |
---|
40 | // gtk_container_set_border_width (GTK_CONTAINER (widget), 5); |
---|
41 | |
---|
42 | /* WINDOW */ |
---|
43 | |
---|
44 | Window::Window (void) |
---|
45 | { |
---|
46 | widget = gtk_window_new (GTK_WINDOW_TOPLEVEL); |
---|
47 | gtk_window_set_policy(GTK_WINDOW(widget), TRUE, TRUE, TRUE); |
---|
48 | } |
---|
49 | |
---|
50 | Window::Window (char* windowName) |
---|
51 | { |
---|
52 | widget = gtk_window_new (GTK_WINDOW_TOPLEVEL); |
---|
53 | gtk_window_set_policy(GTK_WINDOW(widget), TRUE, TRUE, TRUE); |
---|
54 | this->setTitle(windowName); |
---|
55 | } |
---|
56 | |
---|
57 | Window::~Window () |
---|
58 | {} |
---|
59 | |
---|
60 | void Window::showall () |
---|
61 | { |
---|
62 | gtk_widget_show_all (widget); |
---|
63 | } |
---|
64 | |
---|
65 | void Window::setTitle (char* title) |
---|
66 | { |
---|
67 | gtk_window_set_title (GTK_WINDOW (widget), title); |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | gint Window::orxonox_gui_quit ( GtkWidget *widget, GdkEvent *event, gpointer data) |
---|
72 | { |
---|
73 | gtk_main_quit(); |
---|
74 | return FALSE; |
---|
75 | } |
---|
76 | |
---|
77 | |
---|
78 | /* FRAME */ |
---|
79 | |
---|
80 | Frame::Frame (void) |
---|
81 | { |
---|
82 | widget = gtk_frame_new (""); |
---|
83 | } |
---|
84 | Frame::Frame (char* title) |
---|
85 | { |
---|
86 | widget = gtk_frame_new (title); |
---|
87 | } |
---|
88 | Frame::~Frame () |
---|
89 | {} |
---|
90 | |
---|
91 | void Frame::setTitle (char* title) |
---|
92 | { |
---|
93 | gtk_frame_set_label (GTK_FRAME (widget), title); |
---|
94 | } |
---|
95 | |
---|
96 | |
---|
97 | |
---|
98 | /* BOX */ |
---|
99 | |
---|
100 | Box::Box (void) |
---|
101 | { |
---|
102 | widget = gtk_hbox_new(FALSE, 0); |
---|
103 | } |
---|
104 | Box::Box (char boxtype) |
---|
105 | { |
---|
106 | if (boxtype == 'v') |
---|
107 | { |
---|
108 | widget = gtk_vbox_new(FALSE, 0); |
---|
109 | } |
---|
110 | else |
---|
111 | { |
---|
112 | widget = gtk_hbox_new(FALSE, 0); |
---|
113 | } |
---|
114 | } |
---|
115 | |
---|
116 | Box::~Box () |
---|
117 | {} |
---|
118 | |
---|
119 | void Box::fill (Widget *lowerWidget) |
---|
120 | { |
---|
121 | gtk_box_pack_start (GTK_BOX(this->widget), lowerWidget->widget, TRUE, TRUE, 0); |
---|
122 | } |
---|