Changeset 2588 in orxonox.OLD for orxonox/trunk/gui/orxonox_gui.cc
- Timestamp:
- Oct 17, 2004, 5:18:58 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/gui/orxonox_gui.cc
r2587 r2588 48 48 /* ORXONOXGUI */ 49 49 50 /** 51 * Initializes the Gui 52 */ 50 53 OrxonoxGui::OrxonoxGui (int argc, char *argv[]) 51 54 { 52 /**53 * Initializes the Gui54 */55 55 gtk_init (&argc, &argv); 56 56 gtk_rc_parse( "rc" ); … … 99 99 100 100 /* WIDGET */ 101 101 /** 102 * Initializes a widget. 103 * Nothing to do here. 104 */ 102 105 void Widget::init() 103 106 { … … 105 108 } 106 109 110 /** 111 * Connect any signal to any given Sub-widget 112 */ 107 113 void Widget::connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *)) 108 114 { 109 /**110 * Connect any signal to any given Sub-widget111 */112 115 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), NULL); 113 116 } 114 117 118 /** 119 * Connect a signal with additionally passing the whole Object 120 */ 115 121 void Widget::connectSignal (char* event, gint (*signal)( GtkWidget*, Widget *)) 116 122 { 117 /**118 * Connect a signal with additionally passing the whole Object119 */120 123 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), this); 121 124 } 122 125 126 /** 127 * Connect a signal with additionally passing a whole external Object 128 */ 123 129 void Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *)) 124 130 { 125 /**126 * Connect a signal with additionally passing a whole external Object127 */128 131 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj); 129 132 } 133 134 135 /** 136 * Function to Shows a specific widget. 137 */ 130 138 void Widget::show() 131 139 { 132 /** 133 * Function to Show any Widget 134 */ 135 gtk_widget_show (widget); 136 } 137 140 gtk_widget_show (this->widget); 141 } 142 143 /** 144 * Moves through all the Widgets downwards from this and executes the function on them. 145 \param function must be of type void and takes a Widget* as an Input. 146 147 */ 138 148 void Widget::walkThrough (void (*function)(Widget*)) 139 149 { 140 /**141 * Moves Through all the Widgets downwards from this and executes the function on them.142 * function must be of type void and takes a Widget* as an Input.143 */144 150 function(this); 145 151 switch (this->is_option) … … 158 164 159 165 166 /** 167 * This is for listing the option of "widget" 168 \param widget specifies the widget that should be listed 169 */ 160 170 void Widget::listOptions (Widget* widget) 161 171 { 162 /**163 * This is for listing the option of "widget"164 */165 172 if (widget->is_option >= 1) 166 173 cout << static_cast<Option*>(widget)->option_name <<" is : " << static_cast<Option*>(widget)->value <<endl; 167 174 } 168 175 176 /** 177 * This is for setting the option of "widget" 178 \param widget specifies the widget that should be set. 179 */ 169 180 void Widget::setOptions (Widget* widget) 170 181 { 171 /**172 * This is for setting the option of "widget"173 */174 182 if (widget->is_option >= 1) 175 183 static_cast<Option*>(widget)->redraw();// <<" is : " << static_cast<Option*>(this)->value <<endl; … … 177 185 178 186 /* CONTAINERS*/ 187 188 /** 189 * Initializes a Container. 190 * nothing to do here 191 */ 179 192 void Container::init (void) 180 193 { 181 194 return; 182 195 } 196 197 /** 198 * Fills a Container with lowerWidget. 199 * It does this by filling up the down pointer only if down points to NULL. 200 \param lowerWidget the Widget that should be filled into the Container. 201 */ 183 202 void Container::fill (Widget *lowerWidget) 184 203 { 185 /**186 * fills any given Container with a lowerwidet187 */188 204 if (this->down == NULL) 189 205 { … … 199 215 /* WINDOW */ 200 216 217 /** 218 * Creating a new Window without a Name 219 */ 201 220 Window::Window (void) 202 221 { 203 /** 204 * Creating a Window 205 */ 206 this->init(); 207 } 208 222 this->init(); 223 } 224 225 /** 226 * Creating a Window with a name 227 \param windowName the name the window should get. 228 */ 209 229 Window::Window (char* windowName) 210 230 { 211 /**212 * Creating a Window with passing a name213 */214 231 this->init(); 215 232 this->setTitle (windowName); 216 233 } 217 234 235 /** 236 * Destoying a Window (very BAD implemented). 237 * For now it just hides the window. 238 */ 218 239 Window::~Window () 219 240 { 220 /**221 * Destoying a Window (very BAD implemented)222 */223 241 gtk_widget_hide (widget); 224 225 } 226 242 } 243 244 /** 245 *initializes a new Window 246 */ 227 247 void Window::init() 228 248 { 229 /**230 *initializes a new Window231 */232 249 is_option = -1; 233 250 next = NULL; … … 241 258 } 242 259 260 /** 261 * Shows all Widgets that are included within this->widget. 262 */ 243 263 void Window::showall () 244 264 { 245 /**246 * Shows all Widgets that are included within this Widget247 */248 265 gtk_widget_show_all (widget); 249 266 } 250 267 268 /** 269 * Set The Window-title to title 270 \param title title the Window should get. 271 */ 251 272 void Window::setTitle (char* title) 252 273 { 253 /**254 * Set The Window title to title255 */256 274 gtk_window_set_title (GTK_WINDOW (widget), title); 257 275 } 258 276 259 277 /** 278 * Quits the orxonox_GUI. 279 * This can be called as a Signal and is therefor static 280 \param widget The widget that called this function 281 \param event the event that happened to execute this function 282 \param data some data passed with the Signal 283 */ 260 284 gint Window::orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data) 261 285 { 262 /**263 * Quits the orxonox_GUI264 */265 286 if (exec->shouldsave()) 266 287 exec->writeToFile (orxonoxGUI); … … 273 294 /* FRAME */ 274 295 296 /** 297 * Creates a new Frame without a name 298 */ 275 299 Frame::Frame (void) 276 300 { 277 /** 278 * Creates a new Frame without a name 279 */ 280 this->init(); 281 } 301 this->init(); 302 } 303 304 /** 305 * Creates a new Frame with name title 306 */ 282 307 Frame::Frame (char* title) 283 308 { 284 /**285 * Creates a new Frame with name title286 */287 309 this->init(); 288 310 this->setTitle(title); 289 311 } 312 313 /** 314 * Destroys given Frame (not implemented yet) 315 */ 290 316 Frame::~Frame () 291 317 { 292 /** 293 * Destroys given Frame (not implemented yet) 294 */ 295 } 296 318 } 319 320 /** 321 * Initializes a new Frame with default settings 322 */ 297 323 void Frame::init() 298 324 { … … 304 330 } 305 331 332 /** 333 * Sets the Frames name to title 334 \param title The title the Frame should get. 335 */ 306 336 void Frame::setTitle (char* title) 307 337 { 308 /**309 * Sets the Frames name to title310 */311 338 gtk_frame_set_label (GTK_FRAME (widget), title); 312 339 } 313 340 314 341 // EVENTBOX // 342 343 /** 344 * Creates a new EventBox with default settings. 345 */ 315 346 EventBox::EventBox () 316 347 { 317 348 this->init(); 318 349 } 319 350 /** 351 * Creates a new EventBox with name title 352 \param title title the Eventbox should get (only data-structure-internal) 353 */ 320 354 EventBox::EventBox (char* title) 321 355 { 322 /**323 * Creates a new EventBox with name title324 */325 356 this->init(); 326 357 this->setTitle(title); 327 358 328 359 } 360 361 /** 362 * Initializes a new EventBox 363 */ 329 364 void EventBox::init(void) 330 365 { … … 337 372 } 338 373 339 374 /** 375 * Sets the Title of the EventBox (not implemented) 376 \param title Name the EventBox should get (only datastructure-internal). 377 */ 340 378 void EventBox::setTitle (char* title) 341 379 { 342 /** 343 * Sets the EventBoxes name to title 344 */ 345 // gtk_frame_set_label (GTK_FRAME (widget), title); 346 } 380 381 } 382 383 /** 384 * Destructs an EventBox (not Implemented) 385 */ 347 386 EventBox::~EventBox () 348 387 { … … 352 391 /* BOX */ 353 392 393 /** 394 * Creates a new horizontal Box 395 */ 354 396 Box::Box (void) 355 397 { 356 /**357 * Creates a new horizontal Box358 */359 398 this->init('h'); 360 399 } 400 401 /** 402 * Creates a new Box of type boxtype 403 \param boxtype if 'v' the Box will be vertically, if 'h' the Box will be horizontally 404 */ 361 405 Box::Box (char boxtype) 362 406 { 363 /**364 * Creates a new Box if boxtype is 'v' it will be vertically, if 'h' it will be horizontally365 */366 407 this->init(boxtype); 367 408 } 409 410 /** 411 * Destroys given Box (not implemented yet) 412 */ 368 413 Box::~Box () 369 414 { 370 /** 371 * Destroys given Frame (not implemented yet) 372 */ 373 } 374 415 } 416 417 /** 418 * Initializes a new Box with type boxtype 419 \param boxtype see Box(char boxtype) 420 */ 375 421 void Box::init(char boxtype) 376 422 { … … 388 434 } 389 435 390 436 /** 437 * Fills a box with a given Widget. 438 * It does this by apending the first one to its down-pointer and all its following ones to the preceding next-pointer. The last one will receive a NULL pointer as Next 439 \param lowerWidget the next Widget that should be appendet to this Box 440 */ 391 441 void Box::fill (Widget *lowerWidget) 392 442 { … … 411 461 /* IMAGE */ 412 462 463 /** 464 * Creates a new Image 465 \param imagename the location of the Image on the Hard Disc 466 */ 413 467 Image::Image (char* imagename) 414 468 { 469 this->init(); 470 widget = gtk_image_new_from_file (imagename); 471 } 472 473 /** 474 * Initializes a new Image 475 */ 476 void Image::init() 477 { 415 478 is_option = 0; 416 479 next = NULL; 417 widget = gtk_image_new_from_file (imagename);418 }419 void Image::init()420 {421 422 480 } 423 481 424 482 425 483 /* OPTION */ 484 485 /** 486 * Initializes a new Option: nothing to do here 487 */ 426 488 void Option::init() 427 489 { 428 490 return; 429 491 } 492 493 /** 494 * This sets The FlagName of an Option and defines its default Values 495 !! Options will be saved if flagname is different from "" !! 496 \param flagname the Name that will be displayed in the output 497 \param defaultvalue the default Value for this Option (see definition of defaultvalue 498 */ 430 499 void Option::setFlagName (char* flagname, int defaultvalue) 431 500 { … … 435 504 } 436 505 506 /** 507 * see Option::setFlagName (char* flagname, int defaultvalue) 508 \param flagname the Name that will be displayed in the output 509 \param defaultvalue the default Value for this Option (see definition of defaultvalue 510 \param flagnameshort a short flagname to be displayed in the output 511 */ 437 512 void Option::setFlagName (char* flagname, char* flagnameshort, int defaultvalue) 438 513 { 439 /**440 * \brief Sets the Flagname of an Option. If it is set different then "" this Option will be saved to the Configurationfile441 */442 514 flag_name = flagname; 443 515 flag_name_short = flagnameshort; … … 448 520 449 521 /* BUTTON */ 522 523 /** 524 * Creates a new Button with a buttonname 525 \param buttonname sets the Name of the Button 526 */ 450 527 Button::Button(char* buttonname) 451 528 { 452 /**453 * Creates a new Button with name buttonname454 */455 529 this->init(); 456 530 this->setTitle(buttonname); 457 531 } 458 532 533 /** 534 * Initializes a new Button 535 */ 459 536 void Button::init(void) 460 537 { … … 469 546 } 470 547 548 /** 549 * Sets a new name to the Button 550 \param title The name the Button should get 551 */ 471 552 void Button::setTitle (char *title) 472 553 { … … 475 556 } 476 557 558 /** 559 * redraws the Button 560 * not implemented yet 561 */ 477 562 void Button::redraw () 478 563 { … … 480 565 481 566 /* CHECKBUTTON */ 567 568 /** 569 * Creates a new CheckButton with an ame 570 \param buttonname The name the CheckButton should display. 571 */ 482 572 CheckButton::CheckButton (char* buttonname) 483 573 { 484 /**485 * Creates a new CheckButton with name buttonname486 */487 574 this->init(); 488 575 this->setTitle(buttonname); … … 490 577 this->connectSignal ("clicked", this->OptionChange); 491 578 } 579 580 /** 581 * Destructs a CheckButton (not Implemented yet). 582 */ 492 583 CheckButton::~CheckButton() 493 584 { 494 585 } 495 586 587 /** 588 * Initiali a new CheckButton with default settings 589 */ 496 590 void CheckButton::init(void) 497 591 { … … 505 599 widget = gtk_check_button_new_with_label (""); 506 600 } 601 602 /** 603 * Sets a new Title to a CheckButton 604 \param title The new Name the CheckButton should display. 605 */ 507 606 void CheckButton::setTitle(char* title) 508 607 { … … 511 610 } 512 611 612 613 /** 614 * Signal OptionChange writes the Value from the CheckButton to its Object-Database. 615 \param widget The widget(CheckButton) that has a changed Value 616 \param checkbutton the CheckButton-Object that should receive the change. 617 */ 513 618 gint CheckButton::OptionChange (GtkWidget *widget, Widget* checkbutton) 514 619 { 515 /**516 * Writes value, if changed on the checkbutton, to the object.517 */518 620 static_cast<CheckButton*>(checkbutton)->value = (int)gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON ((CheckButton*)checkbutton->widget)); 519 621 flags->setTextFromFlags(orxonoxGUI); … … 521 623 } 522 624 625 /** 626 * Redraws the CheckButton (if option has changed). 627 * Example: if new settings are loaded the Button must be redrawn for the GUI to display that Change 628 */ 523 629 void CheckButton::redraw () 524 630 { … … 527 633 528 634 /* SLIDER */ 635 636 /** 637 * Creates a new Slider 638 \param slidername The data-structure-name of the slider. 639 \param start The minimal Value of the slider. 640 \param end The maximal Value of the slider. 641 */ 529 642 Slider::Slider (char* slidername, int start, int end) 530 643 { 531 /**532 * Creates a new Slider with name slidername a beginning value of start and an end value of end.533 */534 644 this->init(start, end); 535 645 this->setValue(start); … … 538 648 } 539 649 650 /** 651 * Destructs a Slider (not implemented yet) 652 */ 540 653 Slider::~Slider() 541 654 { 542 655 } 543 656 657 /** 658 * Initializes a Slider with start and end Values 659 * params: see Slider::Slider (char* slidername, int start, int end) 660 */ 544 661 void Slider::init(int start, int end) 545 662 { … … 553 670 widget = gtk_hscale_new_with_range (start, end, 5); 554 671 } 672 673 /** 674 * Sets a new Title to the Slider 675 \param title The new Name of the slider 676 */ 555 677 void Slider::setTitle(char* title) 556 678 { 557 679 option_name = title; 558 680 } 681 682 /** 683 * Setting a new value to the Slider. 684 * Maybe you also require a Slider::redraw() for this to display 685 */ 559 686 void Slider::setValue(int value) 560 687 { … … 562 689 } 563 690 691 /** 692 * Signal OptionChange writes the Value from the Slider to its Object-Database. 693 \param widget The widget(Slider) that has a changed Value 694 \param slider the Slider-Object that should receive the change. 695 */ 564 696 gint Slider::OptionChange (GtkWidget *widget, Widget* slider) 565 697 { 566 /**567 * Writes value, if changed on the slider, to the object.568 */569 698 static_cast<Slider*>(slider)->value = (int)gtk_range_get_value (GTK_RANGE ((Slider*)slider->widget)); 570 699 flags->setTextFromFlags(orxonoxGUI); … … 572 701 } 573 702 703 /** 704 * Redraws the widget 705 * Example: see void CheckButton::redraw () 706 */ 574 707 void Slider::redraw () 575 708 { … … 577 710 } 578 711 712 /* MENU */ 713 714 /** 715 * Creates a Menu-Item-list out of multiple input. 716 * !! Consider, that the last input argument has to be "lastItem" for this to work!! 717 \param menuname The Database-Name of this Menu 718 \param ... items to be added to this Menu. !! Consider, that the last input argument has to be "lastItem" for this to work!! 719 */ 579 720 Menu::Menu (char* menuname, ...) 580 721 { 581 /**582 * Creates an Menu-Item-list out of multiple input. Consider, that the last input argument has to be "lastItem" for this to work.583 */584 722 this->init(); 585 723 this->setTitle(menuname); … … 598 736 } 599 737 738 /** 739 * Initializes a new Menu with no items 740 */ 600 741 void Menu::init(void) 601 742 { … … 611 752 } 612 753 754 /** 755 * Sets the Database-Name of this Menu 756 \param title Database-Name to be set. 757 */ 613 758 void Menu::setTitle(char* title) 614 759 { … … 616 761 } 617 762 763 /** 764 * appends a new Item to the Menu-List. 765 \param itemName the itemName to be appendet. 766 */ 618 767 void Menu::addItem (char* itemName) 619 768 { … … 622 771 } 623 772 624 gint Menu::OptionChange (GtkWidget *widget, Widget* menu) 625 { 626 /** 627 * Writes value, if changed on the Menu, to the object. 628 */ 773 /** 774 * Signal OptionChange writes the Value from the Menu to its Object-Database. 775 \param widget The widget(Menu) that has a changed Value 776 \param menu the Menu-Object that should receive the change. 777 */gint Menu::OptionChange (GtkWidget *widget, Widget* menu) 778 { 629 779 static_cast<Menu*>(menu)->value = (int)gtk_option_menu_get_history (GTK_OPTION_MENU (menu->widget)); 630 780 flags->setTextFromFlags(orxonoxGUI); … … 632 782 } 633 783 784 /** 785 * Redraws the widget 786 * Example: see void CheckButton::redraw () 787 */ 634 788 void Menu::redraw () 635 789 { … … 637 791 } 638 792 793 /** 794 * Creates a new default Label with no Text. 795 * You migth consider adding Label::setTitle with this. 796 */ 639 797 Label:: Label () 640 798 { … … 642 800 } 643 801 802 /** 803 * Creates a new Label with a Text. 804 \param text The text to be displayed. 805 */ 644 806 Label:: Label (char* text) 645 807 { … … 650 812 } 651 813 814 /** 815 * Destructs a Label 816 */ 652 817 Label::~Label () 653 818 {} 654 819 820 /** 821 * initializes a new Label 822 */ 655 823 void Label::init(void) 656 824 { … … 661 829 gtk_label_set_line_wrap (GTK_LABEL(widget), TRUE); 662 830 } 663 831 832 /** 833 * Sets a new Text to a Label. 834 \param text The text to be inserted into the Label. 835 */ 664 836 void Label::setText (char * text) 665 837 { … … 667 839 } 668 840 841 /** 842 * get the Text of a Label 843 \return The Text the Label holds. 844 */ 669 845 char* Label::getText () 670 846 {
Note: See TracChangeset
for help on using the changeset viewer.