зеркало из https://github.com/mozilla/pjs.git
work for new drag session interface.
This commit is contained in:
Родитель
51e2943d54
Коммит
6b8d71eb41
|
@ -22,11 +22,11 @@
|
|||
#include "nsIServiceManager.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsITransferable.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsSize.h"
|
||||
#include "nsIRegion.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIDragServiceIID, NS_IDRAGSERVICE_IID);
|
||||
|
||||
NS_IMPL_ADDREF(nsBaseDragService)
|
||||
NS_IMPL_RELEASE(nsBaseDragService)
|
||||
|
||||
|
@ -36,11 +36,15 @@ NS_IMPL_RELEASE(nsBaseDragService)
|
|||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsBaseDragService::nsBaseDragService() :
|
||||
mTargetSize(0,0)
|
||||
mTargetSize(0,0), mCanDrop(PR_FALSE), mDragAction(DRAGDROP_ACTION_NONE),
|
||||
mDoingDrag(PR_FALSE)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mCanDrop = PR_FALSE;
|
||||
mDragAction = DRAGDROP_ACTION_NONE;
|
||||
nsresult result = NS_NewISupportsArray(getter_AddRefs(mTransArray));
|
||||
if ( !NS_SUCCEEDED(result) ) {
|
||||
//what do we do? we can't throw!
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -60,15 +64,18 @@ nsBaseDragService::~nsBaseDragService()
|
|||
*/
|
||||
nsresult nsBaseDragService::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
|
||||
if (NULL == aInstancePtr) {
|
||||
if (NULL == aInstancePtr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsresult rv = NS_NOINTERFACE;
|
||||
|
||||
if (aIID.Equals(kIDragServiceIID)) {
|
||||
*aInstancePtr = (void*) ((nsIDragService*)this);
|
||||
if ( aIID.Equals(nsIDragService::GetIID()) ) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIDragService*,this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(nsIDragSession::GetIID())) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIDragSession*,this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -120,14 +127,63 @@ NS_IMETHODIMP nsBaseDragService::GetTargetSize (nsSize * aDragTargetSize)
|
|||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsBaseDragService::StartDragSession (nsITransferable * aTransferable, PRUint32 aActionType)
|
||||
|
||||
NS_IMETHODIMP nsBaseDragService::GetData (nsITransferable * aTransferable)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsBaseDragService::GetData (nsITransferable * aTransferable)
|
||||
NS_IMETHODIMP nsBaseDragService::IsDataFlavorSupported(nsIDataFlavor * aDataFlavor)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsBaseDragService::InvokeDragSession (nsISupportsArray * anArrayTransferables, nsIRegion * aRegion, PRUint32 aActionType)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsBaseDragService::InvokeDragSessionSingle (nsITransferable * aTransferable, nsIRegion * aRegion, PRUint32 aActionType)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsBaseDragService::GetCurrentSession (nsIDragSession ** aSession)
|
||||
{
|
||||
if ( !aSession )
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
// "this" also implements a drag session, so say we are one but only if there
|
||||
// is currently a drag going on.
|
||||
if ( mDoingDrag ) {
|
||||
NS_ADDREF_THIS(); // addRef because we're a "getter"
|
||||
*aSession = this;
|
||||
}
|
||||
else
|
||||
*aSession = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsBaseDragService::StartDragSession ()
|
||||
{
|
||||
if (mDoingDrag) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mDoingDrag = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsBaseDragService::EndDragSession ()
|
||||
{
|
||||
if (!mDoingDrag) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mDoingDrag = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define nsBaseDragService_h__
|
||||
|
||||
#include "nsIDragService.h"
|
||||
#include "nsIDragSession.h"
|
||||
#include "nsITransferable.h"
|
||||
#include "nsSize.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -28,7 +29,7 @@
|
|||
* XP DragService wrapper base class
|
||||
*/
|
||||
|
||||
class nsBaseDragService : public nsIDragService
|
||||
class nsBaseDragService : public nsIDragService, public nsIDragSession
|
||||
{
|
||||
|
||||
public:
|
||||
|
@ -39,6 +40,13 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
//nsIDragService
|
||||
NS_IMETHOD InvokeDragSession (nsISupportsArray * anArrayTransferables, nsIRegion * aRegion, PRUint32 aActionType);
|
||||
NS_IMETHOD InvokeDragSessionSingle (nsITransferable * aTransferable, nsIRegion * aRegion, PRUint32 aActionType);
|
||||
NS_IMETHOD GetCurrentSession (nsIDragSession ** aSession);
|
||||
NS_IMETHOD StartDragSession ();
|
||||
NS_IMETHOD EndDragSession ();
|
||||
|
||||
// nsIDragSession
|
||||
NS_IMETHOD SetCanDrop (PRBool aCanDrop);
|
||||
NS_IMETHOD GetCanDrop (PRBool * aCanDrop);
|
||||
|
||||
|
@ -48,15 +56,16 @@ public:
|
|||
NS_IMETHOD SetTargetSize (nsSize aDragTargetSize);
|
||||
NS_IMETHOD GetTargetSize (nsSize * aDragTargetSize);
|
||||
|
||||
NS_IMETHOD StartDragSession (nsITransferable * aTransferable, PRUint32 aActionType);
|
||||
NS_IMETHOD GetData (nsITransferable * aTransferable);
|
||||
NS_IMETHOD IsDataFlavorSupported(nsIDataFlavor * aDataFlavor);
|
||||
|
||||
protected:
|
||||
|
||||
nsCOMPtr<nsITransferable> mTransferable;
|
||||
PRBool mCanDrop;
|
||||
nsSize mTargetSize;
|
||||
PRUint32 mDragAction;
|
||||
nsCOMPtr<nsISupportsArray> mTransArray;
|
||||
PRBool mCanDrop;
|
||||
PRBool mDoingDrag;
|
||||
nsSize mTargetSize;
|
||||
PRUint32 mDragAction;
|
||||
};
|
||||
|
||||
#endif // nsBaseDragService_h__
|
||||
|
|
Загрузка…
Ссылка в новой задаче