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