Changeset 3464 in orxonox.OLD for orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc
- Timestamp:
- Mar 9, 2005, 2:41:38 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc
r3316 r3464 1123 1123 1124 1124 /** 1125 \brief saves an Option 1126 \returns the String that should be saved. 1127 1128 this is a default Option save 1129 */ 1130 char* Option::save(void) 1131 { 1132 char* value = new char [10]; 1133 sprintf (value, "%d", this->value); 1134 return value; 1135 } 1136 1137 /** 1138 \brief loads an Option from of its loadString 1139 \param loadString the string from which to load the data from 1140 */ 1141 void Option::load(char* loadString) 1142 { 1143 this->value = atoi(loadString); 1144 printf( "Loading %s: %s %d\n", this->title, loadString, value); 1145 this->redraw(); 1146 } 1147 1148 /** 1125 1149 \returns The saveable-state. 1126 1150 */ … … 1448 1472 this->init(); 1449 1473 this->setTitle(menuname); 1450 1474 va_list itemlist; //!< The list to readin multiple Options. 1475 1451 1476 char *itemName; 1452 1477 … … 1480 1505 { 1481 1506 this->isOption = 2; 1507 this->firstItem = NULL; 1482 1508 1483 1509 static_cast<Option*>(this)->init(); … … 1489 1515 1490 1516 } 1491 1492 1517 /** 1493 1518 \brief Destroys a Menu. … … 1500 1525 PRINTF(3)("deleting the Menu.\n"); 1501 1526 //! \todo destroy menu 1527 1528 // deleting all the items 1529 Item* tmpItem = this->firstItem; 1530 while(tmpItem) 1531 { 1532 delete []tmpItem->label; 1533 1534 tmpItem = tmpItem->next; 1535 } 1502 1536 1503 1537 static_cast<Option*>(this)->destroy(); 1504 1538 } 1505 1539 1540 /** 1541 \brief saves the Label of the Menu 1542 \returns the name of the selected Menu-Item 1543 */ 1544 char* Menu::save(void) 1545 { 1546 Item* tmpItem = this->firstItem; 1547 for (int i = 0; i<this->value; i++) 1548 tmpItem = tmpItem->next; 1549 1550 return tmpItem->label; 1551 } 1552 1553 /** 1554 \brief loads a Menu from of its loadString 1555 \param loadString the string from which to load the data from 1556 */ 1557 void Menu::load(char* loadString) 1558 { 1559 Item* tmpItem = firstItem; 1560 bool foundItem = false; 1561 while (tmpItem) 1562 { 1563 if (!strcmp(loadString, tmpItem->label)) 1564 {foundItem = true; break;} 1565 tmpItem = tmpItem->next; 1566 } 1567 if (foundItem) 1568 this->value = tmpItem->itemNumber; 1569 else 1570 { 1571 this->value = 0; 1572 PRINTF(2)("Sorry, but %s has not been found in the Itemlist of %s\n", loadString, this->title); 1573 } 1574 PRINTF(3)( "Loading %s: setting to %d\n", this->title, this->value); 1575 this->redraw(); 1576 } 1506 1577 1507 1578 /** … … 1525 1596 void Menu::addItem(char* itemName) 1526 1597 { 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); 1598 Item* tmpItem; 1599 int i = 0; 1600 if (!this->firstItem) 1601 { 1602 tmpItem = this->firstItem = new Item; 1603 } 1604 else 1605 { 1606 ++i; 1607 tmpItem = this->firstItem; 1608 while (tmpItem->next) 1609 { 1610 ++i; 1611 tmpItem = tmpItem->next; 1612 } 1613 tmpItem = tmpItem->next = new Item; 1614 } 1615 tmpItem->next = NULL; 1616 tmpItem->itemNumber = i; 1617 tmpItem->label = new char[strlen(itemName)+1]; 1618 strcpy(tmpItem->label, itemName); 1619 #ifdef HAVE_GTK2 1620 tmpItem->item = gtk_menu_item_new_with_label(itemName); 1621 gtk_menu_shell_append(GTK_MENU_SHELL(this->menu), tmpItem->item); 1530 1622 #endif /* HAVE_GTK2 */ 1531 1623 } … … 1666 1758 1667 1759 /** 1760 \brief creates the Optionlabel save-string 1761 \returns the String to save. 1762 */ 1763 char* OptionLabel::save(void) 1764 { 1765 return cValue; 1766 } 1767 1768 /** 1769 \brief loads an Option from of its loadString 1770 \param loadString the string from which to load the data from 1771 */ 1772 void OptionLabel::load(char* loadString) 1773 { 1774 PRINTF(3)( "Loading %s: setting to %s\n", this->title, loadString); 1775 this->setValue(loadString); 1776 } 1777 1778 /** 1668 1779 \brief Creates a new default Label with no Text. 1669 1780 You migth consider adding Label::setTitle with this.
Note: See TracChangeset
for help on using the changeset viewer.