Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4319 in orxonox.OLD


Ignore:
Timestamp:
May 27, 2005, 1:11:42 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches/physics: slider now supports floats

Location:
orxonox/branches/physics/src/lib/gui/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/physics/src/lib/gui/gui/gui_gtk.cc

    r4316 r4319  
    12491249   \param end The maximal Value of the slider.
    12501250*/
    1251 Slider::Slider(const char* slidername, int start, int end)
    1252 {
    1253   this->optionType = GUI_INT;
     1251Slider::Slider(const char* slidername, float start, float end)
     1252{
     1253  this->optionType = GUI_FLOAT;
    12541254
    12551255  this->start = start;
     
    12781278   Maybe you also require a Slider::redraw() for this to display
    12791279*/
    1280 void Slider::setValue(int value)
    1281 {
    1282   this->value = value;
     1280void Slider::setValue(float value)
     1281{
     1282  this->fValue = value;
    12831283}
    12841284
     
    12901290{
    12911291#ifdef HAVE_GTK2
    1292   gtk_range_set_value(GTK_RANGE(this->widget), this->value);
     1292  gtk_range_set_value(GTK_RANGE(this->widget), this->fValue);
    12931293#endif /* HAVE_GTK2 */
    12941294}
     
    13001300{
    13011301#ifdef HAVE_GTK2
    1302   this->value =(int)gtk_range_get_value(GTK_RANGE(this->widget));
     1302  this->fValue = gtk_range_get_value(GTK_RANGE(this->widget));
    13031303#else /* HAVE_GTK2 */
    13041304  char tmpChar[20];
     
    13061306  scanf("%s", tmpChar);
    13071307
    1308   if ((this->value = atoi(tmpChar))> this->end)
    1309     this->value = this->end;
    1310   if (this->value <= this->start)
    1311     this->value = this->start;
    1312 
    1313   PRINT(0)("%s set to: %d\n",this->title, this->value);
    1314 #endif /* HAVE_GTK2 */
    1315 }
     1308  if ((this->fValue = atof(tmpChar))> this->end)
     1309    this->fValue = this->end;
     1310  if (this->fValue <= this->start)
     1311    this->fValue = this->start;
     1312
     1313  PRINT(0)("%s set to: %d\n",this->title, this->fValue);
     1314#endif /* HAVE_GTK2 */
     1315}
     1316
     1317char* Slider::save(void)
     1318{
     1319  char* value = new char [30];
     1320  sprintf (value, "%f", this->fValue);
     1321  return value;
     1322}
     1323void Slider::load(char* loadString)
     1324{
     1325  this->fValue = atof(loadString);
     1326  PRINT(5)("Loading %s: %s %f\n", this->title, loadString, fValue);
     1327  this->redraw();
     1328}
     1329
    13161330
    13171331//////////
  • orxonox/branches/physics/src/lib/gui/gui/gui_gtk.h

    r4178 r4319  
    296296{
    297297 private:
    298   int start;                            //!< The beginning of the Slider-range.
    299   int end;                              //!< The end of the Slider-range.
    300  public:
    301   Slider(const char* slidername, int start, int end);
     298  float start;                            //!< The beginning of the Slider-range.
     299  float end;                              //!< The end of the Slider-range.
     300  float fValue;                           //!< a value for the slider
     301 public:
     302  Slider(const char* slidername, float start, float end);
    302303  virtual ~Slider(void);
    303304
    304   void setValue(int value);
    305   virtual void redraw(void);
    306   virtual void changeOption(void);
     305  void setValue(float value);
     306  virtual void redraw(void);
     307  virtual void changeOption(void);
     308
     309  virtual char* save(void);
     310  virtual void load(char* loadString);
    307311};
    308312
Note: See TracChangeset for help on using the changeset viewer.