00001 /*===========================================================================*\ 00002 * * 00003 * OpenFlipper * 00004 * Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen * 00005 * www.openflipper.org * 00006 * * 00007 *---------------------------------------------------------------------------* 00008 * This file is part of OpenFlipper. * 00009 * * 00010 * OpenFlipper is free software: you can redistribute it and/or modify * 00011 * it under the terms of the GNU Lesser General Public License as * 00012 * published by the Free Software Foundation, either version 3 of * 00013 * the License, or (at your option) any later version with the * 00014 * following exceptions: * 00015 * * 00016 * If other files instantiate templates or use macros * 00017 * or inline functions from this file, or you compile this file and * 00018 * link it with other files to produce an executable, this file does * 00019 * not by itself cause the resulting executable to be covered by the * 00020 * GNU Lesser General Public License. This exception does not however * 00021 * invalidate any other reasons why the executable file might be * 00022 * covered by the GNU Lesser General Public License. * 00023 * * 00024 * OpenFlipper is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU Lesser General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU LesserGeneral Public * 00030 * License along with OpenFlipper. If not, * 00031 * see <http://www.gnu.org/licenses/>. * 00032 * * 00033 \*===========================================================================*/ 00034 00035 #ifndef CURSORPAINTER_HH 00036 #define CURSORPAINTER_HH 00037 00038 //== INCLUDES ================================================================= 00039 00040 #include <QObject> 00041 #include <QCursor> 00042 #include <QVector> 00043 #include <QRectF> 00044 00045 #include <ACG/GL/GLState.hh> 00046 #include <OpenFlipper/common/GlobalDefines.hh> 00047 00048 //== NAMESPACES =============================================================== 00049 00050 //== FORWARDDECLARATIONS ====================================================== 00051 class glViewer; 00052 00053 //== CLASS DEFINITION ========================================================= 00054 00055 00059 class DLLEXPORT CursorPainter : public QObject 00060 { 00061 Q_OBJECT 00062 00063 public: 00065 CursorPainter (QObject *_parent = 0); 00066 00068 ~CursorPainter (); 00069 00071 void setCursor (const QCursor &_cursor); 00072 00074 void initializeGL (); 00075 00077 void registerViewer (glViewer *_viewer); 00078 00080 void paintCursor (ACG::GLState *_state); 00081 00083 void updateCursorPosition (QPointF _scenePos); 00084 00086 QPointF cursorPosition (); 00087 00089 void setEnabled (bool _enabled); 00090 00092 void setForceNative (bool _enabled); 00093 00095 bool enabled (); 00096 00098 void setMouseIn (bool _in); 00099 00101 QRectF cursorBoundingBox (); 00102 00103 private: 00104 // Create a texture for the cursor 00105 void cursorToTexture (); 00106 void cursorToCursor (); 00107 00108 private: 00109 QCursor cursor_; 00110 QCursor nativeCursor_; 00111 QPointF cursorPos_; 00112 00113 bool initialized_; 00114 00115 QVector<glViewer *> views_; 00116 00117 bool enabled_; 00118 bool mouseIn_; 00119 bool forceNative_; 00120 00121 // x and y offset between click position and texture (hotspot) 00122 int xOff_; 00123 int yOff_; 00124 GLuint texture_; 00125 bool hasCursor_; 00126 }; 00127 00128 //============================================================================= 00129 #endif 00130 //=============================================================================