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.

125 lines
3.5KB

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