2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-04-17 01:03:22 +04:00
|
|
|
|
|
|
|
#ifndef nsBaseDragService_h__
|
|
|
|
#define nsBaseDragService_h__
|
|
|
|
|
|
|
|
#include "nsIDragService.h"
|
1999-05-07 23:51:50 +04:00
|
|
|
#include "nsIDragSession.h"
|
1999-04-17 01:03:22 +04:00
|
|
|
#include "nsITransferable.h"
|
1999-05-08 00:11:46 +04:00
|
|
|
#include "nsISupportsArray.h"
|
2000-08-01 00:51:42 +04:00
|
|
|
#include "nsIDOMDocument.h"
|
2008-08-27 16:07:27 +04:00
|
|
|
#include "nsIDOMDataTransfer.h"
|
2011-04-26 05:37:20 +04:00
|
|
|
#include "nsIContent.h"
|
2011-04-08 05:04:40 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsPoint.h"
|
2007-03-20 15:14:52 +03:00
|
|
|
|
|
|
|
#include "gfxImageSurface.h"
|
1999-04-17 01:03:22 +04:00
|
|
|
|
2007-03-26 07:27:53 +04:00
|
|
|
// translucency level for drag images
|
|
|
|
#define DRAG_TRANSLUCENCY 0.65
|
|
|
|
|
2000-08-16 05:46:34 +04:00
|
|
|
class nsIDOMNode;
|
|
|
|
class nsIFrame;
|
2004-08-01 03:15:21 +04:00
|
|
|
class nsPresContext;
|
2007-03-20 15:14:52 +03:00
|
|
|
class nsIImageLoadingContent;
|
2010-05-18 08:04:22 +04:00
|
|
|
class nsICanvasElementExternal;
|
2000-08-16 05:46:34 +04:00
|
|
|
|
1999-04-17 01:03:22 +04:00
|
|
|
/**
|
|
|
|
* XP DragService wrapper base class
|
|
|
|
*/
|
|
|
|
|
2005-03-15 01:49:00 +03:00
|
|
|
class nsBaseDragService : public nsIDragService,
|
|
|
|
public nsIDragSession
|
1999-04-17 01:03:22 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
nsBaseDragService();
|
|
|
|
virtual ~nsBaseDragService();
|
|
|
|
|
|
|
|
//nsISupports
|
|
|
|
NS_DECL_ISUPPORTS
|
2005-03-15 01:49:00 +03:00
|
|
|
|
1999-09-05 06:28:38 +04:00
|
|
|
//nsIDragSession and nsIDragService
|
|
|
|
NS_DECL_NSIDRAGSERVICE
|
|
|
|
NS_DECL_NSIDRAGSESSION
|
1999-04-17 01:03:22 +04:00
|
|
|
|
2009-04-16 19:58:23 +04:00
|
|
|
void SetDragEndPoint(nsIntPoint aEndDragPoint) { mEndDragPoint = aEndDragPoint; }
|
2009-04-13 17:00:29 +04:00
|
|
|
|
2010-04-06 16:59:24 +04:00
|
|
|
PRUint16 GetInputSource() { return mInputSource; }
|
|
|
|
|
1999-04-17 01:03:22 +04:00
|
|
|
protected:
|
|
|
|
|
2007-03-20 15:14:52 +03:00
|
|
|
/**
|
|
|
|
* Draw the drag image, if any, to a surface and return it. The drag image
|
|
|
|
* is constructed from mImage if specified, or aDOMNode if mImage is null.
|
|
|
|
*
|
|
|
|
* aRegion may be used to draw only a subset of the element. This region
|
|
|
|
* should be supplied using x and y coordinates measured in css pixels
|
|
|
|
* that are relative to the upper-left corner of the window.
|
|
|
|
*
|
|
|
|
* aScreenX and aScreenY should be the screen coordinates of the mouse click
|
|
|
|
* for the drag.
|
|
|
|
*
|
|
|
|
* On return, aScreenDragRect will contain the screen coordinates of the
|
|
|
|
* area being dragged. This is used by the platform-specific part of the
|
|
|
|
* drag service to determine the drag feedback.
|
|
|
|
*
|
|
|
|
* If there is no drag image, the returned surface will be null, but
|
|
|
|
* aScreenDragRect will still be set to the drag area.
|
2008-01-09 01:03:53 +03:00
|
|
|
*
|
|
|
|
* aPresContext will be set to the nsPresContext used determined from
|
|
|
|
* whichever of mImage or aDOMNode is used.
|
2007-03-20 15:14:52 +03:00
|
|
|
*/
|
|
|
|
nsresult DrawDrag(nsIDOMNode* aDOMNode,
|
|
|
|
nsIScriptableRegion* aRegion,
|
|
|
|
PRInt32 aScreenX, PRInt32 aScreenY,
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntRect* aScreenDragRect,
|
2008-01-09 01:03:53 +03:00
|
|
|
gfxASurface** aSurface,
|
|
|
|
nsPresContext **aPresContext);
|
2007-03-20 15:14:52 +03:00
|
|
|
|
|
|
|
/**
|
2008-09-10 20:57:58 +04:00
|
|
|
* Draw a drag image for an image node specified by aImageLoader or aCanvas.
|
|
|
|
* This is called by DrawDrag.
|
2007-03-20 15:14:52 +03:00
|
|
|
*/
|
|
|
|
nsresult DrawDragForImage(nsPresContext* aPresContext,
|
|
|
|
nsIImageLoadingContent* aImageLoader,
|
2010-05-18 08:04:22 +04:00
|
|
|
nsICanvasElementExternal* aCanvas,
|
2007-03-20 15:14:52 +03:00
|
|
|
PRInt32 aScreenX, PRInt32 aScreenY,
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntRect* aScreenDragRect,
|
2007-03-20 15:14:52 +03:00
|
|
|
gfxASurface** aSurface);
|
|
|
|
|
2008-01-09 01:03:53 +03:00
|
|
|
/**
|
|
|
|
* Convert aScreenX and aScreenY from CSS pixels into unscaled device pixels.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ConvertToUnscaledDevPixels(nsPresContext* aPresContext,
|
|
|
|
PRInt32* aScreenX, PRInt32* aScreenY);
|
|
|
|
|
2011-04-26 05:37:20 +04:00
|
|
|
/**
|
|
|
|
* If the drag image is a popup, open the popup when the drag begins.
|
|
|
|
*/
|
|
|
|
void OpenDragPopup();
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mCanDrop;
|
|
|
|
bool mOnlyChromeDrop;
|
|
|
|
bool mDoingDrag;
|
2007-03-20 15:14:52 +03:00
|
|
|
// true if mImage should be used to set a drag image
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mHasImage;
|
2009-02-17 18:51:12 +03:00
|
|
|
// true if the user cancelled the drag operation
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mUserCancelled;
|
2007-03-20 15:14:52 +03:00
|
|
|
|
2005-03-15 01:49:00 +03:00
|
|
|
PRUint32 mDragAction;
|
|
|
|
nsSize mTargetSize;
|
2001-05-20 09:58:25 +04:00
|
|
|
nsCOMPtr<nsIDOMNode> mSourceNode;
|
2000-08-01 00:51:42 +04:00
|
|
|
nsCOMPtr<nsIDOMDocument> mSourceDocument; // the document at the drag source. will be null
|
|
|
|
// if it came from outside the app.
|
2008-08-27 16:07:27 +04:00
|
|
|
nsCOMPtr<nsIDOMDataTransfer> mDataTransfer;
|
2007-03-20 15:14:52 +03:00
|
|
|
|
|
|
|
// used to determine the image to appear on the cursor while dragging
|
|
|
|
nsCOMPtr<nsIDOMNode> mImage;
|
|
|
|
// offset of cursor within the image
|
|
|
|
PRInt32 mImageX;
|
|
|
|
PRInt32 mImageY;
|
|
|
|
|
|
|
|
// set if a selection is being dragged
|
|
|
|
nsCOMPtr<nsISelection> mSelection;
|
|
|
|
|
2011-04-26 05:37:20 +04:00
|
|
|
// set if the image in mImage is a popup. If this case, the popup will be opened
|
|
|
|
// and moved instead of using a drag image.
|
|
|
|
nsCOMPtr<nsIContent> mDragPopup;
|
|
|
|
|
2010-05-13 16:19:50 +04:00
|
|
|
// the screen position where drag gesture occurred, used for positioning the
|
2007-03-20 15:14:52 +03:00
|
|
|
// drag image when no image is specified. If a value is -1, no event was
|
|
|
|
// supplied so the screen position is not known
|
|
|
|
PRInt32 mScreenX;
|
|
|
|
PRInt32 mScreenY;
|
2008-03-19 03:06:22 +03:00
|
|
|
|
2009-04-13 17:00:29 +04:00
|
|
|
// the screen position where the drag ended
|
2009-04-16 19:58:23 +04:00
|
|
|
nsIntPoint mEndDragPoint;
|
2009-04-13 17:00:29 +04:00
|
|
|
|
2008-03-19 03:06:22 +03:00
|
|
|
PRUint32 mSuppressLevel;
|
2010-04-06 16:59:24 +04:00
|
|
|
|
2011-08-26 11:43:56 +04:00
|
|
|
// The input source of the drag event. Possible values are from nsIDOMMouseEvent.
|
2010-04-06 16:59:24 +04:00
|
|
|
PRUint16 mInputSource;
|
1999-04-17 01:03:22 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsBaseDragService_h__
|