• 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., 51 Franklin Street, Fifth Floor, Boston, MA
00019  * 02110-1301 USA.
00020  */
00021 
00022 #ifndef XAP_UNIXCLIPBOARD_H
00023 #define XAP_UNIXCLIPBOARD_H
00024 
00025 #include "ut_compiler.h"
00026 
00027 #include <glib.h>
00028 ABI_W_NO_CONST_QUAL
00029 #include <gdk/gdk.h>
00030 #include <gtk/gtk.h>
00031 ABI_W_POP
00032 
00033 #include "ut_types.h"
00034 #include "ut_vector.h"
00035 #include "ut_bytebuf.h"
00036 #include "xap_FakeClipboard.h"
00037 #include "xap_UnixApp.h"
00038 #include "xap_EditMethods.h"
00039 #include "ev_EditMethod.h"
00040 
00042 
00043 class XAP_UnixClipboard
00044 {
00045 public:
00046     typedef enum _T_AllowGet { TAG_ClipboardOnly, TAG_PrimaryOnly } T_AllowGet;
00047 
00048     XAP_UnixClipboard(XAP_UnixApp * pUnixApp);
00049     virtual ~XAP_UnixClipboard();
00050 
00051     void                initialize();
00052     bool                assertSelection();
00053 
00054     bool                addData(T_AllowGet tTo, const char* format, const void* pData,
00055                                 UT_sint32 iNumBytes);
00056 
00057     void                clearData(bool bClipboard, bool bPrimary);
00058     void            finishedAddingData(void);
00059     bool                getData(T_AllowGet tFrom, const char** formatList,
00060                                 void ** ppData, UT_uint32 * pLen,
00061                                 const char **pszFormatFound);
00062 
00063     bool                getTextData(T_AllowGet tFrom, void ** ppData,
00064                                     UT_uint32 * pLen);
00065 
00066     bool canPaste(T_AllowGet tFrom);
00067 
00068     GtkTargetEntry * getTargets () const { return m_Targets ; }
00069     UT_uint32 getNumTargets () const { return m_nTargets; }
00070 
00071 protected:
00072 
00073     void                AddFmt(const char * fmt);
00074     void                deleteFmt(const char * fmt);
00075 
00076  private:
00077 
00078     GtkClipboard * gtkClipboardForTarget(XAP_UnixClipboard::_T_AllowGet get);
00079 
00080     bool                _getDataFromServer(T_AllowGet tFrom, const char** formatList,
00081                                void ** ppData, UT_uint32 * pLen,
00082                                const char **pszFormatFound);
00083     bool                _getDataFromFakeClipboard(T_AllowGet tFrom, const char** formatList,
00084                                   void ** ppData, UT_uint32 * pLen,
00085                                   const char **pszFormatFound);
00086 
00087     static inline void s_primary_get_func(GtkClipboard *clipboard,
00088                        GtkSelectionData *selection_data,
00089                        guint info,
00090                        gpointer ptr)
00091       {
00092         XAP_UnixClipboard * pThis = static_cast<XAP_UnixClipboard*>(ptr);
00093         pThis->primary_get_func(clipboard, selection_data, info);
00094       }
00095 
00096     static inline void s_primary_clear_func (GtkClipboard *clipboard,
00097                       gpointer ptr)
00098       {
00099         XAP_UnixClipboard * pThis = static_cast<XAP_UnixClipboard*>(ptr);
00100         pThis->primary_clear_func(clipboard);
00101       }
00102 
00103     void primary_get_func(GtkClipboard *clipboard,
00104                   GtkSelectionData *selection_data,
00105                   guint info);
00106 
00107     void primary_clear_func (GtkClipboard *clipboard);
00108 
00109     static inline void s_clipboard_get_func(GtkClipboard *clipboard,
00110                      GtkSelectionData *selection_data,
00111                      guint info,
00112                      gpointer ptr)
00113       {
00114         XAP_UnixClipboard * pThis = static_cast<XAP_UnixClipboard*>(ptr);
00115         pThis->clipboard_get_func(clipboard, selection_data, info);
00116       }
00117 
00118     static inline void s_clipboard_clear_func (GtkClipboard *clipboard,
00119                       gpointer ptr)
00120       {
00121         XAP_UnixClipboard * pThis = static_cast<XAP_UnixClipboard*>(ptr);
00122         pThis->clipboard_clear_func(clipboard);
00123       }
00124 
00125     void clipboard_get_func(GtkClipboard *clipboard,
00126                 GtkSelectionData *selection_data,
00127                 guint info);
00128 
00129     void clipboard_clear_func (GtkClipboard *clipboard);
00130 
00131     void common_get_func(GtkClipboard *clipboard,
00132                  GtkSelectionData *selection_data,
00133                  guint info, T_AllowGet which);
00134 
00135     UT_GenericVector<const char*>  m_vecFormat_AP_Name;
00136     UT_GenericVector<GdkAtom>  m_vecFormat_GdkAtom;
00137 
00138     UT_ByteBuf m_databuf; // for gets only
00139 
00140     XAP_UnixApp *       m_pUnixApp;
00141     XAP_FakeClipboard   m_fakeClipboard;        // internal clipboard to short-circut the XServer.
00142 
00143     XAP_FakeClipboard       m_fakePrimaryClipboard;
00144     GtkTargetEntry * m_Targets ;
00145     UT_uint32 m_nTargets;
00146 
00147     GtkClipboard * m_clip;
00148     GtkClipboard * m_primary;
00149 };
00150 
00151 #endif /* XAP_UNIXCLIPBOARD_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1