Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/gui/guicc/orxonox_gui.cc @ 1895

Last change on this file since 1895 was 1895, checked in by bensch, 21 years ago

orxonox/branches/gui/guicc: added Box-support, casting

File size: 2.2 KB
Line 
1#include "orxonox_gui.h"
2
3int 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 */
22void Widget::show()
23{
24  gtk_widget_show (widget);
25}
26
27void 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
34void 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
44Window::Window (void)
45{
46  widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
47  gtk_window_set_policy(GTK_WINDOW(widget), TRUE, TRUE, TRUE);
48}
49
50Window::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
57Window::~Window ()
58{}
59
60void Window::showall ()
61{
62  gtk_widget_show_all  (widget);
63}
64
65void Window::setTitle (char* title)
66{
67  gtk_window_set_title (GTK_WINDOW (widget), title);
68}
69
70
71gint Window::orxonox_gui_quit ( GtkWidget *widget, GdkEvent *event, gpointer data)
72{
73  gtk_main_quit();
74  return FALSE;
75}
76
77
78   /* FRAME */
79
80Frame::Frame (void)
81{
82  widget = gtk_frame_new ("");
83}
84Frame::Frame (char* title)
85{
86  widget = gtk_frame_new (title);
87}
88Frame::~Frame ()
89{}
90
91void Frame::setTitle (char* title)
92{
93  gtk_frame_set_label (GTK_FRAME (widget), title);
94}
95
96
97
98 /* BOX */
99
100Box::Box (void)
101{
102  widget = gtk_hbox_new(FALSE, 0);
103}
104Box::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
116Box::~Box ()
117{}
118
119void Box::fill (Widget *lowerWidget)
120{
121  gtk_box_pack_start (GTK_BOX(this->widget), lowerWidget->widget, TRUE, TRUE, 0);
122}
Note: See TracBrowser for help on using the repository browser.