Move the sources to trunk
[opencv] / otherlibs / _fltk / include / FL / Fl_Valuator.H
1 //
2 // "$Id: Fl_Valuator.H,v 1.2 2002/12/01 15:38:37 neurosurg Exp $"
3 //
4 // Valuator header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2002 by Bill Spitzak and others.
7 //
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.
12 //
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.
17 //
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
21 // USA.
22 //
23 // Please report all bugs and problems to "fltk-bugs@fltk.org".
24 //
25
26 #ifndef Fl_Valuator_H
27 #define Fl_Valuator_H
28
29 #ifndef Fl_Widget_H
30 #include "Fl_Widget.H"
31 #endif
32
33 // shared type() values for classes that work in both directions:
34 #define FL_VERTICAL             0
35 #define FL_HORIZONTAL           1
36
37 class FL_EXPORT Fl_Valuator : public Fl_Widget {
38
39   double value_;
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
43
44 protected:
45
46   int horizontal() const {return type()&1;}
47   Fl_Valuator(int X, int Y, int W, int H, const char* L);
48
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;}
56
57 public:
58
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;}
67   void step(double s);
68   double step() const {return A/B;}
69   void precision(int);
70
71   double value() const {return value_;}
72   int value(double);
73
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
78 };
79
80 #endif
81
82 //
83 // End of "$Id: Fl_Valuator.H,v 1.2 2002/12/01 15:38:37 neurosurg Exp $".
84 //