source: trunk/include/qdragobject.h@ 137

Last change on this file since 137 was 97, checked in by dmik, 19 years ago

kernel: Created the initial implementation of the Drag'n'Drop support for OS/2 (not fully functiona yet: updating widget contents under the drag pointer will cause screen corruption, setting the drag object's pixmap is not possible). See ticket:22 for more info.

  • Property svn:keywords set to Id
File size: 7.9 KB
Line 
1/****************************************************************************
2** $Id: qdragobject.h 97 2006-07-06 21:25:56Z 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
39class QWidget;
40class QTextDragPrivate;
41class QDragObjectData;
42class QStoredDragData;
43class 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
54class Q_EXPORT QDragObject: public QObject, public QMimeSource {
55 Q_OBJECT
56public:
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
80protected:
81 virtual bool drag(DragMode);
82#endif
83
84private:
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
92class Q_EXPORT QStoredDrag: public QDragObject {
93 Q_OBJECT
94 QStoredDragData * d;
95
96public:
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
106private:
107#if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
108 QStoredDrag( const QStoredDrag & );
109 QStoredDrag &operator=( const QStoredDrag & );
110#endif
111};
112
113class Q_EXPORT QTextDrag: public QDragObject {
114 Q_OBJECT
115 QTextDragPrivate* d;
116public:
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
132private:
133#if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
134 QTextDrag( const QTextDrag & );
135 QTextDrag &operator=( const QTextDrag & );
136#endif
137};
138
139class Q_EXPORT QImageDrag: public QDragObject {
140 Q_OBJECT
141 QImage img;
142 QStrList ofmts;
143 QImageDragData* d;
144
145public:
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
159private:
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
167class Q_EXPORT QUriDrag: public QStoredDrag {
168 Q_OBJECT
169
170public:
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
189private:
190#if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
191 QUriDrag( const QUriDrag & );
192 QUriDrag &operator=( const QUriDrag & );
193#endif
194};
195
196class Q_EXPORT QColorDrag : public QStoredDrag
197{
198 Q_OBJECT
199 QColor color;
200
201public:
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
209private:
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
217typedef QUriDrag QUrlDrag;
218#endif
219
220#ifndef QT_NO_DRAGANDDROP
221
222// QDragManager is not part of the public API. It is defined in a
223// header file simply so different .cpp files can implement different
224// member functions.
225//
226
227class Q_EXPORT QDragManager: public QObject {
228 Q_OBJECT
229
230private:
231 QDragManager();
232 ~QDragManager();
233 // only friend classes can use QDragManager.
234 friend class QDragObject;
235 friend class QDragMoveEvent;
236 friend class QDropEvent;
237 friend class QApplication;
238
239 bool eventFilter( QObject *, QEvent * );
240 void timerEvent( QTimerEvent* );
241
242 bool drag( QDragObject *, QDragObject::DragMode );
243
244 void cancel( bool deleteSource = TRUE );
245 void move( const QPoint & );
246 void drop();
247 void updatePixmap();
248
249private:
250 QDragObject * object;
251 void updateMode( ButtonState newstate );
252 void updateCursor();
253
254 QWidget * dragSource;
255 QWidget * dropWidget;
256 bool beingCancelled;
257 bool restoreCursor;
258 bool willDrop;
259
260 QPixmap *pm_cursor;
261 int n_cursor;
262#if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
263 QDragManager( const QDragManager & );
264 QDragManager &operator=( const QDragManager & );
265#endif
266};
267
268#endif
269
270#endif // QT_NO_MIME
271
272#endif // QDRAGOBJECT_H
Note: See TracBrowser for help on using the repository browser.