SCV  4.2.1
Simple Components for Visual
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Cursor.h
Go to the documentation of this file.
1 
7 #ifndef __SCV_CURSOR_H__
8 #define __SCV_CURSOR_H__
9 
10 #ifndef DOXYGEN_SKIP_THIS
11 #include "Singleton.h"
12 #include "Point.h"
13 
14 #include "ColorScheme.h"
15 #include "ComponentTexture.h"
16 #endif // DOXYGEN_SKIP_THIS
17 
18 namespace scv {
19 
20 class Kernel;
21 
26 class Cursor : public Singleton<Cursor> {
27 friend class Singleton<Cursor>;
28 friend class Kernel;
29 public:
30 
31  inline void requestResetCursor(void) {
32  _requestedCursorChange = false;
33  }
34 
35  inline void setDefaultCursor(void) {
36  if (_requestedCursorChange == false)
37  glutSetCursor(GLUT_CURSOR_LEFT_ARROW);
38  }
39 
40  inline void requestDefaultCursor(void) {
41  glutSetCursor(GLUT_CURSOR_LEFT_ARROW);
42  _requestedCursorChange = true;
43  }
44 
45  inline void setGlutCursor(int cursor) {
46  if (_requestedCursorChange == false)
47  glutSetCursor(cursor);
48  _requestedCursorChange = true;
49  }
50 
51  inline void forceGlutCursor(int cursor) {
52  glutSetCursor(cursor);
53  _requestedCursorChange = true;
54  }
55 
56  inline bool isInsertActive(void) const {
57  return _insert;
58  }
59 
60  inline void swapInsertState(void) {
61  _insert =! _insert;
62  }
63 
64  inline void cursorInMovement(void) {
65  _isShowingCursor = true;
66  _cursorInMovement = true;
67  }
68 
69  inline void display(const Point &p) {
70  static ColorScheme *scheme = ColorScheme::getInstance();
71  if (_isShowingCursor) {
72  _cursorTexture->enable();
74  _cursorTexture->display(Point(p.x,p.y+2), 0, Point(1, 14));
75  _cursorTexture->disable();
76  }
77  }
78 
79 private:
80  Cursor(void);
81 
82  void genTexture(void);
83 
84  void refreshMouse(void);
85 
86  bool _requestedCursorChange;
87  bool _insert;
88  bool _isShowingCursor;
89  bool _cursorInMovement;
90 
91  int _time, _timebase;
92  unsigned int _blinkTime;
93 
94  ComponentTexture *_cursorTexture;
95 };
96 
97 } // namespace scv
98 
99 #endif // __SCV_CURSOR_H__