53 #ifndef QT_NO_ACCESSIBILITY 59 #if defined(Q_OS_WINCE) 65 #define MK_XBUTTON1 0x0020 66 #define MK_XBUTTON2 0x0040 71 #if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) 111 if (iid == IID_IUnknown || iid == IID_IDataObject) {
117 return ResultFromScode(E_NOINTERFACE);
121 QOleDataObject::AddRef(
void)
155 qDebug(
"QOleDataObject::GetData(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium)");
157 wchar_t buf[256] = {0};
158 GetClipboardFormatName(pformatetc->cfFormat, buf, 255);
164 return ResultFromScode(DATA_E_FORMATETC);
169 return ResultFromScode(S_OK);
171 return ResultFromScode(DATA_E_FORMATETC);
177 return ResultFromScode(DATA_E_FORMATETC);
184 qDebug(
"QOleDataObject::QueryGetData(LPFORMATETC pformatetc)");
188 return ResultFromScode(DATA_E_FORMATETC);
191 return ResultFromScode(S_OK);
192 return ResultFromScode(S_FALSE);
198 pformatetcOut->ptd = NULL;
199 return ResultFromScode(E_NOTIMPL);
206 DWORD * val = (DWORD*)GlobalLock(pMedium->hGlobal);
208 GlobalUnlock(pMedium->hGlobal);
210 ReleaseStgMedium(pMedium);
211 return ResultFromScode(S_OK);
213 return ResultFromScode(E_NOTIMPL);
221 qDebug(
"QOleDataObject::EnumFormatEtc(DWORD dwDirection, LPENUMFORMATETC FAR* ppenumFormatEtc)");
225 return ResultFromScode(DATA_E_FORMATETC);
230 if (dwDirection == DATADIR_GET) {
235 formatetc.dwAspect = DVASPECT_CONTENT;
236 formatetc.lindex = -1;
237 formatetc.ptd = NULL;
238 formatetc.tymed = TYMED_HGLOBAL;
239 fmtetcs.
append(formatetc);
243 *ppenumFormatEtc = enumFmtEtc;
244 if (enumFmtEtc->
isNull()) {
246 *ppenumFormatEtc = NULL;
250 return ResultFromScode(sc);
255 LPADVISESINK, DWORD FAR*)
257 return ResultFromScode(OLE_E_ADVISENOTSUPPORTED);
264 return ResultFromScode(OLE_E_ADVISENOTSUPPORTED);
270 return ResultFromScode(OLE_E_ADVISENOTSUPPORTED);
273 #endif // QT_NO_DRAGANDDROP && QT_NO_CLIPBOARD 275 #ifndef QT_NO_DRAGANDDROP 280 extern QString dragActionsToString(Qt::DropActions actions);
286 if (pdwEffects & DROPEFFECT_LINK)
288 if (pdwEffects & DROPEFFECT_COPY)
290 if (pdwEffects & DROPEFFECT_MOVE)
297 if (pdwEffect & DROPEFFECT_LINK)
299 if (pdwEffect & DROPEFFECT_COPY)
301 if (pdwEffect & DROPEFFECT_MOVE)
308 DWORD effect = DROPEFFECT_NONE;
310 effect |= DROPEFFECT_LINK;
312 effect |= DROPEFFECT_COPY;
314 effect |= DROPEFFECT_MOVE;
322 if (keyState & MK_SHIFT)
324 if (keyState & MK_CONTROL)
326 if (keyState & MK_ALT)
336 if (keyState & MK_LBUTTON)
338 if (keyState & MK_RBUTTON)
340 if (keyState & MK_MBUTTON)
352 void createCursors();
360 STDMETHOD(QueryContinueDrag)(BOOL fEscapePressed, DWORD grfKeyState);
361 STDMETHOD(GiveFeedback)(DWORD dwEffect);
386 if (manager && manager->
object 395 for (
int cnum = 0; cnum < actions.
size(); ++cnum) {
401 int x1 =
qMin(-hotSpot.
x(), 0);
403 int y1 =
qMin(-hotSpot.
y(), 0);
412 QPoint newHotSpot = hotSpot;
414 #if defined(Q_OS_WINCE) 419 QPoint hotspotInPM = newHotSpot - pmDest;
423 newHotSpot =
QPoint(
int(r * reqw), newHotSpot.y());
424 if (newHotSpot.x() + cpm.
width() > reqw)
431 newHotSpot =
QPoint(newHotSpot.x(), int(r * reqh));
432 if (newHotSpot.y() + cpm.
height() > reqh)
470 if(iid == IID_IUnknown || iid == IID_IDropSource)
477 return ResultFromScode(E_NOINTERFACE);
482 QOleDropSource::AddRef(
void)
501 Qt::MouseButtons result;
502 if (grfKeyState & MK_LBUTTON)
504 if (grfKeyState & MK_MBUTTON)
506 if (grfKeyState & MK_RBUTTON)
522 qDebug(
"QOleDropSource::QueryContinueDrag(fEscapePressed %d, grfKeyState %d)", fEscapePressed, grfKeyState);
525 if (fEscapePressed) {
526 return ResultFromScode(DRAGDROP_S_CANCEL);
527 }
else if ((GetAsyncKeyState(VK_LBUTTON) == 0)
528 && (GetAsyncKeyState(VK_MBUTTON) == 0)
529 && (GetAsyncKeyState(VK_RBUTTON) == 0)) {
532 return ResultFromScode(DRAGDROP_S_DROP);
534 #if !defined(Q_OS_WINCE) 539 if (!(currentButtons & buttons))
540 return ResultFromScode(DRAGDROP_S_DROP);
556 qDebug(
"QOleDropSource::GiveFeedback(DWORD dwEffect)");
557 qDebug(
"dwEffect = %s", dragActionsToString(action).toLatin1().
data());
560 if (currentAction != action) {
561 currentAction = action;
565 if (cursors.contains(currentAction)) {
567 SetCursor(cursors[currentAction].handle());
569 return ResultFromScode(S_OK);
572 return ResultFromScode(DRAGDROP_S_USEDEFAULTCURSORS);
598 if(iid == IID_IUnknown || iid == IID_IDropTarget)
605 return ResultFromScode(E_NOINTERFACE);
610 QOleDropTarget::AddRef(
void)
635 qDebug(
"QOleDropTarget::DragEnter(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect)");
639 *pdwEffect = DROPEFFECT_NONE;
653 POINTL pt, LPDWORD pdwEffect)
702 qDebug(
"QOleDropTarget::DragOver(grfKeyState %d, pt (%d,%d), pdwEffect %d)", grfKeyState, pt.x, pt.y, pdwEffect);
711 *pdwEffect = DROPEFFECT_NONE;
720 if (!dragOverWidget || !
acceptsDrop(dragOverWidget)) {
721 *pdwEffect = DROPEFFECT_NONE;
738 if (!dragOverWidgetGuard) {
781 qDebug(
"QOleDropTarget::DragLeave()");
802 #define KEY_STATE_BUTTON_MASK (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON) 808 qDebug(
"QOleDropTarget::Drop(LPDATAOBJECT /*pDataObj*/, grfKeyState %d, POINTL pt, LPDWORD pdwEffect)", grfKeyState);
817 *pdwEffect = DROPEFFECT_NONE;
848 HGLOBAL hData = GlobalAlloc(0,
sizeof(DWORD));
850 DWORD *moveEffect = (DWORD *)GlobalLock(hData);;
851 *moveEffect = DROPEFFECT_MOVE;
855 medium.tymed = TYMED_HGLOBAL;
856 medium.hGlobal = hData;
859 format.tymed = TYMED_HGLOBAL;
891 if (!currentDataObject)
900 if (!currentDataObject)
912 if (!currentDataObject)
918 result = converter->
convertToMime(mimeType, currentDataObject, type);
927 qDebug(
"QDragManager::drag(QDrag *drag)");
930 if (
object == o || !o || !o->d_func()->
source)
935 qApp->removeEventFilter(
this);
936 beingCancelled =
false;
945 dragPrivate()->target = 0;
947 #ifndef QT_NO_ACCESSIBILITY 957 #if !defined(Q_OS_WINCE) || defined(GWES_ICONCURS) 958 HRESULT r = DoDragDrop(obj, src, allowedEffects, &resultEffect);
961 resultEffect = DROPEFFECT_MOVE;
965 if (r == DRAGDROP_S_DROP) {
968 resultEffect = DROPEFFECT_MOVE;
974 if (resultEffect != DROPEFFECT_NONE && !(resultEffect & allowedEffects))
977 dragPrivate()->target = 0;
988 #ifndef QT_NO_ACCESSIBILITY 998 beingCancelled =
true;
1002 #ifndef QT_NO_CURSOR 1005 if (restoreCursor) {
1007 restoreCursor =
false;
1010 #ifndef QT_NO_ACCESSIBILITY 1043 #endif // QT_NO_DRAGANDDROP The QVariant class acts like a union for the most common Qt data types.
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
The QWindowsMime class maps open-standard MIME to Window Clipboard formats.
STDMETHOD() GetData(LPFORMATETC pformatetcIn, LPSTGMEDIUM pmedium)
The QPainter class performs low-level painting on widgets and other paint devices.
The QColor class provides colors based on RGB, HSV or CMYK values.
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object's accessibility information.
QMap< Qt::DropAction, QCursor > cursors
bool hasFormat_sys(const QString &mimeType) const
QOleDropTarget(QWidget *w)
STDMETHOD() Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect)
QStringList formats_sys() const
Qt::DropActions translateToQDragDropActions(DWORD pdwEffects)
The QCursor class provides a mouse cursor with an arbitrary shape.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
QWidget * source() const
Returns the source of the drag object.
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > currentWidget
The QDrag class provides support for MIME-based drag and drop data transfer.
int width() const
Returns the width of the pixmap.
void setMimeData(QMimeData *data)
Sets the data to be sent to the given MIME data.
QPointer< QWidget > widget
Qt::DropAction translateToQDragDropAction(DWORD pdwEffect)
STDMETHOD() SetData(LPFORMATETC pformatetc, STGMEDIUM FAR *pmedium, BOOL fRelease)
static QStringList allMimesForFormats(IDataObject *pDataObj)
void sendDragEnterEvent(QWidget *to, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect)
DWORD reportedPerformedEffect() const
Qt::MouseButtons currentButtons
static Qt::MouseButtons buttons
QPointer< QMimeData > data
void setDropAction(Qt::DropAction action)
Sets the action to be performed on the data by the target.
STDMETHOD() GetDataHere(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium)
Qt::DropAction dropAction() const
Returns the action to be performed on the data by the target.
int left() const
Returns the x-coordinate of the rectangle's left edge.
void accept()
Calls QDropEvent::accept().
int width() const
Returns the width of the rectangle.
#define KEY_STATE_BUTTON_MASK
#define CFSTR_PERFORMEDDROPEFFECT
void cancel(bool deleteSource=true)
struct tagFORMATETC FORMATETC
int height() const
Returns the height of the rectangle.
The QString class provides a Unicode character string.
STDMETHOD() DUnadvise(DWORD dwConnection)
The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress...
void emitActionChanged(Qt::DropAction newAction)
The QVector class is a template class that provides a dynamic array.
The QObject class is the base class of all Qt objects.
Qt::KeyboardModifiers keyboardModifiers() const
Returns the modifier keys that are pressed.
static Qt::MouseButtons keystate_to_mousebutton(DWORD grfKeyState)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
DWORD translateToWinDragEffects(Qt::DropActions action)
static void processEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
Processes all pending events for the calling thread according to the specified flags until there are ...
STDMETHOD() QueryGetData(LPFORMATETC pformatetc)
Qt::DropAction drag(QDrag *)
#define QT_ENSURE_STACK_ALIGNED_FOR_SSE
STDMETHOD() QueryInterface(REFIID riid, void FAR *FAR *ppvObj)
Q_CORE_EXPORT void qDebug(const char *,...)
#define QT_BEGIN_NAMESPACE
This macro expands to.
virtual ~QOleDataObject()
int CF_PERFORMEDDROPEFFECT
QRect answerRect() const
Returns the rectangle in the widget where the drop will occur if accepted.
STDMETHOD_(ULONG, AddRef)(void)
const T & at(int i) const
Returns the item at index position i in the list.
The QStringList class provides a list of strings.
void append(const T &t)
Inserts value at the end of the vector.
static Qt::DropActions possible_actions
static const char * data(const QByteArray &arr)
Type
This enum type defines the types of variable that a QVariant can contain.
struct tagSTGMEDIUM STGMEDIUM
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leav...
STDMETHOD() DragEnter(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect)
Qt::MouseButtons toQtMouseButtons(DWORD keyState)
QPixmap pixmap() const
Returns the pixmap used to represent the data in a drag and drop operation.
virtual bool convertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData, STGMEDIUM *pmedium) const =0
Convert the mimeData to the format specified in formatetc.
STDMETHOD() QueryInterface(REFIID riid, void **ppvObj)
The QMimeData class provides a container for data that records information about its MIME type...
STDMETHOD() QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState)
virtual ~QOleDropSource()
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
STDMETHOD() EnumDAdvise(LPENUMSTATDATA FAR *ppenumAdvise)
static QDragManager * self()
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const
static bool tryModalHelper(QWidget *widget, QWidget **rettop=0)
STDMETHOD() DAdvise(FORMATETC FAR *pFormatetc, DWORD advf, LPADVISESINK pAdvSink, DWORD FAR *pdwConnection)
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
const QMimeData * mimeData() const
int top() const
Returns the y-coordinate of the rectangle's top edge.
The QDropEvent class provides an event which is sent when a drag and drop action is completed...
static QWindowsMime * converterFromMime(const FORMATETC &formatetc, const QMimeData *mimeData)
The QTimerEvent class contains parameters that describe a timer event.
LPDATAOBJECT currentDataObject
QMimeData * mimeData() const
Returns the MIME data that is encapsulated by the drag object.
static bool acceptsDrop(const QWidget *w)
STDMETHOD() GiveFeedback(DWORD dwEffect)
The QDragEnterEvent class provides an event which is sent to a widget when a drag and drop action ent...
The QPoint class defines a point in the plane using integer precision.
int size() const
Returns the number of items in the list.
Qt::DropAction currentAction
static QWindowsMime * converterToMime(const QString &mimeType, IDataObject *pDataObj)
The QRect class defines a rectangle in the plane using integer precision.
QRect rect() const
Returns the pixmap's enclosing rectangle.
int y() const
Returns the y coordinate of this point.
The QPixmap class is an off-screen image representation that can be used as a paint device...
virtual QVariant convertToMime(const QString &mimeType, IDataObject *pDataObj, QVariant::Type preferredType) const =0
Returns a QVariant containing the converted data for mimeType from pDataObj.
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
int height() const
Returns the height of the pixmap.
STDMETHOD() DragOver(DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect)
QOleDataObject(QMimeData *mimeData)
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
The QSize class defines the size of a two-dimensional object using integer point precision.
QPixmap dragCursor(Qt::DropAction action) const
int x() const
Returns the x coordinate of this point.
void move(const QPoint &)
STDMETHOD() GetCanonicalFormatEtc(LPFORMATETC pformatetc, LPFORMATETC pformatetcOut)
static void restoreOverrideCursor()
Undoes the last setOverrideCursor().
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
bool hasCustomDragCursors() const
The QEvent class is the base class of all event classes.
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
static QVector< FORMATETC > allFormatsForMime(const QMimeData *mimeData)
bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
QDragPrivate * dragPrivate() const
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
void deleteLater()
Schedules this object for deletion.
STDMETHOD() EnumFormatEtc(DWORD dwDirection, LPENUMFORMATETC FAR *ppenumFormatEtc)
static QWidget * dropWidget
STDMETHOD() QueryInterface(REFIID riid, void FAR *FAR *ppvObj)
QPoint hotSpot() const
Returns the position of the hot spot relative to the top-left corner of the cursor.
The QList class is a template class that provides lists.
void timerEvent(QTimerEvent *)
This event handler can be reimplemented in a subclass to receive timer events for the object...
Qt::KeyboardModifiers toQtKeyboardModifiers(DWORD keyState)