Changeset 3464 in orxonox.OLD for orxonox/branches/updater/src/gui
- Timestamp:
- Mar 9, 2005, 2:41:38 PM (20 years ago)
- Location:
- orxonox/branches/updater/src/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/updater/src/gui/orxonox_gui_exec.cc
r3379 r3464 50 50 this->saveSettings->saveability(); 51 51 this->execBox->fill(this->saveSettings); 52 this->verboseMode = new Menu("verbose mode", "no output", "error", "warning", "info", "lastItem");52 this->verboseMode = new Menu("verbose mode", "nothing", "error", "warning", "info", "lastItem"); 53 53 this->verboseMode->setFlagName("verbose", "v", 0); 54 54 this->verboseMode->saveability(); … … 190 190 space2under[0] = '_'; 191 191 } 192 if(widget->isOption <=3) 193 fprintf(CONFIG_FILE, "%s = %d\n", Buffer, static_cast<Option*>(widget)->value); 194 else if(widget->isOption == 5) 195 fprintf(CONFIG_FILE, "%s = %s\n", Buffer, static_cast<OptionLabel*>(widget)->cValue); 192 fprintf(CONFIG_FILE, "%s = %s\n", Buffer, static_cast<Option*>(widget)->save()); 196 193 } 197 194 … … 259 256 { 260 257 PRINT(3)("Located Option %s.\n", widget->title); 261 if(widget->isOption >= 1 && widget->isOption <= 3) 262 { 263 static_cast<Option*>(widget)->value = atoi(info->variableValue); 264 static_cast<Option*>(widget)->redraw(); //!< \todo change this to setValue. 265 } 266 else if(widget->isOption == 5) 267 static_cast<OptionLabel*>(widget)->setValue(info->variableValue); 258 if(widget->isOption >= 1) 259 static_cast<Option*>(widget)->load(info->variableValue); 268 260 } 269 261 } -
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. -
orxonox/branches/updater/src/gui/orxonox_gui_gtk.h
r3317 r3464 230 230 void saveability(void); 231 231 void saveability(bool isSaveable); 232 virtual char* save(void); 233 virtual void load(char* loadString); 234 232 235 bool isSaveable(void); 233 236 void setFlagName(char* flagname, int defaultvalue); … … 304 307 GtkWidget* item; //!< One Item From a Menu. 305 308 #endif /* HAVE_GTK2 */ 306 va_list itemlist; //!< The list to readin multiple Options. 309 310 //! A Struct to handle information about the different Items of the Menu. 311 struct Item 312 { 313 int itemNumber; //!< The n-th item of the List 314 #ifdef HAVE_GTK2 315 GtkWidget* item; //!< The GTK-widget of the Item 316 #endif /* HAVE_GTK2 */ 317 char* label; //!< The label of the Item 318 Item* next; //!< Pointer to the next Item 319 }; 320 321 Item* firstItem; 307 322 308 323 public: … … 311 326 void init(void); 312 327 void destroy(void); 328 329 virtual char* save(void); 330 virtual void load(char* loadString); 313 331 314 332 void setTitle(char* title); … … 332 350 void setValue(char* newValue); 333 351 void setTitle(char* title); 352 353 virtual char* save(void); 354 virtual void load(char* loadString); 355 334 356 void redraw(void); 335 357 void changeOption(void);
Note: See TracChangeset
for help on using the changeset viewer.