FLTK 1.3.2

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

Fl_Valuator.H

    00001 //
    00002 // "$Id: Fl_Valuator.H 8864 2011-07-19 04:49:30Z greg.ercolano $"
    00003 //
    00004 // Valuator header file for the Fast Light Tool Kit (FLTK).
    00005 //
    00006 // Copyright 1998-2010 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 ///< The valuator can work vertically
    00031 #define FL_HORIZONTAL           1 ///< The valuator can work horizontally
    00032
    00046 class FL_EXPORT Fl_Valuator : public Fl_Widget {
    00047
    00048   double value_;
    00049   double previous_value_;
    00050   double min, max; // truncates to this range *after* rounding
    00051   double A; int B; // rounds to multiples of A/B, or no rounding if A is zero
    00052
    00053 protected:
    00055   int horizontal() const {return type()& FL_HORIZONTAL;}
    00056   Fl_Valuator(int X, int Y, int W, int H, const char* L);
    00057
    00059   double previous_value() const {return previous_value_;}
    00061   void handle_push() {previous_value_ = value_;}
    00062   double softclamp(double);
    00063   void handle_drag(double newvalue);
    00064   void handle_release(); // use drag() value
    00065   virtual void value_damage(); // cause damage() due to value() changing
    00067   void set_value(double v) {value_ = v;}
    00068
    00069 public:
    00070
    00072     void bounds(double a, double b) {min=a; max=b;}
    00074     double minimum() const {return min;}
    00076     void minimum(double a) {min = a;}
    00078     double maximum() const {return max;}
    00080     void maximum(double a) {max = a;}
    00101   void range(double a, double b) {min = a; max = b;}
    00103   void step(int a) {A = a; B = 1;}
    00105   void step(double a, int b) {A = a; B = b;}
    00106   void step(double s);
    00118   double step() const {return A/B;}
    00119   void precision(int);
    00120
    00122   double value() const {return value_;}
    00123   int value(double);
    00124
    00125   virtual int format(char*);
    00126   double round(double); // round to nearest multiple of step
    00127   double clamp(double); // keep in range
    00128   double increment(double, int); // add n*step to value
    00129 };
    00130
    00131 #endif
    00132
    00133 //
    00134 // End of "$Id: Fl_Valuator.H 8864 2011-07-19 04:49:30Z greg.ercolano $".
    00135 //