Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

mouseGrabber.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the QGLViewer library
00004  Copyright (C) 2002-2004  Gilles Debunne (Gilles.Debunne@imag.fr)
00005  Version 1.3.5 Release 8. Packaged on Monday December 22, 2003.
00006 
00007  http://www-imagis.imag.fr/Membres/Gilles.Debunne/CODE/QGLViewer
00008 
00009  libQGLViewer is free software; you can redistribute it and/or modify
00010  it under the terms of the GNU General Public License as published by
00011  the Free Software Foundation; either version 2 of the License, or
00012  (at your option) any later version.
00013 
00014  libQGLViewer is distributed in the hope that it will be useful,
00015  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  GNU General Public License for more details.
00018 
00019  You should have received a copy of the GNU General Public License
00020  along with libQGLViewer; if not, write to the Free Software
00021  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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     // Copy constructor and opertor= are declared private and undefined
00214     // Prevents everyone from trying to use them
00215     MouseGrabber(const MouseGrabber&);
00216     MouseGrabber& operator=(const MouseGrabber&);
00217 
00218     bool grabsMouse_;
00219     
00220     // Q G L V i e w e r   p o o l
00221     static QPtrList<MouseGrabber> MouseGrabberPool_;
00222   };
00223 
00224 } // namespace qglviewer
00225 
00226 #endif // QGLVIEWER_MOUSE_GRABBER_H

Generated on Fri Feb 27 12:01:39 2004 for Glitch by doxygen 1.3.2