• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

Fl_Valuator.H

00001 //
00002 // "$Id$"
00003 //
00004 // Valuator header file for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2016 by Bill Spitzak and others.
00007 //
00008 // This library is free software. Distribution and use rights are outlined in
00009 // the file "COPYING" which should have been included with this file.  If this
00010 // file is missing or damaged, see the license at:
00011 //
00012 //     http://www.fltk.org/COPYING.php
00013 //
00014 // Please report all bugs and problems on the following page:
00015 //
00016 //     http://www.fltk.org/str.php
00017 //
00018 
00019 /* \file
00020    Fl_Valuator widget . */
00021 
00022 #ifndef Fl_Valuator_H
00023 #define Fl_Valuator_H
00024 
00025 #ifndef Fl_Widget_H
00026 #include "Fl_Widget.H"
00027 #endif
00028 
00029 // shared type() values for classes that work in both directions:
00030 #define FL_VERTICAL             0 
00031 #define FL_HORIZONTAL           1 
00032 
00033 
00049 class FL_EXPORT Fl_Valuator : public Fl_Widget {
00050 
00051   double value_;
00052   double previous_value_;
00053   double min, max; // truncates to this range *after* rounding
00054   double A; int B; // rounds to multiples of A/B, or no rounding if A is zero
00055 
00056 protected:
00058   int horizontal() const {return type()& FL_HORIZONTAL;}
00059   Fl_Valuator(int X, int Y, int W, int H, const char* L);
00060 
00062   double previous_value() const {return previous_value_;}
00064   void handle_push() {previous_value_ = value_;}
00065   double softclamp(double);
00066   void handle_drag(double newvalue);
00067   void handle_release(); // use drag() value
00068   virtual void value_damage(); // cause damage() due to value() changing
00070   void set_value(double v) {value_ = v;}
00071 
00072 public:
00073 
00075     void bounds(double a, double b) {min=a; max=b;}
00077     double minimum() const {return min;}
00079     void minimum(double a) {min = a;}
00081     double maximum() const {return max;}
00083     void maximum(double a) {max = a;}
00104   void range(double a, double b) {min = a; max = b;}
00106   void step(int a) {A = a; B = 1;}
00108   void step(double a, int b) {A = a; B = b;}
00109   void step(double s);
00121   double step() const {return A/B;}
00122   void precision(int digits);
00123 
00125   double value() const {return value_;}
00126   int value(double);
00127 
00128   virtual int format(char*);
00129   double round(double); // round to nearest multiple of step
00130   double clamp(double); // keep in range
00131   double increment(double, int); // add n*step to value
00132 };
00133 
00134 #endif
00135 
00136 //
00137 // End of "$Id$".
00138 //
  • © 1998-2016 by Bill Spitzak and others.     FLTK

  • © 1998-2016 by Bill Spitzak and others.     FLTK

    Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.