You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
5.1KB

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