Changeset 3292 in orxonox.OLD for orxonox/branches/updater/src/gui
- Timestamp:
- Dec 26, 2004, 5:56:18 PM (20 years ago)
- Location:
- orxonox/branches/updater/src/gui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/updater/src/gui/orxonox_gui.cc
r3263 r3292 102 102 exec->readFromFile (orxonoxGUI); 103 103 104 // orxonoxGUI->walkThrough(orxonoxGUI->listOptions);105 106 104 orxonoxGUI->showall (); 107 105 … … 110 108 mainloopGTK(); 111 109 #else /* HAVE_GTK2 */ 112 cout << " Listing all the Orxonox Options: \n";113 cout << " #############################\n";114 orxonoxGUI->walkThrough(orxonoxGUI->listOptions );110 PRINTF(0)(" Listing all the Orxonox Options: \n"); 111 PRINTF(0)(" #############################\n"); 112 orxonoxGUI->walkThrough(orxonoxGUI->listOptions, 0); 115 113 116 cout << "\nDo you want me to save the the above values now? [Yn] ";114 PRINTF(0)("\nDo you want me to save the the above values now? [Yn] "); 117 115 char c = getchar(); 118 116 if ((c == 'y' || c == 'Y' || c== 10) && exec->shouldsave()) -
orxonox/branches/updater/src/gui/orxonox_gui_exec.cc
r3290 r3292 184 184 { 185 185 CONFIG_FILE = fopen (configFile, "r"); 186 VarInfo varInfo; 186 187 if (CONFIG_FILE) 187 188 { … … 211 212 212 213 fscanf (CONFIG_FILE, "%s", Buffer); 213 Value = Buffer; 214 readFileText (groupWidget, Variable, Value, 0); 214 varInfo.variableName = Variable; 215 varInfo.variableValue = Buffer; 216 groupWidget->walkThrough(readFileText, &varInfo, 0); 215 217 sprintf (Variable, ""); 216 218 } 217 219 sprintf (Variable, "%s", Buffer); 218 220 } 219 widget->walkThrough(widget->setOptions );221 widget->walkThrough(widget->setOptions, 0); 220 222 } 221 223 } … … 227 229 \param depth the depth of the local Widget 228 230 */ 229 void OrxonoxGuiExec::readFileText (Widget* widget, char* variableName, char* variableValue, int depth) 230 { 231 void OrxonoxGuiExec::readFileText (Widget* widget, void* varInfo) 232 { 233 VarInfo* info = (VarInfo*)varInfo; 234 231 235 if (widget->isOption >= 1 && widget->isOption <= 3) 232 236 { 233 if (!strcmp (static_cast<Option*>(widget)->title, variableName))234 static_cast<Option*>(widget)->value = atoi( variableValue);237 if (!strcmp (static_cast<Option*>(widget)->title, info->variableName)) 238 static_cast<Option*>(widget)->value = atoi(info->variableValue); 235 239 } 236 240 else if (widget->isOption == 5) 237 241 { 238 if (!strcmp (static_cast<Option*>(widget)->title, variableName)) 239 static_cast<OptionLabel*>(widget)->setValue(variableValue); 240 } 241 if (widget->isOption < 0) 242 { 243 readFileText (static_cast<Packer*>(widget)->down, variableName, variableValue, depth+1); 244 } 245 246 if (widget->next != NULL && depth !=0) 247 readFileText (widget->next, variableName, variableValue, depth); 242 if (!strcmp (static_cast<Option*>(widget)->title, info->variableName)) 243 static_cast<OptionLabel*>(widget)->setValue(info->variableValue); 244 } 248 245 } 249 246 -
orxonox/branches/updater/src/gui/orxonox_gui_exec.h
r3187 r3292 24 24 char* configFile; //!< The name of the .orxonox.conf(ig)-file. 25 25 FILE* CONFIG_FILE; //!< Filehandler for reading and writing. 26 27 //! A struct that holds informations about variables. 28 struct VarInfo 29 { 30 char* variableName; //!< The Name of this variable; 31 char* variableValue; //!< The Value this variable gets. 32 }; 26 33 27 34 public: … … 36 43 void writeFileText (Widget* widget, int depth); 37 44 void readFromFile (Widget* widget); 38 void readFileText (Widget* widget, char* variableName, char* variableValue, int depth);45 static void readFileText (Widget* widget, void* varInfo); 39 46 Widget* locateGroup(Widget* widget, char* groupName, int depth); 40 47 -
orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc
r3291 r3292 155 155 \param function must be of type void and takes a Widget* as an Input. 156 156 */ 157 void Widget::walkThrough (void (*function)(Widget*) )157 void Widget::walkThrough (void (*function)(Widget*), unsigned int depth) 158 158 { 159 159 function(this); 160 160 if (this->isOption < 0) 161 161 { 162 static_cast<Packer*>(this)->down->walkThrough (function );162 static_cast<Packer*>(this)->down->walkThrough (function, depth+1); 163 163 } 164 164 165 if (this->next != NULL) 166 this->next->walkThrough(function); 165 if (this->next && depth != 0) 166 this->next->walkThrough(function, depth); 167 } 168 169 /** 170 \brief Moves through all the Widgets downwards from this and executes the function on them. 171 \param function must be of type void and takes a Widget* as an Input. 172 \param data Additional Data you want to pass to the function. 173 */ 174 void Widget::walkThrough (void (*function)(Widget*, void*), void* data, unsigned int depth) 175 { 176 function(this, data); 177 if (this->isOption < 0) 178 { 179 static_cast<Packer*>(this)->down->walkThrough(function, data, depth+1); 180 } 181 if (this->next && depth != 0) 182 this->next->walkThrough(function, data, depth); 167 183 } 168 184 … … 188 204 { 189 205 if (widget->isOption >= 1) 190 static_cast<Option*>(widget)->redraw(); // <<" is : " << static_cast<Option*>(this)->value <<endl;206 static_cast<Option*>(widget)->redraw(); 191 207 } 192 208 … … 635 651 636 652 /** 637 \ destructs an EventBox.653 \brief destructs an EventBox. 638 654 */ 639 655 EventBox::~EventBox(void) … … 703 719 704 720 /** 705 \ destructs a Box.721 \brief destructs a Box. 706 722 */ 707 723 Box::~Box(void) … … 890 906 891 907 /** 892 \ destructs a Button.908 \brief destructs a Button. 893 909 */ 894 910 Button::~Button(void) … … 964 980 965 981 /** 966 \ destructs a CheckButton.982 \brief destructs a CheckButton. 967 983 */ 968 984 CheckButton::~CheckButton(void) … … 1064 1080 1065 1081 /** 1066 \ destructs a Slider.1082 \brief destructs a Slider. 1067 1083 */ 1068 1084 Slider::~Slider(void) … … 1178 1194 1179 1195 /** 1180 \ destructs a Menu.1196 \brief destructs a Menu. 1181 1197 */ 1182 1198 Menu::~Menu(void) … … 1280 1296 1281 1297 /** 1282 \ destructs an OptionLabel.1298 \brief destructs an OptionLabel. 1283 1299 */ 1284 1300 OptionLabel::~OptionLabel(void) … … 1375 1391 1376 1392 /** 1377 \ destructs a Label.1393 \brief destructs a Label. 1378 1394 */ 1379 1395 Label::~Label(void) … … 1553 1569 1554 1570 /** 1555 \ destructs an Image.1571 \brief destructs an Image. 1556 1572 */ 1557 1573 Image::~Image(void) -
orxonox/branches/updater/src/gui/orxonox_gui_gtk.h
r3290 r3292 53 53 virtual void setTitle(char* title) = 0; //!< An abstract Function, that sets the title of Widgets. 54 54 55 void walkThrough (void (*function)(Widget*)); 55 void walkThrough (void (*function)(Widget*), unsigned int depth); 56 void walkThrough (void (*function)(Widget*, void*), void* data, unsigned int depth); 56 57 static void listOptions (Widget* widget); 57 58 static void setOptions (Widget* widget);
Note: See TracChangeset
for help on using the changeset viewer.