Changeset 3165 in orxonox.OLD for orxonox/trunk/gui
- Timestamp:
- Dec 13, 2004, 2:17:30 AM (20 years ago)
- Location:
- orxonox/trunk/gui
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/gui/orxonox_gui.cc
r3164 r3165 34 34 35 35 */ 36 37 #include <gtk/gtkmain.h>38 39 36 #include "orxonox_gui.h" 40 37 #include "orxonox_gui_video.h" … … 66 63 OrxonoxGui::OrxonoxGui (int argc, char *argv[]) 67 64 { 68 65 #ifdef HAVE_GTK2 69 66 initGTK(argc, argv); 70 67 #endif 71 68 orxonoxGUI = new Window( "Grafical OrxOnoX loader, "PACKAGE_VERSION); 69 #ifdef HAVE_GTK2 72 70 orxonoxGUI->connectSignal ("destroy", orxonoxGUI->orxonox_gui_quit); 73 71 orxonoxGUI->connectSignal ("delete_event", orxonoxGUI->orxonox_gui_quit); 72 #endif /* HAVE_GTK2 */ 74 73 75 74 Box* windowBox = new Box ('h'); … … 111 110 112 111 112 #ifdef HAVE_GTK2 113 113 mainloopGTK(); 114 #endif 114 115 } 115 116 -
orxonox/trunk/gui/orxonox_gui_banner.cc
r3164 r3165 38 38 // Banner Window // 39 39 logoWindow = new Window("Logo"); 40 bannerEventBox->connectSignal ("button_press_event", logoWindow, Window::windowOpen); 40 41 #ifdef HAVE_GTK2 42 bannerEventBox->connectSignal ("button_press_event", logoWindow, Window::windowOpen); 41 43 42 44 logoWindow->connectSignal("destroy", logoWindow, Window::windowClose); 43 45 logoWindow->connectSignal("delete_event", logoWindow, Window::windowClose); 46 #endif /* HAVE_GTK2 */ 44 47 logoEventBox = new EventBox(); 45 48 logoBox = new Box('v'); … … 50 53 logoBox->fill(logoLabel); 51 54 logoBox->fill(logoEventBox); 55 #ifdef HAVE_GTK2 52 56 logoEventBox->connectSignal("button_press_event",logoWindow, Window::windowClose); 53 57 #endif /* HAVE_GTK2 */ 58 54 59 logoWindow->fill (logoBox); 55 60 -
orxonox/trunk/gui/orxonox_gui_exec.cc
r3162 r3165 41 41 42 42 start = new Button ("Start"); 43 #ifdef HAVE_GTK2 43 44 start->connectSignal ("clicked", startOrxonox); 45 #endif /* HAVE_GTK2 */ 44 46 execBox->fill (start); 45 47 saveSettings = new CheckButton ("Save Settings"); … … 56 58 execBox->fill (alwaysShow); 57 59 quit = new Button ("Quit"); 60 #ifdef HAVE_GTK2 58 61 quit->connectSignal ("clicked", orxonoxGUI->orxonox_gui_quit); 62 #endif /* HAVE_GTK2 */ 59 63 execBox->fill (quit); 60 64 … … 278 282 } 279 283 284 #ifdef HAVE_GTK2 280 285 /** 281 286 \brief Starts ORXONOX. (not really implemented yet, but the function is there.\n … … 288 293 cout << "Starting Orxonox" <<endl; 289 294 } 295 #endif /* HAVE_GTK2 */ -
orxonox/trunk/gui/orxonox_gui_exec.h
r3162 r3165 39 39 40 40 }; 41 #ifdef HAVE_GTK2 41 42 gint startOrxonox (GtkWidget *widget, Widget* data); 42 43 #endif /* HAVE_GTK2 */ 43 44 #endif /* _ORXONOX_GUI_EXEC_H */ -
orxonox/trunk/gui/orxonox_gui_gtk.cc
r3164 r3165 39 39 extern OrxonoxGuiExec* exec; 40 40 41 #ifdef HAVE_GTK2 41 42 bool initGTK(int argc, char *argv[]) 42 43 { … … 48 49 gtk_main(); 49 50 } 51 #endif /* HAVE_GTK2 */ 52 50 53 /* WIDGET */ 51 54 … … 87 90 void Widget::show() 88 91 { 92 #ifdef HAVE_GTK2 89 93 gtk_widget_show (this->widget); 94 #endif /* HAVE_GTK2 */ 90 95 } 91 96 … … 95 100 void Widget::hide() 96 101 { 102 #ifdef HAVE_GTK2 97 103 gtk_widget_hide (this->widget); 104 #endif /* HAVE_GTK2 */ 98 105 } 99 106 … … 105 112 void Widget::setSize(int width, int height) 106 113 { 114 #ifdef HAVE_GTK2 107 115 gtk_widget_set_usize (this->widget, width, height); 108 } 109 116 #endif /* HAVE_GTK2 */ 117 } 118 119 #ifdef HAVE_GTK2 110 120 /** 111 121 \brief Connect any signal to any given Sub-widget … … 144 154 g_signal_handler_disconnect (G_OBJECT (this->widget), signalID); 145 155 } 156 #endif /* HAVE_GTK2 */ 146 157 147 158 /** … … 181 192 } 182 193 194 #ifdef HAVE_GTK2 183 195 gint Widget::doNothingSignal (GtkWidget *widget, GdkEvent* event, void* nothing) 184 196 { 185 197 } 198 #endif /* HAVE_GTK2 */ 186 199 187 200 //void deleteWidget(Widget* lastWidget) … … 249 262 if (this->down == NULL) 250 263 { 264 #ifdef HAVE_GTK2 251 265 gtk_container_add (GTK_CONTAINER (this->widget), lowerWidget->widget); 266 #endif /* HAVE_GTK2 */ 252 267 this->down = lowerWidget; 253 268 } … … 310 325 static_cast<Container*>(this)->init(); 311 326 327 #ifdef HAVE_GTK2 312 328 widget = gtk_window_new (GTK_WINDOW_TOPLEVEL); 313 329 gtk_window_set_policy (GTK_WINDOW(widget), TRUE, TRUE, TRUE); … … 316 332 #endif 317 333 gtk_container_set_border_width (GTK_CONTAINER (widget), 3); 318 334 #endif /* HAVE_GTK2 */ 319 335 } 320 336 … … 327 343 { 328 344 printf ("showall\n"); 345 #ifdef HAVE_GTK2 329 346 gtk_widget_show_all (widget); 330 isOpen = true; 347 #endif /* HAVE_GTK2 */ 348 isOpen = true; 331 349 } 332 350 else 333 351 { 334 352 printf ("showone\n"); 353 #ifdef HAVE_GTK2 335 354 gtk_widget_show (widget); 355 #endif /* HAVE_GTK2 */ 336 356 } 337 357 } … … 347 367 label = new char[strlen(title)+1]; 348 368 strcpy(label, title); 369 #ifdef HAVE_GTK2 349 370 gtk_window_set_title (GTK_WINDOW (widget), title); 371 #endif /* HAVE_GTK2 */ 350 372 } 351 373 … … 358 380 { 359 381 isOpen = true; 382 #ifdef HAVE_GTK2 360 383 gtk_widget_show_all(widget); 361 384 gtk_grab_add(widget); 385 #endif /* HAVE_GTK2 */ 362 386 } 363 387 } … … 371 395 { 372 396 isOpen = false; 397 #ifdef HAVE_GTK2 373 398 gtk_grab_remove(widget); 374 399 gtk_widget_hide (widget); 400 #endif /* HAVE_GTK2 */ 375 401 } 376 402 } 377 403 404 #ifdef HAVE_GTK2 378 405 /** 379 406 \brief opens up a window (not topmost Window). … … 415 442 return FALSE; 416 443 } 444 #endif /* HAVE_GTK2 */ 417 445 418 446 … … 442 470 { 443 471 static_cast<Container*>(this)->init(); 444 472 473 #ifdef HAVE_GTK2 445 474 widget = gtk_frame_new (""); 446 475 gtk_container_set_border_width (GTK_CONTAINER (widget), 3); 476 #endif /* HAVE_GTK2 */ 447 477 } 448 478 … … 457 487 label = new char[strlen(title)+1]; 458 488 strcpy(label, title); 489 #ifdef HAVE_GTK2 459 490 gtk_frame_set_label (GTK_FRAME (widget), title); 491 #endif /* HAVE_GTK2 */ 460 492 } 461 493 … … 488 520 static_cast<Container*>(this)->init(); 489 521 522 #ifdef HAVE_GTK2 490 523 widget = gtk_event_box_new (); 491 524 gtk_container_set_border_width (GTK_CONTAINER (widget), 3); 492 525 #endif /* HAVE_GTK2 */ 493 526 } 494 527 … … 533 566 534 567 static_cast<Packer*>(this)->init(); 568 #ifdef HAVE_GTK2 535 569 if (boxtype == 'v') 536 570 { … … 541 575 widget = gtk_hbox_new (FALSE, 0); 542 576 } 577 #endif /* HAVE_GTK2 */ 578 543 579 } 544 580 … … 550 586 void Box::fill (Widget *lowerWidget) 551 587 { 588 #ifdef HAVE_GTK2 552 589 gtk_box_pack_start (GTK_BOX (this->widget), lowerWidget->widget, TRUE, TRUE, 0); 590 #endif /* HAVE_GTK2 */ 553 591 if (this->down == NULL) 554 592 this->down = lowerWidget; … … 579 617 580 618 this->init(); 619 #ifdef HAVE_GTK2 581 620 widget = gtk_image_new_from_file (imagename); 621 #endif /* HAVE_GTK2 */ 582 622 } 583 623 … … 671 711 static_cast<Option*>(this)->init(); 672 712 713 #ifdef HAVE_GTK2 673 714 widget = gtk_button_new_with_label (""); 715 #endif /* HAVE_GTK2 */ 674 716 } 675 717 … … 684 726 label = new char[strlen(title)+1]; 685 727 strcpy(label, title); 728 #ifdef HAVE_GTK2 686 729 gtk_button_set_label (GTK_BUTTON(widget), title); 730 #endif /* HAVE_GTK2 */ 687 731 } 688 732 … … 706 750 this->setTitle(buttonname); 707 751 752 #ifdef HAVE_GTK2 708 753 this->connectSignal ("clicked", this->OptionChange); 754 #endif /* HAVE_GTK2 */ 709 755 } 710 756 … … 718 764 static_cast<Option*>(this)->init(); 719 765 766 #ifdef HAVE_GTK2 720 767 widget = gtk_check_button_new_with_label (""); 768 #endif /* HAVE_GTK2 */ 721 769 } 722 770 … … 731 779 label = new char[strlen(title)+1]; 732 780 strcpy(label, title); 781 #ifdef HAVE_GTK2 733 782 gtk_button_set_label(GTK_BUTTON(widget), title); 783 #endif /* HAVE_GTK2 */ 734 784 } 735 785 736 786 bool CheckButton::isActive() 737 787 { 788 #ifdef HAVE_GTK2 738 789 return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); 739 } 740 790 #endif /* HAVE_GTK2 */ 791 } 792 793 #ifdef HAVE_GTK2 741 794 /** 742 795 \brief Signal OptionChange writes the Value from the CheckButton to its Object-Database. … … 750 803 cout << static_cast<CheckButton*>(checkbutton)->label << " set to: " << static_cast<CheckButton*>(checkbutton)->value << endl; 751 804 } 805 #endif /* HAVE_GTK2 */ 752 806 753 807 /** … … 757 811 void CheckButton::redraw () 758 812 { 813 #ifdef HAVE_GTK2 759 814 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value); 815 #endif /* HAVE_GTK2 */ 760 816 } 761 817 … … 773 829 this->setValue(start); 774 830 this->setTitle(slidername); 831 #ifdef HAVE_GTK2 775 832 this->connectSignal ("value_changed", this->OptionChange); 833 #endif /* HAVE_GTK2 */ 776 834 } 777 835 … … 786 844 static_cast<Option*>(this)->init(); 787 845 788 widget = gtk_hscale_new_with_range (start, end, 5); 846 #ifdef HAVE_GTK2 847 widget = gtk_hscale_new_with_range (start, end, 5); 848 #endif /* HAVE_GTK2 */ 789 849 } 790 850 … … 810 870 } 811 871 872 #ifdef HAVE_GTK2 812 873 /** 813 874 \brief Signal OptionChange writes the Value from the Slider to its Object-Database. … … 821 882 cout << static_cast<Slider*>(slider)->label << " set to: "<< static_cast<Slider*>(slider)->value << endl; 822 883 } 884 #endif /* HAVE_GTK2 */ 823 885 824 886 /** … … 828 890 void Slider::redraw () 829 891 { 892 #ifdef HAVE_GTK2 830 893 gtk_range_set_value (GTK_RANGE (widget), value); 894 #endif /* HAVE_GTK2 */ 831 895 } 832 896 … … 845 909 846 910 char *itemName; 847 911 912 #ifdef HAVE_GTK2 /////////////////////// REINPLEMENT 848 913 va_start (itemlist, menuname); 849 914 while (strcmp (itemName = va_arg (itemlist, char*), "lastItem")) … … 852 917 } 853 918 va_end(itemlist); 854 919 #endif /* HAVE_GTK2 */ 920 921 #ifdef HAVE_GTK2 855 922 gtk_option_menu_set_menu (GTK_OPTION_MENU (widget), menu); 856 923 this->connectSignal ("changed", this->OptionChange); 924 #endif /* HAVE_GTK2 */ 857 925 } 858 926 … … 866 934 static_cast<Option*>(this)->init(); 867 935 936 #ifdef HAVE_GTK2 868 937 widget = gtk_option_menu_new (); 869 938 menu = gtk_menu_new (); 939 #endif /* HAVE_GTK2 */ 870 940 871 941 } … … 889 959 void Menu::addItem (char* itemName) 890 960 { 961 #ifdef HAVE_GTK2 891 962 item = gtk_menu_item_new_with_label (itemName); 892 963 gtk_menu_shell_append(GTK_MENU_SHELL (menu), item); 893 } 894 964 #endif /* HAVE_GTK2 */ 965 } 966 967 #ifdef HAVE_GTK2 895 968 /** 896 969 \brief Signal OptionChange writes the Value from the Menu to its Object-Database. … … 904 977 cout << static_cast<Menu*>(menu)->label << " changed to : " << static_cast<Menu*>(menu)->value << endl; 905 978 } 979 #endif /* HAVE_GTK2 */ 906 980 907 981 /** … … 911 985 void Menu::redraw () 912 986 { 913 gtk_option_menu_set_history (GTK_OPTION_MENU (widget), value); 987 #ifdef HAVE_GTK2 988 gtk_option_menu_set_history (GTK_OPTION_MENU (widget), value); 989 #endif /* HAVE_GTK2 */ 914 990 } 915 991 … … 927 1003 cValue = NULL; 928 1004 1005 #ifdef HAVE_GTK2 929 1006 widget = gtk_label_new (""); 930 } 1007 #endif /* HAVE_GTK2 */ 1008 } 1009 931 1010 void OptionLabel::setValue(char* newValue) 932 1011 { … … 935 1014 cValue = new char [strlen(newValue)+1]; 936 1015 strcpy(cValue, newValue); 1016 #ifdef HAVE_GTK2 937 1017 gtk_label_set_text (GTK_LABEL (widget), cValue); 1018 #endif /* HAVE_GTK2 */ 938 1019 } 939 1020 … … 944 1025 label = new char [strlen(title)+1]; 945 1026 strcpy(label, title); 1027 #ifdef HAVE_GTK2 946 1028 gtk_label_set_text (GTK_LABEL (widget), title); 1029 #endif /* HAVE_GTK2 */ 947 1030 } 948 1031 … … 980 1063 static_cast<Widget*>(this)->init(); 981 1064 1065 #ifdef HAVE_GTK2 982 1066 widget = gtk_label_new (""); 983 1067 gtk_label_set_line_wrap (GTK_LABEL(widget), TRUE); 1068 #endif /* HAVE_GTK2 */ 984 1069 } 985 1070 … … 994 1079 label = new char[strlen(text)+1]; 995 1080 strcpy(label, text); 1081 #ifdef HAVE_GTK2 996 1082 gtk_label_set_text (GTK_LABEL (this->widget), text); 1083 #endif /* HAVE_GTK2 */ 997 1084 } 998 1085 … … 1003 1090 char* Label::getText () 1004 1091 { 1005 return ((char*)gtk_label_get_text (GTK_LABEL (this->widget)));1006 } 1092 return label; 1093 } -
orxonox/trunk/gui/orxonox_gui_gtk.h
r3164 r3165 11 11 #endif 12 12 13 #ifdef HAVE_GTK2 13 14 #include <gtk/gtkmain.h> 14 15 #include <gtk/gtkwindow.h> … … 25 26 #include <gtk/gtkimage.h> 26 27 #include <gtk/gtkeventbox.h> 27 28 #endif /* HAVE_GTK2 */ 29 30 #ifdef HAVE_GTK2 28 31 bool initGTK(int argc, char *argv[]); 29 32 bool mainloopGTK(void); 33 #endif /* HAVE_GTK2 */ 34 30 35 31 36 //! This is the topmost object that can be displayed all others are derived from it. … … 37 42 38 43 Widget* next; //!< next always points to the next Widget in the list. Every Widget has a next one, or has NULL as next 44 #ifdef HAVE_GTK2 39 45 GtkWidget* widget; //!< widget is the gtk_widget that the specific Object Contains. 46 #endif /* HAVE_GTK2 */ 40 47 void init(void); 41 48 int isOption; //!< with this Paramenter one can set the option-type: -2:Container, -1: Box, 0: not an Option, 1: Bool-option, 2: int-option, 3: float option, 4:char option, 5: char* option … … 45 52 enum option { containerType = -2, boxType = -1, nothingType = 0, boolType = 1, intType = 2}; 46 53 char* label; //!< The name of the Widget. Some do display it, Options need it to save; 54 #ifdef HAVE_GTK2 47 55 gulong connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *)); 48 56 gulong connectSignal (char* event, gint (*signal)(GtkWidget*, Widget *)); … … 50 58 gulong connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *)); 51 59 void disconnectSignal (gulong signalID); 60 #endif /* HAVE_GTK2 */ 52 61 void show (); 53 62 void hide (); … … 58 67 static void setOptions (Widget* widget); 59 68 69 #ifdef HAVE_GTK2 60 70 static gint doNothingSignal (GtkWidget *widget, GdkEvent* event, void* nothing); 71 #endif /* HAVE_GTK2 */ 61 72 }; 62 73 … … 114 125 void close(); 115 126 127 #ifdef HAVE_GTK2 116 128 static gint windowOpen (GtkWidget *widget, GdkEvent* event, void* window); 117 129 static gint windowClose (GtkWidget *widget, GdkEvent* event, void* window); 118 130 static gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data); 131 #endif /* HAVE_GTK2 */ 119 132 }; 120 133 … … 220 233 public: 221 234 CheckButton (char* buttonname); 235 #ifdef HAVE_GTK2 222 236 static gint OptionChange (GtkWidget* widget, Widget* checkbutton); 237 #endif /* HAVE_GTK2 */ 223 238 224 239 void init(void); … … 242 257 void setValue(int value); 243 258 259 #ifdef HAVE_GTK2 244 260 static gint OptionChange (GtkWidget* widget, Widget* slider); 261 #endif /* HAVE_GTK2 */ 245 262 void redraw(); 246 263 }; … … 250 267 { 251 268 private: 269 #ifdef HAVE_GTK2 252 270 GtkWidget* menu; 253 271 GtkWidget* item; 272 #endif /* HAVE_GTK2 */ 254 273 va_list itemlist; 255 274 … … 261 280 262 281 void addItem(char* itemName); 282 #ifdef HAVE_GTK2 263 283 static gint OptionChange (GtkWidget* widget, Widget* menu); 284 #endif /* HAVE_GTK2 */ 264 285 void redraw(); 265 286 }; -
orxonox/trunk/gui/orxonox_gui_keys.cc
r3164 r3165 68 68 69 69 closeButton = new Button("close"); 70 #ifdef HAVE_GTK2 70 71 closeButton->connectSignal("button_press_event", pKeyWindow, Window::windowClose); 72 #endif /* HAVE_GTK2 */ 71 73 72 74 pKeysBox->fill(closeButton); … … 74 76 pKeyWindow->fill(pKeyFrame); 75 77 Window::addWindow(pKeyWindow); 78 #ifdef HAVE_GTK2 76 79 pKeyWindow->connectSignal("destroy", pKeyWindow, Window::windowClose); 77 80 pKeyWindow->connectSignal("delete_event", pKeyWindow, Window::windowClose); 81 #endif /* HAVE_GTK2 */ 78 82 79 83 openButton = new Button (player); 84 #ifdef HAVE_GTK2 80 85 openButton->connectSignal("button_press_event", pKeyWindow, Window::windowOpen); 86 #endif /* HAVE_GTK2 */ 81 87 82 88 inputWindow = new Window("inputWindow"); … … 84 90 inputButton = new Button ("test"); 85 91 inputWindow->fill (inputButton); 92 #ifdef HAVE_GTK2 86 93 inputWindow->connectSignal("destroy", Widget::doNothingSignal); 87 94 inputWindow->connectSignal("delete_event", Widget::doNothingSignal); 95 #endif /* HAVE_GTK2 */ 88 96 89 97 } … … 96 104 inputKey[key]->pKeyOLabel = new OptionLabel (name, name); 97 105 inputKey[key]->pKeyOLabel->saveable = true; 98 106 107 #ifdef HAVE_GTK2 99 108 //inputKey[key]->pKeyButton->connectSignal("key_press_event", inputKey[key]->pKeyButton, key_cb); 100 109 inputKey[key]->pKeyButton->connectSignal("button_press_event", inputKey[key], inputWindowEvent); 110 #endif /* HAVE_GTK2 */ 101 111 102 112 inputKey[key]->pKeyBox->fill(inputKey[key]->pKeyButton); … … 120 130 long Player::keySignal = 0; 121 131 132 #ifdef HAVE_GTK2 122 133 gint Player::inputWindowEvent(GtkWidget* w, GdkEventKey* event, void* inputKey) 123 134 { … … 264 275 inputWindow->close(); 265 276 } 277 #endif /* HAVE_GTK2 */ -
orxonox/trunk/gui/orxonox_gui_keys.h
r3163 r3165 8 8 9 9 #include "orxonox_gui.h" 10 #ifdef HAVE_GTK2 10 11 #include <gdk/gdkkeysyms.h> 11 12 #endif /* HAVE_GTK2 */ 12 13 /** 13 14 * defines the Possible Player Keys … … 62 63 Button* getOpenButton(); 63 64 65 #ifdef HAVE_GTK2 64 66 static gint inputWindowEvent(GtkWidget* w, GdkEventKey* event, void* widget); 65 67 static gint key_cb(GtkWidget* w, GdkEventKey* event, void* inputKey); 68 #endif /* HAVE_GTK2 */ 66 69 void setkey(KEYS key); 67 70
Note: See TracChangeset
for help on using the changeset viewer.