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