Back to index

lightning-sunbird  0.9+nobinonly
nsDragService.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* vim:expandtab:shiftwidth=4:tabstop=4:
00003  */
00004 /* ***** BEGIN LICENSE BLOCK *****
00005  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00006  *
00007  * The contents of this file are subject to the Mozilla Public License Version
00008  * 1.1 (the "License"); you may not use this file except in compliance with
00009  * the License. You may obtain a copy of the License at
00010  * http://www.mozilla.org/MPL/
00011  *
00012  * Software distributed under the License is distributed on an "AS IS" basis,
00013  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00014  * for the specific language governing rights and limitations under the
00015  * License.
00016  *
00017  * The Original Code is mozilla.org code.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Christopher Blizzard <blizzard@mozilla.org>.
00021  * Portions created by the Initial Developer are Copyright (C) 1998
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *   Christopher Blizzard <blizzard@mozilla.org>
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either the GNU General Public License Version 2 or later (the "GPL"), or
00029  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 
00041 #ifndef nsDragService_h__
00042 #define nsDragService_h__
00043 
00044 #include "nsBaseDragService.h"
00045 #include "nsIDragSessionGTK.h"
00046 #include "nsIObserver.h"
00047 #include <gtk/gtk.h>
00048 
00049 
00054 class nsDragService : public nsBaseDragService,
00055                       public nsIDragSessionGTK,
00056                       public nsIObserver
00057 {
00058 public:
00059     nsDragService();
00060     virtual ~nsDragService();
00061 
00062     NS_DECL_ISUPPORTS_INHERITED
00063 
00064     NS_DECL_NSIOBSERVER
00065 
00066     // nsIDragService
00067     NS_IMETHOD InvokeDragSession (nsIDOMNode *aDOMNode,
00068                                   nsISupportsArray * anArrayTransferables,
00069                                   nsIScriptableRegion * aRegion,
00070                                   PRUint32 aActionType);
00071     NS_IMETHOD StartDragSession();
00072     NS_IMETHOD EndDragSession();
00073 
00074     // nsIDragSession
00075     NS_IMETHOD SetCanDrop            (PRBool           aCanDrop);
00076     NS_IMETHOD GetCanDrop            (PRBool          *aCanDrop);
00077     NS_IMETHOD GetNumDropItems       (PRUint32 * aNumItems);
00078     NS_IMETHOD GetData               (nsITransferable * aTransferable,
00079                                       PRUint32 aItemIndex);
00080     NS_IMETHOD IsDataFlavorSupported (const char *aDataFlavor, PRBool *_retval);
00081 
00082     // nsIDragSessionGTK
00083 
00084     NS_IMETHOD TargetSetLastContext  (GtkWidget      *aWidget,
00085                                       GdkDragContext *aContext,
00086                                       guint           aTime);
00087     NS_IMETHOD TargetStartDragMotion (void);
00088     NS_IMETHOD TargetEndDragMotion   (GtkWidget      *aWidget,
00089                                       GdkDragContext *aContext,
00090                                       guint           aTime);
00091     NS_IMETHOD TargetDataReceived    (GtkWidget         *aWidget,
00092                                       GdkDragContext    *aContext,
00093                                       gint               aX,
00094                                       gint               aY,
00095                                       GtkSelectionData  *aSelection_data,
00096                                       guint              aInfo,
00097                                       guint32            aTime);
00098 
00099     NS_IMETHOD TargetSetTimeCallback (nsIDragSessionGTKTimeCB aCallback);
00100 
00101     // This is called when the drag started with the invisible widget
00102     // finishes.  It's called from within the drag service code but from
00103     // a callback - it needs to be public.
00104     void           SourceEndDrag(void);
00105     void           SourceDataGet(GtkWidget        *widget,
00106                                  GdkDragContext   *context,
00107                                  GtkSelectionData *selection_data,
00108                                  guint             info,
00109                                  guint32           aTime);
00110 
00111     //  END PUBLIC API
00112 
00113 private:
00114 
00115     // target side vars
00116 
00117     // the last widget that was the target of a drag
00118     GtkWidget      *mTargetWidget;
00119     GdkDragContext *mTargetDragContext;
00120     guint           mTargetTime;
00121     // is it OK to drop on us?
00122     PRBool          mCanDrop;
00123     // have we received our drag data?
00124     PRBool          mTargetDragDataReceived;
00125     // last data received and its length
00126     void           *mTargetDragData;
00127     PRUint32        mTargetDragDataLen;
00128     // is the current target drag context contain a list?
00129     PRBool         IsTargetContextList(void);
00130     // this will get the native data from the last target given a
00131     // specific flavor
00132     void           GetTargetDragData(GdkAtom aFlavor);
00133     // this will reset all of the target vars
00134     void           TargetResetData(void);
00135 
00136     // source side vars
00137 
00138     // the source of our drags
00139     GtkWidget     *mHiddenWidget;
00140     // our source data items
00141     nsCOMPtr<nsISupportsArray> mSourceDataItems;
00142     // get a list of the sources in gtk's format
00143     GtkTargetList *GetSourceList(void);
00144 
00145 };
00146 
00147 #endif // nsDragService_h__
00148