Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Dec 27, 2004, 2:02:11 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/updater: flags now working perfectly. not the fastest way to implement this, but still….

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

Legend:

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

    r3187 r3299  
    2828  ~OrxonoxGui ();
    2929
     30  void copyOptionsToGameStruct();
    3031};
    3132
    3233
    33 
    3434#endif /* _ORXONOX_GUI_H */
  • orxonox/branches/updater/src/gui/orxonox_gui_flags.cc

    r3287 r3299  
    3232OrxonoxGuiFlags::OrxonoxGuiFlags (Widget* widget)
    3333{
    34   flagText = (char*) malloc (1024);
     34  this->flagsFrame = new Frame ("Orxonox-Startup-Flags:");
     35  this->flagsBox = new Box ('v');
    3536
    36   flagsFrame = new Frame ("Orxonox-Startup-Flags:");
    37   flagsBox = new Box ('v');
     37  this->flagsLabel = new Label ();
     38  this->flagsLabel->setSize (260,60);
     39  this->flagsBox->fill (flagsLabel);
     40  this->shortFlags = new CheckButton ("shortFlags");
     41  this->flagsBox->fill (shortFlags);
    3842
    39   flagsLabel = new Label ();
    40   flagsLabel->setSize (260,60);
    41   flagsBox->fill (flagsLabel);
    42   shortFlags = new CheckButton ("shortFlags");
    43   flagsBox->fill (shortFlags);
    44 
    45   flagsFrame->fill (flagsBox);
     43  this->flagsFrame->fill (flagsBox);
    4644}
    4745
     
    5250Widget* OrxonoxGuiFlags::getWidget ()
    5351{
    54   return flagsFrame;
     52  return this->flagsFrame;
    5553}
    5654
     
    6159void OrxonoxGuiFlags::setTextFromFlags (Widget* widget)
    6260{
    63   sprintf (flagText, "");
    64   strcat (flagText, "orxonox");
    65   FlagsText (widget);
    66   flagsLabel->setTitle(flagText);
     61  FlagInfo flagInfo;
     62  flagInfo.shortFlags = this->shortFlags;
     63  flagInfo.flagsLabel = this->flagsLabel;
     64
     65  this->flagsLabel->ereaseText();
     66  this->flagsLabel->appendText("orxonox");
     67  widget->walkThrough(OrxonoxGuiFlags::flagsText, &flagInfo, 0);
     68  //  flagsLabel->setTitle(flagText);
    6769}
    6870
     
    7173    \param widget like OrxonoxGuiFlags::setTextFromFlags(widget)
    7274*/
    73 void OrxonoxGuiFlags::FlagsText(Widget* widget)
     75void OrxonoxGuiFlags::flagsText(Widget* widget, void* flagInfo)
    7476{
     77  FlagInfo* info = (FlagInfo*)flagInfo;
    7578  if (widget->isOption >= 1)
    76     if  (static_cast<Option*>(widget)->value != static_cast<Option*>(widget)->defaultValue && (static_cast<Option*>(widget)->flagName || static_cast<Option*>(widget)->flagNameShort ))
     79    if  (static_cast<Option*>(widget)->value != static_cast<Option*>(widget)->defaultValue )
    7780      {
    78         if (shortFlags->isActive())
     81        if (info->shortFlags->isActive() && static_cast<Option*>(widget)->flagNameShort)
    7982          {
    80             strcat (flagText, " -");
    81             strcat (flagText, static_cast<Option*>(widget)->flagNameShort);
     83            info->flagsLabel->appendText(" -");
     84            info->flagsLabel->appendText(static_cast<Option*>(widget)->flagNameShort);
    8285          }
    83         else
     86        else if (!info->shortFlags->isActive() && static_cast<Option*>(widget)->flagName)
    8487          {
    85             strcat (flagText, " --");
    86             strcat (flagText, static_cast<Option*>(widget)->flagName);
     88            info->flagsLabel->appendText(" --");
     89            info->flagsLabel->appendText(static_cast<Option*>(widget)->flagName);
    8790          }
     91
    8892        if (static_cast<Option*>(widget)->isOption == 2)
    8993          {
    90             sprintf (flagText, "%s=%i", flagText, static_cast<Option*>(widget)->value);
     94            info->flagsLabel->appendText("=");
     95            info->flagsLabel->appendInt(static_cast<Option*>(widget)->value);
    9196          }
    9297      }
    93   switch (widget->isOption)
    94     {
    95     case -1:
    96       FlagsText (static_cast<Container*>(widget)->down);
    97       break;
    98     case -2:
    99       FlagsText (static_cast<Box*>(widget)->down);
    100       break;
    101     }
    102  
    103   if (widget->next != NULL)
    104     FlagsText (widget->next);
    10598}
  • orxonox/branches/updater/src/gui/orxonox_gui_flags.h

    r3187 r3299  
    1717  CheckButton* shortFlags;    //!< CheckButton to change the display of short and long flags \todo show long if long not availible...
    1818  Label* flagsLabel;          //!< The Label of the Flags
    19   char* flagText;             //!< The Text of the Label. \todo Delete when Object is destroyed.
    2019
    2120 public:
     
    2423
    2524  void setTextFromFlags (Widget* widget);
    26   void OrxonoxGuiFlags::FlagsText(Widget* widget);
     25  static void flagsText(Widget* widget, void* flagInfo);
    2726 
     27  struct FlagInfo
     28  {
     29    CheckButton* shortFlags;
     30    Label* flagsLabel;
     31  };
    2832  Widget* getWidget ();
    2933};
  • orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc

    r3298 r3299  
    15131513
    15141514/**
     1515   \brief ereases the Text of a Label
     1516*/
     1517void Label::ereaseText(void)
     1518{
     1519  this->setTitle("");
     1520}
     1521
     1522/**
     1523    \brief appends some Text to a Label
     1524    \param textToAppend The text that will be appended to this Label
     1525*/
     1526void Label::appendText(char* textToAppend)
     1527{
     1528  if (this->title)
     1529    {
     1530      char* tmpTitle = new char[strlen(this->title)+strlen(textToAppend)+1];
     1531      strcpy(tmpTitle, title); 
     1532      strcat(tmpTitle, textToAppend);
     1533      delete []this->title;
     1534      this->title = tmpTitle;
     1535    }
     1536  else
     1537    {
     1538      this->title = new char[strlen(textToAppend)];
     1539    }
     1540 
     1541#ifdef HAVE_GTK2
     1542  gtk_label_set_text (GTK_LABEL (this->widget), title);
     1543#endif /* HAVE_GTK2 */
     1544}
     1545
     1546/**
     1547    \brief Appends some integer to the Label
     1548    \param intToAppend The Int that will be added.
     1549   
     1550    it does this by just converting the int into a char* and send it to appendText
     1551*/
     1552void Label::appendInt(int intToAppend)
     1553{
     1554  char append [20];
     1555  sprintf(append, "%d", intToAppend);
     1556  this->appendText(append);
     1557}
     1558
     1559
     1560/**
    15151561   \brief get the Text of a Label
    15161562   \return The Text the Label holds.
  • orxonox/branches/updater/src/gui/orxonox_gui_gtk.h

    r3296 r3299  
    316316};
    317317
    318 //! A CharLabel is a simple Label, that holds a char*, and will be updated, if changed.
     318//! A OptionLabel is a simple Label, that holds a char*, and will be updated, if changed.
    319319class OptionLabel : public Option
    320320{
     
    347347 
    348348  void setTitle(char* text);
     349  void ereaseText(void);
     350  void appendText(char* textToAppend);
     351  void appendInt(int intToAppend);
    349352  char* getText ();
    350353};
  • orxonox/branches/updater/src/gui/rc

    r2595 r3299  
    120120# just listed in this document for the users reference.
    121121
    122 widget_class "GtkWindow" style "window"
    123 widget_class "GtkFrame" style "window"
    124 widget_class "Gtk*EventBox" style "window"
    125 widget_class "GtkDialog" style "window"
    126 widget_class "GtkFileSelection" style "window"
    127 widget_class "*Gtk*Scale" style "scale"
    128 widget_class "*GtkCheckButton*" style "toggle_button"
    129 widget_class "*Gtk*Menu*" style "toggle_button"
    130 widget_class "*GtkRadioButton*" style "toggle_button"
    131 widget_class "*GtkButton*" style "button"
    132 widget_class "*Ruler" style "ruler"
    133 widget_class "*GtkText" style "text"
    134 widget_class "*GtkLabel" style "text"
     122widget_class "GtkWindow"           style "window"
     123widget_class "GtkFrame"            style "window"
     124widget_class "Gtk*EventBox"        style "window"
     125widget_class "GtkDialog"           style "window"
     126widget_class "GtkFileSelection"    style "window"
     127widget_class "*Gtk*Scale"          style "scale"
     128widget_class "*GtkCheckButton*"    style "toggle_button"
     129widget_class "*Gtk*Menu*"          style "toggle_button"
     130widget_class "*GtkRadioButton*"    style "toggle_button"
     131widget_class "*GtkButton*"         style "button"
     132widget_class "*Ruler"              style "ruler"
     133widget_class "*GtkText"            style "text"
     134widget_class "*GtkLabel"           style "text"
    135135
    136136
Note: See TracChangeset for help on using the changeset viewer.