Back to index

lightning-sunbird  0.9+nobinonly
nsClipboard.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is mozilla.org code.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 1999-2000
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Stuart Parmenter <pavlov@netscape.com>
00025  *   Mike Pinkerton   <pinkerton@netscape.com>
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 nsClipboard_h__
00042 #define nsClipboard_h__
00043 
00044 #include <gtk/gtk.h>
00045 #include <gtk/gtkinvisible.h>
00046 
00047 #include "nsIClipboard.h"
00048 #include "nsITransferable.h"
00049 #include "nsIClipboardOwner.h"
00050 #include <nsCOMPtr.h>
00051 
00052 class nsITransferable;
00053 class nsIClipboardOwner;
00054 class nsIWidget;
00055 
00060 class nsClipboard : public nsIClipboard
00061 {
00062 
00063 public:
00064   nsClipboard();
00065   virtual ~nsClipboard();
00066 
00067   //nsISupports
00068   NS_DECL_ISUPPORTS
00069 
00070   // nsIClipboard
00071   NS_DECL_NSICLIPBOARD
00072 
00073 protected:
00074   void Init(void);
00075 
00076   NS_IMETHOD SetNativeClipboardData(PRInt32 aWhichClipboard);
00077   NS_IMETHOD GetNativeClipboardData(nsITransferable * aTransferable, 
00078                                     PRInt32 aWhichClipboard );
00079 
00080   inline nsITransferable *GetTransferable(PRInt32 aWhichClipboard);
00081 
00082 
00083   PRBool  mIgnoreEmptyNotification;
00084 
00085 private:
00086   inline GdkAtom GetSelectionAtom(PRInt32 aWhichClipboard);
00087   inline void AddTarget(GdkAtom aAtom, GdkAtom aSelectionAtom);
00088   void RegisterFormat(const char *aMimeStr, GdkAtom aSelectionAtom);
00089   PRBool DoRealConvert(GdkAtom type, GdkAtom aSelectionAtom);
00090   PRBool DoConvert(const char *aMimeStr, GdkAtom aSelectionAtom);
00091   PRBool GetTargets(GdkAtom aSelectionAtom);
00092 
00093   nsCOMPtr<nsIClipboardOwner> mSelectionOwner;
00094   nsCOMPtr<nsIClipboardOwner> mGlobalOwner;
00095   nsCOMPtr<nsITransferable>   mSelectionTransferable;
00096   nsCOMPtr<nsITransferable>   mGlobalTransferable;
00097 
00098   // Used for communicating pasted data
00099   // from the asynchronous X routines back to a blocking paste:
00100   GtkSelectionData mSelectionData;
00101   PRBool mBlocking;
00102 
00103   // invisible widget.  also used by dragndrop
00104   static GtkWidget *sWidget;
00105 
00106   void SelectionReceiver(GtkWidget *aWidget,
00107                          GtkSelectionData *aSD);
00108 
00118   static void SelectionGetCB(GtkWidget *aWidget, 
00119                              GtkSelectionData *aSelectionData,
00120                              guint      /*info*/,
00121                              guint      /*time*/);
00122 
00130   static void SelectionClearCB(GtkWidget *aWidget, 
00131                                GdkEventSelection *aEvent,
00132                                gpointer aData);
00133 
00141   static void SelectionRequestCB(GtkWidget *aWidget,
00142                                  GtkSelectionData *aSelectionData,
00143                                  gpointer data);
00144   
00152   static void SelectionReceivedCB(GtkWidget *aWidget,
00153                                   GtkSelectionData *aSelectionData,
00154                                   guint aTime);
00155 
00156 
00157   static void SelectionNotifyCB(GtkWidget *aWidget,
00158                                 GtkSelectionData *aSelectionData,
00159                                 gpointer aData);
00160   
00161 
00162   /* functions to do blocking when trying to get info from another client */
00163   PRBool FindSelectionNotifyEvent();
00164 
00165 
00166   void SetCutBuffer();
00167 };
00168 
00169 #endif // nsClipboard_h__