Changeset 3315 in orxonox.OLD for orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc
- Timestamp:
- Jan 3, 2005, 12:13:38 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc
r3313 r3315 50 50 gdk_threads_init(); 51 51 #endif /* HAVE_GTHREAD */ 52 gtk_init 52 gtk_init(&argc, &argv); 53 53 gtk_rc_parse( "rc" ); 54 54 #endif /* HAVE_GTK2 */ … … 138 138 This is still pretty crappy. 139 139 */ 140 Widget::~Widget( )140 Widget::~Widget(void) 141 141 { 142 142 this->destroy(); … … 147 147 Initializes the next Pointer and the other Widget-specific Defaults. 148 148 */ 149 void Widget::init( )149 void Widget::init(void) 150 150 { 151 151 next = NULL; … … 181 181 \brief makes the widget visible. 182 182 */ 183 void Widget::show( )184 { 185 #ifdef HAVE_GTK2 186 gtk_widget_show 183 void Widget::show(void) 184 { 185 #ifdef HAVE_GTK2 186 gtk_widget_show(this->widget); 187 187 #endif /* HAVE_GTK2 */ 188 188 } … … 191 191 \brief hides the widget. 192 192 */ 193 void Widget::hide( )194 { 195 #ifdef HAVE_GTK2 196 gtk_widget_hide 193 void Widget::hide(void) 194 { 195 #ifdef HAVE_GTK2 196 gtk_widget_hide(this->widget); 197 197 #endif /* HAVE_GTK2 */ 198 198 } … … 206 206 { 207 207 #ifdef HAVE_GTK2 208 gtk_widget_set_usize 208 gtk_widget_set_usize(this->widget, width, height); 209 209 #endif /* HAVE_GTK2 */ 210 210 } … … 237 237 \param depth the current depth. if > 0 then the next Widget will also be walked through. 238 238 */ 239 void Widget::walkThrough (void(*function)(Widget*), unsigned int depth)239 void Widget::walkThrough(void(*function)(Widget*), unsigned int depth) 240 240 { 241 241 function(this); 242 242 if (this->isOption < 0) 243 243 { 244 static_cast<Packer*>(this)->down->walkThrough 244 static_cast<Packer*>(this)->down->walkThrough(function, depth+1); 245 245 } 246 246 … … 255 255 \param depth the current depth. if > 0 then the next Widget will also be walked through. 256 256 */ 257 void Widget::walkThrough (void(*function)(Widget*, void*), void* data, unsigned int depth)257 void Widget::walkThrough(void(*function)(Widget*, void*), void* data, unsigned int depth) 258 258 { 259 259 function(this, data); … … 270 270 \param widget specifies the widget that should be listed 271 271 */ 272 void Widget::listOptionsAndGroups 272 void Widget::listOptionsAndGroups(Widget* widget) 273 273 { 274 274 if (widget->isOption < 0 && static_cast<Packer*>(widget)->groupName) … … 284 284 \param widget specifies the widget that should be listed 285 285 */ 286 void Widget::listOptions 286 void Widget::listOptions(Widget* widget) 287 287 { 288 288 if (widget->isOption >= 1 && widget->isOption <= 3) … … 297 297 \param data A Counter, that always knows how many Options have been found yet. 298 298 */ 299 void Widget::listOptions 299 void Widget::listOptions(Widget* widget, void* data) 300 300 { 301 301 302 302 if (widget->isOption >= 1 && widget->isOption <= 3) 303 303 { 304 int* count = 304 int* count =(int*)data; 305 305 *count = *count +1; 306 306 cout << *count << ": " << static_cast<Option*>(widget)->title <<" is : " << static_cast<Option*>(widget)->value <<endl; … … 308 308 else if (widget->isOption == 5) 309 309 { 310 int* count = 310 int* count =(int*)data; 311 311 *count = *count +1; 312 312 cout << *count << ": " << static_cast<Option*>(widget)->title <<" is : " << static_cast<OptionLabel*>(widget)->cValue <<endl; … … 315 315 316 316 /** 317 \brief Finds an Option by a given number 318 \param number The Count of options to wait 317 \brief Finds an Option by a given number(the n'th option found away from this Widget) 318 \param number The Count of options to wait(by reference) 319 319 \param depth The depth of the sarch. if 0 it will not search next pointer 320 320 … … 349 349 void Widget::listGroups(Widget* widget) 350 350 { 351 if (widget->isOption < 0 && static_cast<Packer*>(widget)->groupName)351 if (widget->isOption < 0 && static_cast<Packer*>(widget)->groupName) 352 352 cout << "[" << static_cast<Packer*>(widget)->groupName << "]\n"; 353 353 } … … 356 356 \brief This is for listing the Groups of "widget". It also displays the n'th number found. 357 357 \param widget specifies the widget that should be listed 358 \param data the Counter, that will show the number 358 \param data the Counter, that will show the number(this function will raise it by one if a Group is fount. 359 359 */ 360 360 void Widget::listGroups(Widget* widget, void* data) 361 361 { 362 if (widget->isOption < 0 && static_cast<Packer*>(widget)->groupName)363 { 364 int* count = 362 if (widget->isOption < 0 && static_cast<Packer*>(widget)->groupName) 363 { 364 int* count =(int*)data; 365 365 *count = *count +1; 366 366 cout << *count <<": [" << static_cast<Packer*>(widget)->groupName << "]\n"; … … 369 369 370 370 /** 371 \brief Finds a Group by a given number 372 \param number The Count of options to wait 371 \brief Finds a Group by a given number(the n'th Group found away from this Widget) 372 \param number The Count of options to wait(by reference) 373 373 \param depth The depth of the sarch. if 0 it will not search next pointer 374 374 */ … … 399 399 \param widget specifies the widget that should be set. 400 400 */ 401 void Widget::setOptions 401 void Widget::setOptions(Widget* widget) 402 402 { 403 403 if (widget->isOption >= 1) … … 412 412 if (widget->isOption>=1) 413 413 { 414 Option* option = 415 char* name = 414 Option* option =(Option*)widget; 415 char* name =(char*)flagName; 416 416 char* value = NULL; 417 417 bool found = false; 418 418 // check if long flag matches 419 if ((option->flagName && strlen(name)>2 && !strncmp(name+2, option->flagName, strlen(option->flagName)) && 419 if ((option->flagName && strlen(name)>2 && !strncmp(name+2, option->flagName, strlen(option->flagName)) &&(name[strlen(option->flagName)+2] == '\0' || name[strlen(option->flagName)+2] == '=') )) 420 420 { 421 421 found = true; … … 425 425 } 426 426 } 427 else if (option->flagNameShort && strlen(name)>1 && !strncmp(name+1, option->flagNameShort, strlen(option->flagNameShort))&& 427 else if (option->flagNameShort && strlen(name)>1 && !strncmp(name+1, option->flagNameShort, strlen(option->flagNameShort))&&(name[strlen(option->flagNameShort)+1] == '\0' || name[strlen(option->flagNameShort)+1] == '=')) // check if short flag matches 428 428 { 429 429 found = true; … … 456 456 \brief Connect any signal to any given Sub-widget 457 457 */ 458 gulong Widget::connectSignal (char* event, gint(*signal)(GtkWidget*, GdkEvent*, void *))459 { 460 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK(signal), NULL);458 gulong Widget::connectSignal(char* event, gint(*signal)(GtkWidget*, GdkEvent*, void *)) 459 { 460 return g_signal_connect(G_OBJECT(this->widget), event, G_CALLBACK(signal), NULL); 461 461 } 462 462 … … 464 464 \brief Connect a signal with additionally passing the whole Object 465 465 */ 466 gulong Widget::connectSignal (char* event, gint(*signal)( GtkWidget*, Widget *))467 { 468 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK(signal), this);466 gulong Widget::connectSignal(char* event, gint(*signal)( GtkWidget*, Widget *)) 467 { 468 return g_signal_connect(G_OBJECT(this->widget), event, G_CALLBACK(signal), this); 469 469 } 470 470 … … 472 472 \brief Connect a signal with additionally passing a whole external Object 473 473 */ 474 gulong Widget::connectSignal (char* event, void* extObj, gint(*signal)(GtkWidget*, GdkEvent*, void *))475 { 476 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK(signal), extObj);474 gulong Widget::connectSignal(char* event, void* extObj, gint(*signal)(GtkWidget*, GdkEvent*, void *)) 475 { 476 return g_signal_connect(G_OBJECT(this->widget), event, G_CALLBACK(signal), extObj); 477 477 } 478 478 … … 480 480 \brief Connect a signal with additionally passing a whole external Object 481 481 */ 482 gulong Widget::connectSignal (char* event, void* extObj, gint(*signal)(GtkWidget*, void *))483 { 484 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK(signal), extObj);482 gulong Widget::connectSignal(char* event, void* extObj, gint(*signal)(GtkWidget*, void *)) 483 { 484 return g_signal_connect(G_OBJECT(this->widget), event, G_CALLBACK(signal), extObj); 485 485 } 486 486 … … 488 488 \brief Connect a signal with additionally passing a whole external Object 489 489 */ 490 gulong Widget::connectSignal (char* event, void* extObj, gint(*signal)(GtkWidget*, GdkEventKey*, void *))491 { 492 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK(signal), extObj);493 } 494 495 void Widget::disconnectSignal 496 { 497 g_signal_handler_disconnect (G_OBJECT(this->widget), signalID);490 gulong Widget::connectSignal(char* event, void* extObj, gint(*signal)(GtkWidget*, GdkEventKey*, void *)) 491 { 492 return g_signal_connect(G_OBJECT(this->widget), event, G_CALLBACK(signal), extObj); 493 } 494 495 void Widget::disconnectSignal(gulong signalID) 496 { 497 g_signal_handler_disconnect(G_OBJECT(this->widget), signalID); 498 498 } 499 499 … … 504 504 \param nothing nothin. 505 505 */ 506 gint Widget::doNothingSignal 506 gint Widget::doNothingSignal(GtkWidget *widget, GdkEvent* event, void* nothing) 507 507 { 508 508 } … … 519 519 Sets the down-pinter to NULL and other PackerSpecific-values to their defaults. 520 520 */ 521 void Packer::init 522 { 523 down = NULL;524 groupName = NULL;521 void Packer::init(void) 522 { 523 this->down = NULL; 524 this->groupName = NULL; 525 525 526 526 … … 536 536 PRINTF(4)("deleting the Packer part.\n"); 537 537 538 if ( groupName)539 delete [] groupName;538 if (this->groupName) 539 delete []this->groupName; 540 540 541 541 //deleting recursively. … … 551 551 \param name The name of the group. 552 552 */ 553 void Packer::setGroupName 554 { 555 if ( groupName)556 delete groupName;557 groupName = new char[strlen(name)+1];558 strcpy( groupName, name);553 void Packer::setGroupName(char* name) 554 { 555 if (this->groupName) 556 delete []this->groupName; 557 this->groupName = new char[strlen(name)+1]; 558 strcpy(this->groupName, name); 559 559 } 560 560 … … 563 563 \returns name The name of the group. 564 564 */ 565 char* Packer::getGroupName 566 { 567 return groupName;565 char* Packer::getGroupName(void) 566 { 567 return this->groupName; 568 568 } 569 569 … … 575 575 sets the Container-Specific defaults. 576 576 */ 577 void Container::init 578 { 579 isOption = -1;577 void Container::init(void) 578 { 579 this->isOption = -1; 580 580 581 581 static_cast<Packer*>(this)->init(); … … 600 600 It does this by filling up the down pointer only if down points to NULL. 601 601 */ 602 void Container::fill 602 void Container::fill(Widget *lowerWidget) 603 603 { 604 604 if (this->down == NULL) 605 605 { 606 606 #ifdef HAVE_GTK2 607 gtk_container_add (GTK_CONTAINER(this->widget), lowerWidget->widget);607 gtk_container_add(GTK_CONTAINER(this->widget), lowerWidget->widget); 608 608 #endif /* HAVE_GTK2 */ 609 609 this->down = lowerWidget; … … 613 613 } 614 614 615 // gtk_container_set_border_width (GTK_CONTAINER(widget), 5);615 // gtk_container_set_border_width(GTK_CONTAINER(widget), 5); 616 616 617 617 /* WINDOW */ … … 622 622 \brief Adds a new Window Windows to the List of Windows. 623 623 \param windowToAdd The Windows that should be added to the List 624 \todo this instead of windowToAdd 624 \todo this instead of windowToAdd(possibly) 625 625 */ 626 626 void Window::addWindow(Window* windowToAdd) … … 633 633 634 634 Widget* tmpWindow = mainWindow; 635 while 635 while(tmpWindow->next) 636 636 tmpWindow = tmpWindow->next; 637 637 tmpWindow->next = windowToAdd; … … 644 644 \brief Creating a new Window without a Name 645 645 */ 646 Window::Window 646 Window::Window(void) 647 647 { 648 648 this->init(); … … 654 654 */ 655 655 656 Window::Window 656 Window::Window(char* windowName) 657 657 { 658 658 this->init(); 659 this->setTitle 659 this->setTitle(windowName); 660 660 } 661 661 … … 671 671 \brief initializes a new Window 672 672 */ 673 void Window::init( )673 void Window::init(void) 674 674 { 675 675 if (!mainWindow) … … 681 681 682 682 #ifdef HAVE_GTK2 683 widget = gtk_window_new 684 gtk_window_set_policy 683 widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); 684 gtk_window_set_policy(GTK_WINDOW(widget), TRUE, TRUE, TRUE); 685 685 #if !defined(__WIN32__) 686 // gtk_window_set_decorated (GTK_WINDOW(widget), FALSE);686 // gtk_window_set_decorated(GTK_WINDOW(widget), FALSE); 687 687 #endif 688 gtk_container_set_border_width (GTK_CONTAINER(widget), 3);688 gtk_container_set_border_width(GTK_CONTAINER(widget), 3); 689 689 #endif /* HAVE_GTK2 */ 690 690 } … … 708 708 \brief Shows all Widgets that are included within this->widget. 709 709 */ 710 void Window::showall ()711 { 712 if (! isOpen)713 { 714 // printf 715 #ifdef HAVE_GTK2 716 gtk_widget_show_all (widget);710 void Window::showall(void) 711 { 712 if (!this->isOpen) 713 { 714 // printf("showall\n"); 715 #ifdef HAVE_GTK2 716 gtk_widget_show_all(this->widget); 717 717 #endif /* HAVE_GTK2 */ 718 isOpen = true;718 this->isOpen = true; 719 719 } 720 720 else 721 721 { 722 // printf 723 #ifdef HAVE_GTK2 724 gtk_widget_show (widget);722 // printf("showone\n"); 723 #ifdef HAVE_GTK2 724 gtk_widget_show(this->widget); 725 725 #endif /* HAVE_GTK2 */ 726 726 } … … 731 731 \param title title the Window should get. 732 732 */ 733 void Window::setTitle 733 void Window::setTitle(char* title) 734 734 { 735 735 if (this->title) … … 738 738 strcpy(this->title, title); 739 739 #ifdef HAVE_GTK2 740 gtk_window_set_title (GTK_WINDOW(widget), title);740 gtk_window_set_title(GTK_WINDOW(widget), title); 741 741 #endif /* HAVE_GTK2 */ 742 742 } … … 745 745 \brief opens up a Window and fixes the Focus to it 746 746 */ 747 void Window::open( )747 void Window::open(void) 748 748 { 749 749 if (this != mainWindow) … … 751 751 isOpen = true; 752 752 #ifdef HAVE_GTK2 753 gtk_widget_show_all( widget);754 gtk_grab_add( widget);753 gtk_widget_show_all(this->widget); 754 gtk_grab_add(this->widget); 755 755 #endif /* HAVE_GTK2 */ 756 756 } … … 760 760 \brief closes up a Window and removes the Focus from it 761 761 */ 762 void Window::close( )762 void Window::close(void) 763 763 { 764 764 if (this != mainWindow) 765 765 { 766 isOpen = false;767 #ifdef HAVE_GTK2 768 gtk_grab_remove( widget);769 gtk_widget_hide (widget);770 #endif /* HAVE_GTK2 */ 771 } 772 } 773 774 #ifdef HAVE_GTK2 775 /** 776 \brief opens up a window 766 this->isOpen = false; 767 #ifdef HAVE_GTK2 768 gtk_grab_remove(this->widget); 769 gtk_widget_hide(this->widget); 770 #endif /* HAVE_GTK2 */ 771 } 772 } 773 774 #ifdef HAVE_GTK2 775 /** 776 \brief opens up a window(not topmost Window). 777 777 this is the Signal that does it. !!SIGNALS ARE STATIC!! 778 778 \param widget the widget that did it. … … 780 780 \param window the Window that should be opened 781 781 */ 782 gint Window::windowOpen 782 gint Window::windowOpen(GtkWidget *widget, GdkEvent* event, void* window) 783 783 { 784 784 static_cast<Window*>(window)->open(); … … 786 786 787 787 /** 788 \brief closes a window 788 \brief closes a window(not topmost Window). 789 789 this is the Signal that does it. !!SIGNALS ARE STATIC!! 790 790 \param widget the widget that did it! … … 792 792 \param window the Window that should be closed 793 793 */ 794 gint Window::windowClose 794 gint Window::windowClose(GtkWidget *widget, GdkEvent* event, void* window) 795 795 { 796 796 static_cast<Window*>(window)->close(); … … 805 805 \brief Creates a new Frame without a name 806 806 */ 807 Frame::Frame 807 Frame::Frame(void) 808 808 { 809 809 this->init(); … … 813 813 \brief Creates a new Frame with name title 814 814 */ 815 Frame::Frame 815 Frame::Frame(char* title) 816 816 { 817 817 this->init(); … … 822 822 \brief destrcucts a Frame 823 823 */ 824 Frame::~Frame( )824 Frame::~Frame(void) 825 825 { 826 826 this->destroy(); … … 830 830 \brief Initializes a new Frame with default settings 831 831 */ 832 void Frame::init( )832 void Frame::init(void) 833 833 { 834 834 static_cast<Container*>(this)->init(); 835 835 836 836 #ifdef HAVE_GTK2 837 widget = gtk_frame_new("");838 gtk_container_set_border_width (GTK_CONTAINER (widget), 3);837 this->widget = gtk_frame_new(""); 838 gtk_container_set_border_width(GTK_CONTAINER(this->widget), 3); 839 839 #endif /* HAVE_GTK2 */ 840 840 } … … 857 857 \param title The title the Frame should get. 858 858 */ 859 void Frame::setTitle 859 void Frame::setTitle(char* title) 860 860 { 861 861 if (this->title) … … 864 864 strcpy(this->title, title); 865 865 #ifdef HAVE_GTK2 866 gtk_frame_set_label (GTK_FRAME(widget), title);866 gtk_frame_set_label(GTK_FRAME(widget), title); 867 867 #endif /* HAVE_GTK2 */ 868 868 } … … 873 873 \brief Creates a new EventBox with default settings. 874 874 */ 875 EventBox::EventBox 875 EventBox::EventBox(void) 876 876 { 877 877 this->init(); … … 880 880 /** 881 881 \brief Creates a new EventBox with name title 882 \param title title the Eventbox should get 883 */ 884 EventBox::EventBox 882 \param title title the Eventbox should get(only data-structure-internal) 883 */ 884 EventBox::EventBox(char* title) 885 885 { 886 886 this->init(); … … 902 902 void EventBox::init(void) 903 903 { 904 isOption = -1;904 this->isOption = -1; 905 905 906 906 static_cast<Container*>(this)->init(); 907 907 908 908 #ifdef HAVE_GTK2 909 widget = gtk_event_box_new();910 gtk_container_set_border_width (GTK_CONTAINER (widget), 3);909 this->widget = gtk_event_box_new(); 910 gtk_container_set_border_width(GTK_CONTAINER(this->widget), 3); 911 911 #endif /* HAVE_GTK2 */ 912 912 } … … 926 926 927 927 /** 928 \brief Sets the Title of the EventBox 929 \param title Name the EventBox should get 930 */ 931 void EventBox::setTitle 928 \brief Sets the Title of the EventBox(not implemented) 929 \param title Name the EventBox should get(only datastructure-internal). 930 */ 931 void EventBox::setTitle(char* title) 932 932 { 933 933 if (this->title) … … 942 942 \brief Creates a new horizontal Box 943 943 */ 944 Box::Box 944 Box::Box(void) 945 945 { 946 946 this->init('h'); … … 951 951 \param boxtype if 'v' the Box will be vertically, if 'h' the Box will be horizontally 952 952 */ 953 Box::Box 953 Box::Box(char boxtype) 954 954 { 955 955 this->init(boxtype); … … 970 970 void Box::init(char boxtype) 971 971 { 972 isOption = -2;972 this->isOption = -2; 973 973 974 974 static_cast<Packer*>(this)->init(); … … 976 976 if (boxtype == 'v') 977 977 { 978 widget = gtk_vbox_new(FALSE, 0);978 this->widget = gtk_vbox_new(FALSE, 0); 979 979 } 980 980 else 981 981 { 982 widget = gtk_hbox_new(FALSE, 0);982 this->widget = gtk_hbox_new(FALSE, 0); 983 983 } 984 984 #endif /* HAVE_GTK2 */ … … 1004 1004 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 1005 1005 */ 1006 void Box::fill (Widget *lowerWidget)1007 { 1008 #ifdef HAVE_GTK2 1009 gtk_box_pack_start (GTK_BOX(this->widget), lowerWidget->widget, TRUE, TRUE, 0);1006 void Box::fill(Widget* lowerWidget) 1007 { 1008 #ifdef HAVE_GTK2 1009 gtk_box_pack_start(GTK_BOX(this->widget), lowerWidget->widget, TRUE, TRUE, 0); 1010 1010 #endif /* HAVE_GTK2 */ 1011 1011 if (this->down == NULL) … … 1015 1015 Widget* tmp; 1016 1016 tmp = this->down; 1017 while 1017 while(tmp->next != NULL) 1018 1018 { 1019 1019 tmp = tmp->next; … … 1041 1041 sets all Option-Specific-Values to their defaults. 1042 1042 */ 1043 void Option::init( )1044 { 1045 value = 0;1046 flagName = NULL;1047 flagNameShort = NULL;1048 saveable = false;1049 defaultValue = 0;1043 void Option::init(void) 1044 { 1045 this->value = 0; 1046 this->flagName = NULL; 1047 this->flagNameShort = NULL; 1048 this->saveable = false; 1049 this->defaultValue = 0; 1050 1050 1051 1051 static_cast<Widget*>(this)->init(); … … 1060 1060 { 1061 1061 PRINTF(4)("deleting the Option Part.\n"); 1062 if ( flagName)1063 delete [] flagName;1064 if ( flagNameShort)1065 delete [] flagNameShort;1062 if (this->flagName) 1063 delete []this->flagName; 1064 if (this->flagNameShort) 1065 delete []this->flagNameShort; 1066 1066 1067 1067 static_cast<Widget*>(this)->destroy(); … … 1072 1072 !! Options will be saved if flagname is different from NULL !! 1073 1073 \param flagname the Name that will be displayed in the output 1074 \param defaultvalue the default Value for this Option 1075 */ 1076 void Option::setFlagName 1077 { 1078 if ( flagName)1079 delete flagName;1080 flagName = new char [strlen(flagname)+1];1081 strcpy( flagName, flagname);1082 defaultValue = defaultvalue;1074 \param defaultvalue the default Value for this Option(see definition of defaultvalue 1075 */ 1076 void Option::setFlagName(char* flagname, int defaultvalue) 1077 { 1078 if (this->flagName) 1079 delete this->flagName; 1080 this->flagName = new char [strlen(flagname)+1]; 1081 strcpy(this->flagName, flagname); 1082 this->defaultValue = defaultvalue; 1083 1083 1084 1084 // cout << "Set Flagname of " << this->title << " to " << flagname << endl; … … 1086 1086 1087 1087 /** 1088 \brief see Option::setFlagName 1088 \brief see Option::setFlagName(char* flagname, int defaultvalue) 1089 1089 \param flagname the Name that will be displayed in the output 1090 \param defaultvalue the default Value for this Option 1090 \param defaultvalue the default Value for this Option(see definition of defaultvalue 1091 1091 \param flagnameshort a short flagname to be displayed in the output 1092 1092 */ 1093 void Option::setFlagName 1094 { 1095 if ( flagName)1096 delete flagName;1097 flagName = new char [strlen(flagname)+1];1098 strcpy( flagName, flagname);1099 1100 if ( flagNameShort)1101 delete flagNameShort;1102 flagNameShort = new char [strlen(flagnameshort)+1];1103 strcpy( flagNameShort, flagnameshort);1104 defaultValue = defaultvalue;1093 void Option::setFlagName(char* flagname, char* flagnameshort, int defaultvalue) 1094 { 1095 if (this->flagName) 1096 delete []this->flagName; 1097 this->flagName = new char [strlen(flagname)+1]; 1098 strcpy(this->flagName, flagname); 1099 1100 if (this->flagNameShort) 1101 delete []this->flagNameShort; 1102 this->flagNameShort = new char [strlen(flagnameshort)+1]; 1103 strcpy(this->flagNameShort, flagnameshort); 1104 this->defaultValue = defaultvalue; 1105 1105 // cout << "Set Flagname of " << this->title << " to " << flagname << endl; 1106 1106 } … … 1137 1137 \param slider the Slider-Object that should receive the change. 1138 1138 */ 1139 gint Option::OptionChange 1139 gint Option::OptionChange(GtkWidget *widget, Widget* option) 1140 1140 { 1141 1141 static_cast<Option*>(option)->changeOption(); 1142 flags->setTextFromFlags( orxonoxGUI); //// must be different !!!1142 flags->setTextFromFlags(Window::mainWindow); //// must be different !!! 1143 1143 } 1144 1144 #endif /* HAVE_GTK2 */ … … 1175 1175 1176 1176 #ifdef HAVE_GTK2 1177 widget = gtk_button_new_with_label 1177 widget = gtk_button_new_with_label(""); 1178 1178 #endif /* HAVE_GTK2 */ 1179 1179 } … … 1196 1196 \param title The name the Button should get 1197 1197 */ 1198 void Button::setTitle 1198 void Button::setTitle(char *title) 1199 1199 { 1200 1200 if (this->title) … … 1203 1203 strcpy(this->title, title); 1204 1204 #ifdef HAVE_GTK2 1205 gtk_button_set_label 1205 gtk_button_set_label(GTK_BUTTON(widget), title); 1206 1206 #endif /* HAVE_GTK2 */ 1207 1207 } … … 1211 1211 not implemented yet 1212 1212 */ 1213 void Button::redraw 1213 void Button::redraw(void) 1214 1214 { 1215 1215 } … … 1217 1217 /** 1218 1218 \brief Button can not be changed, optionChange is empty) 1219 1220 \todo Actions for non-GTK-mode 1219 1221 */ 1220 1222 void Button::changeOption(void) … … 1229 1231 \param buttonname The name the CheckButton should display. 1230 1232 */ 1231 CheckButton::CheckButton 1233 CheckButton::CheckButton(char* buttonname) 1232 1234 { 1233 1235 this->init(); … … 1235 1237 1236 1238 #ifdef HAVE_GTK2 1237 this->connectSignal 1239 this->connectSignal("clicked", this->OptionChange); 1238 1240 #endif /* HAVE_GTK2 */ 1239 1241 } … … 1252 1254 void CheckButton::init(void) 1253 1255 { 1254 isOption = 1;1256 this->isOption = 1; 1255 1257 1256 1258 static_cast<Option*>(this)->init(); 1257 1259 1258 1260 #ifdef HAVE_GTK2 1259 widget = gtk_check_button_new_with_label("");1261 this->widget = gtk_check_button_new_with_label(""); 1260 1262 #endif /* HAVE_GTK2 */ 1261 1263 } … … 1289 1291 } 1290 1292 1291 bool CheckButton::isActive( )1293 bool CheckButton::isActive(void) 1292 1294 { 1293 1295 #ifdef HAVE_GTK2 … … 1299 1301 \brief Changed the Option, call this Function 1300 1302 */ 1301 void CheckButton::changeOption( )1302 { 1303 #ifdef HAVE_GTK2 1304 this->value = (int)gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(this->widget));1303 void CheckButton::changeOption(void) 1304 { 1305 #ifdef HAVE_GTK2 1306 this->value =(int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(this->widget)); 1305 1307 #else /* HAVE_GTK2 */ 1306 1308 char tmpChar[20]; … … 1316 1318 1317 1319 /** 1318 \brief Redraws the CheckButton 1320 \brief Redraws the CheckButton(if option has changed). 1319 1321 Example: if new settings are loaded the Button must be redrawn for the GUI to display that Change 1320 1322 */ 1321 void CheckButton::redraw ()1322 { 1323 #ifdef HAVE_GTK2 1324 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);1323 void CheckButton::redraw(void) 1324 { 1325 #ifdef HAVE_GTK2 1326 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(this->widget), value); 1325 1327 #endif /* HAVE_GTK2 */ 1326 1328 } … … 1334 1336 \param end The maximal Value of the slider. 1335 1337 */ 1336 Slider::Slider 1338 Slider::Slider(char* slidername, int start, int end) 1337 1339 { 1338 1340 this->init(start, end); … … 1340 1342 this->setTitle(slidername); 1341 1343 #ifdef HAVE_GTK2 1342 this->connectSignal 1344 this->connectSignal("value_changed", this->OptionChange); 1343 1345 #endif /* HAVE_GTK2 */ 1344 1346 } … … 1354 1356 /** 1355 1357 \brief Initializes a Slider with start and end Values 1356 params: see Slider::Slider 1358 params: see Slider::Slider(char* slidername, int start, int end) 1357 1359 */ 1358 1360 void Slider::init(int start, int end) 1359 1361 { 1360 isOption = 2;1362 this->isOption = 2; 1361 1363 1362 1364 static_cast<Option*>(this)->init(); … … 1365 1367 this->end = end; 1366 1368 #ifdef HAVE_GTK2 1367 widget = gtk_hscale_new_with_range (start,end, 5);1369 widget = gtk_hscale_new_with_range(this->start, this->end, 5); 1368 1370 #endif /* HAVE_GTK2 */ 1369 1371 } … … 1406 1408 /** 1407 1409 \brief Redraws the widget 1408 Example: see void CheckButton::redraw ()1409 */ 1410 void Slider::redraw ()1411 { 1412 #ifdef HAVE_GTK2 1413 gtk_range_set_value (GTK_RANGE (widget), value);1410 Example: see void CheckButton::redraw(void) 1411 */ 1412 void Slider::redraw(void) 1413 { 1414 #ifdef HAVE_GTK2 1415 gtk_range_set_value(GTK_RANGE(this->widget), value); 1414 1416 #endif /* HAVE_GTK2 */ 1415 1417 } … … 1418 1420 \brief Changed the Option, call this Function 1419 1421 */ 1420 void Slider::changeOption( )1421 { 1422 #ifdef HAVE_GTK2 1423 this->value = 1422 void Slider::changeOption(void) 1423 { 1424 #ifdef HAVE_GTK2 1425 this->value =(int)gtk_range_get_value(GTK_RANGE(this->widget)); 1424 1426 #else /* HAVE_GTK2 */ 1425 1427 char tmpChar[20]; … … 1443 1445 \param ... items to be added to this Menu. !! Consider, that the last input argument has to be "lastItem" for this to work!! 1444 1446 */ 1445 Menu::Menu 1447 Menu::Menu(char* menuname, ...) 1446 1448 { 1447 1449 this->init(); … … 1451 1453 1452 1454 #ifdef HAVE_GTK2 /////////////////////// REINPLEMENT 1453 va_start 1454 while (strcmp (itemName = va_arg(itemlist, char*), "lastItem"))1455 va_start(itemlist, menuname); 1456 while(strcmp(itemName = va_arg(itemlist, char*), "lastItem")) 1455 1457 { 1456 1458 this->addItem(itemName); … … 1460 1462 1461 1463 #ifdef HAVE_GTK2 1462 gtk_option_menu_set_menu (GTK_OPTION_MENU (widget), menu);1463 this->connectSignal 1464 gtk_option_menu_set_menu(GTK_OPTION_MENU(this->widget), menu); 1465 this->connectSignal("changed", this->OptionChange); 1464 1466 #endif /* HAVE_GTK2 */ 1465 1467 } … … 1478 1480 void Menu::init(void) 1479 1481 { 1480 isOption = 2;1482 this->isOption = 2; 1481 1483 1482 1484 static_cast<Option*>(this)->init(); 1483 1485 1484 1486 #ifdef HAVE_GTK2 1485 widget = gtk_option_menu_new();1486 menu = gtk_menu_new();1487 this->widget = gtk_option_menu_new(); 1488 this->menu = gtk_menu_new(); 1487 1489 #endif /* HAVE_GTK2 */ 1488 1490 … … 1519 1521 \brief appends a new Item to the Menu-List. 1520 1522 \param itemName the itemName to be appendet. 1521 */ 1522 void Menu::addItem (char* itemName) 1523 { 1524 #ifdef HAVE_GTK2 1525 item = gtk_menu_item_new_with_label (itemName); 1526 gtk_menu_shell_append(GTK_MENU_SHELL (menu), item); 1523 1524 \todo make the item-list readable without GTK 1525 */ 1526 void Menu::addItem(char* itemName) 1527 { 1528 #ifdef HAVE_GTK2 1529 this->item = gtk_menu_item_new_with_label(itemName); 1530 gtk_menu_shell_append(GTK_MENU_SHELL(this->menu), this->item); 1527 1531 #endif /* HAVE_GTK2 */ 1528 1532 } … … 1530 1534 /** 1531 1535 \brief Redraws the widget 1532 Example: see void CheckButton::redraw ()1533 */ 1534 void Menu::redraw ()1535 { 1536 #ifdef HAVE_GTK2 1537 gtk_option_menu_set_history (GTK_OPTION_MENU (widget),value);1536 Example: see void CheckButton::redraw(void) 1537 */ 1538 void Menu::redraw(void) 1539 { 1540 #ifdef HAVE_GTK2 1541 gtk_option_menu_set_history(GTK_OPTION_MENU(this->widget), this->value); 1538 1542 #endif /* HAVE_GTK2 */ 1539 1543 } … … 1542 1546 \brief Changed the Option, call this Function 1543 1547 */ 1544 void Menu::changeOption( )1545 { 1546 #ifdef HAVE_GTK2 1547 this->value = (int)gtk_option_menu_get_history (GTK_OPTION_MENU(this->widget));1548 void Menu::changeOption(void) 1549 { 1550 #ifdef HAVE_GTK2 1551 this->value =(int)gtk_option_menu_get_history(GTK_OPTION_MENU(this->widget)); 1548 1552 #else /* HAVE_GTK2 */ 1549 1553 char tmpChar[20]; 1550 cout << "\nPlease give me a new value for " << this->title << " 1554 cout << "\nPlease give me a new value for " << this->title << "(defualt:" << this->defaultValue << "): "; 1551 1555 cin >> tmpChar; 1552 1556 this->value = atoi(tmpChar); … … 1561 1565 \brief Creates a new OptionLabel with a LabelName and a Value. 1562 1566 \param label The name of the OptionLabel. 1563 \param value The Value of the OptionLabel 1567 \param value The Value of the OptionLabel(what will be displayed). 1564 1568 */ 1565 1569 OptionLabel::OptionLabel(char* label, char* value) 1566 1570 { 1567 init();1568 setTitle(label);1569 setValue(value);1571 this->init(); 1572 this->setTitle(label); 1573 this->setValue(value); 1570 1574 } 1571 1575 … … 1583 1587 void OptionLabel::init(void) 1584 1588 { 1589 this->isOption = 5; 1585 1590 static_cast<Option*>(this)->init(); 1586 isOption = 5; 1591 1587 1592 cValue = NULL; 1588 1593 1589 1594 #ifdef HAVE_GTK2 1590 widget = gtk_label_new("");1595 this->widget = gtk_label_new(""); 1591 1596 #endif /* HAVE_GTK2 */ 1592 1597 } … … 1601 1606 else 1602 1607 PRINTF(3)("deleting the OptionLabel.\n"); 1603 if ( cValue)1604 delete [] cValue;1608 if (this->cValue) 1609 delete []this->cValue; 1605 1610 1606 1611 static_cast<Option*>(this)->destroy(); … … 1614 1619 void OptionLabel::setValue(char* newValue) 1615 1620 { 1616 if ( cValue)1617 delete cValue;1618 cValue = new char [strlen(newValue)+1];1619 strcpy( cValue, newValue);1620 #ifdef HAVE_GTK2 1621 gtk_label_set_text (GTK_LABEL (widget),cValue);1621 if (this->cValue) 1622 delete []this->cValue; 1623 this->cValue = new char [strlen(newValue)+1]; 1624 strcpy(this->cValue, newValue); 1625 #ifdef HAVE_GTK2 1626 gtk_label_set_text(GTK_LABEL(this->widget), this->cValue); 1622 1627 #endif /* HAVE_GTK2 */ 1623 1628 } … … 1633 1638 this->title = new char [strlen(title)+1]; 1634 1639 strcpy(this->title, title); 1635 #ifdef HAVE_GTK2 1636 gtk_label_set_text (GTK_LABEL(widget), title); 1637 #endif /* HAVE_GTK2 */ 1638 } 1639 1640 /** 1641 \brief Redraws an OptionLabel (not implemented yet, but it works). 1640 this->redraw(); 1641 } 1642 1643 /** 1644 \brief Redraws an OptionLabel(not implemented yet, but it works). 1642 1645 */ 1643 1646 void OptionLabel::redraw(void) 1644 1647 { 1645 1648 #ifdef HAVE_GTK2 1649 gtk_label_set_text(GTK_LABEL(widget), title); 1650 #endif /* HAVE_GTK2 */ 1646 1651 } 1647 1652 … … 1649 1654 \brief Changed the Option, call this Function 1650 1655 */ 1651 void OptionLabel::changeOption( )1652 { 1653 #ifdef HAVE_GTK2 1654 this->cValue = (char*)gtk_label_get_text(GTK_LABEL(this->widget));1656 void OptionLabel::changeOption(void) 1657 { 1658 #ifdef HAVE_GTK2 1659 this->cValue =(char*)gtk_label_get_text(GTK_LABEL(this->widget)); 1655 1660 #else /* HAVE_GTK2 */ 1656 1661 cout << "\nPlease give me a new input for " << this->title << ": "; … … 1665 1670 You migth consider adding Label::setTitle with this. 1666 1671 */ 1667 Label::Label ()1672 Label::Label(void) 1668 1673 { 1669 1674 this->init(); … … 1674 1679 \param text The text to be displayed. 1675 1680 */ 1676 Label:: Label 1681 Label:: Label(char* text) 1677 1682 { 1678 1683 this->init(); … … 1693 1698 void Label::init(void) 1694 1699 { 1695 isOption = 0;1700 this->isOption = 0; 1696 1701 1697 1702 static_cast<Widget*>(this)->init(); 1698 1703 1699 1704 #ifdef HAVE_GTK2 1700 widget = gtk_label_new("");1701 gtk_label_set_line_wrap (GTK_LABEL(widget), TRUE);1705 this->widget = gtk_label_new(""); 1706 gtk_label_set_line_wrap(GTK_LABEL(this->widget), TRUE); 1702 1707 #endif /* HAVE_GTK2 */ 1703 1708 } … … 1727 1732 strcpy(this->title, text); 1728 1733 #ifdef HAVE_GTK2 1729 gtk_label_set_text (GTK_LABEL (this->widget), text);1734 gtk_label_set_text(GTK_LABEL(this->widget), this->title); 1730 1735 #endif /* HAVE_GTK2 */ 1731 1736 } … … 1759 1764 1760 1765 #ifdef HAVE_GTK2 1761 gtk_label_set_text (GTK_LABEL(this->widget), title);1766 gtk_label_set_text(GTK_LABEL(this->widget), title); 1762 1767 #endif /* HAVE_GTK2 */ 1763 1768 } … … 1771 1776 void Label::appendInt(int intToAppend) 1772 1777 { 1773 char append [ 20];1778 char append [32]; 1774 1779 sprintf(append, "%d", intToAppend); 1775 1780 this->appendText(append); … … 1781 1786 \return The Text the Label holds. 1782 1787 */ 1783 char* Label::getText ()1788 char* Label::getText(void) 1784 1789 { 1785 1790 return this->title; … … 1789 1794 \brief Creates a new ProgressBar. 1790 1795 */ 1791 ProgressBar::ProgressBar 1792 { 1793 this->init 1796 ProgressBar::ProgressBar(void) 1797 { 1798 this->init(); 1794 1799 } 1795 1800 … … 1798 1803 \param label The name you want to get the ProgressBar. 1799 1804 */ 1800 ProgressBar::ProgressBar 1805 ProgressBar::ProgressBar(char* label) 1801 1806 { 1802 1807 this->init(); 1803 this->setTitle 1808 this->setTitle(label); 1804 1809 } 1805 1810 … … 1807 1812 \brief destructs a ProgressBar 1808 1813 */ 1809 ProgressBar::~ProgressBar ()1814 ProgressBar::~ProgressBar(void) 1810 1815 { 1811 1816 this->destroy(); … … 1815 1820 \brief Initializes a ProgressBar 1816 1821 */ 1817 void ProgressBar::init 1818 { 1819 isOption = 0;1820 progress = 0.0;1821 t otalSize = 0.0;1822 void ProgressBar::init(void) 1823 { 1824 this->isOption = 0; 1825 this->progress = 0.0; 1826 this->totalSize = 0.0; 1822 1827 1823 1828 static_cast<Widget*>(this)->init(); 1824 1829 #ifdef HAVE_GTK2 1825 adjustment =(GtkAdjustment*)gtk_adjustment_new(0, 0, 100, 0, 0, 0);1826 widget = gtk_progress_bar_new_with_adjustment(adjustment);1830 this->adjustment =(GtkAdjustment*)gtk_adjustment_new(0, 0, 100, 0, 0, 0); 1831 this->widget = gtk_progress_bar_new_with_adjustment(this->adjustment); 1827 1832 #endif /* HAVE_GTK2 */ 1828 1833 } … … 1854 1859 1855 1860 /** 1856 \brief Sets the Total size of the Bar. 1857 */ 1858 void ProgressBar::setTotalSize 1861 \brief Sets the Total size of the Bar.(ex. The maximum one can download) 1862 */ 1863 void ProgressBar::setTotalSize(double totalSize) 1859 1864 { 1860 1865 this->totalSize = totalSize; … … 1864 1869 \brief Sets the progress maximum is this->totalSize 1865 1870 */ 1866 void ProgressBar::setProgress 1871 void ProgressBar::setProgress(double progress) 1867 1872 { 1868 1873 this->progress = progress; … … 1874 1879 gtk_progress_set_value(GTK_PROGRESS(widget), this->progress*100.0/this->totalSize); 1875 1880 #endif /* HAVE_GTK2 */ 1876 PRINTF(3)("Progress: %f\n", progress*100.0/totalSize);1881 PRINTF(3)("Progress: %f\n", this->progress*100.0/this->totalSize); 1877 1882 } 1878 1883 … … 1880 1885 \brief returns the Progress Status 1881 1886 */ 1882 double ProgressBar::getProgress 1887 double ProgressBar::getProgress(void) 1883 1888 { 1884 1889 return this->progress; … … 1891 1896 \param imagename the location of the Image on the Hard Disc 1892 1897 */ 1893 Image::Image 1898 Image::Image(char* imagename) 1894 1899 { 1895 1900 this->init(); … … 1900 1905 1901 1906 #ifdef HAVE_GTK2 1902 widget = gtk_image_new_from_file 1907 widget = gtk_image_new_from_file(imagename); 1903 1908 #endif /* HAVE_GTK2 */ 1904 1909 } … … 1915 1920 \brief Initializes a new Image 1916 1921 */ 1917 void Image::init( )1922 void Image::init(void) 1918 1923 { 1919 1924 isOption = 0;
Note: See TracChangeset
for help on using the changeset viewer.