Fl_Counter.H 3.2 KB

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