- Timestamp:
- Jun 18, 2004, 9:05:08 AM (20 years ago)
- Location:
- orxonox/branches/gui/guicc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/gui/guicc/orxonox_gui.cc
r1974 r1976 15 15 Frametest->fill(box); 16 16 17 CheckButton* button = new CheckButton(" test");17 CheckButton* button = new CheckButton("button"); 18 18 button->connectSignal ("clicked", orxonoxGUI->orxonox_gui_quit); 19 19 box->fill(button); 20 Slider* slider = new Slider(" testslider", 0, 100);20 Slider* slider = new Slider("slider", 0, 100); 21 21 slider->connectSignal ("value_changed", slider->OptionChange); 22 22 box->fill(slider); 23 Menu* menu = new Menu(" test1", "no output", "verbose", "debug", "lastItem");23 Menu* menu = new Menu("menu1", "no output", "verbose", "debug", "lastItem"); 24 24 menu->connectSignal ("changed", menu->OptionChange); 25 25 box->fill(menu); 26 Menu* menu2 = new Menu("menu2", "no output", "verbose", "debug", "lastItem"); 27 menu2->connectSignal ("changed", menu->OptionChange); 28 box->fill(menu2); 29 orxonoxGUI->listOptions(); 26 30 orxonoxGUI->showall (); 27 31 … … 32 36 33 37 /* WIDGET */ 38 39 void Widget::connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *)) 40 { 41 /** 42 * Connect any signal to any given Sub-widget 43 */ 44 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), NULL); 45 } 46 47 void Widget::connectSignal (char* event, gint (*signal)( GtkWidget*, Widget *)) 48 { 49 /** 50 * Connect a signal with additionally passing the whole Object 51 */ 52 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), this); 53 } 54 34 55 void Widget::show() 35 56 { … … 40 61 } 41 62 42 void Widget::connectSignal (char* event, gint ( *signal)( GtkWidget*, GdkEvent*, void *)) 43 { 44 /** 45 * Connect any signal to any given Sub-widget 46 */ 47 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), NULL); 48 } 49 50 void Widget::connectSignal (char* event, gint ( *signal)( GtkWidget*, Widget *)) 51 { 52 /** 53 * Connect a signal with additionally passing the whole Object 54 */ 55 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), this); 63 void Widget::listOptions () 64 { 65 /** 66 * This is For listing all the Options witch are located beneath this Widget. 67 */ 68 if (this->is_option >= 1) 69 cout << static_cast<Option*>(this)->option_name <<" is : " << static_cast<Option*>(this)->value <<endl; 70 71 if (this->next != NULL) 72 this->next->listOptions (); 73 74 switch (this->is_option) 75 { 76 case -1: 77 static_cast<Container*>(this)->down->listOptions (); 78 break; 79 case -2: 80 static_cast<Box*>(this)->down->listOptions (); 81 break; 82 } 56 83 } 57 84 … … 63 90 * fill any given Container with a lowerwidet 64 91 */ 65 gtk_container_add (GTK_CONTAINER(this->widget), lowerWidget->widget); 66 this->down = lowerWidget; 92 if (this->down == NULL) 93 { 94 gtk_container_add (GTK_CONTAINER (this->widget), lowerWidget->widget); 95 this->down = lowerWidget; 96 } 97 else 98 cout << "!!error!! You try to put more than one Widget into a container.\nnot including this item."<<endl; 67 99 } 68 100 … … 76 108 * Creating a Window 77 109 */ 110 is_option = -1; 78 111 widget = gtk_window_new (GTK_WINDOW_TOPLEVEL); 79 gtk_window_set_policy(GTK_WINDOW(widget), TRUE, TRUE, TRUE); 112 gtk_window_set_policy (GTK_WINDOW(widget), TRUE, TRUE, TRUE); 113 next = NULL; 114 down = NULL; 80 115 } 81 116 … … 85 120 * Creating a Window with passing a name 86 121 */ 122 is_option = -1; 87 123 widget = gtk_window_new (GTK_WINDOW_TOPLEVEL); 88 gtk_window_set_policy (GTK_WINDOW(widget), TRUE, TRUE, TRUE);89 this->setTitle (windowName);124 gtk_window_set_policy (GTK_WINDOW (widget), TRUE, TRUE, TRUE); 125 this->setTitle (windowName); 90 126 } 91 127 … … 114 150 115 151 116 gint Window::orxonox_gui_quit ( 152 gint Window::orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data) 117 153 { 118 154 /** … … 131 167 * Creates a new Frame without a name 132 168 */ 169 is_option = -1; 170 next = NULL; 171 down = NULL; 133 172 widget = gtk_frame_new (""); 134 173 } … … 138 177 * Creates a new Frame with name title 139 178 */ 179 is_option = -1; 180 next = NULL; 181 down = NULL; 140 182 widget = gtk_frame_new (title); 141 183 } … … 164 206 * Creates a new horizontal Box 165 207 */ 208 is_option = -2; 209 next = NULL; 210 down = NULL; 166 211 widget = gtk_hbox_new(FALSE, 0); 167 212 } … … 171 216 * Creates a new Box if boxtype is 'v' it will be vertically, if 'h' it will be horizontally 172 217 */ 218 is_option = -2; 219 next = NULL; 220 down = NULL; 173 221 if (boxtype == 'v') 174 222 { 175 widget = gtk_vbox_new (FALSE, 0);223 widget = gtk_vbox_new (FALSE, 0); 176 224 } 177 225 else 178 226 { 179 widget = gtk_hbox_new (FALSE, 0);227 widget = gtk_hbox_new (FALSE, 0); 180 228 } 181 229 } … … 193 241 * Fill a Box with its lowerwidgets 194 242 */ 195 gtk_box_pack_start (GTK_BOX(this->widget), lowerWidget->widget, TRUE, TRUE, 0); 243 gtk_box_pack_start (GTK_BOX (this->widget), lowerWidget->widget, TRUE, TRUE, 0); 244 if (this->down == NULL) 245 this->down = lowerWidget; 246 else 247 { 248 Widget* tmp; 249 tmp = this->down; 250 while (tmp->next != NULL) 251 { 252 tmp = tmp->next; 253 } 254 tmp->next = lowerWidget; 255 } 196 256 } 197 257 … … 205 265 * Creates a new Button with name buttonname 206 266 */ 207 widget = gtk_button_new_with_label(buttonname); 267 is_option = 0; 268 next = NULL; 208 269 option_name = buttonname; 270 widget = gtk_button_new_with_label (buttonname); 209 271 } 210 272 211 273 /* CHECKBUTTON */ 212 CheckButton::CheckButton (char* buttonname)274 CheckButton::CheckButton (char* buttonname) 213 275 { 214 276 /** 215 277 * Creates a new CheckButton with name buttonname 216 278 */ 217 widget = gtk_check_button_new_with_label(buttonname); 279 is_option = 1; 280 next = NULL; 218 281 option_name = buttonname; 282 widget = gtk_check_button_new_with_label (buttonname); 219 283 } 220 284 … … 225 289 * Creates a new Slider with name slidername a beginning value of start and an end value of end. 226 290 */ 291 is_option = 1; 292 next = NULL; 293 option_name = slidername; 227 294 widget = gtk_hscale_new_with_range (start, end, 5); 228 295 value = start; 229 option_name = slidername;230 296 } 231 297 … … 235 301 * Writes value, if changed on the slider, to the object. 236 302 */ 237 static_cast<Slider*>(slider)->value = (int)gtk_range_get_value (GTK_RANGE ((Slider*)slider->widget));303 static_cast<Slider*>(slider)->value = (int)gtk_range_get_value (GTK_RANGE ((Slider*)slider->widget)); 238 304 cout << static_cast<Slider*>(slider)->value << endl; 239 305 } 240 306 241 307 242 Menu::Menu (char* menuname, ...)308 Menu::Menu (char* menuname, ...) 243 309 { 244 310 /** 245 311 * Creates an Menu-Item-list out of multiple input. Consider, that the last input argument has to be "lastItem" for this to work. 246 312 */ 313 is_option = 1; 314 next = NULL; 315 option_name = menuname; 247 316 char *tmp; 248 317 va_list itemlist; 249 widget = gtk_option_menu_new ();318 widget = gtk_option_menu_new (); 250 319 GtkWidget* menu = gtk_menu_new (); 251 320 GtkWidget* item; 252 321 253 va_start (itemlist, menuname);254 while (strcmp (tmp = va_arg(itemlist, char*), "lastItem"))322 va_start (itemlist, menuname); 323 while (strcmp (tmp = va_arg (itemlist, char*), "lastItem")) 255 324 { 256 325 item = gtk_menu_item_new_with_label (tmp); … … 267 336 * Writes value, if changed on the Menu, to the object. 268 337 */ 269 static_cast<Menu*>(menu)->value = (int)gtk_option_menu_get_history (GTK_OPTION_MENU (menu->widget));270 cout << static_cast<Menu*>(menu)-> value << endl;271 } 338 static_cast<Menu*>(menu)->value = (int)gtk_option_menu_get_history (GTK_OPTION_MENU (menu->widget)); 339 cout << static_cast<Menu*>(menu)->option_name << " changed to : " << static_cast<Menu*>(menu)->value << endl; 340 } -
orxonox/branches/gui/guicc/orxonox_gui.h
r1974 r1976 22 22 public: 23 23 Widget* next; 24 GtkWidget* widget; 24 GtkWidget* widget; 25 int is_option; 25 26 26 27 //virtual void create (); 27 28 // void addWidget (); 28 void connectSignal (char* event, gint (*signal)( 29 void connectSignal (char* event, gint (*signal)(GtkWidget*, 29 void connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *)); 30 void connectSignal (char* event, gint (*signal)(GtkWidget*, Widget *)); 30 31 void show (); 32 void listOptions (); 33 31 34 }; 32 35 … … 56 59 void setTitle (char* title); 57 60 void showall (); 58 static gint orxonox_gui_quit ( 61 static gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data); 59 62 }; 60 63 … … 76 79 ~Box (void); 77 80 81 Widget* down; 78 82 void fill (Widget *lowerWidget); 79 83 … … 107 111 public: 108 112 Slider (char* slidername,int start, int end); 109 ~Slider ();113 ~Slider (); 110 114 int i; 111 115 static gint OptionChange (GtkWidget *widget, Widget* slider); … … 115 119 { 116 120 public: 117 Menu (char* menuname, ...);118 ~Menu ();121 Menu (char* menuname, ...); 122 ~Menu (); 119 123 120 124 static gint OptionChange (GtkWidget *widget, Widget* menu); 121 125 }; 122 126 123 //gint orxonox_gui_quit ( 127 //gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data); 124 128 125 129 #endif /* _ORXONOX_GUI_H */
Note: See TracChangeset
for help on using the changeset viewer.