1 | // |
---|
2 | // "$Id: Valuator.h 4326 2005-05-10 03:55:14Z trilec $" |
---|
3 | // |
---|
4 | // Base class for all the widgets that control a single floating-point |
---|
5 | // value. |
---|
6 | // |
---|
7 | // Copyright 1998-2003 by Bill Spitzak and others. |
---|
8 | // |
---|
9 | // This library is free software; you can redistribute it and/or |
---|
10 | // modify it under the terms of the GNU Library General Public |
---|
11 | // License as published by the Free Software Foundation; either |
---|
12 | // version 2 of the License, or (at your option) any later version. |
---|
13 | // |
---|
14 | // This library is distributed in the hope that it will be useful, |
---|
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
17 | // Library General Public License for more details. |
---|
18 | // |
---|
19 | // You should have received a copy of the GNU Library General Public |
---|
20 | // License along with this library; if not, write to the Free Software |
---|
21 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
---|
22 | // USA. |
---|
23 | // |
---|
24 | // Please report all bugs and problems to "fltk-bugs@fltk.org". |
---|
25 | // |
---|
26 | |
---|
27 | #ifndef fltk_Valuator_h |
---|
28 | #define fltk_Valuator_h |
---|
29 | |
---|
30 | #ifndef fltk_Widget_h |
---|
31 | #include "Widget.h" |
---|
32 | #endif |
---|
33 | |
---|
34 | namespace fltk { |
---|
35 | |
---|
36 | class FL_API Valuator : public Widget { |
---|
37 | |
---|
38 | public: |
---|
39 | |
---|
40 | double value() const {return value_;} |
---|
41 | int value(double); |
---|
42 | |
---|
43 | float minimum() const {return minimum_;} |
---|
44 | void minimum(double a) {minimum_ = float(a);} |
---|
45 | |
---|
46 | float maximum() const {return maximum_;} |
---|
47 | void maximum(double a) {maximum_ = float(a);} |
---|
48 | |
---|
49 | void range(double a, double b) {minimum_ = float(a); maximum_ = float(b);} |
---|
50 | |
---|
51 | float step() const {return step_;} |
---|
52 | void step(double a) {step_ = float(a);} |
---|
53 | |
---|
54 | float linesize() const {return linesize_;} |
---|
55 | void linesize(double a) {linesize_ = float(a);} |
---|
56 | |
---|
57 | virtual int format(char*); |
---|
58 | |
---|
59 | int handle(int); |
---|
60 | |
---|
61 | #ifdef FLTK_1_SLIDER |
---|
62 | void step(double a, int b) {step(a/b);} |
---|
63 | void bounds(double a, double b) {minimum_=float(a); maximum_=float(b);} |
---|
64 | void precision(int p) { |
---|
65 | int B = 1; |
---|
66 | for (int i=0; i<p; i++) B *= 10; |
---|
67 | step_ = 1.0f/B; |
---|
68 | } |
---|
69 | #endif |
---|
70 | |
---|
71 | //protected: |
---|
72 | |
---|
73 | Valuator(int X, int Y, int W, int H, const char* L); |
---|
74 | double previous_value() const {return previous_value_;} |
---|
75 | void handle_push() {previous_value_ = value_;} |
---|
76 | void handle_drag(double newvalue); |
---|
77 | void handle_release(); |
---|
78 | |
---|
79 | virtual void value_damage(); // callback whenever value changes |
---|
80 | void set_value(double v) {value_ = v;} // change w/o doing value_damage |
---|
81 | |
---|
82 | private: |
---|
83 | |
---|
84 | double value_; |
---|
85 | static double previous_value_; |
---|
86 | float minimum_; |
---|
87 | float maximum_; |
---|
88 | float step_; |
---|
89 | float linesize_; |
---|
90 | |
---|
91 | }; |
---|
92 | |
---|
93 | } |
---|
94 | |
---|
95 | #endif |
---|
96 | |
---|
97 | // |
---|
98 | // End of "$Id: Valuator.h 4326 2005-05-10 03:55:14Z trilec $". |
---|
99 | // |
---|