blob: 47ffcf3315597084b396770f11db082b94bdf768 [file] [log] [blame]
DRC2ff39b82011-07-28 08:38:59 +00001//
2// "$Id: Fl_Value_Input.H 8337 2011-01-30 09:04:59Z manolo $"
3//
4// Value input 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_Value_Input widget . */
30
31#ifndef Fl_Value_Input_H
32#define Fl_Value_Input_H
33
34#include "Fl_Valuator.H"
35#include "Fl_Input.H"
36
37/**
38 The Fl_Value_Input widget displays a numeric value.
39 The user can click in the text field and edit it - there is in
40 fact a hidden Fl_Input widget with
41 type(FL_FLOAT_INPUT) or type(FL_INT_INPUT) in
42 there - and when they hit return or tab the value updates to
43 what they typed and the callback is done.
44
45 <P>If step() is non-zero and integral, then the range of numbers
46 is limited to integers instead of floating point numbers. As
47 well as displaying the value as an integer, typed input is also
48 limited to integer values, even if the hidden Fl_Input widget
49 is of type(FL_FLOAT_INPUT).</P>
50
51 <P>If step() is non-zero, the user can also drag the
52 mouse across the object and thus slide the value. The left
53 button moves one step() per pixel, the middle by 10
54 * step(), and the right button by 100 * step(). It
55 is therefore impossible to select text by dragging across it,
56 although clicking can still move the insertion cursor.</P>
57
58 <P>If step() is non-zero and integral, then the range
59 of numbers are limited to integers instead of floating point
60 values.
61
62 <P ALIGN="CENTER">\image html Fl_Value_Input.png
63 \image latex Fl_Value_Input.png "Fl_Value_Input" width=4cm
64*/
65class FL_EXPORT Fl_Value_Input : public Fl_Valuator {
66public:
67 /* This is the encapsulated Fl_input attribute to which
68 this class delegates the value font, color and shortcut */
69 Fl_Input input;
70private:
71 char soft_;
72 static void input_cb(Fl_Widget*,void*);
73 virtual void value_damage(); // cause damage() due to value() changing
74public:
75 int handle(int);
76protected:
77 void draw();
78public:
79 void resize(int,int,int,int);
80 Fl_Value_Input(int x,int y,int w,int h,const char *l=0);
81 ~Fl_Value_Input();
82
83 /** See void Fl_Value_Input::soft(char s) */
84 void soft(char s) {soft_ = s;}
85 /**
86 If "soft" is turned on, the user is allowed to drag
87 the value outside the range. If they drag the value to one of
88 the ends, let go, then grab again and continue to drag, they can
89 get to any value. The default is true.
90 */
91 char soft() const {return soft_;}
92 /**
93 Returns the current shortcut key for the Input.
94 \see Fl_Value_Input::shortcut(int)
95 */
96 int shortcut() const {return input.shortcut();}
97 /**
98 Sets the shortcut key to \p s. Setting this
99 overrides the use of '&' in the label(). The value is a bitwise
100 OR of a key and a set of shift flags, for example FL_ALT | 'a'
101 , FL_ALT | (FL_F + 10), or just 'a'. A value
102 of 0 disables the shortcut.
103
104 The key can be any value returned by
105 Fl::event_key(), but will usually be an ASCII letter. Use
106 a lower-case letter unless you require the shift key to be held down.
107
108 The shift flags can be any set of values accepted by
109 Fl::event_state(). If the bit is on that shift key must
110 be pushed. Meta, Alt, Ctrl, and Shift must be off if they are not in
111 the shift flags (zero for the other bits indicates a "don't care"
112 setting).
113 */
114 void shortcut(int s) {input.shortcut(s);}
115
116 /** Gets the typeface of the text in the value box. */
117 Fl_Font textfont() const {return input.textfont();}
118 /** Sets the typeface of the text in the value box. */
119 void textfont(Fl_Font s) {input.textfont(s);}
120 /** Gets the size of the text in the value box. */
121 Fl_Fontsize textsize() const {return input.textsize();}
122 /** Sets the size of the text in the value box. */
123 void textsize(Fl_Fontsize s) {input.textsize(s);}
124 /** Gets the color of the text in the value box. */
125 Fl_Color textcolor() const {return input.textcolor();}
126 /** Sets the color of the text in the value box.*/
127 void textcolor(Fl_Color n) {input.textcolor(n);}
128 /** Gets the color of the text cursor. The text cursor is black by default. */
129 Fl_Color cursor_color() const {return input.cursor_color();}
130 /** Sets the color of the text cursor. The text cursor is black by default. */
131 void cursor_color(Fl_Color n) {input.cursor_color(n);}
132
133};
134
135#endif
136
137//
138// End of "$Id: Fl_Value_Input.H 8337 2011-01-30 09:04:59Z manolo $".
139//