2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#ifndef nsBaseDragService_h__
|
|
|
|
#define nsBaseDragService_h__
|
|
|
|
|
|
|
|
#include "nsIDragService.h"
|
|
|
|
#include "nsIDragSession.h"
|
|
|
|
#include "nsITransferable.h"
|
|
|
|
#include "nsISupportsArray.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
2008-08-27 05:07:27 -07:00
|
|
|
#include "nsIDOMDataTransfer.h"
|
2011-04-25 18:37:20 -07:00
|
|
|
#include "nsIContent.h"
|
2011-04-07 18:04:40 -07:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsPoint.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "gfxImageSurface.h"
|
|
|
|
|
2007-03-25 20:27:53 -07:00
|
|
|
// translucency level for drag images
|
|
|
|
#define DRAG_TRANSLUCENCY 0.65
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsIDOMNode;
|
|
|
|
class nsIFrame;
|
|
|
|
class nsPresContext;
|
|
|
|
class nsIImageLoadingContent;
|
2010-05-17 21:04:22 -07:00
|
|
|
class nsICanvasElementExternal;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* XP DragService wrapper base class
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsBaseDragService : public nsIDragService,
|
|
|
|
public nsIDragSession
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
nsBaseDragService();
|
|
|
|
virtual ~nsBaseDragService();
|
|
|
|
|
|
|
|
//nsISupports
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
//nsIDragSession and nsIDragService
|
|
|
|
NS_DECL_NSIDRAGSERVICE
|
|
|
|
NS_DECL_NSIDRAGSESSION
|
|
|
|
|
2009-04-16 08:58:23 -07:00
|
|
|
void SetDragEndPoint(nsIntPoint aEndDragPoint) { mEndDragPoint = aEndDragPoint; }
|
2009-04-13 06:00:29 -07:00
|
|
|
|
2010-04-06 05:59:24 -07:00
|
|
|
PRUint16 GetInputSource() { return mInputSource; }
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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-08 14:03:53 -08:00
|
|
|
*
|
|
|
|
* aPresContext will be set to the nsPresContext used determined from
|
|
|
|
* whichever of mImage or aDOMNode is used.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
nsresult DrawDrag(nsIDOMNode* aDOMNode,
|
|
|
|
nsIScriptableRegion* aRegion,
|
|
|
|
PRInt32 aScreenX, PRInt32 aScreenY,
|
2009-01-14 19:27:09 -08:00
|
|
|
nsIntRect* aScreenDragRect,
|
2008-01-08 14:03:53 -08:00
|
|
|
gfxASurface** aSurface,
|
|
|
|
nsPresContext **aPresContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
2008-09-10 09:57:58 -07:00
|
|
|
* Draw a drag image for an image node specified by aImageLoader or aCanvas.
|
|
|
|
* This is called by DrawDrag.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
nsresult DrawDragForImage(nsPresContext* aPresContext,
|
|
|
|
nsIImageLoadingContent* aImageLoader,
|
2010-05-17 21:04:22 -07:00
|
|
|
nsICanvasElementExternal* aCanvas,
|
2007-03-22 10:30:00 -07:00
|
|
|
PRInt32 aScreenX, PRInt32 aScreenY,
|
2009-01-14 19:27:09 -08:00
|
|
|
nsIntRect* aScreenDragRect,
|
2007-03-22 10:30:00 -07:00
|
|
|
gfxASurface** aSurface);
|
|
|
|
|
2008-01-08 14:03:53 -08:00
|
|
|
/**
|
|
|
|
* Convert aScreenX and aScreenY from CSS pixels into unscaled device pixels.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ConvertToUnscaledDevPixels(nsPresContext* aPresContext,
|
|
|
|
PRInt32* aScreenX, PRInt32* aScreenY);
|
|
|
|
|
2011-04-25 18:37:20 -07:00
|
|
|
/**
|
|
|
|
* If the drag image is a popup, open the popup when the drag begins.
|
|
|
|
*/
|
|
|
|
void OpenDragPopup();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mCanDrop;
|
|
|
|
bool mOnlyChromeDrop;
|
|
|
|
bool mDoingDrag;
|
2007-03-22 10:30:00 -07:00
|
|
|
// true if mImage should be used to set a drag image
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mHasImage;
|
2009-02-17 07:51:12 -08:00
|
|
|
// true if the user cancelled the drag operation
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mUserCancelled;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
PRUint32 mDragAction;
|
|
|
|
nsSize mTargetSize;
|
|
|
|
nsCOMPtr<nsIDOMNode> mSourceNode;
|
|
|
|
nsCOMPtr<nsIDOMDocument> mSourceDocument; // the document at the drag source. will be null
|
|
|
|
// if it came from outside the app.
|
2008-08-27 05:07:27 -07:00
|
|
|
nsCOMPtr<nsIDOMDataTransfer> mDataTransfer;
|
2007-03-22 10:30:00 -07: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-25 18:37:20 -07: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 05:19:50 -07:00
|
|
|
// the screen position where drag gesture occurred, used for positioning the
|
2007-03-22 10:30:00 -07: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-18 17:06:22 -07:00
|
|
|
|
2009-04-13 06:00:29 -07:00
|
|
|
// the screen position where the drag ended
|
2009-04-16 08:58:23 -07:00
|
|
|
nsIntPoint mEndDragPoint;
|
2009-04-13 06:00:29 -07:00
|
|
|
|
2008-03-18 17:06:22 -07:00
|
|
|
PRUint32 mSuppressLevel;
|
2010-04-06 05:59:24 -07:00
|
|
|
|
2011-08-26 00:43:56 -07:00
|
|
|
// The input source of the drag event. Possible values are from nsIDOMMouseEvent.
|
2010-04-06 05:59:24 -07:00
|
|
|
PRUint16 mInputSource;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsBaseDragService_h__
|