Changeset 3165 in orxonox.OLD for orxonox/trunk/gui/orxonox_gui_gtk.cc
- Timestamp:
- Dec 13, 2004, 2:17:30 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.