00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef QGLVIEWER_MOUSE_GRABBER_H
00026 #define QGLVIEWER_MOUSE_GRABBER_H
00027
00028 #include "config.h"
00029 #include "qevent.h"
00030
00031 class QGLViewer;
00032
00033 namespace qglviewer {
00034 class Camera;
00035
00114 class QGLVIEWER_EXPORT MouseGrabber
00115 {
00116 #ifndef DOXYGEN
00117 friend class ::QGLViewer;
00118 #endif
00119
00120 public:
00121 MouseGrabber();
00123 virtual ~MouseGrabber() { MouseGrabber::MouseGrabberPool_.removeRef(this); };
00124
00127 public:
00154 virtual void checkIfGrabsMouse(int x, int y, const Camera* const camera) = 0;
00155
00159 bool grabsMouse() { return grabsMouse_; };
00160
00161 protected:
00164 void setGrabsMouse(const bool flag) { grabsMouse_ = flag; };
00166
00167
00170 public:
00180 static const QPtrList<MouseGrabber>& MouseGrabberPool() { return MouseGrabber::MouseGrabberPool_; };
00181
00185 bool isInMouseGrabberPool() const { return MouseGrabber::MouseGrabberPool_.findRef( this ) != -1; };
00186 void addInMouseGrabberPool();
00187 void removeFromMouseGrabberPool();
00188 void clearMouseGrabberPool(bool autoDelete = false);
00190
00191
00195 protected:
00198 virtual void mousePressEvent(QMouseEvent* const, Camera* const) {};
00200 virtual void mouseDoubleClickEvent(QMouseEvent* const, Camera* const) {};
00203 virtual void mouseReleaseEvent(QMouseEvent* const, Camera* const) {};
00207 virtual void mouseMoveEvent(QMouseEvent* const, const Camera* const) {};
00209 virtual void wheelEvent(QWheelEvent* const, const Camera* const) {};
00211
00212 private:
00213
00214
00215 MouseGrabber(const MouseGrabber&);
00216 MouseGrabber& operator=(const MouseGrabber&);
00217
00218 bool grabsMouse_;
00219
00220
00221 static QPtrList<MouseGrabber> MouseGrabberPool_;
00222 };
00223
00224 }
00225
00226 #endif // QGLVIEWER_MOUSE_GRABBER_H