Changeset 3144 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Dec 11, 2004, 12:11:03 AM (20 years ago)
- Location:
- orxonox/trunk/gui
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/gui/Makefile.am
r3027 r3144 4 4 5 5 bin_PROGRAMS=gui 6 gui_SOURCES=orxonox_gui.cc orxonox_gui_video.cc orxonox_gui_audio.cc orxonox_gui_exec.cc orxonox_gui_flags.cc orxonox_gui_banner.cc orxonox_gui_keys.cc 6 gui_SOURCES=orxonox_gui.cc \ 7 orxonox_gui_gtk.cc \ 8 orxonox_gui_video.cc \ 9 orxonox_gui_audio.cc \ 10 orxonox_gui_exec.cc \ 11 orxonox_gui_flags.cc \ 12 orxonox_gui_banner.cc \ 13 orxonox_gui_keys.cc 7 14 8 noinst_HEADERS=orxonox_gui.h orxonox_gui_video.h orxonox_gui_audio.h orxonox_gui_exec.h orxonox_gui_flags.h orxonox_gui_banner.h orxonox_gui_keys.h 15 noinst_HEADERS=orxonox_gui.h \ 16 orxonox_gui_gtk.h \ 17 orxonox_gui_video.h \ 18 orxonox_gui_audio.h \ 19 orxonox_gui_exec.h \ 20 orxonox_gui_flags.h \ 21 orxonox_gui_banner.h \ 22 orxonox_gui_keys.h 9 23 10 # uncomment the following if orxonox requires the math 24 # uncomment the following if orxonox requires the mathlibrary 11 25 #gui_LDADD=-lm 12 26 -
orxonox/trunk/gui/Makefile.in
r3099 r3144 53 53 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) 54 54 PROGRAMS = $(bin_PROGRAMS) 55 am_gui_OBJECTS = orxonox_gui.$(OBJEXT) orxonox_gui_ video.$(OBJEXT) \56 orxonox_gui_ audio.$(OBJEXT) orxonox_gui_exec.$(OBJEXT) \57 orxonox_gui_ flags.$(OBJEXT) orxonox_gui_banner.$(OBJEXT) \58 orxonox_gui_ keys.$(OBJEXT)55 am_gui_OBJECTS = orxonox_gui.$(OBJEXT) orxonox_gui_gtk.$(OBJEXT) \ 56 orxonox_gui_video.$(OBJEXT) orxonox_gui_audio.$(OBJEXT) \ 57 orxonox_gui_exec.$(OBJEXT) orxonox_gui_flags.$(OBJEXT) \ 58 orxonox_gui_banner.$(OBJEXT) orxonox_gui_keys.$(OBJEXT) 59 59 gui_OBJECTS = $(am_gui_OBJECTS) 60 60 gui_LDADD = $(LDADD) … … 67 67 @AMDEP_TRUE@ ./$(DEPDIR)/orxonox_gui_exec.Po \ 68 68 @AMDEP_TRUE@ ./$(DEPDIR)/orxonox_gui_flags.Po \ 69 @AMDEP_TRUE@ ./$(DEPDIR)/orxonox_gui_gtk.Po \ 69 70 @AMDEP_TRUE@ ./$(DEPDIR)/orxonox_gui_keys.Po \ 70 71 @AMDEP_TRUE@ ./$(DEPDIR)/orxonox_gui_video.Po … … 174 175 target_vendor = @target_vendor@ 175 176 AM_CXXFLAGS = $(GTK2_CFLAGS) $(MSBITFIELDS) 176 gui_SOURCES = orxonox_gui.cc orxonox_gui_video.cc orxonox_gui_audio.cc orxonox_gui_exec.cc orxonox_gui_flags.cc orxonox_gui_banner.cc orxonox_gui_keys.cc 177 noinst_HEADERS = orxonox_gui.h orxonox_gui_video.h orxonox_gui_audio.h orxonox_gui_exec.h orxonox_gui_flags.h orxonox_gui_banner.h orxonox_gui_keys.h 178 179 # uncomment the following if orxonox requires the math library 177 gui_SOURCES = orxonox_gui.cc \ 178 orxonox_gui_gtk.cc \ 179 orxonox_gui_video.cc \ 180 orxonox_gui_audio.cc \ 181 orxonox_gui_exec.cc \ 182 orxonox_gui_flags.cc \ 183 orxonox_gui_banner.cc \ 184 orxonox_gui_keys.cc 185 186 noinst_HEADERS = orxonox_gui.h \ 187 orxonox_gui_gtk.h \ 188 orxonox_gui_video.h \ 189 orxonox_gui_audio.h \ 190 orxonox_gui_exec.h \ 191 orxonox_gui_flags.h \ 192 orxonox_gui_banner.h \ 193 orxonox_gui_keys.h 194 195 196 # uncomment the following if orxonox requires the mathlibrary 180 197 #gui_LDADD=-lm 181 198 … … 257 274 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox_gui_exec.Po@am__quote@ 258 275 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox_gui_flags.Po@am__quote@ 276 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox_gui_gtk.Po@am__quote@ 259 277 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox_gui_keys.Po@am__quote@ 260 278 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox_gui_video.Po@am__quote@ -
orxonox/trunk/gui/orxonox_gui.cc
r2740 r3144 104 104 } 105 105 106 /* WIDGET */107 108 /**109 \brief deletes any given Widget110 This is still pretty crappy.111 */112 Widget::~Widget()113 {114 // cout << "hiding: " <<this->label <<"\n";115 this->hide();116 // cout << "check if Packer: "<<this->label <<"\n";117 if (this->is_option < 0)118 {119 // cout << "get Down "<<this->label <<"\n";120 static_cast<Packer*>(this)->down->~Widget();121 }122 // cout << "next != NULL?: " <<this->label <<"\n";123 if (this->next != NULL)124 this->next->~Widget();125 cout << "delete Widget: " <<this->label <<"\n";126 // delete widget;127 }128 129 /**130 \brief Initializes a widget.131 Initializes the next Pointer and the other Widget-specific Defaults.132 */133 void Widget::init()134 {135 next = NULL;136 label = "";137 return;138 }139 140 /**141 \brief makes the widget visible.142 */143 void Widget::show()144 {145 gtk_widget_show (this->widget);146 }147 148 /**149 \brief hides the widget.150 */151 void Widget::hide()152 {153 gtk_widget_hide (this->widget);154 }155 156 /**157 \brief Sets the resolution of a specific widget to the given size.158 \param width the width of the widget to set.159 \param height the height of the widget to set.160 */161 void Widget::setSize(int width, int height)162 {163 gtk_widget_set_usize (this->widget, width, height);164 }165 166 /**167 \brief Connect any signal to any given Sub-widget168 */169 void Widget::connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *))170 {171 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), NULL);172 }173 174 /**175 \brief Connect a signal with additionally passing the whole Object176 */177 void Widget::connectSignal (char* event, gint (*signal)( GtkWidget*, Widget *))178 {179 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), this);180 }181 182 /**183 \brief Connect a signal with additionally passing a whole external Object184 */185 void Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *))186 {187 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj);188 }189 190 /**191 \brief Connect a signal with additionally passing a whole external Object192 */193 void Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *))194 {195 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj);196 }197 198 /**199 \brief Moves through all the Widgets downwards from this and executes the function on them.200 \param function must be of type void and takes a Widget* as an Input.201 */202 void Widget::walkThrough (void (*function)(Widget*))203 {204 function(this);205 if (this->is_option < 0)206 {207 static_cast<Packer*>(this)->down->walkThrough (function);208 }209 210 if (this->next != NULL)211 this->next->walkThrough(function);212 }213 214 /**215 \brief This is for listing the option of "widget"216 \param widget specifies the widget that should be listed217 */218 void Widget::listOptions (Widget* widget)219 {220 if (widget->is_option >= 1)221 cout << static_cast<Option*>(widget)->label <<" is : " << static_cast<Option*>(widget)->value <<endl;222 }223 224 /**225 \brief This is for setting the option of "widget"226 \param widget specifies the widget that should be set.227 */228 void Widget::setOptions (Widget* widget)229 {230 if (widget->is_option >= 1)231 static_cast<Option*>(widget)->redraw();// <<" is : " << static_cast<Option*>(this)->value <<endl;232 }233 234 //void deleteWidget(Widget* lastWidget)235 236 237 /* PACKERS */238 239 /**240 \brief Initializes a Packer.241 Sets the down-pinter to NULL and other PackerSpecific-values to their defaults.242 */243 void Packer::init (void)244 {245 down = NULL;246 this->setGroupName ("");247 248 249 static_cast<Widget*>(this)->init();250 return;251 }252 253 /**254 \brief Sets the group name under which all the lower widgets of this will be saved.255 \param name The name of the group.256 */257 void Packer::setGroupName (char* name)258 {259 groupName = name;260 }261 262 /**263 \brief Retrieves the group name under which all the lower widgets of this will be saved.264 \returns name The name of the group.265 */266 char* Packer::getGroupName (void)267 {268 return groupName;269 }270 271 /* CONTAINERS */272 273 /**274 \brief Initializes a Container.275 sets the Container-Specific defaults.276 */277 void Container::init (void)278 {279 is_option = -1;280 281 static_cast<Packer*>(this)->init();282 283 return;284 }285 286 /**287 \briefFills a Container with lowerWidget.288 It does this by filling up the down pointer only if down points to NULL.289 \param lowerWidget the Widget that should be filled into the Container.290 */291 void Container::fill (Widget *lowerWidget)292 {293 if (this->down == NULL)294 {295 gtk_container_add (GTK_CONTAINER (this->widget), lowerWidget->widget);296 this->down = lowerWidget;297 }298 else299 cout << "!!error!! You try to put more than one Widget into a container. \nNot including this item.\nThis is only possible with Boxes"<<endl;300 }301 302 // gtk_container_set_border_width (GTK_CONTAINER (widget), 5);303 304 /* WINDOW */305 306 /**307 \brief Creating a new Window without a Name308 */309 Window::Window (void)310 {311 this->init();312 }313 314 /**315 \brief Creating a Window with a name316 \param windowName the name the window should get.317 */318 Window::Window (char* windowName)319 {320 this->init();321 this->setTitle (windowName);322 }323 324 Window* Window::lastWindow = NULL;325 326 /**327 \brief initializes a new Window328 */329 void Window::init()330 {331 isOpen = false;332 333 static_cast<Container*>(this)->init();334 335 widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);336 gtk_window_set_policy (GTK_WINDOW(widget), TRUE, TRUE, TRUE);337 #if !defined(__WIN32__)338 gtk_window_set_decorated (GTK_WINDOW (widget), FALSE);339 #endif340 gtk_container_set_border_width (GTK_CONTAINER (widget), 3);341 342 // printf("%p\n",lastWindow);343 344 if (lastWindow !=NULL)345 {346 lastWindow->next = this;347 printf("%p, %p\n", lastWindow, this);348 }349 Window::lastWindow = this;350 }351 352 /**353 \brief Shows all Widgets that are included within this->widget.354 */355 void Window::showall ()356 {357 if (!isOpen)358 {359 printf ("showall\n");360 gtk_widget_show_all (widget);361 isOpen = true;362 }363 else364 {365 printf ("showone\n");366 gtk_widget_show (widget);367 }368 }369 370 /**371 \brief Set The Window-title to title372 \param title title the Window should get.373 */374 void Window::setTitle (char* title)375 {376 label=title;377 gtk_window_set_title (GTK_WINDOW (widget), title);378 }379 380 /**381 * Quits the orxonox_GUI.382 * This can be called as a Signal and is therefor static383 \param widget The widget that called this function384 \param event the event that happened to execute this function385 \param data some data passed with the Signal386 */387 gint Window::orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data)388 {389 if (exec->shouldsave())390 exec->writeToFile (orxonoxGUI);391 392 gtk_main_quit();393 return FALSE;394 }395 396 397 /* FRAME */398 399 /**400 \brief Creates a new Frame without a name401 */402 Frame::Frame (void)403 {404 this->init();405 }406 407 /**408 \brief Creates a new Frame with name title409 */410 Frame::Frame (char* title)411 {412 this->init();413 this->setTitle(title);414 }415 416 /**417 \brief Initializes a new Frame with default settings418 */419 void Frame::init()420 {421 static_cast<Container*>(this)->init();422 423 widget = gtk_frame_new ("");424 gtk_container_set_border_width (GTK_CONTAINER (widget), 3);425 }426 427 /**428 \brief Sets the Frames name to title429 \param title The title the Frame should get.430 */431 void Frame::setTitle (char* title)432 {433 label = title;434 gtk_frame_set_label (GTK_FRAME (widget), title);435 }436 437 // EVENTBOX //438 439 /**440 \brief Creates a new EventBox with default settings.441 */442 EventBox::EventBox ()443 {444 this->init();445 }446 /**447 \brief Creates a new EventBox with name title448 \param title title the Eventbox should get (only data-structure-internal)449 */450 EventBox::EventBox (char* title)451 {452 this->init();453 this->setTitle(title);454 455 }456 457 /**458 \brief Initializes a new EventBox459 */460 void EventBox::init(void)461 {462 is_option = -1;463 464 static_cast<Container*>(this)->init();465 466 widget = gtk_event_box_new ();467 gtk_container_set_border_width (GTK_CONTAINER (widget), 3);468 469 }470 471 /**472 \brief Sets the Title of the EventBox (not implemented)473 \param title Name the EventBox should get (only datastructure-internal).474 */475 void EventBox::setTitle (char* title)476 {477 label = title;478 }479 480 /* BOX */481 482 /**483 \brief Creates a new horizontal Box484 */485 Box::Box (void)486 {487 this->init('h');488 }489 490 /**491 \brief Creates a new Box of type boxtype492 \param boxtype if 'v' the Box will be vertically, if 'h' the Box will be horizontally493 */494 Box::Box (char boxtype)495 {496 this->init(boxtype);497 }498 499 /**500 \brief Initializes a new Box with type boxtype501 \param boxtype see Box(char boxtype)502 */503 void Box::init(char boxtype)504 {505 is_option = -2;506 507 static_cast<Packer*>(this)->init();508 if (boxtype == 'v')509 {510 widget = gtk_vbox_new (FALSE, 0);511 }512 else513 {514 widget = gtk_hbox_new (FALSE, 0);515 }516 }517 518 /**519 \brief Fills a box with a given Widget.520 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 Next521 \param lowerWidget the next Widget that should be appendet to this Box522 */523 void Box::fill (Widget *lowerWidget)524 {525 gtk_box_pack_start (GTK_BOX (this->widget), lowerWidget->widget, TRUE, TRUE, 0);526 if (this->down == NULL)527 this->down = lowerWidget;528 else529 {530 Widget* tmp;531 tmp = this->down;532 while (tmp->next != NULL)533 {534 tmp = tmp->next;535 }536 tmp->next = lowerWidget;537 }538 }539 540 /* IMAGE */541 542 /**543 \brief Creates a new Image544 \param imagename the location of the Image on the Hard Disc545 */546 Image::Image (char* imagename)547 {548 this->init();549 widget = gtk_image_new_from_file (imagename);550 label = imagename;551 }552 553 /**554 \brief Initializes a new Image555 */556 void Image::init()557 {558 is_option = 0;559 560 static_cast<Widget*>(this)->init();561 }562 563 564 /* OPTION */565 566 /**567 \brief Initializes a new Option.568 sets all Option-Specific-Values to their defaults.569 */570 void Option::init()571 {572 value = 0;573 flag_name = "";574 flag_name_short = "";575 saveable = false;576 default_value = 0;577 578 static_cast<Widget*>(this)->init();579 580 return;581 }582 583 /**584 \brief This sets The FlagName of an Option and defines its default Values585 !! Options will be saved if flagname is different from "" !!586 \param flagname the Name that will be displayed in the output587 \param defaultvalue the default Value for this Option (see definition of defaultvalue588 */589 void Option::setFlagName (char* flagname, int defaultvalue)590 {591 flag_name = flagname;592 default_value = defaultvalue;593 cout << "Set Flagname of " << label << " to " << flagname << endl;594 }595 596 /**597 \brief see Option::setFlagName (char* flagname, int defaultvalue)598 \param flagname the Name that will be displayed in the output599 \param defaultvalue the default Value for this Option (see definition of defaultvalue600 \param flagnameshort a short flagname to be displayed in the output601 */602 void Option::setFlagName (char* flagname, char* flagnameshort, int defaultvalue)603 {604 flag_name = flagname;605 flag_name_short = flagnameshort;606 default_value = defaultvalue;607 cout << "Set Flagname of " << label << " to " << flagname << endl;608 }609 610 611 /* BUTTON */612 613 /**614 \brief Creates a new Button with a buttonname615 \param buttonname sets the Name of the Button616 */617 Button::Button(char* buttonname)618 {619 this->init();620 this->setTitle(buttonname);621 }622 623 /**624 \brief Initializes a new Button625 */626 void Button::init(void)627 {628 is_option = 0;629 630 static_cast<Option*>(this)->init();631 632 widget = gtk_button_new_with_label ("");633 }634 635 /**636 \brief Sets a new name to the Button637 \param title The name the Button should get638 */639 void Button::setTitle (char *title)640 {641 label = title;642 gtk_button_set_label (GTK_BUTTON(widget), title);643 }644 645 /**646 \brief redraws the Button647 not implemented yet648 */649 void Button::redraw ()650 {651 }652 653 /* CHECKBUTTON */654 655 /**656 \brief Creates a new CheckButton with an ame657 \param buttonname The name the CheckButton should display.658 */659 CheckButton::CheckButton (char* buttonname)660 {661 this->init();662 this->setTitle(buttonname);663 664 this->connectSignal ("clicked", this->OptionChange);665 }666 667 /**668 \brief Initialize a new CheckButton with default settings669 */670 void CheckButton::init(void)671 {672 is_option = 1;673 674 static_cast<Option*>(this)->init();675 676 widget = gtk_check_button_new_with_label ("");677 }678 679 /**680 \brief Sets a new Title to a CheckButton681 \param title The new Name the CheckButton should display.682 */683 void CheckButton::setTitle(char* title)684 {685 label = title;686 gtk_button_set_label(GTK_BUTTON(widget), title);687 }688 689 690 /**691 \brief Signal OptionChange writes the Value from the CheckButton to its Object-Database.692 \param widget The widget(CheckButton) that has a changed Value693 \param checkbutton the CheckButton-Object that should receive the change.694 */695 gint CheckButton::OptionChange (GtkWidget *widget, Widget* checkbutton)696 {697 static_cast<CheckButton*>(checkbutton)->value = (int)gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON ((CheckButton*)checkbutton->widget));698 flags->setTextFromFlags(orxonoxGUI);699 cout << static_cast<CheckButton*>(checkbutton)->label << " set to: " << static_cast<CheckButton*>(checkbutton)->value << endl;700 }701 702 /**703 \brief Redraws the CheckButton (if option has changed).704 Example: if new settings are loaded the Button must be redrawn for the GUI to display that Change705 */706 void CheckButton::redraw ()707 {708 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);709 }710 711 /* SLIDER */712 713 /**714 \brief Creates a new Slider715 \param slidername The data-structure-name of the slider.716 \param start The minimal Value of the slider.717 \param end The maximal Value of the slider.718 */719 Slider::Slider (char* slidername, int start, int end)720 {721 this->init(start, end);722 this->setValue(start);723 this->setTitle(slidername);724 this->connectSignal ("value_changed", this->OptionChange);725 }726 727 /**728 \brief Initializes a Slider with start and end Values729 params: see Slider::Slider (char* slidername, int start, int end)730 */731 void Slider::init(int start, int end)732 {733 is_option = 2;734 735 static_cast<Option*>(this)->init();736 737 widget = gtk_hscale_new_with_range (start, end, 5);738 }739 740 /**741 \brief Sets a new Title to the Slider742 \param title The new Name of the slider743 */744 void Slider::setTitle(char* title)745 {746 label = title;747 }748 749 /**750 \brief Setting a new value to the Slider.751 Maybe you also require a Slider::redraw() for this to display752 */753 void Slider::setValue(int value)754 {755 this->value = value;756 }757 758 /**759 \brief Signal OptionChange writes the Value from the Slider to its Object-Database.760 \param widget The widget(Slider) that has a changed Value761 \param slider the Slider-Object that should receive the change.762 */763 gint Slider::OptionChange (GtkWidget *widget, Widget* slider)764 {765 static_cast<Slider*>(slider)->value = (int)gtk_range_get_value (GTK_RANGE ((Slider*)slider->widget));766 flags->setTextFromFlags(orxonoxGUI);767 cout << static_cast<Slider*>(slider)->label << " set to: "<< static_cast<Slider*>(slider)->value << endl;768 }769 770 /**771 \brief Redraws the widget772 Example: see void CheckButton::redraw ()773 */774 void Slider::redraw ()775 {776 gtk_range_set_value (GTK_RANGE (widget), value);777 }778 779 /* MENU */780 781 /**782 \brief Creates a Menu-Item-list out of multiple input.783 !! Consider, that the last input argument has to be "lastItem" for this to work!!784 \param menuname The Database-Name of this Menu785 \param ... items to be added to this Menu. !! Consider, that the last input argument has to be "lastItem" for this to work!!786 */787 Menu::Menu (char* menuname, ...)788 {789 this->init();790 this->setTitle(menuname);791 792 char *itemName;793 794 va_start (itemlist, menuname);795 while (strcmp (itemName = va_arg (itemlist, char*), "lastItem"))796 {797 this->addItem(itemName);798 }799 va_end(itemlist);800 801 gtk_option_menu_set_menu (GTK_OPTION_MENU (widget), menu);802 this->connectSignal ("changed", this->OptionChange);803 }804 805 /**806 \brief Initializes a new Menu with no items807 */808 void Menu::init(void)809 {810 is_option = 2;811 812 static_cast<Option*>(this)->init();813 814 widget = gtk_option_menu_new ();815 menu = gtk_menu_new ();816 817 }818 819 /**820 * Sets the Database-Name of this Menu821 \param title Database-Name to be set.822 */823 void Menu::setTitle(char* title)824 {825 label = title;826 }827 828 /**829 \brief appends a new Item to the Menu-List.830 \param itemName the itemName to be appendet.831 */832 void Menu::addItem (char* itemName)833 {834 item = gtk_menu_item_new_with_label (itemName);835 gtk_menu_shell_append(GTK_MENU_SHELL (menu), item);836 }837 838 /**839 \brief Signal OptionChange writes the Value from the Menu to its Object-Database.840 \param widget The widget(Menu) that has a changed Value841 \param menu the Menu-Object that should receive the change.842 */843 gint Menu::OptionChange (GtkWidget *widget, Widget* menu)844 {845 static_cast<Menu*>(menu)->value = (int)gtk_option_menu_get_history (GTK_OPTION_MENU (menu->widget));846 flags->setTextFromFlags(orxonoxGUI);847 cout << static_cast<Menu*>(menu)->label << " changed to : " << static_cast<Menu*>(menu)->value << endl;848 }849 850 /**851 \brief Redraws the widget852 Example: see void CheckButton::redraw ()853 */854 void Menu::redraw ()855 {856 gtk_option_menu_set_history (GTK_OPTION_MENU (widget), value);857 }858 859 /**860 \brief Creates a new default Label with no Text.861 You migth consider adding Label::setTitle with this.862 */863 Label:: Label ()864 {865 this->init();866 }867 868 /**869 \brief Creates a new Label with a Text.870 \param text The text to be displayed.871 */872 Label:: Label (char* text)873 {874 this->init();875 this->setText(text);876 }877 878 /**879 \brief initializes a new Label880 */881 void Label::init(void)882 {883 is_option = 0;884 885 static_cast<Widget*>(this)->init();886 887 widget = gtk_label_new ("");888 gtk_label_set_line_wrap (GTK_LABEL(widget), TRUE);889 }890 891 /**892 \brief Sets a new Text to a Label.893 \param text The text to be inserted into the Label.894 */895 void Label::setText (char* text)896 {897 label = text;898 gtk_label_set_text (GTK_LABEL (this->widget), text);899 }900 901 /**902 \brief get the Text of a Label903 \return The Text the Label holds.904 */905 char* Label::getText ()906 {907 return ((char*)gtk_label_get_text (GTK_LABEL (this->widget)));908 } -
orxonox/trunk/gui/orxonox_gui.h
r2740 r3144 10 10 #include <config.h> 11 11 #endif 12 13 #include "orxonox_gui_gtk.h" 12 14 13 15 #include <stdlib.h> … … 36 38 }; 37 39 38 //! This is the topmost object that can be displayed all others are derived from it.39 class Widget40 {41 private:42 public:43 ~Widget ();44 40 45 Widget* next; //!< next always points to the next Widget in the list. Every Widget has a next one, or has NULL as next46 GtkWidget* widget; //!< widget is the gtk_widget that the specific Object Contains.47 void init(void);48 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-option49 /**50 \briefdefines is_option states51 */52 enum option { containerType = -2, boxType = -1, nothingType = 0, boolType = 1, intType = 2};53 char* label; //!< The name of the Widget. Some do display it, Options need it to save;54 void connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *));55 void connectSignal (char* event, gint (*signal)(GtkWidget*, Widget *));56 void connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *));57 void connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *));58 void show ();59 void hide ();60 void setSize(int width, int height);61 62 void walkThrough (void (*function)(Widget*));63 static void listOptions (Widget* widget);64 static void setOptions (Widget* widget);65 66 };67 68 //! This is a Packer Object, which has the ability to Pack other Widgets into itself.69 class Packer : public Widget70 {71 public:72 Widget* down; //!< this points to the Widget below this.73 char* groupName; //!< For each Packer you can specify a Groupname under which the lowerWidgets will be saved.74 75 void init(void);76 void setGroupName (char* name);77 char* getGroupName (void);78 };79 80 //! This is a Container Class, it can contain one sub-Widget: down.81 /**82 * A Container is a Widget that can hold a subWidget in addition to a next-Widget.83 * The Container can by itself not be displayed created or used.84 * The derived classes of Container can be displayed85 */86 class Container : public Packer87 {88 private:89 int borderwidth;90 int policy;91 92 public:93 void init(void);94 // void setBorderWidth (int borderwidth);95 // virtual void setTitle (char* title) = 0;96 void fill (Widget *lowerWidget);97 };98 99 //! Window is the class that creates new Windows, and handels them100 /**101 * A Window is a class derived from Container that contains a window-widget.102 * It has the ability to hold one sub-object103 */104 class Window : public Container105 {106 private:107 bool isOpen;108 public:109 static Window* lastWindow;110 Window (void);111 Window (char* windowName);112 void init ();113 114 void setTitle (char* title);115 void showall ();116 static gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data);117 };118 119 //! Frame is the class that handles frames120 /**121 * A Frame is an object, that has a border and if you like a name on it.122 * It can contain a Widget, which means that you can insert anything you like inside of a frame123 */124 class Frame :public Container125 {126 public:127 Frame (char* frameName);128 Frame (void);129 void init(void);130 131 void setTitle (char* title);132 };133 134 //! EventBox is a Container that can Handle all Events happening inside of it.135 /**136 * Example: if you have a picture, and you want it to catch mouse-clicks, you have to pack it inside a EventBox137 */138 class EventBox : public Container139 {140 public:141 EventBox (char* eventBoxName);142 EventBox (void);143 void init(void);144 145 void setTitle (char* title);146 };147 148 //! A Box can contain multiple Widgets149 /**150 * A Box can Contain multiple Widgets, that are ordered either horizontally or vertically151 * I defined the standartbox to be horizontally.152 * A Box is always filled left->right (horizontally) or up->down (vertically)153 */154 class Box : public Packer155 {156 public:157 Box (void);158 Box (char boxtype);159 void init(char boxtype);160 161 void fill (Widget* lowerWidget);162 163 };164 165 //! Image is the keeper of one Image166 /**167 * Images are mighty cool.168 * Images can help you lighten up the Programming process, and will give everyone a better impression of the Software.169 */170 class Image : public Widget171 {172 public:173 Image (char* imgaename);174 void init(void);175 };176 177 //! An Option is a Widget that contains something that may change its state.178 /**179 * Options are the essence of a GUI, they: Configure, Start, Quit, Execute, and make it worth something180 */181 class Option : public Widget182 {183 public:184 //virtual gint OptionChange (GtkWidget *widget, GdkEvent *event, gpointer data);185 void init(void);186 187 int value; //!< every option has a value either true or false (0,1) or something else like 25 for 25% of the volume188 char* flag_name; //!< options have a flag name that will be appendet if you start the Program from the GUI.189 char* flag_name_short; //!< like flag_name but shorter190 int default_value; //!< A default value is good, for hiding a option if it is not needed. (hidden if value == default_value)191 bool saveable;192 193 void setFlagName (char* flagname, int defaultvalue);194 void setFlagName (char* flagname, char* flagnameshort, int defaultvalue);195 virtual void redraw () = 0; //!< A Option must be able to redraw itself.196 };197 198 //! Buttons can be pressed, and released.199 /**200 * Buttons are mainly there for executing some action like Starting the Programm, or Quiting it.201 */202 class Button : public Option203 {204 public:205 Button (char* buttonname);206 void init(void);207 208 void setTitle(char* title);209 210 void redraw();211 };212 213 //! CheckButtons are a key in configuring bool Variables214 /** CheckButtons can configure bool Variables like wireframe on/off, enable_sound etc.215 */216 class CheckButton : public Option217 {218 public:219 CheckButton (char* buttonname);220 static gint OptionChange (GtkWidget* widget, Widget* checkbutton);221 222 void init(void);223 void setTitle(char* title);224 225 void redraw ();226 };227 228 //! Sliders are Options that can be modified in their value229 /**230 * good for volume, brightness, etc.231 */232 class Slider : public Option233 {234 public:235 Slider (char* slidername,int start, int end);236 void init(int start, int end);237 238 void setTitle(char* title);239 void setValue(int value);240 241 static gint OptionChange (GtkWidget* widget, Widget* slider);242 void redraw();243 };244 245 //! A Menu is an Option that has a dropdown menu, where you can chose between different Items246 class Menu : public Option247 {248 private:249 GtkWidget* menu;250 GtkWidget* item;251 va_list itemlist;252 253 public:254 Menu (char* menuname, ...);255 void init(void);256 257 void setTitle(char* title);258 259 void addItem(char* itemName);260 static gint OptionChange (GtkWidget* widget, Widget* menu);261 void redraw();262 };263 264 //! A label is a Widget, that displays a text265 class Label : public Widget266 {267 public:268 Label ();269 Label (char* text);270 void init(void);271 272 void setText (char* text);273 char* getText ();274 };275 276 //gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data);277 41 278 42 #endif /* _ORXONOX_GUI_H */
Note: See TracChangeset
for help on using the changeset viewer.