Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3292 in orxonox.OLD for orxonox/branches/updater


Ignore:
Timestamp:
Dec 26, 2004, 5:56:18 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/updater: walkThrough is better now.

Location:
orxonox/branches/updater/src/gui
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/updater/src/gui/orxonox_gui.cc

    r3263 r3292  
    102102  exec->readFromFile (orxonoxGUI);
    103103
    104   //  orxonoxGUI->walkThrough(orxonoxGUI->listOptions);
    105 
    106104  orxonoxGUI->showall ();
    107105
     
    110108  mainloopGTK();
    111109#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);
    115113
    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] ");
    117115  char c = getchar();
    118116  if ((c == 'y' || c == 'Y' || c== 10) && exec->shouldsave())
  • orxonox/branches/updater/src/gui/orxonox_gui_exec.cc

    r3290 r3292  
    184184{
    185185  CONFIG_FILE = fopen (configFile, "r");
     186  VarInfo varInfo;
    186187  if (CONFIG_FILE)
    187188    {
     
    211212             
    212213              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);
    215217              sprintf (Variable, "");
    216218            }
    217219          sprintf (Variable, "%s", Buffer);
    218220        }
    219       widget->walkThrough(widget->setOptions);
     221      widget->walkThrough(widget->setOptions, 0);
    220222    }
    221223}
     
    227229   \param depth the depth of the local Widget
    228230*/
    229 void OrxonoxGuiExec::readFileText (Widget* widget, char* variableName, char* variableValue, int depth)
    230 {
     231void OrxonoxGuiExec::readFileText (Widget* widget, void* varInfo)
     232{
     233  VarInfo* info = (VarInfo*)varInfo;
     234
    231235  if (widget->isOption >= 1 && widget->isOption <= 3)
    232236    {
    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);
    235239    }
    236240  else if (widget->isOption == 5)
    237241    {
    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    }
    248245}
    249246
  • orxonox/branches/updater/src/gui/orxonox_gui_exec.h

    r3187 r3292  
    2424  char* configFile;            //!< The name of the .orxonox.conf(ig)-file.
    2525  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  };
    2633
    2734 public:
     
    3643  void writeFileText (Widget* widget, int depth);
    3744  void readFromFile (Widget* widget);
    38   void readFileText (Widget* widget, char* variableName, char* variableValue, int depth);
     45  static void readFileText (Widget* widget, void* varInfo);
    3946  Widget* locateGroup(Widget* widget, char* groupName, int depth);
    4047
  • orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc

    r3291 r3292  
    155155   \param function must be of type void and takes a Widget* as an Input.
    156156*/
    157 void Widget::walkThrough (void (*function)(Widget*))
     157void Widget::walkThrough (void (*function)(Widget*), unsigned int depth)
    158158{
    159159  function(this);
    160160  if (this->isOption < 0)
    161161    {
    162       static_cast<Packer*>(this)->down->walkThrough (function);
     162      static_cast<Packer*>(this)->down->walkThrough (function, depth+1);
    163163    }
    164164
    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*/
     174void 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);
    167183}
    168184
     
    188204{
    189205  if (widget->isOption >= 1)
    190     static_cast<Option*>(widget)->redraw();// <<" is : " << static_cast<Option*>(this)->value <<endl;
     206    static_cast<Option*>(widget)->redraw();
    191207}
    192208
     
    635651
    636652/**
    637    \destructs an EventBox.
     653   \brief destructs an EventBox.
    638654*/
    639655EventBox::~EventBox(void)
     
    703719
    704720/**
    705    \destructs a Box.
     721   \brief destructs a Box.
    706722*/
    707723Box::~Box(void)
     
    890906
    891907/**
    892    \destructs a Button.
     908   \brief destructs a Button.
    893909*/
    894910Button::~Button(void)
     
    964980
    965981/**
    966    \destructs a CheckButton.
     982   \brief destructs a CheckButton.
    967983*/
    968984CheckButton::~CheckButton(void)
     
    10641080
    10651081/**
    1066    \destructs a Slider.
     1082   \brief destructs a Slider.
    10671083*/
    10681084Slider::~Slider(void)
     
    11781194
    11791195/**
    1180    \destructs a Menu.
     1196   \brief destructs a Menu.
    11811197*/
    11821198Menu::~Menu(void)
     
    12801296
    12811297/**
    1282    \destructs an OptionLabel.
     1298   \brief destructs an OptionLabel.
    12831299*/
    12841300OptionLabel::~OptionLabel(void)
     
    13751391
    13761392/**
    1377    \destructs a Label.
     1393   \brief destructs a Label.
    13781394*/
    13791395Label::~Label(void)
     
    15531569
    15541570/**
    1555    \destructs an Image.
     1571   \brief destructs an Image.
    15561572*/
    15571573Image::~Image(void)
  • orxonox/branches/updater/src/gui/orxonox_gui_gtk.h

    r3290 r3292  
    5353  virtual void setTitle(char* title) = 0;  //!< An abstract Function, that sets the title of Widgets.
    5454
    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);
    5657  static void listOptions (Widget* widget);
    5758  static void setOptions (Widget* widget);
Note: See TracChangeset for help on using the changeset viewer.