Changeset 3305 in orxonox.OLD for orxonox/branches/updater/src
- Timestamp:
- Dec 29, 2004, 12:05:29 AM (20 years ago)
- Location:
- orxonox/branches/updater/src/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/updater/src/gui/orxonox_gui.cc
r3303 r3305 58 58 OrxonoxGui::OrxonoxGui (int argc, char *argv[]) 59 59 { 60 #ifdef HAVE_GTK2 61 initGTK(argc, argv); 62 #endif /* HAVE_GTK2 */ 60 initGUI(argc, argv); 63 61 64 62 orxonoxGUI = new Window( "Grafical OrxOnoX loader, "PACKAGE_VERSION); … … 121 119 OrxonoxGuiExec::startOrxonox(NULL, exec); 122 120 else 121 { 123 122 #ifdef HAVE_GTK2 124 { 125 mainloopGTK(); 123 mainloopGUI(); 124 #else /* HAVE_GTK2 */ 125 char boolAns = 'y'; 126 char ans[10]; 127 while(true) 128 { 129 PRINT(0)(" Listing all the Orxonox Options: \n"); 130 PRINT(0)(" #############################\n"); 131 Window::mainWindow->walkThrough(Widget::listOptionsAndGroups, 1); 132 133 PRINT(0)("\nDo you want change any of the above values now? [Yn] "); 134 cin >>boolAns ; 135 if (boolAns =='n' || boolAns=='N') 136 break; 137 138 PRINT(0)("\n Listing all groups\n"); 139 PRINT(0)(" #################\n"); 140 int groupCount = 0; 141 Window::mainWindow->walkThrough(Widget::listGroups, &groupCount, 1); 142 143 PRINT(0)("\nIn which Group? [1-%d] ", groupCount); 144 Packer* group; 145 while(true) 146 { 147 cin >> ans; 148 int ansIp = atoi(ans); 149 if (ansIp <= groupCount) 150 { 151 group = static_cast<Packer*>(Window::mainWindow->findGroupByNumber(&ansIp, 1)); 152 break; 153 } 154 else 155 PRINT(0)("\nChoose a smaler Number please: [1-%d] ", groupCount); 156 } 157 PRINT(0)("\n\nGroup: [%s]\n\n", group->groupName); 158 int optionCount = 0; 159 group->walkThrough(Widget::listOptions, &optionCount, 0); 160 PRINT(0)("\nWhich Option? [1-%d] ", optionCount); 161 Option* option; 162 while(true) 163 { 164 cin >> ans; 165 int ansIp = atoi(ans); 166 if (ansIp <= groupCount) 167 { 168 option = static_cast<Option*>(group->findOptionByNumber(&ansIp, 0)); 169 break; 170 } 171 else 172 PRINT(0)("\nChoose a smaler Number please: [1-%d] ", optionCount); 173 } 174 PRINT(0)("\n\n:: %s ::\n", option->title); 175 176 // here follows the rest.... this will be nasty. 177 //! \todo move this into the gui-gtk-file 178 //! \todo finish it. 179 } 126 180 } 127 #else /* HAVE_GTK2 */128 {129 PRINT(0)(" Listing all the Orxonox Options: \n");130 PRINT(0)(" #############################\n");131 orxonoxGUI->walkThrough(orxonoxGUI->listOptions, 0);132 133 PRINT(0)("\nDo you want me to save the the above values now? [Yn] ");134 char c = getchar();135 if ((c == 'y' || c == 'Y' || c== 10) && exec->shouldsave())136 exec->writeToFile (Window::mainWindow);137 OrxonoxGuiExec::startOrxonox(NULL, exec);138 }139 181 140 182 #endif /* HAVE_GTK2 */ -
orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc
r3304 r3305 37 37 extern OrxonoxGuiFlags* flags; 38 38 39 #ifdef HAVE_GTK240 39 /** 41 40 \brief Initializes the Guis GTK-stuff. … … 43 42 \param argv The Argument strings. 44 43 */ 45 bool initGTK(int argc, char *argv[]) 46 { 44 bool initGUI(int argc, char *argv[]) 45 { 46 #ifdef HAVE_GTK2 47 47 #ifdef HAVE_GTHREAD 48 48 PRINTF(3)("Initializing the ThreadSystem of the GUI\n"); … … 52 52 gtk_init (&argc, &argv); 53 53 gtk_rc_parse( "rc" ); 54 } 54 #endif /* HAVE_GTK2 */ 55 } 56 55 57 56 58 /** 57 59 \brief enters the GTK-main-loop 58 60 */ 59 bool mainloopGTK(void) 60 { 61 bool mainloopGUI(void) 62 { 63 #ifdef HAVE_GTK2 61 64 gdk_threads_enter(); 62 65 gtk_main(); 63 66 gdk_threads_leave(); 64 67 delete Window::mainWindow; 65 } 66 #endif /* HAVE_GTK2 */ 68 #endif /* HAVE_GTK2 */ 69 } 67 70 68 71 … … 154 157 Widget* Widget::findWidgetByName(char* name, unsigned int depth) 155 158 { 156 Widget* tmp = NULL;157 159 158 160 if (this->title && !strcmp(this->title, name)) … … 160 162 161 163 if (this->isOption < 0 && static_cast<Packer*>(this)->down) 162 tmp = static_cast<Packer*>(this)->down->findWidgetByName(name, depth+1); 163 if (tmp) 164 return tmp; 165 164 { 165 Widget* tmp = static_cast<Packer*>(this)->down->findWidgetByName(name, depth+1); 166 if (tmp) 167 return tmp; 168 } 166 169 167 170 if (depth>0 && this->next) … … 206 209 207 210 /** 208 \brief This is for listing the option of "widget"211 \brief This is for listing the options of "widget" 209 212 \param widget specifies the widget that should be listed 210 213 */ 211 void Widget::listOptions (Widget* widget)214 void Widget::listOptionsAndGroups (Widget* widget) 212 215 { 213 216 if (widget->isOption < 0 && static_cast<Packer*>(widget)->groupName) … … 219 222 } 220 223 224 /** 225 \brief This is for listing the options of "widget" 226 \param widget specifies the widget that should be listed 227 */ 228 void Widget::listOptions (Widget* widget) 229 { 230 if (widget->isOption >= 1 && widget->isOption <= 3) 231 cout << " " << static_cast<Option*>(widget)->title <<" is : " << static_cast<Option*>(widget)->value <<endl; 232 else if (widget->isOption == 5) 233 cout << " " << static_cast<Option*>(widget)->title <<" is : " << static_cast<OptionLabel*>(widget)->cValue <<endl; 234 } 235 236 /** 237 \brief This is for listing the options of "widget" 238 \param widget specifies the widget that should be listed 239 \param data A Counter, that always knows how many Options have been found yet. 240 */ 241 void Widget::listOptions (Widget* widget, void* data) 242 { 243 244 if (widget->isOption >= 1 && widget->isOption <= 3) 245 { 246 int* count = (int*)data; 247 *count = *count +1; 248 cout << *count << ": " << static_cast<Option*>(widget)->title <<" is : " << static_cast<Option*>(widget)->value <<endl; 249 } 250 else if (widget->isOption == 5) 251 { 252 int* count = (int*)data; 253 *count = *count +1; 254 cout << *count << ": " << static_cast<Option*>(widget)->title <<" is : " << static_cast<OptionLabel*>(widget)->cValue <<endl; 255 } 256 } 257 258 /** 259 \brief Finds an Option by a given number (the n'th option found away from this Widget) 260 \param number The Count of options to wait (by reference) 261 \param depth The depth of the sarch. if 0 it will not search next pointer 262 263 \todo should return Option* would be much sexier. 264 */ 265 Widget* Widget::findOptionByNumber(int* number, unsigned int depth) 266 { 267 if (isOption > 0) 268 { 269 --*number; 270 if (*number <= 0) 271 { 272 return this; 273 } 274 } 275 if (this->isOption < 0 && static_cast<Packer*>(this)->down) 276 { 277 Widget* tmp = static_cast<Packer*>(this)->down->findOptionByNumber(number, depth+1); 278 if (tmp) 279 return tmp; 280 } 281 if (depth>0 && this->next) 282 return this->next->findOptionByNumber(number, depth); 283 284 return NULL; 285 } 286 287 /** 288 \brief This is for listing the groups of "widget" 289 \param widget specifies the widget that should be listed 290 */ 291 void Widget::listGroups(Widget* widget) 292 { 293 if(widget->isOption < 0 && static_cast<Packer*>(widget)->groupName) 294 cout << "[" << static_cast<Packer*>(widget)->groupName << "]\n"; 295 } 296 297 /** 298 \brief This is for listing the Groups of "widget". It also displays the n'th number found. 299 \param widget specifies the widget that should be listed 300 \param data the Counter, that will show the number (this function will raise it by one if a Group is fount. 301 */ 302 void Widget::listGroups(Widget* widget, void* data) 303 { 304 if(widget->isOption < 0 && static_cast<Packer*>(widget)->groupName) 305 { 306 int* count = (int*)data; 307 *count = *count +1; 308 cout << *count <<": [" << static_cast<Packer*>(widget)->groupName << "]\n"; 309 } 310 } 311 312 /** 313 \brief Finds a Group by a given number (the n'th Group found away from this Widget) 314 \param number The Count of options to wait (by reference) 315 \param depth The depth of the sarch. if 0 it will not search next pointer 316 */ 317 Widget* Widget::findGroupByNumber(int* number, unsigned int depth) 318 { 319 if (isOption < 0 && static_cast<Packer*>(this)->groupName) 320 { 321 --*number; 322 if (*number <= 0) 323 { 324 return this; 325 } 326 } 327 if (this->isOption < 0 && static_cast<Packer*>(this)->down) 328 { 329 Widget* tmp = static_cast<Packer*>(this)->down->findGroupByNumber(number, depth+1); 330 if (tmp) 331 return tmp; 332 } 333 if (depth>0 && this->next) 334 return this->next->findGroupByNumber(number, depth); 335 336 return NULL; 337 } 338 221 339 /** 222 340 \brief This is for setting the option of "widget" -
orxonox/branches/updater/src/gui/orxonox_gui_gtk.h
r3304 r3305 33 33 #endif /* HAVE_GTK2 */ 34 34 35 #ifdef HAVE_GTK2 36 bool initGTK(int argc, char* argv[]); 37 bool mainloopGTK(void); 38 #endif /* HAVE_GTK2 */ 35 bool initGUI(int argc, char* argv[]); 36 bool mainloopGUI(void); 39 37 40 38 //! This is the topmost object that can be displayed all others are derived from it. … … 56 54 void walkThrough (void (*function)(Widget*), unsigned int depth); 57 55 void walkThrough (void (*function)(Widget*, void*), void* data, unsigned int depth); 56 static void listOptionsAndGroups(Widget* widget); 58 57 static void listOptions(Widget* widget); 58 static void listOptions(Widget* widget, void* data); 59 Widget* findOptionByNumber(int* number, unsigned int depth); 60 static void listGroups(Widget* widget); 61 static void listGroups(Widget* widget, void* data); 62 Widget* findGroupByNumber(int* number, unsigned int depth); 59 63 static void setOptions(Widget* widget); 60 64 static void flagCheck(Widget* widget, void* flagName);
Note: See TracChangeset
for help on using the changeset viewer.