Changeset 3289 in orxonox.OLD for orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc
- Timestamp:
- Dec 26, 2004, 3:44:44 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc
r3288 r3289 64 64 gtk_main(); 65 65 gdk_threads_leave(); 66 } 67 #endif /* HAVE_GTK2 */ 66 delete Window::mainWindow; 67 } 68 #endif /* HAVE_GTK2 */ 69 70 71 ////////////////////////////// 72 /// DEFINING WIDGET-CLASES /// 73 ////////////////////////////// 68 74 69 75 /* WIDGET */ … … 75 81 Widget::~Widget() 76 82 { 77 // cout << "hiding: " <<this->label <<"\n"; 78 this->hide(); 79 // cout << "check if Packer: "<<this->label <<"\n"; 80 if (this->isOption < 0) 81 { 82 // cout << "get Down "<<this->label <<"\n"; 83 static_cast<Packer*>(this)->down->~Widget(); 84 } 85 // cout << "next != NULL?: " <<this->label <<"\n"; 86 if (this->next != NULL) 87 this->next->~Widget(); 88 cout << "delete Widget: " <<this->label <<"\n"; 89 // delete widget; 83 this->destroy(); 90 84 } 91 85 … … 102 96 103 97 /** 98 \brief Destroys a Widget 99 */ 100 void Widget::destroy(void) 101 { 102 if (label) 103 { 104 delete []label; 105 } 106 107 PRINTF(4)("deleting the Widget part.\n"); 108 109 PRINTF(4)("deleting recursively\n"); 110 111 // deleting next item if existent 112 if (this->next) 113 delete this->next; 114 this->next = NULL; 115 116 //! \todo not hiding widget, deleting. 117 // this->hide(); 118 } 119 120 /** 104 121 \brief makes the widget visible. 105 122 */ … … 132 149 #endif /* HAVE_GTK2 */ 133 150 } 134 135 #ifdef HAVE_GTK2136 /**137 \brief Connect any signal to any given Sub-widget138 */139 gulong Widget::connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *))140 {141 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), NULL);142 }143 144 /**145 \brief Connect a signal with additionally passing the whole Object146 */147 gulong Widget::connectSignal (char* event, gint (*signal)( GtkWidget*, Widget *))148 {149 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), this);150 }151 152 /**153 \brief Connect a signal with additionally passing a whole external Object154 */155 gulong Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *))156 {157 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj);158 }159 160 /**161 \brief Connect a signal with additionally passing a whole external Object162 */163 gulong Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *))164 {165 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj);166 }167 168 void Widget::disconnectSignal (gulong signalID)169 {170 g_signal_handler_disconnect (G_OBJECT (this->widget), signalID);171 }172 #endif /* HAVE_GTK2 */173 151 174 152 /** … … 213 191 214 192 #ifdef HAVE_GTK2 193 /** 194 \brief Connect any signal to any given Sub-widget 195 */ 196 gulong Widget::connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *)) 197 { 198 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), NULL); 199 } 200 201 /** 202 \brief Connect a signal with additionally passing the whole Object 203 */ 204 gulong Widget::connectSignal (char* event, gint (*signal)( GtkWidget*, Widget *)) 205 { 206 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), this); 207 } 208 209 /** 210 \brief Connect a signal with additionally passing a whole external Object 211 */ 212 gulong Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *)) 213 { 214 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj); 215 } 216 217 /** 218 \brief Connect a signal with additionally passing a whole external Object 219 */ 220 gulong Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *)) 221 { 222 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj); 223 } 224 225 void Widget::disconnectSignal (gulong signalID) 226 { 227 g_signal_handler_disconnect (G_OBJECT (this->widget), signalID); 228 } 215 229 216 230 /** … … 246 260 247 261 /** 262 \brief Destroys a Packer. 263 */ 264 void Packer::destroy(void) 265 { 266 PRINTF(4)("deleting the Packer part.\n"); 267 268 if (groupName) 269 delete []groupName; 270 271 //deleting recursively. 272 if (this->down) 273 delete this->down; 274 this->down = NULL; 275 276 static_cast<Widget*>(this)->destroy(); 277 } 278 279 /** 248 280 \brief Sets the group name under which all the lower widgets of this will be saved. 249 281 \param name The name of the group. … … 283 315 284 316 /** 317 \brief Destroys a Container. 318 */ 319 void Container::destroy(void) 320 { 321 PRINTF(4)("deleting the Container part.\n"); 322 323 static_cast<Packer*>(this)->destroy(); 324 } 325 326 /** 285 327 \briefFills a Container with lowerWidget. 286 328 \param lowerWidget the Widget that should be filled into the Container. … … 298 340 } 299 341 else 300 cout << "!!error!! You try to put more than one Widget into a Container. \nNot including this item.\nThis is only possible with Boxes.\n"<<endl;342 PRINTF(1)("!!error!! You try to put more than one Widget into a Container. \nNot including this item.\nThis is only possible with Boxes.\n"); 301 343 } 302 344 … … 329 371 330 372 331 332 373 /** 333 374 \brief Creating a new Window without a Name … … 342 383 \param windowName the name the window should get. 343 384 */ 385 344 386 Window::Window (char* windowName) 345 387 { 346 388 this->init(); 347 389 this->setTitle (windowName); 390 } 391 392 /** 393 \brief Destructs a Window. 394 */ 395 Window::~Window(void) 396 { 397 this->destroy(); 348 398 } 349 399 … … 368 418 gtk_container_set_border_width (GTK_CONTAINER (widget), 3); 369 419 #endif /* HAVE_GTK2 */ 420 } 421 422 /** 423 \brief Destroys a Window. 424 */ 425 void Window::destroy(void) 426 { 427 if (label) 428 PRINTF(3)("deleting the Window: %s\n", label); 429 else 430 PRINTF(3)("deleting the Window.\n"); 431 432 static_cast<Container*>(this)->destroy(); 433 370 434 } 371 435 … … 499 563 } 500 564 565 /** 566 \brief destrcucts a Frame 567 */ 568 Frame::~Frame() 569 { 570 this->destroy(); 571 } 572 501 573 /** 502 574 \brief Initializes a new Frame with default settings … … 510 582 gtk_container_set_border_width (GTK_CONTAINER (widget), 3); 511 583 #endif /* HAVE_GTK2 */ 584 } 585 586 /** 587 \brief Destroys a Frame. 588 */ 589 void Frame::destroy(void) 590 { 591 if (label) 592 PRINTF(3)("deleting the Frame: %s\n", label); 593 else 594 PRINTF(3)("deleting the Frame.\n"); 595 596 static_cast<Container*>(this)->destroy(); 512 597 } 513 598 … … 532 617 \brief Creates a new EventBox with default settings. 533 618 */ 534 EventBox::EventBox ( )619 EventBox::EventBox (void) 535 620 { 536 621 this->init(); … … 548 633 549 634 /** 635 \destructs an EventBox. 636 */ 637 EventBox::~EventBox(void) 638 { 639 this->destroy(); 640 641 } 642 643 /** 550 644 \brief Initializes a new EventBox 551 645 */ … … 560 654 gtk_container_set_border_width (GTK_CONTAINER (widget), 3); 561 655 #endif /* HAVE_GTK2 */ 656 } 657 658 /** 659 \brief Destroys an EventBox. 660 */ 661 void EventBox::destroy(void) 662 { 663 if (label) 664 PRINTF(3)("deleting the EventBox: %s\n", label); 665 else 666 PRINTF(3)("deleting the EventBox.\n"); 667 668 static_cast<Container*>(this)->destroy(); 562 669 } 563 670 … … 591 698 { 592 699 this->init(boxtype); 700 } 701 702 /** 703 \destructs a Box. 704 */ 705 Box::~Box(void) 706 { 707 this->destroy(); 593 708 } 594 709 … … 612 727 } 613 728 #endif /* HAVE_GTK2 */ 729 } 730 731 /** 732 \brief Destroys a Box. 733 */ 734 void Box::destroy(void) 735 { 736 if (label) 737 PRINTF(3)("deleting the Box: %s\n", label); 738 else 739 PRINTF(3)("deleting the Box.\n"); 740 741 static_cast<Packer*>(this)->destroy(); 614 742 } 615 743 … … 641 769 /** 642 770 \brief Sets the Title of a Box. 643 \ title the new Title to set.771 \param title the new Title to set. 644 772 */ 645 773 void Box::setTitle(char* title) … … 668 796 669 797 return; 798 } 799 800 /** 801 \brief Destroys an Option. 802 */ 803 void Option::destroy(void) 804 { 805 PRINTF(4)("deleting the Option Part.\n"); 806 if (flagName) 807 delete []flagName; 808 if (flagNameShort) 809 delete []flagNameShort; 810 811 static_cast<Widget*>(this)->destroy(); 670 812 } 671 813 … … 746 888 747 889 /** 890 \destructs a Button. 891 */ 892 Button::~Button(void) 893 { 894 this->destroy(); 895 } 896 897 /** 748 898 \brief Initializes a new Button 749 899 */ … … 757 907 widget = gtk_button_new_with_label (""); 758 908 #endif /* HAVE_GTK2 */ 909 } 910 911 /** 912 \brief Destroys a Button. 913 */ 914 void Button::destroy(void) 915 { 916 if (label) 917 PRINTF(3)("deleting the Label: %s\n", label); 918 else 919 PRINTF(3)("deleting the Label.\n"); 920 921 static_cast<Option*>(this)->destroy(); 759 922 } 760 923 … … 799 962 800 963 /** 964 \destructs a CheckButton. 965 */ 966 CheckButton::~CheckButton(void) 967 { 968 this->destroy(); 969 } 970 971 /** 801 972 \brief Initialize a new CheckButton with default settings 802 973 */ … … 810 981 widget = gtk_check_button_new_with_label (""); 811 982 #endif /* HAVE_GTK2 */ 983 } 984 985 /** 986 \brief Destroys a CheckButton. 987 */ 988 void CheckButton::destroy(void) 989 { 990 if (label) 991 PRINTF(3)("deleting the CheckButton: %s\n", label); 992 else 993 PRINTF(3)("deleting the CheckButton.\n"); 994 995 static_cast<Option*>(this)->destroy(); 812 996 } 813 997 … … 878 1062 879 1063 /** 1064 \destructs a Slider. 1065 */ 1066 Slider::~Slider(void) 1067 { 1068 this->destroy(); 1069 } 1070 1071 /** 880 1072 \brief Initializes a Slider with start and end Values 881 1073 params: see Slider::Slider (char* slidername, int start, int end) … … 890 1082 widget = gtk_hscale_new_with_range (start, end, 5); 891 1083 #endif /* HAVE_GTK2 */ 1084 } 1085 1086 /** 1087 \brief Destroys a Slider. 1088 */ 1089 void Slider::destroy(void) 1090 { 1091 if (label) 1092 PRINTF(3)("deleting the Slider: %s\n", label); 1093 else 1094 PRINTF(3)("deleting the Slider.\n"); 1095 1096 static_cast<Option*>(this)->destroy(); 1097 892 1098 } 893 1099 … … 911 1117 { 912 1118 this->value = value; 1119 } 1120 1121 /** 1122 \brief Redraws the widget 1123 Example: see void CheckButton::redraw () 1124 */ 1125 void Slider::redraw () 1126 { 1127 #ifdef HAVE_GTK2 1128 gtk_range_set_value (GTK_RANGE (widget), value); 1129 #endif /* HAVE_GTK2 */ 913 1130 } 914 1131 … … 927 1144 #endif /* HAVE_GTK2 */ 928 1145 929 /**930 \brief Redraws the widget931 Example: see void CheckButton::redraw ()932 */933 void Slider::redraw ()934 {935 #ifdef HAVE_GTK2936 gtk_range_set_value (GTK_RANGE (widget), value);937 #endif /* HAVE_GTK2 */938 }939 1146 940 1147 /* MENU */ … … 969 1176 970 1177 /** 1178 \destructs a Menu. 1179 */ 1180 Menu::~Menu(void) 1181 { 1182 this->destroy(); 1183 } 1184 1185 /** 971 1186 \brief Initializes a new Menu with no items 972 1187 */ … … 983 1198 984 1199 } 1200 1201 /** 1202 \brief Destroys a Menu. 1203 */ 1204 void Menu::destroy(void) 1205 { 1206 if (label) 1207 PRINTF(3)("deleting the Menu: %s\n", label); 1208 else 1209 PRINTF(3)("deleting the Menu.\n"); 1210 //! \todo destroy menu 1211 1212 static_cast<Option*>(this)->destroy(); 1213 } 1214 985 1215 986 1216 /** … … 1005 1235 item = gtk_menu_item_new_with_label (itemName); 1006 1236 gtk_menu_shell_append(GTK_MENU_SHELL (menu), item); 1237 #endif /* HAVE_GTK2 */ 1238 } 1239 1240 /** 1241 \brief Redraws the widget 1242 Example: see void CheckButton::redraw () 1243 */ 1244 void Menu::redraw () 1245 { 1246 #ifdef HAVE_GTK2 1247 gtk_option_menu_set_history (GTK_OPTION_MENU (widget), value); 1007 1248 #endif /* HAVE_GTK2 */ 1008 1249 } … … 1022 1263 #endif /* HAVE_GTK2 */ 1023 1264 1024 /** 1025 \brief Redraws the widget 1026 Example: see void CheckButton::redraw () 1027 */ 1028 void Menu::redraw () 1029 { 1030 #ifdef HAVE_GTK2 1031 gtk_option_menu_set_history (GTK_OPTION_MENU (widget), value); 1032 #endif /* HAVE_GTK2 */ 1033 } 1265 /* OPTION LABEL */ 1034 1266 1035 1267 /** … … 1046 1278 1047 1279 /** 1280 \destructs an OptionLabel. 1281 */ 1282 OptionLabel::~OptionLabel(void) 1283 { 1284 this->destroy(); 1285 } 1286 1287 /** 1048 1288 \brief Initializes an OptionLabel 1049 1289 */ … … 1058 1298 #endif /* HAVE_GTK2 */ 1059 1299 } 1300 1301 /** 1302 \brief Destroys a OptionLabel. 1303 */ 1304 void OptionLabel::destroy(void) 1305 { 1306 if (label) 1307 PRINTF(3)("deleting the OptionLabel: %s\n", label); 1308 else 1309 PRINTF(3)("deleting the OptionLabel.\n"); 1310 if (cValue) 1311 delete []cValue; 1312 1313 static_cast<Option*>(this)->destroy(); 1314 } 1315 1060 1316 1061 1317 /** … … 1117 1373 1118 1374 /** 1375 \destructs a Label. 1376 */ 1377 Label::~Label(void) 1378 { 1379 this->destroy(); 1380 } 1381 1382 /** 1119 1383 \brief initializes a new Label 1120 1384 */ … … 1129 1393 gtk_label_set_line_wrap (GTK_LABEL(widget), TRUE); 1130 1394 #endif /* HAVE_GTK2 */ 1395 } 1396 1397 /** 1398 \brief Destroys a Label. 1399 */ 1400 void Label::destroy(void) 1401 { 1402 if (label) 1403 PRINTF(3)("deleting the Label: %s\n", label); 1404 else 1405 PRINTF(3)("deleting the Label.\n"); 1406 1407 static_cast<Widget*>(this)->destroy(); 1131 1408 } 1132 1409 … … 1178 1455 ProgressBar::~ProgressBar () 1179 1456 { 1457 this->destroy(); 1180 1458 } 1181 1459 … … 1197 1475 1198 1476 /** 1477 \brief Destroys a ProgressBar. 1478 */ 1479 void ProgressBar::destroy(void) 1480 { 1481 if (label) 1482 PRINTF(3)("deleting the ProgressBar: %s\n", label); 1483 else 1484 PRINTF(3)("deleting the ProgressBar.\n"); 1485 1486 static_cast<Widget*>(this)->destroy(); 1487 } 1488 1489 /** 1199 1490 \brief Sets a ned Title to the ProgressBar. 1200 1491 \param title The now title of the ProgressBar. … … 1259 1550 } 1260 1551 1552 /** 1553 \destructs an Image. 1554 */ 1555 Image::~Image(void) 1556 { 1557 this->destroy(); 1558 } 1559 1261 1560 /** 1262 1561 \brief Initializes a new Image … … 1267 1566 1268 1567 static_cast<Widget*>(this)->init(); 1568 } 1569 1570 /** 1571 \brief Destroys a Image. 1572 */ 1573 void Image::destroy(void) 1574 { 1575 if (label) 1576 PRINTF(3)("deleting the Image: %s\n", label); 1577 else 1578 PRINTF(3)("deleting the Image.\n"); 1579 1580 static_cast<Widget*>(this)->destroy(); 1269 1581 } 1270 1582
Note: See TracChangeset
for help on using the changeset viewer.