mouseGrabber.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  Copyright (C) 2002-2013 Gilles Debunne. All rights reserved.
00004 
00005  This file is part of the QGLViewer library version 2.4.0.
00006 
00007  http://www.libqglviewer.com - contact@libqglviewer.com
00008 
00009  This file may be used under the terms of the GNU General Public License 
00010  versions 2.0 or 3.0 as published by the Free Software Foundation and
00011  appearing in the LICENSE file included in the packaging of this file.
00012  In addition, as a special exception, Gilles Debunne gives you certain 
00013  additional rights, described in the file GPL_EXCEPTION in this package.
00014 
00015  libQGLViewer uses dual licensing. Commercial/proprietary software must
00016  purchase a libQGLViewer Commercial License.
00017 
00018  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00019  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00020 
00021 *****************************************************************************/
00022 
00023 #ifndef QGLVIEWER_MOUSE_GRABBER_H
00024 #define QGLVIEWER_MOUSE_GRABBER_H
00025 
00026 #include "config.h"
00027 
00028 #if QT_VERSION >= 0x040000
00029 # include <QEvent>
00030 #else
00031 # include <qevent.h>
00032 #endif
00033 
00034 class QGLViewer;
00035 
00036 namespace qglviewer {
00037   class Camera;
00038 
00134   class QGLVIEWER_EXPORT MouseGrabber
00135   {
00136 #ifndef DOXYGEN
00137     friend class ::QGLViewer;
00138 #endif
00139 
00140   public:
00141     MouseGrabber();
00143 #if QT_VERSION >= 0x040000
00144     virtual ~MouseGrabber() { MouseGrabber::MouseGrabberPool_.removeAll(this); };
00145 #else
00146     virtual ~MouseGrabber() { MouseGrabber::MouseGrabberPool_.removeRef(this); };
00147 #endif
00148 
00151   public:
00182     virtual void checkIfGrabsMouse(int x, int y, const Camera* const camera) = 0;
00183 
00187     bool grabsMouse() const { return grabsMouse_; };
00188 
00189   protected:
00191     void setGrabsMouse(bool grabs) { grabsMouse_ = grabs; };
00193 
00194 
00197   public:
00207 #if QT_VERSION >= 0x040000
00208     static const QList<MouseGrabber*>& MouseGrabberPool() { return MouseGrabber::MouseGrabberPool_; };
00209 #else
00210 # if QT_VERSION >= 0x030000
00211     static const QPtrList<MouseGrabber>& MouseGrabberPool() { return MouseGrabber::MouseGrabberPool_; };
00212 # else
00213     static const QList<MouseGrabber>& MouseGrabberPool() { return MouseGrabber::MouseGrabberPool_; };
00214 # endif
00215 #endif
00216 
00222 #if QT_VERSION >= 0x040000
00223     bool isInMouseGrabberPool() const { return MouseGrabber::MouseGrabberPool_.contains(const_cast<MouseGrabber*>(this)); };
00224 #else
00225     bool isInMouseGrabberPool() const { return MouseGrabber::MouseGrabberPool_.findRef(this) != -1; };
00226 #endif
00227     void addInMouseGrabberPool();
00228     void removeFromMouseGrabberPool();
00229     void clearMouseGrabberPool(bool autoDelete=false);
00231 
00232 
00235   protected:
00251     virtual void mousePressEvent(QMouseEvent* const event, Camera* const camera) { Q_UNUSED(event) Q_UNUSED(camera) };
00255     virtual void mouseDoubleClickEvent(QMouseEvent* const event, Camera* const camera) { Q_UNUSED(event) Q_UNUSED(camera) };
00257     virtual void mouseReleaseEvent(QMouseEvent* const event, Camera* const camera) { Q_UNUSED(event) Q_UNUSED(camera) };
00263     virtual void mouseMoveEvent(QMouseEvent* const event, Camera* const camera) { Q_UNUSED(event) Q_UNUSED(camera) };
00267     virtual void wheelEvent(QWheelEvent* const event, Camera* const camera) { Q_UNUSED(event) Q_UNUSED(camera) };
00269 
00270   private:
00271     // Copy constructor and opertor= are declared private and undefined
00272     // Prevents everyone from trying to use them
00273     MouseGrabber(const MouseGrabber&);
00274     MouseGrabber& operator=(const MouseGrabber&);
00275 
00276     bool grabsMouse_;
00277 
00278     // Q G L V i e w e r   p o o l
00279 #if QT_VERSION >= 0x040000
00280     static QList<MouseGrabber*> MouseGrabberPool_;
00281 #else
00282     static QPtrList<MouseGrabber> MouseGrabberPool_;
00283 #endif
00284   };
00285 
00286 } // namespace qglviewer
00287 
00288 #endif // QGLVIEWER_MOUSE_GRABBER_H


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Thu Aug 27 2015 14:13:26