blob: 419715bea735a57ef605b40b3261353ac8224cd4 [file] [log] [blame]
DRC2ff39b82011-07-28 08:38:59 +00001//
2// "$Id: Fl_Counter.H 7981 2010-12-08 23:53:04Z greg.ercolano $"
3//
4// Counter header file for the Fast Light Tool Kit (FLTK).
5//
6// Copyright 1998-2010 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 on the following page:
24//
25// http://www.fltk.org/str.php
26//
27
28/* \file
29 Fl_Counter widget . */
30
31// A numerical value with up/down step buttons. From Forms.
32
33#ifndef Fl_Counter_H
34#define Fl_Counter_H
35
36#ifndef Fl_Valuator_H
37#include "Fl_Valuator.H"
38#endif
39
40// values for type():
41#define FL_NORMAL_COUNTER 0 /**< type() for counter with fast buttons */
42#define FL_SIMPLE_COUNTER 1 /**< type() for counter without fast buttons */
43
44/**
45 Controls a single floating point value with button (or keyboard) arrows.
46 Double arrows buttons achieve larger steps than simple arrows.
47 \see Fl_Spinner for value input with vertical step arrows.
48 <P align=center>\image html counter.png</P>
49 \image latex counter.png "Fl_Counter" width=4cm
50
51 \todo Refactor the doxygen comments for Fl_Counter type() documentation.
52
53 The type of an Fl_Counter object can be set using type(uchar t) to:
54 \li \c FL_NORMAL_COUNTER: Displays a counter with 4 arrow buttons.
55 \li \c FL_SIMPLE_COUNTER: Displays a counter with only 2 arrow buttons.
56*/
57class FL_EXPORT Fl_Counter : public Fl_Valuator {
58
59 Fl_Font textfont_;
60 Fl_Fontsize textsize_;
61 Fl_Color textcolor_;
62 double lstep_;
63 uchar mouseobj;
64 static void repeat_callback(void *);
65 int calc_mouseobj();
66 void increment_cb();
67
68protected:
69
70 void draw();
71
72public:
73
74 int handle(int);
75
76 Fl_Counter(int X, int Y, int W, int H, const char* L = 0);
77 ~Fl_Counter();
78
79 /**
80 Sets the increment for the large step buttons.
81 The default value is 1.0.
82 \param[in] a large step increment.
83 */
84 void lstep(double a) {lstep_ = a;}
85
86 /**
87 Sets the increments for the normal and large step buttons.
88 \param[in] a, b normal and large step increments.
89 */
90 void step(double a,double b) {Fl_Valuator::step(a); lstep_ = b;}
91
92 /**
93 Sets the increment for the normal step buttons.
94 \param[in] a normal step increment.
95 */
96 void step(double a) {Fl_Valuator::step(a);}
97
98 /**
99 Returns the increment for normal step buttons.
100 */
101 double step() const {return Fl_Valuator::step();}
102
103 /** Gets the text font */
104 Fl_Font textfont() const {return textfont_;}
105 /** Sets the text font to \p s */
106 void textfont(Fl_Font s) {textfont_ = s;}
107
108 /** Gets the font size */
109 Fl_Fontsize textsize() const {return textsize_;}
110 /** Sets the font size to \p s */
111 void textsize(Fl_Fontsize s) {textsize_ = s;}
112
113 /** Gets the font color */
114 Fl_Color textcolor() const {return textcolor_;}
115 /** Sets the font color to \p s */
116 void textcolor(Fl_Color s) {textcolor_ = s;}
117
118};
119
120#endif
121
122//
123// End of "$Id: Fl_Counter.H 7981 2010-12-08 23:53:04Z greg.ercolano $".
124//