Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3304 in orxonox.OLD for orxonox/branches/updater/src


Ignore:
Timestamp:
Dec 28, 2004, 9:46:54 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/updater: nicer optionChange-Function

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

Legend:

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

    r3300 r3304  
    955955}
    956956
     957#ifdef HAVE_GTK2
     958/**
     959    \brief Signal OptionChange writes the Value from the Slider to its Object-Database.
     960    \param widget The widget(Slider) that has a changed Value
     961    \param slider the Slider-Object that should receive the change.
     962*/
     963gint Option::OptionChange (GtkWidget *widget, Widget* option)
     964{
     965  static_cast<Option*>(option)->changeOption();
     966  flags->setTextFromFlags(orxonoxGUI);  //// must be different !!!
     967}
     968#endif /* HAVE_GTK2 */
     969
     970
    957971/* BUTTON */
    958972
     
    10211035   not implemented yet
    10221036*/
    1023 void Button::redraw ()
    1024 {
     1037void Button::redraw (void)
     1038{
     1039}
     1040
     1041/**
     1042   \brief Button can not be changed, optionChange is empty)
     1043*/
     1044void Button::changeOption(void)
     1045{
     1046 
    10251047}
    10261048
     
    10981120}
    10991121
    1100 #ifdef HAVE_GTK2
    1101 /**
    1102     \brief Signal OptionChange writes the Value from the CheckButton to its Object-Database.
    1103     \param widget The widget(CheckButton) that has a changed Value
    1104     \param checkbutton the CheckButton-Object that should receive the change.
    1105 */
    1106 gint CheckButton::OptionChange (GtkWidget *widget, Widget* checkbutton)
    1107 {
    1108   static_cast<CheckButton*>(checkbutton)->value = (int)gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON ((CheckButton*)checkbutton->widget));
    1109   flags->setTextFromFlags(orxonoxGUI);   ////// must be different!!!
    1110   cout << static_cast<CheckButton*>(checkbutton)->title << " set to: " << static_cast<CheckButton*>(checkbutton)->value << endl;
    1111 }
    1112 #endif /* HAVE_GTK2 */
     1122/**
     1123   \brief Changed the Option, call this Function
     1124*/
     1125void CheckButton::changeOption()
     1126{
     1127#ifdef HAVE_GTK2
     1128  this->value = (int)gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (this->widget));
     1129#endif /* HAVE_GTK2 */
     1130  cout << this->title << " set to: " << this->value << endl;
     1131}
     1132
    11131133
    11141134/**
     
    12101230}
    12111231
    1212 #ifdef HAVE_GTK2
    1213 /**
    1214     \brief Signal OptionChange writes the Value from the Slider to its Object-Database.
    1215     \param widget The widget(Slider) that has a changed Value
    1216     \param slider the Slider-Object that should receive the change.
    1217 */
    1218 gint Slider::OptionChange (GtkWidget *widget, Widget* slider)
    1219 {
    1220   static_cast<Slider*>(slider)->value = (int)gtk_range_get_value (GTK_RANGE ((Slider*)slider->widget));
    1221   flags->setTextFromFlags(orxonoxGUI);  //// must be different !!!
    1222   cout << static_cast<Slider*>(slider)->title << " set to: "<< static_cast<Slider*>(slider)->value << endl;
    1223 }
    1224 #endif /* HAVE_GTK2 */
    1225 
     1232/**
     1233   \brief Changed the Option, call this Function
     1234*/
     1235void Slider::changeOption()
     1236{
     1237#ifdef HAVE_GTK2
     1238  this->value = (int)gtk_range_get_value(GTK_RANGE(this->widget));
     1239#endif /* HAVE_GTK2 */
     1240  cout << this->title << " set to: " << this->value << endl;
     1241}
    12261242
    12271243/* MENU */
     
    13291345}
    13301346
    1331 #ifdef HAVE_GTK2
    1332 /**
    1333     \brief Signal OptionChange writes the Value from the Menu to its Object-Database.
    1334     \param widget The widget(Menu) that has a changed Value
    1335     \param menu the Menu-Object that should receive the change.
    1336 */
    1337 gint Menu::OptionChange (GtkWidget *widget, Widget* menu)
    1338 {
    1339   static_cast<Menu*>(menu)->value = (int)gtk_option_menu_get_history (GTK_OPTION_MENU (menu->widget));
    1340   flags->setTextFromFlags(orxonoxGUI); //// must be different !!!
    1341   cout << static_cast<Menu*>(menu)->title << " changed to : " << static_cast<Menu*>(menu)->value << endl;
    1342 }
    1343 #endif /* HAVE_GTK2 */
     1347/**
     1348   \brief Changed the Option, call this Function
     1349*/
     1350void Menu::changeOption()
     1351{
     1352#ifdef HAVE_GTK2
     1353  this->value = (int)gtk_option_menu_get_history (GTK_OPTION_MENU (this->widget));
     1354#endif /* HAVE_GTK2 */
     1355  cout << this->title << " set to: " << this->value << endl;
     1356}
    13441357
    13451358/* OPTION LABEL */
     
    14211434  strcpy(this->title, title);
    14221435#ifdef HAVE_GTK2
    1423   gtk_label_set_text (GTK_LABEL (widget), title);
     1436  gtk_label_set_text (GTK_LABEL(widget), title);
    14241437#endif /* HAVE_GTK2 */
    14251438}
     
    14321445 
    14331446}
     1447
     1448/**
     1449   \brief Changed the Option, call this Function
     1450*/
     1451void OptionLabel::changeOption()
     1452{
     1453#ifdef HAVE_GTK2
     1454  this->cValue = (char*)gtk_label_get_text (GTK_LABEL(this->widget));
     1455#endif /* HAVE_GTK2 */
     1456  cout << this->title << " set to: " << this->cValue << endl;
     1457}
     1458
    14341459
    14351460/**
  • orxonox/branches/updater/src/gui/orxonox_gui_gtk.h

    r3300 r3304  
    216216 
    217217 public:
    218   //virtual gint OptionChange (GtkWidget* widget, GdkEvent* event, gpointer data);
    219218  void init(void);
    220219  void destroy(void);
     
    230229  void setFlagName (char* flagname, int defaultvalue);
    231230  void setFlagName (char* flagname, char* flagnameshort, int defaultvalue);
    232   virtual void redraw () = 0; //!< A Option must be able to redraw itself.
     231  virtual void redraw (void) = 0; //!< A Option must be able to redraw itself.
     232  virtual void changeOption(void) = 0; //!< What to do, if an Option is Changed. eacht option decides for itself.
     233#ifdef HAVE_GTK2
     234    // Signals 
     235  static gint OptionChange (GtkWidget* widget, Widget* option); //!< Signal for Options that change.
     236#endif /* HAVE_GTK2 */
    233237};
    234238
     
    247251  void setTitle(char* title);
    248252  void redraw();
     253  void changeOption(void);
    249254};
    250255
     
    263268  bool isActive();           //!< a Bool value to see, if this CheckButton is active.
    264269  void redraw ();
    265 
    266 #ifdef HAVE_GTK2
    267   // Signals
    268   static gint OptionChange (GtkWidget* widget, Widget* checkbutton);
    269 #endif /* HAVE_GTK2 */
     270  void changeOption(void);
    270271};
    271272
     
    284285  void setTitle(char* title);
    285286  void setValue(int value);
    286   void redraw();
    287 
    288 #ifdef HAVE_GTK2
    289   // Signals
    290   static gint OptionChange (GtkWidget* widget, Widget* slider);
    291 #endif /* HAVE_GTK2 */
     287  void redraw(void);
     288  void changeOption(void);
    292289};
    293290
     
    310307  void setTitle(char* title);
    311308  void addItem(char* itemName);
    312 #ifdef HAVE_GTK2
    313   static gint OptionChange (GtkWidget* widget, Widget* menu);
    314 #endif /* HAVE_GTK2 */
    315   void redraw();
     309  void redraw(void);
     310  void changeOption(void);
    316311};
    317312
     
    331326  void setTitle(char* title);
    332327  void redraw();
     328  void changeOption();
    333329
    334330  char* cValue;                          //!< The Value the Label will have. \todo make private
Note: See TracChangeset for help on using the changeset viewer.