1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsNativeDragSource.h"
8 #include "nsISupportsImpl.h"
10 #include "nsIServiceManager.h"
11 #include "nsToolkit.h"
12 #include "nsWidgetsCID.h"
13 #include "nsIDragService.h"
16 * class nsNativeDragSource
18 nsNativeDragSource::nsNativeDragSource(nsIDOMDataTransfer
* aDataTransfer
) :
23 mDataTransfer
= do_QueryInterface(aDataTransfer
);
26 nsNativeDragSource::~nsNativeDragSource()
31 nsNativeDragSource::QueryInterface(REFIID riid
, void** ppv
)
35 if (IID_IUnknown
==riid
|| IID_IDropSource
==riid
)
39 ((LPUNKNOWN
)*ppv
)->AddRef();
47 nsNativeDragSource::AddRef(void)
50 NS_LOG_ADDREF(this, m_cRef
, "nsNativeDragSource", sizeof(*this));
55 nsNativeDragSource::Release(void)
58 NS_LOG_RELEASE(this, m_cRef
, "nsNativeDragSource");
67 nsNativeDragSource::QueryContinueDrag(BOOL fEsc
, DWORD grfKeyState
)
69 static NS_DEFINE_IID(kCDragServiceCID
, NS_DRAGSERVICE_CID
);
71 nsCOMPtr
<nsIDragService
> dragService
= do_GetService(kCDragServiceCID
);
73 DWORD pos
= ::GetMessagePos();
74 dragService
->DragMoved(GET_X_LPARAM(pos
), GET_Y_LPARAM(pos
));
78 mUserCancelled
= true;
79 return DRAGDROP_S_CANCEL
;
82 if (!(grfKeyState
& MK_LBUTTON
) || (grfKeyState
& MK_RBUTTON
))
83 return DRAGDROP_S_DROP
;
89 nsNativeDragSource::GiveFeedback(DWORD dwEffect
)
91 // For drags involving tabs, we do some custom work with cursors.
94 mDataTransfer
->GetMozCursor(cursor
);
95 if (cursor
.EqualsLiteral("default")) {
96 m_hCursor
= ::LoadCursor(0, IDC_ARROW
);
103 ::SetCursor(m_hCursor
);
107 // Let the system choose which cursor to apply.
108 return DRAGDROP_S_USEDEFAULTCURSORS
;