[2] | 1 | /****************************************************************************
|
---|
| 2 | ** $Id: qdragobject.h 8 2005-11-16 19:36:46Z dmik $
|
---|
| 3 | **
|
---|
| 4 | ** Definition of QDragObject
|
---|
| 5 | **
|
---|
| 6 | ** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
|
---|
| 7 | **
|
---|
| 8 | ** This file is part of the kernel module of the Qt GUI Toolkit.
|
---|
| 9 | **
|
---|
| 10 | ** This file may be distributed under the terms of the Q Public License
|
---|
| 11 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
| 12 | ** LICENSE.QPL included in the packaging of this file.
|
---|
| 13 | **
|
---|
| 14 | ** This file may be distributed and/or modified under the terms of the
|
---|
| 15 | ** GNU General Public License version 2 as published by the Free Software
|
---|
| 16 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 17 | ** packaging of this file.
|
---|
| 18 | **
|
---|
| 19 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
| 20 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
| 21 | ** Agreement provided with the Software.
|
---|
| 22 | **
|
---|
| 23 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
| 24 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
| 25 | **
|
---|
| 26 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
| 27 | ** information about Qt Commercial License Agreements.
|
---|
| 28 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
| 29 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
| 30 | **
|
---|
| 31 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
| 32 | ** not clear to you.
|
---|
| 33 | **
|
---|
| 34 | **********************************************************************/
|
---|
| 35 |
|
---|
| 36 | #ifndef QDRAGOBJECT_H
|
---|
| 37 | #define QDRAGOBJECT_H
|
---|
| 38 |
|
---|
| 39 | class QWidget;
|
---|
| 40 | class QTextDragPrivate;
|
---|
| 41 | class QDragObjectData;
|
---|
| 42 | class QStoredDragData;
|
---|
| 43 | class QImageDragData;
|
---|
| 44 |
|
---|
| 45 | #ifndef QT_H
|
---|
| 46 | #include "qobject.h"
|
---|
| 47 | #include "qimage.h"
|
---|
| 48 | #include "qstrlist.h"
|
---|
| 49 | #include "qcolor.h"
|
---|
| 50 | #endif // QT_H
|
---|
| 51 |
|
---|
| 52 | #ifndef QT_NO_MIME
|
---|
| 53 |
|
---|
| 54 | class Q_EXPORT QDragObject: public QObject, public QMimeSource {
|
---|
| 55 | Q_OBJECT
|
---|
| 56 | public:
|
---|
| 57 | QDragObject( QWidget * dragSource = 0, const char * name = 0 );
|
---|
| 58 | virtual ~QDragObject();
|
---|
| 59 |
|
---|
| 60 | #ifndef QT_NO_DRAGANDDROP
|
---|
| 61 | bool drag();
|
---|
| 62 | bool dragMove();
|
---|
| 63 | void dragCopy();
|
---|
| 64 | void dragLink();
|
---|
| 65 |
|
---|
| 66 | virtual void setPixmap(QPixmap);
|
---|
| 67 | virtual void setPixmap(QPixmap, const QPoint& hotspot);
|
---|
| 68 | QPixmap pixmap() const;
|
---|
| 69 | QPoint pixmapHotSpot() const;
|
---|
| 70 | #endif
|
---|
| 71 |
|
---|
| 72 | QWidget * source();
|
---|
| 73 | static QWidget * target();
|
---|
| 74 |
|
---|
| 75 | static void setTarget(QWidget*);
|
---|
| 76 |
|
---|
| 77 | #ifndef QT_NO_DRAGANDDROP
|
---|
| 78 | enum DragMode { DragDefault, DragCopy, DragMove, DragLink, DragCopyOrMove };
|
---|
| 79 |
|
---|
| 80 | protected:
|
---|
| 81 | virtual bool drag(DragMode);
|
---|
| 82 | #endif
|
---|
| 83 |
|
---|
| 84 | private:
|
---|
| 85 | QDragObjectData * d;
|
---|
| 86 | #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
|
---|
| 87 | QDragObject( const QDragObject & );
|
---|
| 88 | QDragObject &operator=( const QDragObject & );
|
---|
| 89 | #endif
|
---|
| 90 | };
|
---|
| 91 |
|
---|
| 92 | class Q_EXPORT QStoredDrag: public QDragObject {
|
---|
| 93 | Q_OBJECT
|
---|
| 94 | QStoredDragData * d;
|
---|
| 95 |
|
---|
| 96 | public:
|
---|
| 97 | QStoredDrag( const char * mimeType,
|
---|
| 98 | QWidget * dragSource = 0, const char * name = 0 );
|
---|
| 99 | ~QStoredDrag();
|
---|
| 100 |
|
---|
| 101 | virtual void setEncodedData( const QByteArray & );
|
---|
| 102 |
|
---|
| 103 | const char * format(int i) const;
|
---|
| 104 | virtual QByteArray encodedData(const char*) const;
|
---|
| 105 |
|
---|
| 106 | private:
|
---|
| 107 | #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
|
---|
| 108 | QStoredDrag( const QStoredDrag & );
|
---|
| 109 | QStoredDrag &operator=( const QStoredDrag & );
|
---|
| 110 | #endif
|
---|
| 111 | };
|
---|
| 112 |
|
---|
| 113 | class Q_EXPORT QTextDrag: public QDragObject {
|
---|
| 114 | Q_OBJECT
|
---|
| 115 | QTextDragPrivate* d;
|
---|
| 116 | public:
|
---|
| 117 | QTextDrag( const QString &,
|
---|
| 118 | QWidget * dragSource = 0, const char * name = 0 );
|
---|
| 119 | QTextDrag( QWidget * dragSource = 0, const char * name = 0 );
|
---|
| 120 | ~QTextDrag();
|
---|
| 121 |
|
---|
| 122 | virtual void setText( const QString &);
|
---|
| 123 | virtual void setSubtype( const QCString &);
|
---|
| 124 |
|
---|
| 125 | const char * format(int i) const;
|
---|
| 126 | virtual QByteArray encodedData(const char*) const;
|
---|
| 127 |
|
---|
| 128 | static bool canDecode( const QMimeSource* e );
|
---|
| 129 | static bool decode( const QMimeSource* e, QString& s );
|
---|
| 130 | static bool decode( const QMimeSource* e, QString& s, QCString& subtype );
|
---|
| 131 |
|
---|
| 132 | private:
|
---|
| 133 | #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
|
---|
| 134 | QTextDrag( const QTextDrag & );
|
---|
| 135 | QTextDrag &operator=( const QTextDrag & );
|
---|
| 136 | #endif
|
---|
| 137 | };
|
---|
| 138 |
|
---|
| 139 | class Q_EXPORT QImageDrag: public QDragObject {
|
---|
| 140 | Q_OBJECT
|
---|
| 141 | QImage img;
|
---|
| 142 | QStrList ofmts;
|
---|
| 143 | QImageDragData* d;
|
---|
| 144 |
|
---|
| 145 | public:
|
---|
| 146 | QImageDrag( QImage image, QWidget * dragSource = 0, const char * name = 0 );
|
---|
| 147 | QImageDrag( QWidget * dragSource = 0, const char * name = 0 );
|
---|
| 148 | ~QImageDrag();
|
---|
| 149 |
|
---|
| 150 | virtual void setImage( QImage image );
|
---|
| 151 |
|
---|
| 152 | const char * format(int i) const;
|
---|
| 153 | virtual QByteArray encodedData(const char*) const;
|
---|
| 154 |
|
---|
| 155 | static bool canDecode( const QMimeSource* e );
|
---|
| 156 | static bool decode( const QMimeSource* e, QImage& i );
|
---|
| 157 | static bool decode( const QMimeSource* e, QPixmap& i );
|
---|
| 158 |
|
---|
| 159 | private:
|
---|
| 160 | #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
|
---|
| 161 | QImageDrag( const QImageDrag & );
|
---|
| 162 | QImageDrag &operator=( const QImageDrag & );
|
---|
| 163 | #endif
|
---|
| 164 | };
|
---|
| 165 |
|
---|
| 166 |
|
---|
| 167 | class Q_EXPORT QUriDrag: public QStoredDrag {
|
---|
| 168 | Q_OBJECT
|
---|
| 169 |
|
---|
| 170 | public:
|
---|
| 171 | QUriDrag( QStrList uris, QWidget * dragSource = 0, const char * name = 0 );
|
---|
| 172 | QUriDrag( QWidget * dragSource = 0, const char * name = 0 );
|
---|
| 173 | ~QUriDrag();
|
---|
| 174 |
|
---|
| 175 | void setFilenames( const QStringList & fnames ) { setFileNames( fnames ); }
|
---|
| 176 | void setFileNames( const QStringList & fnames );
|
---|
| 177 | void setUnicodeUris( const QStringList & uuris );
|
---|
| 178 | virtual void setUris( QStrList uris );
|
---|
| 179 |
|
---|
| 180 | static QString uriToLocalFile(const char*);
|
---|
| 181 | static QCString localFileToUri(const QString&);
|
---|
| 182 | static QString uriToUnicodeUri(const char*);
|
---|
| 183 | static QCString unicodeUriToUri(const QString&);
|
---|
| 184 | static bool canDecode( const QMimeSource* e );
|
---|
| 185 | static bool decode( const QMimeSource* e, QStrList& i );
|
---|
| 186 | static bool decodeToUnicodeUris( const QMimeSource* e, QStringList& i );
|
---|
| 187 | static bool decodeLocalFiles( const QMimeSource* e, QStringList& i );
|
---|
| 188 |
|
---|
| 189 | private:
|
---|
| 190 | #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
|
---|
| 191 | QUriDrag( const QUriDrag & );
|
---|
| 192 | QUriDrag &operator=( const QUriDrag & );
|
---|
| 193 | #endif
|
---|
| 194 | };
|
---|
| 195 |
|
---|
| 196 | class Q_EXPORT QColorDrag : public QStoredDrag
|
---|
| 197 | {
|
---|
| 198 | Q_OBJECT
|
---|
| 199 | QColor color;
|
---|
| 200 |
|
---|
| 201 | public:
|
---|
| 202 | QColorDrag( const QColor &col, QWidget *dragsource = 0, const char *name = 0 );
|
---|
| 203 | QColorDrag( QWidget * dragSource = 0, const char * name = 0 );
|
---|
| 204 | void setColor( const QColor &col );
|
---|
| 205 |
|
---|
| 206 | static bool canDecode( QMimeSource * );
|
---|
| 207 | static bool decode( QMimeSource *, QColor &col );
|
---|
| 208 |
|
---|
| 209 | private:
|
---|
| 210 | #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
|
---|
| 211 | QColorDrag( const QColorDrag & );
|
---|
| 212 | QColorDrag &operator=( const QColorDrag & );
|
---|
| 213 | #endif
|
---|
| 214 | };
|
---|
| 215 |
|
---|
| 216 | #ifndef QT_NO_COMPAT
|
---|
| 217 | typedef QUriDrag QUrlDrag;
|
---|
| 218 | #endif
|
---|
| 219 |
|
---|
| 220 | #ifndef QT_NO_DRAGANDDROP
|
---|
[8] | 221 | //@@TODO (dmik): no QDragManager yet (MOC ignores preprocessor macros)
|
---|
[2] | 222 | //
|
---|
[8] | 223 | //// QDragManager is not part of the public API. It is defined in a
|
---|
| 224 | //// header file simply so different .cpp files can implement different
|
---|
| 225 | //// member functions.
|
---|
| 226 | ////
|
---|
| 227 | //
|
---|
| 228 | //class Q_EXPORT QDragManager: public QObject {
|
---|
| 229 | // Q_OBJECT
|
---|
| 230 | //
|
---|
| 231 | //private:
|
---|
| 232 | // QDragManager();
|
---|
| 233 | // ~QDragManager();
|
---|
| 234 | // // only friend classes can use QDragManager.
|
---|
| 235 | // friend class QDragObject;
|
---|
| 236 | // friend class QDragMoveEvent;
|
---|
| 237 | // friend class QDropEvent;
|
---|
| 238 | // friend class QApplication;
|
---|
| 239 | //
|
---|
| 240 | // bool eventFilter( QObject *, QEvent * );
|
---|
| 241 | // void timerEvent( QTimerEvent* );
|
---|
| 242 | //
|
---|
| 243 | // bool drag( QDragObject *, QDragObject::DragMode );
|
---|
| 244 | //
|
---|
| 245 | // void cancel( bool deleteSource = TRUE );
|
---|
| 246 | // void move( const QPoint & );
|
---|
| 247 | // void drop();
|
---|
| 248 | // void updatePixmap();
|
---|
| 249 | //
|
---|
| 250 | //private:
|
---|
| 251 | // QDragObject * object;
|
---|
| 252 | // void updateMode( ButtonState newstate );
|
---|
| 253 | // void updateCursor();
|
---|
| 254 | //
|
---|
| 255 | // QWidget * dragSource;
|
---|
| 256 | // QWidget * dropWidget;
|
---|
| 257 | // bool beingCancelled;
|
---|
| 258 | // bool restoreCursor;
|
---|
| 259 | // bool willDrop;
|
---|
| 260 | //
|
---|
| 261 | // QPixmap *pm_cursor;
|
---|
| 262 | // int n_cursor;
|
---|
| 263 | //#if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
|
---|
| 264 | // QDragManager( const QDragManager & );
|
---|
| 265 | // QDragManager &operator=( const QDragManager & );
|
---|
| 266 | //#endif
|
---|
| 267 | //};
|
---|
| 268 | //
|
---|
[2] | 269 | #endif
|
---|
| 270 |
|
---|
| 271 | #endif // QT_NO_MIME
|
---|
| 272 |
|
---|
| 273 | #endif // QDRAGOBJECT_H
|
---|