SCV  4.2.1
Simple Components for Visual
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Spinner.h
Go to the documentation of this file.
1 
7 #ifndef __SCV_SPINNER_H__
8 #define __SCV_SPINNER_H__
9 
10 #include "TextField.h"
11 #include "Counter.h"
12 #include "Timer.h"
13 #include "TextFilter.h"
14 #include "Panel.h"
15 #include "GroupLayout.h"
16 
17 namespace scv {
18 
19 class Spinner : public scv::Panel, public Counter {
20 public:
21  Spinner(const scv::Point &p, unsigned int width, double minValue, double maxValue, double startValue, double stepValue);
22  virtual ~Spinner();
23 
24  virtual void onValueChange(void);
25 
26  void setValue(double value);
27 
28  inline void setEditable(bool edit);
29  inline bool isEditable();
30 
31  virtual void display(void);
32 
33 protected:
34  void processMouse(const scv::MouseEvent &evt);
35  void processKey(const scv::KeyEvent &evt);
36 
37  bool _editable;
38 
39  void createTexture(void);
40 
41 private:
42  class TextFieldSpinner : public TextField {
43  public:
44  TextFieldSpinner(Spinner *spinner, unsigned int width, const std::string &str);
45 
46  void onStringChange(void);
47 
48  private:
49  Spinner *_spinner;
50  };
51 
52  bool isOnUpButton(const Point &p);
53  bool isOnDownButton(const Point &p);
54 
55  static const int s_spinnerSizeX = 15;
56  static const int s_spinnerSizeY = 20;
57  static const int s_minSize = 35;
58 
59  bool _upPress, _downPress, _upOver, _downOver;
60  scv::Timer _whileUp, _whileDown;
61 
62  int _lastTime, _incrementTime;
63 
64  static TextFilter s_filter;
65  TextFieldSpinner *_textField;
66 };
67 
68 void Spinner::setEditable(bool edit)
69 {
70  _editable = edit;
71 }
72 
74 {
75  return _editable;
76 }
77 
78 } // namespace scv
79 
80 #endif // __SCV_SPINNER_H__