Changeset 3625 in orxonox.OLD for orxonox/trunk/src/lib/gui/gui/orxonox_gui_gtk.cc
- Timestamp:
- Mar 22, 2005, 1:37:59 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/gui/gui/orxonox_gui_gtk.cc
r3624 r3625 1032 1032 1033 1033 /** 1034 \brief saves an Option 1035 \returns the String that should be saved. 1036 1037 this is a default Option save 1038 */ 1039 char* Option::save(void) 1040 { 1041 char* value = new char [10]; 1042 sprintf (value, "%d", this->value); 1043 return value; 1044 } 1045 1046 /** 1047 \brief loads an Option from of its loadString 1048 \param loadString the string from which to load the data from 1049 */ 1050 void Option::load(char* loadString) 1051 { 1052 this->value = atoi(loadString); 1053 PRINT(3)("Loading %s: %s %d\n", this->title, loadString, value); 1054 this->redraw(); 1055 } 1056 1057 /** 1034 1058 \returns The saveable-state. 1035 1059 */ … … 1319 1343 this->init(); 1320 1344 this->setTitle(menuname); 1321 1345 va_list itemlist; //!< The list to readin multiple Options. 1346 1322 1347 char *itemName; 1323 1348 … … 1371 1396 1372 1397 /** 1398 \brief saves the Label of the Menu 1399 \returns the name of the selected Menu-Item 1400 */ 1401 char* Menu::save(void) 1402 { 1403 MenuItem* tmpItem = this->firstItem; 1404 for (int i = 0; i<this->value; i++) 1405 tmpItem = tmpItem->next; 1406 1407 return tmpItem->name; 1408 } 1409 1410 /** 1411 \brief loads a Menu from of its loadString 1412 \param loadString the string from which to load the data from 1413 */ 1414 void Menu::load(char* loadString) 1415 { 1416 MenuItem* tmpItem = firstItem; 1417 bool foundItem = false; 1418 while (tmpItem) 1419 { 1420 if (!strcmp(loadString, tmpItem->name)) 1421 {foundItem = true; break;} 1422 tmpItem = tmpItem->next; 1423 } 1424 if (foundItem) 1425 this->value = tmpItem->itemNumber; 1426 else 1427 { 1428 this->value = 0; 1429 PRINTF(2)("Sorry, but %s has not been found in the Itemlist of %s\n", loadString, this->title); 1430 } 1431 PRINTF(3)( "Loading %s: setting to %d\n", this->title, this->value); 1432 this->redraw(); 1433 } 1434 1435 /** 1373 1436 \brief appends a new Item to the Menu-List. 1374 1437 \param itemName the itemName to be appendet. … … 1377 1440 { 1378 1441 if (!this->firstItem) 1379 this->firstItem = this->currItem = new MenuItem; 1442 { 1443 this->firstItem = this->currItem = new MenuItem; 1444 this->currItem->itemNumber = 0; 1445 } 1380 1446 else 1381 this->currItem = this->currItem->next = new MenuItem; 1447 { 1448 int tmpI = this->currItem->itemNumber; 1449 this->currItem = this->currItem->next = new MenuItem; 1450 this->currItem->itemNumber = tmpI+1; 1451 } 1382 1452 1383 1453 this->currItem->name = new char[strlen(itemName)+1]; 1384 1454 strcpy(this->currItem->name, itemName); 1455 1385 1456 #ifdef HAVE_GTK2 1386 1457 this->currItem->item = gtk_menu_item_new_with_label(itemName); … … 1499 1570 1500 1571 /** 1572 \brief creates the Optionlabel save-string 1573 \returns the String to save. 1574 */ 1575 char* OptionLabel::save(void) 1576 { 1577 return cValue; 1578 } 1579 1580 /** 1581 \brief loads an Option from of its loadString 1582 \param loadString the string from which to load the data from 1583 */ 1584 void OptionLabel::load(char* loadString) 1585 { 1586 PRINTF(3)( "Loading %s: setting to %s\n", this->title, loadString); 1587 this->setValue(loadString); 1588 } 1589 1590 /** 1501 1591 \brief Creates a new default Label with no Text. 1502 1592 You migth consider adding Label::setTitle with this.
Note: See TracChangeset
for help on using the changeset viewer.