2 // "$Id: Fl_Valuator.H,v 1.2 2002/12/01 15:38:37 neurosurg Exp $"
4 // Valuator header file for the Fast Light Tool Kit (FLTK).
6 // Copyright 1998-2002 by Bill Spitzak and others.
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // Please report all bugs and problems to "fltk-bugs@fltk.org".
30 #include "Fl_Widget.H"
33 // shared type() values for classes that work in both directions:
35 #define FL_HORIZONTAL 1
37 class FL_EXPORT Fl_Valuator : public Fl_Widget {
40 double previous_value_;
41 double min, max; // truncates to this range *after* rounding
42 double A; int B; // rounds to multiples of A/B, or no rounding if A is zero
46 int horizontal() const {return type()&1;}
47 Fl_Valuator(int X, int Y, int W, int H, const char* L);
49 double previous_value() const {return previous_value_;}
50 void handle_push() {previous_value_ = value_;}
51 double softclamp(double);
52 void handle_drag(double newvalue);
53 void handle_release(); // use drag() value
54 virtual void value_damage(); // cause damage() due to value() changing
55 void set_value(double v) {value_ = v;}
59 void bounds(double a, double b) {min=a; max=b;}
60 double minimum() const {return min;}
61 void minimum(double a) {min = a;}
62 double maximum() const {return max;}
63 void maximum(double a) {max = a;}
64 void range(double a, double b) {min = a; max = b;}
65 void step(int a) {A = a; B = 1;}
66 void step(double a, int b) {A = a; B = b;}
68 double step() const {return A/B;}
71 double value() const {return value_;}
74 virtual int format(char*);
75 double round(double); // round to nearest multiple of step
76 double clamp(double); // keep in range
77 double increment(double, int); // add n*step to value
83 // End of "$Id: Fl_Valuator.H,v 1.2 2002/12/01 15:38:37 neurosurg Exp $".