LCOV - code coverage report
Current view: directory - widget/xpwidgets - nsBaseDragService.h (source / functions) Found Hit Coverage
Test: app.info Lines: 1 0 0.0 %
Date: 2012-06-02 Functions: 1 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      26                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #ifndef nsBaseDragService_h__
      39                 : #define nsBaseDragService_h__
      40                 : 
      41                 : #include "nsIDragService.h"
      42                 : #include "nsIDragSession.h"
      43                 : #include "nsITransferable.h"
      44                 : #include "nsISupportsArray.h"
      45                 : #include "nsIDOMDocument.h"
      46                 : #include "nsIDOMDataTransfer.h"
      47                 : #include "nsIContent.h"
      48                 : #include "nsCOMPtr.h"
      49                 : #include "nsPoint.h"
      50                 : 
      51                 : #include "gfxImageSurface.h"
      52                 : 
      53                 : // translucency level for drag images
      54                 : #define DRAG_TRANSLUCENCY 0.65
      55                 : 
      56                 : class nsIDOMNode;
      57                 : class nsIFrame;
      58                 : class nsPresContext;
      59                 : class nsIImageLoadingContent;
      60                 : class nsICanvasElementExternal;
      61                 : 
      62                 : /**
      63                 :  * XP DragService wrapper base class
      64                 :  */
      65                 : 
      66                 : class nsBaseDragService : public nsIDragService,
      67                 :                           public nsIDragSession
      68                 : {
      69                 : 
      70                 : public:
      71                 :   nsBaseDragService();
      72                 :   virtual ~nsBaseDragService();
      73                 : 
      74                 :   //nsISupports
      75                 :   NS_DECL_ISUPPORTS
      76                 : 
      77                 :   //nsIDragSession and nsIDragService
      78                 :   NS_DECL_NSIDRAGSERVICE
      79                 :   NS_DECL_NSIDRAGSESSION
      80                 : 
      81               0 :   void SetDragEndPoint(nsIntPoint aEndDragPoint) { mEndDragPoint = aEndDragPoint; }
      82                 : 
      83                 :   PRUint16 GetInputSource() { return mInputSource; }
      84                 : 
      85                 : protected:
      86                 : 
      87                 :   /**
      88                 :    * Draw the drag image, if any, to a surface and return it. The drag image
      89                 :    * is constructed from mImage if specified, or aDOMNode if mImage is null.
      90                 :    *
      91                 :    * aRegion may be used to draw only a subset of the element. This region
      92                 :    * should be supplied using x and y coordinates measured in css pixels
      93                 :    * that are relative to the upper-left corner of the window.
      94                 :    *
      95                 :    * aScreenX and aScreenY should be the screen coordinates of the mouse click
      96                 :    * for the drag.
      97                 :    *
      98                 :    * On return, aScreenDragRect will contain the screen coordinates of the
      99                 :    * area being dragged. This is used by the platform-specific part of the
     100                 :    * drag service to determine the drag feedback.
     101                 :    *
     102                 :    * If there is no drag image, the returned surface will be null, but
     103                 :    * aScreenDragRect will still be set to the drag area.
     104                 :    *
     105                 :    * aPresContext will be set to the nsPresContext used determined from
     106                 :    * whichever of mImage or aDOMNode is used.
     107                 :    */
     108                 :   nsresult DrawDrag(nsIDOMNode* aDOMNode,
     109                 :                     nsIScriptableRegion* aRegion,
     110                 :                     PRInt32 aScreenX, PRInt32 aScreenY,
     111                 :                     nsIntRect* aScreenDragRect,
     112                 :                     gfxASurface** aSurface,
     113                 :                     nsPresContext **aPresContext);
     114                 : 
     115                 :   /**
     116                 :    * Draw a drag image for an image node specified by aImageLoader or aCanvas.
     117                 :    * This is called by DrawDrag.
     118                 :    */
     119                 :   nsresult DrawDragForImage(nsPresContext* aPresContext,
     120                 :                             nsIImageLoadingContent* aImageLoader,
     121                 :                             nsICanvasElementExternal* aCanvas,
     122                 :                             PRInt32 aScreenX, PRInt32 aScreenY,
     123                 :                             nsIntRect* aScreenDragRect,
     124                 :                             gfxASurface** aSurface);
     125                 : 
     126                 :   /**
     127                 :    * Convert aScreenX and aScreenY from CSS pixels into unscaled device pixels.
     128                 :    */
     129                 :   void
     130                 :   ConvertToUnscaledDevPixels(nsPresContext* aPresContext,
     131                 :                              PRInt32* aScreenX, PRInt32* aScreenY);
     132                 : 
     133                 :   /**
     134                 :    * If the drag image is a popup, open the popup when the drag begins.
     135                 :    */
     136                 :   void OpenDragPopup();
     137                 : 
     138                 :   bool mCanDrop;
     139                 :   bool mOnlyChromeDrop;
     140                 :   bool mDoingDrag;
     141                 :   // true if mImage should be used to set a drag image
     142                 :   bool mHasImage;
     143                 :   // true if the user cancelled the drag operation
     144                 :   bool mUserCancelled;
     145                 : 
     146                 :   PRUint32 mDragAction;
     147                 :   nsSize mTargetSize;
     148                 :   nsCOMPtr<nsIDOMNode> mSourceNode;
     149                 :   nsCOMPtr<nsIDOMDocument> mSourceDocument;       // the document at the drag source. will be null
     150                 :                                                   //  if it came from outside the app.
     151                 :   nsCOMPtr<nsIDOMDataTransfer> mDataTransfer;
     152                 : 
     153                 :   // used to determine the image to appear on the cursor while dragging
     154                 :   nsCOMPtr<nsIDOMNode> mImage;
     155                 :   // offset of cursor within the image 
     156                 :   PRInt32 mImageX;
     157                 :   PRInt32 mImageY;
     158                 : 
     159                 :   // set if a selection is being dragged
     160                 :   nsCOMPtr<nsISelection> mSelection;
     161                 : 
     162                 :   // set if the image in mImage is a popup. If this case, the popup will be opened
     163                 :   // and moved instead of using a drag image.
     164                 :   nsCOMPtr<nsIContent> mDragPopup;
     165                 : 
     166                 :   // the screen position where drag gesture occurred, used for positioning the
     167                 :   // drag image when no image is specified. If a value is -1, no event was
     168                 :   // supplied so the screen position is not known
     169                 :   PRInt32 mScreenX;
     170                 :   PRInt32 mScreenY;
     171                 : 
     172                 :   // the screen position where the drag ended
     173                 :   nsIntPoint mEndDragPoint;
     174                 : 
     175                 :   PRUint32 mSuppressLevel;
     176                 : 
     177                 :   // The input source of the drag event. Possible values are from nsIDOMMouseEvent.
     178                 :   PRUint16 mInputSource;
     179                 : };
     180                 : 
     181                 : #endif // nsBaseDragService_h__

Generated by: LCOV version 1.7