- Timestamp:
- Oct 19, 2004, 10:39:44 PM (20 years ago)
- Location:
- orxonox/trunk/gui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/gui/orxonox_gui.cc
r2595 r2605 99 99 100 100 /* WIDGET */ 101 102 /** 103 \brief deletes any given Widget 104 This is still pretty crappy. 105 */ 106 Widget::~Widget() 107 { 108 // cout << "hiding: " <<this->label <<"\n"; 109 this->hide(); 110 // cout << "check if Packer: "<<this->label <<"\n"; 111 if (this->is_option < 0) 112 { 113 // cout << "get Down "<<this->label <<"\n"; 114 static_cast<Packer*>(this)->down->~Widget(); 115 } 116 // cout << "next != NULL?: " <<this->label <<"\n"; 117 if (this->next != NULL) 118 this->next->~Widget(); 119 cout << "delete Widget: " <<this->label <<"\n"; 120 // delete widget; 121 } 122 101 123 /** 102 124 * Initializes a widget. … … 108 130 } 109 131 132 /** 133 * makes the widget visible. 134 */ 135 void Widget::show() 136 { 137 gtk_widget_show (this->widget); 138 } 139 140 /** 141 * hides the widget. 142 */ 143 void Widget::hide() 144 { 145 gtk_widget_hide (this->widget); 146 } 147 148 /** 149 \brief Sets the resolution of a specific widget to the given size. 150 \param width the width of the widget to set. 151 \param height the height of the widget to set. 152 */ 153 void Widget::setSize(int width, int height) 154 { 155 gtk_widget_set_usize (this->widget, width, height); 156 } 157 110 158 /** 111 159 * Connect any signal to any given Sub-widget … … 130 178 { 131 179 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj); 132 }133 134 135 /**136 * Function to Shows a specific widget.137 */138 void Widget::show()139 {140 gtk_widget_show (this->widget);141 180 } 142 181 … … 149 188 { 150 189 function(this); 151 switch (this->is_option)190 if (this->is_option < 0) 152 191 { 153 case -1: 154 static_cast<Container*>(this)->down->walkThrough (function); 155 break; 156 case -2: 157 static_cast<Box*>(this)->down->walkThrough (function); 158 break; 192 static_cast<Packer*>(this)->down->walkThrough (function); 159 193 } 160 194 … … 163 197 } 164 198 165 166 199 /** 167 200 * This is for listing the option of "widget" … … 171 204 { 172 205 if (widget->is_option >= 1) 173 cout << static_cast<Option*>(widget)-> option_name<<" is : " << static_cast<Option*>(widget)->value <<endl;206 cout << static_cast<Option*>(widget)->label <<" is : " << static_cast<Option*>(widget)->value <<endl; 174 207 } 175 208 … … 184 217 } 185 218 186 /* CONTAINERS*/ 219 //void deleteWidget(Widget* lastWidget) 220 221 222 /* PACKERS */ 223 224 /** 225 * Initializes a Packer. 226 * nothing to do here 227 */ 228 void Packer::init (void) 229 { 230 return; 231 } 232 233 /* CONTAINERS */ 187 234 188 235 /** … … 234 281 235 282 /** 236 * Destoying a Window (very BAD implemented).237 * For now it just hides the window.238 */239 Window::~Window ()240 {241 gtk_widget_hide (widget);242 }243 244 /**245 283 *initializes a new Window 246 284 */ 247 285 void Window::init() 248 286 { 287 isOpen = true; 249 288 is_option = -1; 289 label = ""; 250 290 next = NULL; 251 291 down = NULL; … … 263 303 void Window::showall () 264 304 { 305 isOpen = true; 265 306 gtk_widget_show_all (widget); 266 307 } … … 272 313 void Window::setTitle (char* title) 273 314 { 315 label=title; 274 316 gtk_window_set_title (GTK_WINDOW (widget), title); 275 317 } … … 311 353 } 312 354 313 /**314 * Destroys given Frame (not implemented yet)315 */316 Frame::~Frame ()317 {318 }319 320 355 /** 321 356 * Initializes a new Frame with default settings … … 324 359 { 325 360 is_option = -1; 361 label = ""; 326 362 next = NULL; 327 363 down = NULL; … … 336 372 void Frame::setTitle (char* title) 337 373 { 374 label = title; 338 375 gtk_frame_set_label (GTK_FRAME (widget), title); 339 376 } … … 365 402 { 366 403 is_option = -1; 404 label = "eventBox"; 367 405 next = NULL; 368 406 down = NULL; … … 378 416 void EventBox::setTitle (char* title) 379 417 { 380 381 } 382 383 /** 384 * Destructs an EventBox (not Implemented) 385 */ 386 EventBox::~EventBox () 387 { 388 } 389 418 label = title; 419 } 390 420 391 421 /* BOX */ … … 409 439 410 440 /** 411 * Destroys given Box (not implemented yet)412 */413 Box::~Box ()414 {415 }416 417 /**418 441 * Initializes a new Box with type boxtype 419 442 \param boxtype see Box(char boxtype) … … 422 445 { 423 446 is_option = -2; 447 label = "box"; 424 448 next = NULL; 425 449 down = NULL; … … 469 493 this->init(); 470 494 widget = gtk_image_new_from_file (imagename); 495 label = imagename; 471 496 } 472 497 … … 477 502 { 478 503 is_option = 0; 504 label = ""; 479 505 next = NULL; 480 506 } … … 501 527 flag_name = flagname; 502 528 default_value = defaultvalue; 503 cout << "Set Flagname of " << option_name<< " to " << flagname << endl;529 cout << "Set Flagname of " << label << " to " << flagname << endl; 504 530 } 505 531 … … 515 541 flag_name_short = flagnameshort; 516 542 default_value = defaultvalue; 517 cout << "Set Flagname of " << option_name<< " to " << flagname << endl;543 cout << "Set Flagname of " << label << " to " << flagname << endl; 518 544 } 519 545 … … 539 565 value = 0; 540 566 next = NULL; 541 option_name="";567 label =""; 542 568 flag_name = ""; 543 569 flag_name_short = ""; … … 552 578 void Button::setTitle (char *title) 553 579 { 554 option_name= title;580 label = title; 555 581 gtk_button_set_label (GTK_BUTTON(widget), title); 556 582 } … … 578 604 } 579 605 580 /**581 * Destructs a CheckButton (not Implemented yet).582 */583 CheckButton::~CheckButton()584 {585 }586 587 606 /** 588 607 * Initiali a new CheckButton with default settings … … 593 612 value = 0; 594 613 next = NULL; 595 option_name= "";614 label = ""; 596 615 flag_name = ""; 597 616 flag_name_short = ""; … … 606 625 void CheckButton::setTitle(char* title) 607 626 { 608 option_name= title;627 label = title; 609 628 gtk_button_set_label(GTK_BUTTON(widget), title); 610 629 } … … 620 639 static_cast<CheckButton*>(checkbutton)->value = (int)gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON ((CheckButton*)checkbutton->widget)); 621 640 flags->setTextFromFlags(orxonoxGUI); 622 cout << static_cast<CheckButton*>(checkbutton)-> option_name<< " set to: " << static_cast<CheckButton*>(checkbutton)->value << endl;641 cout << static_cast<CheckButton*>(checkbutton)->label << " set to: " << static_cast<CheckButton*>(checkbutton)->value << endl; 623 642 } 624 643 … … 649 668 650 669 /** 651 * Destructs a Slider (not implemented yet)652 */653 Slider::~Slider()654 {655 }656 657 /**658 670 * Initializes a Slider with start and end Values 659 671 * params: see Slider::Slider (char* slidername, int start, int end) … … 664 676 value = 0; 665 677 next = NULL; 666 option_name= "";678 label = ""; 667 679 flag_name = ""; 668 680 flag_name_short = ""; … … 677 689 void Slider::setTitle(char* title) 678 690 { 679 option_name= title;691 label = title; 680 692 } 681 693 … … 698 710 static_cast<Slider*>(slider)->value = (int)gtk_range_get_value (GTK_RANGE ((Slider*)slider->widget)); 699 711 flags->setTextFromFlags(orxonoxGUI); 700 cout << static_cast<Slider*>(slider)-> option_name<< " set to: "<< static_cast<Slider*>(slider)->value << endl;712 cout << static_cast<Slider*>(slider)->label << " set to: "<< static_cast<Slider*>(slider)->value << endl; 701 713 } 702 714 … … 758 770 void Menu::setTitle(char* title) 759 771 { 760 option_name= title;772 label = title; 761 773 } 762 774 … … 779 791 static_cast<Menu*>(menu)->value = (int)gtk_option_menu_get_history (GTK_OPTION_MENU (menu->widget)); 780 792 flags->setTextFromFlags(orxonoxGUI); 781 cout << static_cast<Menu*>(menu)-> option_name<< " changed to : " << static_cast<Menu*>(menu)->value << endl;793 cout << static_cast<Menu*>(menu)->label << " changed to : " << static_cast<Menu*>(menu)->value << endl; 782 794 } 783 795 … … 806 818 Label:: Label (char* text) 807 819 { 820 this->init(); 821 this->setText(text); 822 } 823 824 /** 825 * initializes a new Label 826 */ 827 void Label::init(void) 828 { 808 829 is_option = 0; 809 next = NULL; 810 widget = gtk_label_new (text); 811 gtk_label_set_line_wrap (GTK_LABEL(widget), TRUE); 812 } 813 814 /** 815 * Destructs a Label 816 */ 817 Label::~Label () 818 {} 819 820 /** 821 * initializes a new Label 822 */ 823 void Label::init(void) 824 { 825 is_option = 0; 830 label = ""; 826 831 next = NULL; 827 832 widget = gtk_label_new (""); 828 gtk_widget_set_usize (widget, 260, 60);829 833 gtk_label_set_line_wrap (GTK_LABEL(widget), TRUE); 830 834 } … … 836 840 void Label::setText (char * text) 837 841 { 842 label = text; 838 843 gtk_label_set_text (GTK_LABEL (this->widget), text); 839 844 } -
orxonox/trunk/gui/orxonox_gui.h
r2595 r2605 39 39 private: 40 40 public: 41 ~Widget (); 42 41 43 Widget* next; //!< next always points to the next Widget in the list. Every Widget has a next one, or has NULL as next 42 44 GtkWidget* widget; //!< widget is the gtk_widget that the specific Object Contains. 43 45 virtual void init(void); 44 46 int is_option; //!< with this Paramenter one can set the IsOption type: -2:Container, -1: Box, 0: not an Option, 1: Bool-option, 2: int-option 45 enum option { containerType = -2, boxType = -1, nothingType = 0, boolType = 1, intType = 2}; //!< defines is_option states 47 /** 48 \briefdefines is_option states 49 */ 50 enum option { containerType = -2, boxType = -1, nothingType = 0, boolType = 1, intType = 2}; 51 char* label; //!< The name of the Widget. Some do display it, Options need it to save; 46 52 void connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *)); 47 53 void connectSignal (char* event, gint (*signal)(GtkWidget*, Widget *)); 48 54 void connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *)); 49 55 void show (); 56 void hide (); 57 void setSize(int width, int height); 50 58 51 59 void walkThrough (void (*function)(Widget*)); … … 55 63 }; 56 64 65 //! This is a Packer Object, which has the ability to Pack other Widgets into itself. 66 class Packer : public Widget 67 { 68 public: 69 Widget* down; //!< this points to the Widget below this. 70 71 void init(void); 72 }; 57 73 58 74 //! This is a Container Class, it can contain one sub-Widget: down. … … 62 78 * The derived classes of Container can be displayed 63 79 */ 64 class Container : public Widget80 class Container : public Packer 65 81 { 66 82 private: 67 83 int borderwidth; 68 84 int policy; 69 char* label; 70 71 public: 72 void init(void); 73 Widget* down; //!< this points to the Widget below this. 85 86 public: 87 void init(void); 74 88 // void setBorderWidth (int borderwidth); 75 89 // virtual void setTitle (char* title) = 0; … … 84 98 class Window : public Container 85 99 { 100 private: 101 bool isOpen; 86 102 public: 87 103 Window (char* windowName); 88 104 Window (void); 89 ~Window ();90 105 void init (); 91 106 … … 105 120 Frame (char* frameName); 106 121 Frame (void); 107 ~Frame ();108 122 void init(void); 109 123 … … 120 134 EventBox (char* eventBoxName); 121 135 EventBox (void); 122 ~EventBox ();123 136 void init(void); 124 137 … … 132 145 * A Box is always filled left->right (horizontally) or up->down (vertically) 133 146 */ 134 class Box : public Widget147 class Box : public Packer 135 148 { 136 149 public: 137 150 Box (void); 138 151 Box (char boxtype); 139 ~Box (void);140 152 void init(char boxtype); 141 153 142 Widget* down; //!< the Lower Widget of a Box.143 154 void fill (Widget* lowerWidget); 144 155 … … 154 165 public: 155 166 Image (char* imgaename); 156 ~Image ();157 167 void init(void); 158 168 }; … … 169 179 170 180 int value; //!< every option has a value either true or false (0,1) or something else like 25 for 25% of the volume 171 char* option_name; //!< options have a name, that can be displayed around them172 181 char* flag_name; //!< options have a flag name that will be appendet if you start the Program from the GUI. 173 182 char* flag_name_short; //!< like flag_name but shorter … … 187 196 public: 188 197 Button (char* buttonname); 189 ~Button (void);190 198 void init(void); 191 199 … … 202 210 public: 203 211 CheckButton (char* buttonname); 204 ~CheckButton (void);205 212 static gint OptionChange (GtkWidget* widget, Widget* checkbutton); 206 213 … … 219 226 public: 220 227 Slider (char* slidername,int start, int end); 221 ~Slider ();222 228 void init(int start, int end); 223 229 … … 239 245 public: 240 246 Menu (char* menuname, ...); 241 ~Menu ();242 247 void init(void); 243 248 … … 255 260 Label (); 256 261 Label (char* text); 257 ~Label ();258 262 void init(void); 259 263 -
orxonox/trunk/gui/orxonox_gui_banner.cc
r2595 r2605 88 88 { 89 89 logoWindowIsOpen = 0; 90 logoWindow-> ~Window();90 logoWindow->hide(); 91 91 } 92 92 -
orxonox/trunk/gui/orxonox_gui_exec.cc
r2595 r2605 124 124 char Buffer[256]; 125 125 char* space2under; 126 sprintf (Buffer, "%s", static_cast<Option*>(widget)-> option_name);126 sprintf (Buffer, "%s", static_cast<Option*>(widget)->label); 127 127 if (strchr (Buffer, '_')) 128 128 cout << "Warning Optionname" << Buffer << " is not Valid for Saving, because it includes an underscore" << endl; … … 189 189 { 190 190 if (widget->is_option >= 1) 191 if (!strcmp (static_cast<Option*>(widget)-> option_name, variableName))191 if (!strcmp (static_cast<Option*>(widget)->label, variableName)) 192 192 static_cast<Option*>(widget)->value = variableValue; 193 193 -
orxonox/trunk/gui/orxonox_gui_flags.cc
r2595 r2605 39 39 40 40 flagsLabel = new Label (); 41 flagsLabel->setSize (260,60); 41 42 flagsBox->fill (flagsLabel); 42 43 shortFlags = new CheckButton ("shortFlags");
Note: See TracChangeset
for help on using the changeset viewer.