1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim:expandtab:shiftwidth=4:tabstop=4:
4 /* ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
17 * The Original Code is mozilla.org code.
19 * The Initial Developer of the Original Code is
20 * Christopher Blizzard <blizzard@mozilla.org>.
21 * Portions created by the Initial Developer are Copyright (C) 1998
22 * the Initial Developer. All Rights Reserved.
25 * Christopher Blizzard <blizzard@mozilla.org>
27 * Alternatively, the contents of this file may be used under the terms of
28 * either the GNU General Public License Version 2 or later (the "GPL"), or
29 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
41 #ifndef nsDragService_h__
42 #define nsDragService_h__
44 #include "nsBaseDragService.h"
45 #include "nsIDragSessionGTK.h"
46 #include "nsIObserver.h"
51 * Native GTK DragService wrapper
54 class nsDragService
: public nsBaseDragService
,
55 public nsIDragSessionGTK
,
60 virtual ~nsDragService();
62 NS_DECL_ISUPPORTS_INHERITED
67 NS_IMETHOD
InvokeDragSession (nsIDOMNode
*aDOMNode
,
68 nsISupportsArray
* anArrayTransferables
,
69 nsIScriptableRegion
* aRegion
,
70 PRUint32 aActionType
);
71 NS_IMETHOD
StartDragSession();
72 NS_IMETHOD
EndDragSession(PRBool aDoneDrag
);
75 NS_IMETHOD
SetCanDrop (PRBool aCanDrop
);
76 NS_IMETHOD
GetCanDrop (PRBool
*aCanDrop
);
77 NS_IMETHOD
GetNumDropItems (PRUint32
* aNumItems
);
78 NS_IMETHOD
GetData (nsITransferable
* aTransferable
,
80 NS_IMETHOD
IsDataFlavorSupported (const char *aDataFlavor
, PRBool
*_retval
);
84 NS_IMETHOD
TargetSetLastContext (GtkWidget
*aWidget
,
85 GdkDragContext
*aContext
,
87 NS_IMETHOD
TargetStartDragMotion (void);
88 NS_IMETHOD
TargetEndDragMotion (GtkWidget
*aWidget
,
89 GdkDragContext
*aContext
,
91 NS_IMETHOD
TargetDataReceived (GtkWidget
*aWidget
,
92 GdkDragContext
*aContext
,
95 GtkSelectionData
*aSelection_data
,
99 NS_IMETHOD
TargetSetTimeCallback (nsIDragSessionGTKTimeCB aCallback
);
103 // These methods are public only so that they can be called from functions
104 // with C calling conventions. They are called for drags started with the
106 void SourceEndDragSession(GdkDragContext
*aContext
,
108 void SourceDataGet(GtkWidget
*widget
,
109 GdkDragContext
*context
,
110 GtkSelectionData
*selection_data
,
118 // the last widget that was the target of a drag
119 GtkWidget
*mTargetWidget
;
120 GdkDragContext
*mTargetDragContext
;
122 // is it OK to drop on us?
124 // have we received our drag data?
125 PRBool mTargetDragDataReceived
;
126 // last data received and its length
127 void *mTargetDragData
;
128 PRUint32 mTargetDragDataLen
;
129 // is the current target drag context contain a list?
130 PRBool
IsTargetContextList(void);
131 // this will get the native data from the last target given a
133 void GetTargetDragData(GdkAtom aFlavor
);
134 // this will reset all of the target vars
135 void TargetResetData(void);
139 // the source of our drags
140 GtkWidget
*mHiddenWidget
;
141 // the widget receiving mouse events
142 GtkWidget
*mGrabWidget
;
143 // our source data items
144 nsCOMPtr
<nsISupportsArray
> mSourceDataItems
;
145 // get a list of the sources in gtk's format
146 GtkTargetList
*GetSourceList(void);
148 // attempts to create a semi-transparent drag image. Returns TRUE if
149 // successful, FALSE if not
150 PRBool
SetAlphaPixmap(gfxASurface
*aPixbuf
,
151 GdkDragContext
*aContext
,
154 const nsIntRect
&dragRect
);
158 #endif // nsDragService_h__