Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qt/qdragobject.h 3.3.8 edited Jan 11 14:38 $ 00003 ** 00004 ** Definition of QDragObject 00005 ** 00006 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 00007 ** 00008 ** This file is part of the kernel module of the Qt GUI Toolkit. 00009 ** 00010 ** This file may be distributed under the terms of the Q Public License 00011 ** as defined by Trolltech ASA of Norway and appearing in the file 00012 ** LICENSE.QPL included in the packaging of this file. 00013 ** 00014 ** This file may be distributed and/or modified under the terms of the 00015 ** GNU General Public License version 2 as published by the Free Software 00016 ** Foundation and appearing in the file LICENSE.GPL included in the 00017 ** packaging of this file. 00018 ** 00019 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00020 ** licenses may use this file in accordance with the Qt Commercial License 00021 ** Agreement provided with the Software. 00022 ** 00023 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00024 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00025 ** 00026 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00027 ** information about Qt Commercial License Agreements. 00028 ** See http://www.trolltech.com/qpl/ for QPL licensing information. 00029 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00030 ** 00031 ** Contact info@trolltech.com if any conditions of this licensing are 00032 ** not clear to you. 00033 ** 00034 **********************************************************************/ 00035 00036 #ifndef QDRAGOBJECT_H 00037 #define QDRAGOBJECT_H 00038 00039 class QWidget; 00040 class QTextDragPrivate; 00041 class QDragObjectData; 00042 class QStoredDragData; 00043 class QImageDragData; 00044 00045 #ifndef QT_H 00046 #include "qobject.h" 00047 #include "qimage.h" 00048 #include "qstrlist.h" 00049 #include "qcolor.h" 00050 #endif // QT_H 00051 00052 #ifndef QT_NO_MIME 00053 00054 class Q_EXPORT QDragObject: public QObject, public QMimeSource { 00055 Q_OBJECT 00056 public: 00057 QDragObject( QWidget * dragSource = 0, const char * name = 0 ); 00058 virtual ~QDragObject(); 00059 00060 #ifndef QT_NO_DRAGANDDROP 00061 bool drag(); 00062 bool dragMove(); 00063 void dragCopy(); 00064 void dragLink(); 00065 00066 virtual void setPixmap(QPixmap); 00067 virtual void setPixmap(QPixmap, const QPoint& hotspot); 00068 QPixmap pixmap() const; 00069 QPoint pixmapHotSpot() const; 00070 #endif 00071 00072 QWidget * source(); 00073 static QWidget * target(); 00074 00075 static void setTarget(QWidget*); 00076 00077 #ifndef QT_NO_DRAGANDDROP 00078 enum DragMode { DragDefault, DragCopy, DragMove, DragLink, DragCopyOrMove }; 00079 00080 protected: 00081 virtual bool drag(DragMode); 00082 #endif 00083 00084 private: 00085 QDragObjectData * d; 00086 #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator= 00087 QDragObject( const QDragObject & ); 00088 QDragObject &operator=( const QDragObject & ); 00089 #endif 00090 }; 00091 00092 class Q_EXPORT QStoredDrag: public QDragObject { 00093 Q_OBJECT 00094 QStoredDragData * d; 00095 00096 public: 00097 QStoredDrag( const char * mimeType, 00098 QWidget * dragSource = 0, const char * name = 0 ); 00099 ~QStoredDrag(); 00100 00101 virtual void setEncodedData( const QByteArray & ); 00102 00103 const char * format(int i) const; 00104 virtual QByteArray encodedData(const char*) const; 00105 00106 private: 00107 #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator= 00108 QStoredDrag( const QStoredDrag & ); 00109 QStoredDrag &operator=( const QStoredDrag & ); 00110 #endif 00111 }; 00112 00113 class Q_EXPORT QTextDrag: public QDragObject { 00114 Q_OBJECT 00115 QTextDragPrivate* d; 00116 public: 00117 QTextDrag( const QString &, 00118 QWidget * dragSource = 0, const char * name = 0 ); 00119 QTextDrag( QWidget * dragSource = 0, const char * name = 0 ); 00120 ~QTextDrag(); 00121 00122 virtual void setText( const QString &); 00123 virtual void setSubtype( const QCString &); 00124 00125 const char * format(int i) const; 00126 virtual QByteArray encodedData(const char*) const; 00127 00128 static bool canDecode( const QMimeSource* e ); 00129 static bool decode( const QMimeSource* e, QString& s ); 00130 static bool decode( const QMimeSource* e, QString& s, QCString& subtype ); 00131 00132 private: 00133 #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator= 00134 QTextDrag( const QTextDrag & ); 00135 QTextDrag &operator=( const QTextDrag & ); 00136 #endif 00137 }; 00138 00139 class Q_EXPORT QImageDrag: public QDragObject { 00140 Q_OBJECT 00141 QImage img; 00142 QStrList ofmts; 00143 QImageDragData* d; 00144 00145 public: 00146 QImageDrag( QImage image, QWidget * dragSource = 0, const char * name = 0 ); 00147 QImageDrag( QWidget * dragSource = 0, const char * name = 0 ); 00148 ~QImageDrag(); 00149 00150 virtual void setImage( QImage image ); 00151 00152 const char * format(int i) const; 00153 virtual QByteArray encodedData(const char*) const; 00154 00155 static bool canDecode( const QMimeSource* e ); 00156 static bool decode( const QMimeSource* e, QImage& i ); 00157 static bool decode( const QMimeSource* e, QPixmap& i ); 00158 00159 private: 00160 #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator= 00161 QImageDrag( const QImageDrag & ); 00162 QImageDrag &operator=( const QImageDrag & ); 00163 #endif 00164 }; 00165 00166 00167 class Q_EXPORT QUriDrag: public QStoredDrag { 00168 Q_OBJECT 00169 00170 public: 00171 QUriDrag( QStrList uris, QWidget * dragSource = 0, const char * name = 0 ); 00172 QUriDrag( QWidget * dragSource = 0, const char * name = 0 ); 00173 ~QUriDrag(); 00174 00175 void setFilenames( const QStringList & fnames ) { setFileNames( fnames ); } 00176 void setFileNames( const QStringList & fnames ); 00177 void setUnicodeUris( const QStringList & uuris ); 00178 virtual void setUris( QStrList uris ); 00179 00180 static QString uriToLocalFile(const char*); 00181 static QCString localFileToUri(const QString&); 00182 static QString uriToUnicodeUri(const char*); 00183 static QCString unicodeUriToUri(const QString&); 00184 static bool canDecode( const QMimeSource* e ); 00185 static bool decode( const QMimeSource* e, QStrList& i ); 00186 static bool decodeToUnicodeUris( const QMimeSource* e, QStringList& i ); 00187 static bool decodeLocalFiles( const QMimeSource* e, QStringList& i ); 00188 00189 private: 00190 #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator= 00191 QUriDrag( const QUriDrag & ); 00192 QUriDrag &operator=( const QUriDrag & ); 00193 #endif 00194 }; 00195 00196 class Q_EXPORT QColorDrag : public QStoredDrag 00197 { 00198 Q_OBJECT 00199 QColor color; 00200 00201 public: 00202 QColorDrag( const QColor &col, QWidget *dragsource = 0, const char *name = 0 ); 00203 QColorDrag( QWidget * dragSource = 0, const char * name = 0 ); 00204 void setColor( const QColor &col ); 00205 00206 static bool canDecode( QMimeSource * ); 00207 static bool decode( QMimeSource *, QColor &col ); 00208 00209 private: 00210 #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator= 00211 QColorDrag( const QColorDrag & ); 00212 QColorDrag &operator=( const QColorDrag & ); 00213 #endif 00214 }; 00215 00216 #ifndef QT_NO_COMPAT 00217 typedef QUriDrag QUrlDrag; 00218 #endif 00219 00220 #ifndef QT_NO_DRAGANDDROP 00221 00222 // QDragManager is not part of the public API. It is defined in a 00223 // header file simply so different .cpp files can implement different 00224 // member functions. 00225 // 00226 00227 class Q_EXPORT QDragManager: public QObject { 00228 Q_OBJECT 00229 00230 private: 00231 QDragManager(); 00232 ~QDragManager(); 00233 // only friend classes can use QDragManager. 00234 friend class QDragObject; 00235 friend class QDragMoveEvent; 00236 friend class QDropEvent; 00237 friend class QApplication; 00238 00239 bool eventFilter( QObject *, QEvent * ); 00240 void timerEvent( QTimerEvent* ); 00241 00242 bool drag( QDragObject *, QDragObject::DragMode ); 00243 00244 void cancel( bool deleteSource = TRUE ); 00245 void move( const QPoint & ); 00246 void drop(); 00247 void updatePixmap(); 00248 00249 private: 00250 QDragObject * object; 00251 void updateMode( ButtonState newstate ); 00252 void updateCursor(); 00253 #if defined(Q_WS_X11) 00254 void createCursors(); 00255 #endif 00256 00257 QWidget * dragSource; 00258 QWidget * dropWidget; 00259 bool beingCancelled; 00260 bool restoreCursor; 00261 bool willDrop; 00262 00263 QPixmap *pm_cursor; 00264 int n_cursor; 00265 #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator= 00266 QDragManager( const QDragManager & ); 00267 QDragManager &operator=( const QDragManager & ); 00268 #endif 00269 }; 00270 00271 #endif 00272 00273 #endif // QT_NO_MIME 00274 00275 #endif // QDRAGOBJECT_H