Changeset 3746 in orxonox.OLD for orxonox/branches/levelloader/src/lib/gui/gui/orxonox_gui_gtk.cc
- Timestamp:
- Apr 7, 2005, 3:54:49 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/levelloader/src/lib/gui/gui/orxonox_gui_gtk.cc
r3499 r3746 25 25 26 26 27 #include "orxonox_gui_gtk.h" 28 29 #include <stdarg.h> 27 30 #include <iostream> 28 29 #include "orxonox_gui_gtk.h"30 31 31 32 … … 68 69 #else /* HAVE_GTK2 */ 69 70 char boolAns = 'y'; 70 char ans[10]; 71 char ans[10]; 72 PRINT(0)("================================\n"); 73 PRINT(0)("= ORXONOX CONFIGURATION WIZARD =\n"); 74 PRINT(0)("================================ - version:" PACKAGE_VERSION "\n"); 75 71 76 while(true) 72 77 { 73 PRINT(0)(" Listing all the Orxonox Options: \n");78 PRINT(0)("\n Listing all the Orxonox Options: \n"); 74 79 PRINT(0)(" #############################\n"); 75 80 Window::mainWindow->walkThrough(Widget::listOptionsAndGroups, 1); … … 122 127 //! \todo move this into the gui-gtk-file 123 128 //! \todo finish it. 129 //! \todo memory leek at save(); and save is a BAD word, use saveString instead, or something like it. 124 130 } 125 131 #endif /* HAVE_GTK2 */ … … 133 139 134 140 /* WIDGET */ 135 136 /** 137 \brief deletes any given Widget 138 This is still pretty crappy. 139 */ 140 Widget::~Widget(void) 141 { 142 this->destroy(); 143 } 144 145 /** 146 \brief Initializes a widget. 147 Initializes the next Pointer and the other Widget-specific Defaults. 148 */ 149 void Widget::init(void) 141 /** 142 \brief constructs a Widget 143 */ 144 Widget::Widget(void) 150 145 { 151 146 next = NULL; … … 155 150 156 151 /** 157 \brief Destroys a Widget 158 */ 159 void Widget::destroy(void) 160 { 161 if (this->title) 152 \brief deletes any given Widget 153 This is still pretty crappy. 154 */ 155 Widget::~Widget(void) 156 { 157 if (this->title) 162 158 { 163 159 delete []this->title; … … 172 168 delete this->next; 173 169 this->next = NULL; 174 175 170 //! \todo not hiding widget, deleting. 176 171 // this->hide(); 177 172 // delete this->widget; 173 } 174 175 /** 176 \brief sets a new Title to a Widget 177 \param title The new Title to set to the Widget 178 */ 179 void Widget::setTitle(const char* title) 180 { 181 if (this->title) 182 delete []this->title; 183 this->title = new char[strlen(title)+1]; 184 strcpy(this->title, title); 178 185 } 179 186 … … 273 280 { 274 281 if (widget->isOption < 0 && static_cast<Packer*>(widget)->groupName) 275 cout << "[" << static_cast<Packer*>(widget)->groupName << "]\n";276 if (widget->isOption >= 1 && widget->isOption <= 3)277 cout << " " << static_cast<Option*>(widget)->title <<" is : " << static_cast<Option*>(widget)->value <<endl;278 else if (widget->isOption == 5)279 cout << " " << static_cast<Option*>(widget)->title <<" is : " << static_cast<OptionLabel*>(widget)->cValue <<endl;282 PRINT(0)("[%s]\n", static_cast<Packer*>(widget)->groupName); 283 if (widget->isOption >= 1) 284 { 285 Widget::listOptions(widget); 286 } 280 287 } 281 288 … … 286 293 void Widget::listOptions(Widget* widget) 287 294 { 288 if (widget->isOption >= 1 && widget->isOption <= 3) 289 cout << " " << static_cast<Option*>(widget)->title <<" is : " << static_cast<Option*>(widget)->value <<endl; 290 else if (widget->isOption == 5) 291 cout << " " << static_cast<Option*>(widget)->title <<" is : " << static_cast<OptionLabel*>(widget)->cValue <<endl; 295 if(widget->isOption >= 1) 296 PRINT(0)(" %s is %s\n", static_cast<Option*>(widget)->title, static_cast<Option*>(widget)->save()); 292 297 } 293 298 … … 300 305 { 301 306 302 if (widget->isOption >= 1 && widget->isOption <= 3)307 if (widget->isOption >= 1) 303 308 { 304 309 int* count =(int*)data; 305 310 *count = *count +1; 306 cout << *count << ": " << static_cast<Option*>(widget)->title <<" is : " << static_cast<Option*>(widget)->value <<endl; 307 } 308 else if (widget->isOption == 5) 309 { 310 int* count =(int*)data; 311 *count = *count +1; 312 cout << *count << ": " << static_cast<Option*>(widget)->title <<" is : " << static_cast<OptionLabel*>(widget)->cValue <<endl; 311 PRINT(0)(" %d:%s is %s\n", *count, static_cast<Option*>(widget)->title, static_cast<Option*>(widget)->save()); 313 312 } 314 313 } … … 513 512 514 513 /* PACKERS */ 515 516 /** 517 \brief Initializes a Packer. 518 519 Sets the down-pinter to NULL and other PackerSpecific-values to their defaults. 520 */ 521 void Packer::init(void) 514 /** 515 \brief Constructs a Packer 516 */ 517 Packer::Packer(void) 522 518 { 523 519 this->down = NULL; 524 520 this->groupName = NULL; 525 526 527 static_cast<Widget*>(this)->init();528 return;529 521 } 530 522 … … 532 524 \brief Destroys a Packer. 533 525 */ 534 void Packer::destroy(void)526 Packer::~Packer(void) 535 527 { 536 528 PRINTF(4)("deleting the Packer part.\n"); … … 543 535 delete this->down; 544 536 this->down = NULL; 545 546 static_cast<Widget*>(this)->destroy();547 537 } 548 538 … … 575 565 sets the Container-Specific defaults. 576 566 */ 577 void Container::init(void)567 Container::Container(void) 578 568 { 579 569 this->isOption = -1; 580 581 static_cast<Packer*>(this)->init();582 583 return;584 570 } 585 571 … … 587 573 \brief Destroys a Container. 588 574 */ 589 void Container::destroy(void)575 Container::~Container(void) 590 576 { 591 577 PRINTF(4)("deleting the Container part.\n"); 592 593 static_cast<Packer*>(this)->destroy();594 578 } 595 579 … … 665 649 Window::~Window(void) 666 650 { 667 this->destroy(); 651 if (this->title) 652 PRINTF(3)("deleting the Window: %s\n", this->title); 653 else 654 PRINTF(3)("deleting the Window.\n"); 655 // this->hide(); 668 656 } 669 657 … … 677 665 678 666 isOpen = false; 679 680 static_cast<Container*>(this)->init();681 667 682 668 #ifdef HAVE_GTK2 … … 691 677 692 678 /** 693 \brief Destroys a Window.694 */695 void Window::destroy(void)696 {697 if (this->title)698 PRINTF(3)("deleting the Window: %s\n", this->title);699 else700 PRINTF(3)("deleting the Window.\n");701 // this->hide();702 static_cast<Container*>(this)->destroy();703 704 }705 706 /**707 679 \brief Shows all Widgets that are included within this->widget. 708 680 */ … … 730 702 \param title title the Window should get. 731 703 */ 732 void Window::setTitle(c har* title)704 void Window::setTitle(const char* title) 733 705 { 734 706 if (this->title) … … 823 795 Frame::~Frame(void) 824 796 { 825 this->destroy();826 }827 828 /**829 \brief Initializes a new Frame with default settings830 */831 void Frame::init(void)832 {833 static_cast<Container*>(this)->init();834 835 #ifdef HAVE_GTK2836 this->widget = gtk_frame_new("");837 gtk_container_set_border_width(GTK_CONTAINER(this->widget), 3);838 #endif /* HAVE_GTK2 */839 }840 841 /**842 \brief Destroys a Frame.843 */844 void Frame::destroy(void)845 {846 797 if (this->title) 847 798 PRINTF(3)("deleting the Frame: %s\n", this->title); 848 799 else 849 800 PRINTF(3)("deleting the Frame.\n"); 850 851 static_cast<Container*>(this)->destroy(); 801 } 802 803 /** 804 \brief Initializes a new Frame with default settings 805 */ 806 void Frame::init(void) 807 { 808 #ifdef HAVE_GTK2 809 this->widget = gtk_frame_new(""); 810 gtk_container_set_border_width(GTK_CONTAINER(this->widget), 3); 811 #endif /* HAVE_GTK2 */ 852 812 } 853 813 … … 856 816 \param title The title the Frame should get. 857 817 */ 858 void Frame::setTitle(c har* title)818 void Frame::setTitle(const char* title) 859 819 { 860 820 if (this->title) … … 892 852 EventBox::~EventBox(void) 893 853 { 894 this->destroy();895 896 }897 898 /**899 \brief Initializes a new EventBox900 */901 void EventBox::init(void)902 {903 this->isOption = -1;904 905 static_cast<Container*>(this)->init();906 907 #ifdef HAVE_GTK2908 this->widget = gtk_event_box_new();909 gtk_container_set_border_width(GTK_CONTAINER(this->widget), 3);910 #endif /* HAVE_GTK2 */911 }912 913 /**914 \brief Destroys an EventBox.915 */916 void EventBox::destroy(void)917 {918 854 if (this->title) 919 855 PRINTF(3)("deleting the EventBox: %s\n", this->title); 920 856 else 921 857 PRINTF(3)("deleting the EventBox.\n"); 922 923 static_cast<Container*>(this)->destroy(); 924 } 925 926 /** 927 \brief Sets the Title of the EventBox(not implemented) 928 \param title Name the EventBox should get(only datastructure-internal). 929 */ 930 void EventBox::setTitle(char* title) 931 { 932 if (this->title) 933 delete []this->title; 934 this->title = new char[strlen(title)+1]; 935 strcpy(this->title, title); 858 } 859 860 /** 861 \brief Initializes a new EventBox 862 */ 863 void EventBox::init(void) 864 { 865 this->isOption = -1; 866 867 #ifdef HAVE_GTK2 868 this->widget = gtk_event_box_new(); 869 gtk_container_set_border_width(GTK_CONTAINER(this->widget), 3); 870 #endif /* HAVE_GTK2 */ 936 871 } 937 872 … … 960 895 Box::~Box(void) 961 896 { 962 this->destroy();963 }964 965 /**966 \brief Initializes a new Box with type boxtype967 \param boxtype see Box(char boxtype)968 */969 void Box::init(char boxtype)970 {971 this->isOption = -2;972 973 static_cast<Packer*>(this)->init();974 #ifdef HAVE_GTK2975 if (boxtype == 'v')976 {977 this->widget = gtk_vbox_new(FALSE, 0);978 }979 else980 {981 this->widget = gtk_hbox_new(FALSE, 0);982 }983 #endif /* HAVE_GTK2 */984 }985 986 /**987 \brief Destroys a Box.988 */989 void Box::destroy(void)990 {991 897 if (this->title) 992 898 PRINTF(3)("deleting the Box: %s\n", this->title); … … 994 900 PRINTF(3)("deleting the Box.\n"); 995 901 996 static_cast<Packer*>(this)->destroy(); 902 } 903 904 /** 905 \brief Initializes a new Box with type boxtype 906 \param boxtype see Box(char boxtype) 907 */ 908 void Box::init(char boxtype) 909 { 910 this->isOption = -2; 911 912 #ifdef HAVE_GTK2 913 if (boxtype == 'v') 914 { 915 this->widget = gtk_vbox_new(FALSE, 0); 916 } 917 else 918 { 919 this->widget = gtk_hbox_new(FALSE, 0); 920 } 921 #endif /* HAVE_GTK2 */ 997 922 } 998 923 … … 1022 947 } 1023 948 1024 /**1025 \brief Sets the Title of a Box.1026 \param title the new Title to set.1027 */1028 void Box::setTitle(char* title)1029 {1030 if (this->title)1031 delete []this->title;1032 this->title = new char[strlen(title)+1];1033 strcpy(this->title, title);1034 }1035 1036 949 /* OPTION */ 1037 950 … … 1040 953 sets all Option-Specific-Values to their defaults. 1041 954 */ 1042 void Option::init(void)955 Option::Option(void) 1043 956 { 1044 957 this->value = 0; … … 1047 960 this->saveable = false; 1048 961 this->defaultValue = 0; 1049 1050 static_cast<Widget*>(this)->init();1051 1052 return;1053 962 } 1054 963 … … 1056 965 \brief Destroys an Option. 1057 966 */ 1058 void Option::destroy(void)967 Option::~Option(void) 1059 968 { 1060 969 PRINTF(4)("deleting the Option Part.\n"); … … 1063 972 if (this->flagNameShort) 1064 973 delete []this->flagNameShort; 1065 1066 static_cast<Widget*>(this)->destroy();1067 974 } 1068 975 … … 1123 1030 1124 1031 /** 1032 \brief saves an Option 1033 \returns the String that should be saved. 1034 1035 this is a default Option save 1036 */ 1037 char* Option::save(void) 1038 { 1039 char* value = new char [10]; 1040 sprintf (value, "%d", this->value); 1041 return value; 1042 } 1043 1044 /** 1045 \brief loads an Option from of its loadString 1046 \param loadString the string from which to load the data from 1047 */ 1048 void Option::load(char* loadString) 1049 { 1050 this->value = atoi(loadString); 1051 PRINT(3)("Loading %s: %s %d\n", this->title, loadString, value); 1052 this->redraw(); 1053 } 1054 1055 /** 1125 1056 \returns The saveable-state. 1126 1057 */ … … 1161 1092 Button::~Button(void) 1162 1093 { 1163 this->destroy();1164 }1165 1166 /**1167 \brief Initializes a new Button1168 */1169 void Button::init(void)1170 {1171 isOption = 0;1172 1173 static_cast<Option*>(this)->init();1174 1175 #ifdef HAVE_GTK21176 widget = gtk_button_new_with_label("");1177 #endif /* HAVE_GTK2 */1178 }1179 1180 /**1181 \brief Destroys a Button.1182 */1183 void Button::destroy(void)1184 {1185 1094 if (this->title) 1186 1095 PRINTF(3)("deleting the Label: %s\n", this->title); … … 1188 1097 PRINTF(3)("deleting the Label.\n"); 1189 1098 1190 static_cast<Option*>(this)->destroy(); 1099 } 1100 1101 /** 1102 \brief Initializes a new Button 1103 */ 1104 void Button::init(void) 1105 { 1106 isOption = 0; 1107 1108 #ifdef HAVE_GTK2 1109 widget = gtk_button_new_with_label(""); 1110 #endif /* HAVE_GTK2 */ 1191 1111 } 1192 1112 … … 1195 1115 \param title The name the Button should get 1196 1116 */ 1197 void Button::setTitle(c har *title)1117 void Button::setTitle(const char *title) 1198 1118 { 1199 1119 if (this->title) … … 1245 1165 CheckButton::~CheckButton(void) 1246 1166 { 1247 this->destroy();1248 }1249 1250 /**1251 \brief Initialize a new CheckButton with default settings1252 */1253 void CheckButton::init(void)1254 {1255 this->isOption = 1;1256 1257 static_cast<Option*>(this)->init();1258 1259 #ifdef HAVE_GTK21260 this->widget = gtk_check_button_new_with_label("");1261 #endif /* HAVE_GTK2 */1262 }1263 1264 /**1265 \brief Destroys a CheckButton.1266 */1267 void CheckButton::destroy(void)1268 {1269 1167 if (this->title) 1270 1168 PRINTF(3)("deleting the CheckButton: %s\n", this->title); 1271 1169 else 1272 1170 PRINTF(3)("deleting the CheckButton.\n"); 1273 1274 static_cast<Option*>(this)->destroy(); 1171 } 1172 1173 /** 1174 \brief Initialize a new CheckButton with default settings 1175 */ 1176 void CheckButton::init(void) 1177 { 1178 this->isOption = 1; 1179 1180 #ifdef HAVE_GTK2 1181 this->widget = gtk_check_button_new_with_label(""); 1182 #endif /* HAVE_GTK2 */ 1275 1183 } 1276 1184 … … 1279 1187 \param title The new Name the CheckButton should display. 1280 1188 */ 1281 void CheckButton::setTitle(c har* title)1189 void CheckButton::setTitle(const char* title) 1282 1190 { 1283 1191 if (this->title) … … 1306 1214 #else /* HAVE_GTK2 */ 1307 1215 char tmpChar[20]; 1308 cout << "\nPlease give me a new value for " << this->title << " [0,1](def ualt:" << this->defaultValue << "): ";1216 cout << "\nPlease give me a new value for " << this->title << " [0,1](default:" << this->defaultValue << "): "; 1309 1217 cin >> tmpChar; 1310 1218 … … 1350 1258 Slider::~Slider(void) 1351 1259 { 1352 this->destroy();1353 }1354 1355 /**1356 \brief Initializes a Slider with start and end Values1357 params: see Slider::Slider(char* slidername, int start, int end)1358 */1359 void Slider::init(int start, int end)1360 {1361 this->isOption = 2;1362 1363 static_cast<Option*>(this)->init();1364 1365 this->start = start;1366 this->end = end;1367 #ifdef HAVE_GTK21368 widget = gtk_hscale_new_with_range(this->start, this->end, 5);1369 #endif /* HAVE_GTK2 */1370 }1371 1372 /**1373 \brief Destroys a Slider.1374 */1375 void Slider::destroy(void)1376 {1377 1260 if (this->title) 1378 1261 PRINTF(3)("deleting the Slider: %s\n", this->title); 1379 1262 else 1380 1263 PRINTF(3)("deleting the Slider.\n"); 1381 1382 static_cast<Option*>(this)->destroy(); 1383 1384 } 1385 1386 /** 1387 \brief Sets a new Title to the Slider 1388 \param title The new Name of the slider 1389 */ 1390 void Slider::setTitle(char* title) 1391 { 1392 if (this->title)1393 delete []this->title; 1394 this->title = new char[strlen(title)+1];1395 strcpy(this->title, title); 1264 } 1265 1266 /** 1267 \brief Initializes a Slider with start and end Values 1268 params: see Slider::Slider(char* slidername, int start, int end) 1269 */ 1270 void Slider::init(int start, int end) 1271 { 1272 this->isOption = 2; 1273 1274 this->start = start; 1275 this->end = end; 1276 #ifdef HAVE_GTK2 1277 widget = gtk_hscale_new_with_range(this->start, this->end, 5); 1278 #endif /* HAVE_GTK2 */ 1396 1279 } 1397 1280 … … 1425 1308 #else /* HAVE_GTK2 */ 1426 1309 char tmpChar[20]; 1427 cout << "\nPlease give me a new value for " << this->title << " [" <<this->start << "-" << this->end << "](def ualt:" << this->defaultValue << "): ";1310 cout << "\nPlease give me a new value for " << this->title << " [" <<this->start << "-" << this->end << "](default:" << this->defaultValue << "): "; 1428 1311 cin >> tmpChar; 1429 1312 … … 1437 1320 1438 1321 /* MENU */ 1322 1323 /** 1324 \brief constructs a new Menu, without adding any items to it. 1325 \param menuName the Name the Menu gets. 1326 */ 1327 Menu::Menu(const char* menuName) 1328 { 1329 this->init(); 1330 this->setTitle(menuName); 1331 } 1439 1332 1440 1333 /** … … 1448 1341 this->init(); 1449 1342 this->setTitle(menuname); 1450 1343 va_list itemlist; //!< The list to readin multiple Options. 1344 1451 1345 char *itemName; 1452 1346 1453 #ifdef HAVE_GTK2 /////////////////////// REINPLEMENT1454 1347 va_start(itemlist, menuname); 1455 1348 while(strcmp(itemName = va_arg(itemlist, char*), "lastItem")) … … 1458 1351 } 1459 1352 va_end(itemlist); 1460 #endif /* HAVE_GTK2 */1461 1462 #ifdef HAVE_GTK21463 gtk_option_menu_set_menu(GTK_OPTION_MENU(this->widget), menu);1464 this->connectSignal("changed", this->OptionChange);1465 #endif /* HAVE_GTK2 */1466 1353 } 1467 1354 … … 1471 1358 Menu::~Menu(void) 1472 1359 { 1473 this->destroy();1474 }1475 1476 /**1477 \brief Initializes a new Menu with no items1478 */1479 void Menu::init(void)1480 {1481 this->isOption = 2;1482 1483 static_cast<Option*>(this)->init();1484 1485 #ifdef HAVE_GTK21486 this->widget = gtk_option_menu_new();1487 this->menu = gtk_menu_new();1488 #endif /* HAVE_GTK2 */1489 1490 }1491 1492 /**1493 \brief Destroys a Menu.1494 */1495 void Menu::destroy(void)1496 {1497 1360 if (this->title) 1498 1361 PRINTF(3)("deleting the Menu: %s\n", this->title); … … 1500 1363 PRINTF(3)("deleting the Menu.\n"); 1501 1364 //! \todo destroy menu 1502 1503 static_cast<Option*>(this)->destroy(); 1504 } 1505 1506 1507 /** 1508 * Sets the Database-Name of this Menu 1509 \param title Database-Name to be set. 1510 */ 1511 void Menu::setTitle(char* title) 1512 { 1513 if (this->title) 1514 delete []this->title; 1515 this->title = new char[strlen(title)+1]; 1516 strcpy(this->title, title); 1365 this->currItem = this->firstItem; 1366 while(this->currItem) 1367 { 1368 delete []this->currItem->name; 1369 /* 1370 #ifdef HAVE_GTK2 1371 free(this->currItem->item); 1372 #endif /* HAVE_GTK2 */ 1373 MenuItem* tmpItem = this->currItem; 1374 this->currItem = this->currItem->next; 1375 delete tmpItem; 1376 } 1377 } 1378 1379 /** 1380 \brief Initializes a new Menu with no items 1381 */ 1382 void Menu::init(void) 1383 { 1384 this->isOption = 2; 1385 this->firstItem = NULL; 1386 1387 #ifdef HAVE_GTK2 1388 this->widget = gtk_option_menu_new(); 1389 this->menu = gtk_menu_new(); 1390 gtk_option_menu_set_menu(GTK_OPTION_MENU(this->widget), menu); 1391 this->connectSignal("changed", this->OptionChange); 1392 #endif /* HAVE_GTK2 */ 1393 } 1394 1395 /** 1396 \brief saves the Label of the Menu 1397 \returns the name of the selected Menu-Item 1398 */ 1399 char* Menu::save(void) 1400 { 1401 MenuItem* tmpItem = this->firstItem; 1402 for (int i = 0; i<this->value; i++) 1403 tmpItem = tmpItem->next; 1404 1405 return tmpItem->name; 1406 } 1407 1408 /** 1409 \brief loads a Menu from of its loadString 1410 \param loadString the string from which to load the data from 1411 */ 1412 void Menu::load(char* loadString) 1413 { 1414 MenuItem* tmpItem = firstItem; 1415 bool foundItem = false; 1416 while (tmpItem) 1417 { 1418 if (!strcmp(loadString, tmpItem->name)) 1419 {foundItem = true; break;} 1420 tmpItem = tmpItem->next; 1421 } 1422 if (foundItem) 1423 this->value = tmpItem->itemNumber; 1424 else 1425 { 1426 this->value = 0; 1427 PRINTF(2)("Sorry, but %s has not been found in the Itemlist of %s\n", loadString, this->title); 1428 } 1429 PRINTF(3)( "Loading %s: setting to %d\n", this->title, this->value); 1430 this->redraw(); 1517 1431 } 1518 1432 … … 1520 1434 \brief appends a new Item to the Menu-List. 1521 1435 \param itemName the itemName to be appendet. 1522 1523 \todo make the item-list readable without GTK1524 1436 */ 1525 1437 void Menu::addItem(char* itemName) 1526 1438 { 1527 #ifdef HAVE_GTK2 1528 this->item = gtk_menu_item_new_with_label(itemName); 1529 gtk_menu_shell_append(GTK_MENU_SHELL(this->menu), this->item); 1530 #endif /* HAVE_GTK2 */ 1439 if (!this->firstItem) 1440 { 1441 this->firstItem = this->currItem = new MenuItem; 1442 this->currItem->itemNumber = 0; 1443 } 1444 else 1445 { 1446 int tmpI = this->currItem->itemNumber; 1447 this->currItem = this->currItem->next = new MenuItem; 1448 this->currItem->itemNumber = tmpI+1; 1449 } 1450 1451 this->currItem->name = new char[strlen(itemName)+1]; 1452 strcpy(this->currItem->name, itemName); 1453 1454 #ifdef HAVE_GTK2 1455 this->currItem->item = gtk_menu_item_new_with_label(itemName); 1456 gtk_menu_shell_append(GTK_MENU_SHELL(this->menu), this->currItem->item); 1457 #endif /* HAVE_GTK2 */ 1458 this->currItem->next = NULL; 1531 1459 } 1532 1460 … … 1551 1479 #else /* HAVE_GTK2 */ 1552 1480 char tmpChar[20]; 1553 cout << "\nPlease give me a new value for " << this->title << "(def ualt:" << this->defaultValue << "): ";1481 cout << "\nPlease give me a new value for " << this->title << "(default:" << this->defaultValue << "): "; 1554 1482 cin >> tmpChar; 1555 1483 this->value = atoi(tmpChar); … … 1578 1506 OptionLabel::~OptionLabel(void) 1579 1507 { 1580 this->destroy();1581 }1582 1583 /**1584 \brief Initializes an OptionLabel1585 */1586 void OptionLabel::init(void)1587 {1588 this->isOption = 5;1589 static_cast<Option*>(this)->init();1590 1591 cValue = NULL;1592 1593 #ifdef HAVE_GTK21594 this->widget = gtk_label_new("");1595 #endif /* HAVE_GTK2 */1596 }1597 1598 /**1599 \brief Destroys a OptionLabel.1600 */1601 void OptionLabel::destroy(void)1602 {1603 1508 if (this->title) 1604 1509 PRINTF(3)("deleting the OptionLabel: %s\n", this->title); … … 1607 1512 if (this->cValue) 1608 1513 delete []this->cValue; 1609 1610 static_cast<Option*>(this)->destroy(); 1611 } 1612 1514 } 1515 1516 /** 1517 \brief Initializes an OptionLabel 1518 */ 1519 void OptionLabel::init(void) 1520 { 1521 this->isOption = 5; 1522 cValue = NULL; 1523 1524 #ifdef HAVE_GTK2 1525 this->widget = gtk_label_new(""); 1526 #endif /* HAVE_GTK2 */ 1527 } 1613 1528 1614 1529 /** … … 1628 1543 1629 1544 /** 1630 \brief Sets a ned Title to the OptionLabel.1631 \param title The now title of the OptionLabel.1632 */1633 void OptionLabel::setTitle(char* title)1634 {1635 if (this->title)1636 delete []this->title;1637 this->title = new char [strlen(title)+1];1638 strcpy(this->title, title);1639 this->redraw();1640 }1641 1642 /**1643 1545 \brief Redraws an OptionLabel(not implemented yet, but it works). 1644 1546 */ … … 1666 1568 1667 1569 /** 1570 \brief creates the Optionlabel save-string 1571 \returns the String to save. 1572 */ 1573 char* OptionLabel::save(void) 1574 { 1575 return cValue; 1576 } 1577 1578 /** 1579 \brief loads an Option from of its loadString 1580 \param loadString the string from which to load the data from 1581 */ 1582 void OptionLabel::load(char* loadString) 1583 { 1584 PRINTF(3)( "Loading %s: setting to %s\n", this->title, loadString); 1585 this->setValue(loadString); 1586 } 1587 1588 /** 1668 1589 \brief Creates a new default Label with no Text. 1669 1590 You migth consider adding Label::setTitle with this. … … 1689 1610 Label::~Label(void) 1690 1611 { 1691 this->destroy();1692 }1693 1694 /**1695 \brief initializes a new Label1696 */1697 void Label::init(void)1698 {1699 this->isOption = 0;1700 1701 static_cast<Widget*>(this)->init();1702 1703 #ifdef HAVE_GTK21704 this->widget = gtk_label_new("");1705 gtk_label_set_line_wrap(GTK_LABEL(this->widget), TRUE);1706 #endif /* HAVE_GTK2 */1707 }1708 1709 /**1710 \brief Destroys a Label.1711 */1712 void Label::destroy(void)1713 {1714 1612 if (this->title) 1715 1613 PRINTF(3)("deleting the Label: %s\n", this->title); 1716 1614 else 1717 1615 PRINTF(3)("deleting the Label.\n"); 1718 1719 static_cast<Widget*>(this)->destroy(); 1616 } 1617 1618 /** 1619 \brief initializes a new Label 1620 */ 1621 void Label::init(void) 1622 { 1623 this->isOption = 0; 1624 1625 #ifdef HAVE_GTK2 1626 this->widget = gtk_label_new(""); 1627 gtk_label_set_line_wrap(GTK_LABEL(this->widget), TRUE); 1628 #endif /* HAVE_GTK2 */ 1720 1629 } 1721 1630 … … 1813 1722 ProgressBar::~ProgressBar(void) 1814 1723 { 1815 this->destroy(); 1724 if (this->title) 1725 PRINTF(3)("deleting the ProgressBar: %s\n", this->title); 1726 else 1727 PRINTF(3)("deleting the ProgressBar.\n"); 1816 1728 } 1817 1729 … … 1825 1737 this->totalSize = 0.0; 1826 1738 1827 static_cast<Widget*>(this)->init();1828 1739 #ifdef HAVE_GTK2 1829 1740 this->adjustment =(GtkAdjustment*)gtk_adjustment_new(0, 0, 100, 0, 0, 0); 1830 1741 this->widget = gtk_progress_bar_new_with_adjustment(this->adjustment); 1831 1742 #endif /* HAVE_GTK2 */ 1832 }1833 1834 /**1835 \brief Destroys a ProgressBar.1836 */1837 void ProgressBar::destroy(void)1838 {1839 if (this->title)1840 PRINTF(3)("deleting the ProgressBar: %s\n", this->title);1841 else1842 PRINTF(3)("deleting the ProgressBar.\n");1843 1844 static_cast<Widget*>(this)->destroy();1845 }1846 1847 /**1848 \brief Sets a ned Title to the ProgressBar.1849 \param title The now title of the ProgressBar.1850 */1851 void ProgressBar::setTitle(char* title)1852 {1853 if (this->title)1854 delete []this->title;1855 this->title = new char [strlen(title)+1];1856 strcpy(this->title, title);1857 1743 } 1858 1744 … … 1913 1799 Image::~Image(void) 1914 1800 { 1915 this->destroy();1916 }1917 1918 /**1919 \brief Initializes a new Image1920 */1921 void Image::init(void)1922 {1923 isOption = 0;1924 1925 static_cast<Widget*>(this)->init();1926 }1927 1928 /**1929 \brief Destroys a Image.1930 */1931 void Image::destroy(void)1932 {1933 1801 if (this->title) 1934 1802 PRINTF(3)("deleting the Image: %s\n", this->title); 1935 1803 else 1936 1804 PRINTF(3)("deleting the Image.\n"); 1937 1938 static_cast<Widget*>(this)->destroy(); 1939 } 1940 1941 /** 1942 \brief Sets a ned Title to the Image. 1943 \param title The now title of the OptionLabel. 1944 */ 1945 void Image::setTitle(char* title) 1946 { 1947 if (this->title) 1948 delete []this->title; 1949 this->title = new char [strlen(title)+1]; 1950 strcpy(this->title, title); 1951 } 1805 } 1806 1807 /** 1808 \brief Initializes a new Image 1809 */ 1810 void Image::init(void) 1811 { 1812 isOption = 0; 1813 }
Note: See TracChangeset
for help on using the changeset viewer.