qcursor.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the QtGui module of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:LGPL$
00010 ** Commercial Usage
00011 ** Licensees holding valid Qt Commercial licenses may use this file in
00012 ** accordance with the Qt Commercial License Agreement provided with the
00013 ** Software or, alternatively, in accordance with the terms contained in
00014 ** a written agreement between you and Nokia.
00015 **
00016 ** GNU Lesser General Public License Usage
00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
00018 ** General Public License version 2.1 as published by the Free Software
00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
00020 ** packaging of this file.  Please review the following information to
00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00023 **
00024 ** In addition, as a special exception, Nokia gives you certain additional
00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
00027 **
00028 ** GNU General Public License Usage
00029 ** Alternatively, this file may be used under the terms of the GNU
00030 ** General Public License version 3.0 as published by the Free Software
00031 ** Foundation and appearing in the file LICENSE.GPL included in the
00032 ** packaging of this file.  Please review the following information to
00033 ** ensure the GNU General Public License version 3.0 requirements will be
00034 ** met: http://www.gnu.org/copyleft/gpl.html.
00035 **
00036 ** If you have questions regarding the use of this file, please contact
00037 ** Nokia at qt-info@nokia.com.
00038 ** $QT_END_LICENSE$
00039 **
00040 ****************************************************************************/
00041 
00042 #ifndef QCURSOR_H
00043 #define QCURSOR_H
00044 
00045 #include <QtCore/qpoint.h>
00046 #include <QtGui/qwindowdefs.h>
00047 
00048 QT_BEGIN_HEADER
00049 
00050 QT_BEGIN_NAMESPACE
00051 
00052 QT_MODULE(Gui)
00053 
00054 class QVariant;
00055 
00056 /*
00057   ### The fake cursor has to go first with old qdoc.
00058 */
00059 #ifdef QT_NO_CURSOR
00060 
00061 class Q_GUI_EXPORT QCursor
00062 {
00063 public:
00064     static QPoint pos();
00065     static void setPos(int x, int y);
00066     inline static void setPos(const QPoint &p) { setPos(p.x(), p.y()); }
00067 private:
00068     QCursor();
00069 };
00070 
00071 #endif // QT_NO_CURSOR
00072 
00073 #ifndef QT_NO_CURSOR
00074 
00075 class QCursorData;
00076 class QBitmap;
00077 class QPixmap;
00078 
00079 #if defined(Q_WS_MAC)
00080 void qt_mac_set_cursor(const QCursor *c, const QPoint &p);
00081 #endif
00082 #if defined(Q_OS_SYMBIAN)
00083 extern void qt_symbian_show_pointer_sprite();
00084 extern void qt_symbian_hide_pointer_sprite();
00085 extern void qt_symbian_set_pointer_sprite(const QCursor& cursor);
00086 extern void qt_symbian_move_cursor_sprite();
00087 #endif
00088 
00089 class Q_GUI_EXPORT QCursor
00090 {
00091 public:
00092     QCursor();
00093     QCursor(Qt::CursorShape shape);
00094     QCursor(const QBitmap &bitmap, const QBitmap &mask, int hotX=-1, int hotY=-1);
00095     QCursor(const QPixmap &pixmap, int hotX=-1, int hotY=-1);
00096     QCursor(const QCursor &cursor);
00097     ~QCursor();
00098     QCursor &operator=(const QCursor &cursor);
00099     operator QVariant() const;
00100 
00101     Qt::CursorShape shape() const;
00102     void setShape(Qt::CursorShape newShape);
00103 
00104     const QBitmap *bitmap() const;
00105     const QBitmap *mask() const;
00106     QPixmap pixmap() const;
00107     QPoint hotSpot() const;
00108 
00109     static QPoint pos();
00110     static void setPos(int x, int y);
00111     inline static void setPos(const QPoint &p) { setPos(p.x(), p.y()); }
00112     
00113 #ifdef qdoc
00114     HCURSOR_or_HANDLE handle() const;
00115     QCursor(HCURSOR cursor);
00116     QCursor(Qt::HANDLE cursor);
00117 #endif
00118 
00119 #ifndef qdoc
00120 #if defined(Q_WS_WIN)
00121     HCURSOR handle() const;
00122     QCursor(HCURSOR cursor);
00123 #elif defined(Q_WS_X11)
00124     Qt::HANDLE handle() const;
00125     QCursor(Qt::HANDLE cursor);
00126     static int x11Screen();
00127 #elif defined(Q_WS_MAC)
00128     Qt::HANDLE handle() const;
00129 #elif defined(Q_WS_QWS)
00130     int handle() const;
00131 #elif defined(Q_OS_SYMBIAN)
00132     Qt::HANDLE handle() const;
00133 #endif
00134 #endif
00135 
00136 private:
00137     QCursorData *d;
00138 #if defined(Q_WS_MAC)
00139     friend void *qt_mac_nsCursorForQCursor(const QCursor &c);
00140     friend void qt_mac_set_cursor(const QCursor *c, const QPoint &p);
00141 #endif
00142 #if defined(Q_OS_SYMBIAN)
00143     friend void qt_symbian_show_pointer_sprite();
00144     friend void qt_symbian_hide_pointer_sprite();
00145     friend void qt_symbian_set_pointer_sprite(const QCursor& cursor);
00146     friend void qt_symbian_move_cursor_sprite();
00147 #endif
00148 };
00149 
00150 #ifdef QT3_SUPPORT
00151 // CursorShape is defined in X11/X.h
00152 #ifdef CursorShape
00153 #define X_CursorShape CursorShape
00154 #undef CursorShape
00155 #endif
00156 typedef Qt::CursorShape QCursorShape;
00157 #ifdef X_CursorShape
00158 #define CursorShape X_CursorShape
00159 #endif
00160 #endif
00161 
00162 /*****************************************************************************
00163   QCursor stream functions
00164  *****************************************************************************/
00165 #ifndef QT_NO_DATASTREAM
00166 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &outS, const QCursor &cursor);
00167 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &inS, QCursor &cursor);
00168 #endif
00169 #endif // QT_NO_CURSOR
00170 
00171 QT_END_NAMESPACE
00172 
00173 QT_END_HEADER
00174 
00175 #endif // QCURSOR_H