• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

xap_UnixClipboard.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 
00003 /* AbiSource Application Framework
00004  * Copyright (C) 1998 AbiSource, Inc.
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00019  * 02111-1307, USA.
00020  */
00021 
00022 #ifndef XAP_UNIXCLIPBOARD_H
00023 #define XAP_UNIXCLIPBOARD_H
00024 
00025 #include <glib.h>
00026 #include <gdk/gdk.h>
00027 #include <gtk/gtk.h>
00028 
00029 #include "ut_types.h"
00030 #include "ut_vector.h"
00031 #include "ut_bytebuf.h"
00032 #include "xap_FakeClipboard.h"
00033 #include "xap_UnixApp.h"
00034 #include "xap_EditMethods.h"
00035 #include "ev_EditMethod.h"
00036 
00038 
00039 class XAP_UnixClipboard
00040 {
00041 public:
00042     typedef enum _T_AllowGet { TAG_ClipboardOnly, TAG_PrimaryOnly } T_AllowGet;
00043 
00044     XAP_UnixClipboard(XAP_UnixApp * pUnixApp);
00045     virtual ~XAP_UnixClipboard();
00046 
00047     void                initialize();
00048     bool                assertSelection();
00049 
00050     bool                addData(T_AllowGet tTo, const char* format, const void* pData,
00051                                 UT_sint32 iNumBytes);
00052 
00053     void                clearData(bool bClipboard, bool bPrimary);
00054     void            finishedAddingData(void);
00055     bool                getData(T_AllowGet tFrom, const char** formatList,
00056                                 void ** ppData, UT_uint32 * pLen,
00057                                 const char **pszFormatFound);
00058 
00059     bool                getTextData(T_AllowGet tFrom, void ** ppData,
00060                                     UT_uint32 * pLen);
00061 
00062     bool canPaste(T_AllowGet tFrom);
00063 
00064     GtkTargetEntry * getTargets () const { return m_Targets ; }
00065     UT_uint32 getNumTargets () const { return m_nTargets; }
00066 
00067 protected:
00068 
00069     void                AddFmt(const char * fmt);
00070     void                deleteFmt(const char * fmt);
00071 
00072  private:
00073 
00074     GtkClipboard * gtkClipboardForTarget(XAP_UnixClipboard::_T_AllowGet get);
00075 
00076     bool                _getDataFromServer(T_AllowGet tFrom, const char** formatList,
00077                                void ** ppData, UT_uint32 * pLen,
00078                                const char **pszFormatFound);
00079     bool                _getDataFromFakeClipboard(T_AllowGet tFrom, const char** formatList,
00080                                   void ** ppData, UT_uint32 * pLen,
00081                                   const char **pszFormatFound);
00082 
00083     static inline void s_primary_get_func(GtkClipboard *clipboard,
00084                        GtkSelectionData *selection_data,
00085                        guint info,
00086                        gpointer ptr)
00087       {
00088         XAP_UnixClipboard * pThis = static_cast<XAP_UnixClipboard*>(ptr);
00089         pThis->primary_get_func(clipboard, selection_data, info);
00090       }
00091 
00092     static inline void s_primary_clear_func (GtkClipboard *clipboard,
00093                       gpointer ptr)
00094       {
00095         XAP_UnixClipboard * pThis = static_cast<XAP_UnixClipboard*>(ptr);
00096         pThis->primary_clear_func(clipboard);
00097       }
00098 
00099     void primary_get_func(GtkClipboard *clipboard,
00100                   GtkSelectionData *selection_data,
00101                   guint info);
00102 
00103     void primary_clear_func (GtkClipboard *clipboard);
00104 
00105     static inline void s_clipboard_get_func(GtkClipboard *clipboard,
00106                      GtkSelectionData *selection_data,
00107                      guint info,
00108                      gpointer ptr)
00109       {
00110         XAP_UnixClipboard * pThis = static_cast<XAP_UnixClipboard*>(ptr);
00111         pThis->clipboard_get_func(clipboard, selection_data, info);
00112       }
00113 
00114     static inline void s_clipboard_clear_func (GtkClipboard *clipboard,
00115                       gpointer ptr)
00116       {
00117         XAP_UnixClipboard * pThis = static_cast<XAP_UnixClipboard*>(ptr);
00118         pThis->clipboard_clear_func(clipboard);
00119       }
00120 
00121     void clipboard_get_func(GtkClipboard *clipboard,
00122                 GtkSelectionData *selection_data,
00123                 guint info);
00124 
00125     void clipboard_clear_func (GtkClipboard *clipboard);
00126 
00127     void common_get_func(GtkClipboard *clipboard,
00128                  GtkSelectionData *selection_data,
00129                  guint info, T_AllowGet which);
00130 
00131     UT_GenericVector<const char*>  m_vecFormat_AP_Name;
00132     UT_GenericVector<GdkAtom>  m_vecFormat_GdkAtom;
00133 
00134     UT_ByteBuf m_databuf; // for gets only
00135 
00136     XAP_UnixApp *       m_pUnixApp;
00137     XAP_FakeClipboard   m_fakeClipboard;        // internal clipboard to short-circut the XServer.
00138 
00139     XAP_FakeClipboard       m_fakePrimaryClipboard;
00140     GtkTargetEntry * m_Targets ;
00141     UT_uint32 m_nTargets;
00142 
00143     GtkClipboard * m_clip;
00144     GtkClipboard * m_primary;
00145 };
00146 
00147 #endif /* XAP_UNIXCLIPBOARD_H */

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1