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

gr_UnixCairoGraphics.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 /* AbiWord
00003  * Copyright (C) 2004-2006 Tomas Frydrych <dr.tomas@yahoo.co.uk>
00004  * Copyright (C) 2009 Hubert Figuiere
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 
00023 #ifndef __GR_UNIXCAIROGRAPHICS_H__
00024 #define __GR_UNIXCAIROGRAPHICS_H__
00025 
00026 #include <gdk/gdk.h>
00027 #include "xap_Gtk2Compat.h"
00028 #include "gr_CairoGraphics.h"
00029 
00030 class ABI_EXPORT GR_UnixCairoAllocInfo : public GR_CairoAllocInfo
00031 {
00032 public:
00033     GR_UnixCairoAllocInfo(GdkWindow * win, bool double_buffered=false)
00034         : GR_CairoAllocInfo(false, false, double_buffered),
00035         m_win(win)
00036         {}
00037     GR_UnixCairoAllocInfo(GtkWidget *widget)
00038         : GR_CairoAllocInfo(false, false, gtk_widget_get_double_buffered(widget)),
00039           m_win(gtk_widget_get_window(GTK_WIDGET(widget)))
00040     {}
00041 
00042     GR_UnixCairoAllocInfo(bool bPreview)
00043         : GR_CairoAllocInfo(bPreview, true, false),
00044           m_win(NULL){}
00045 
00046     cairo_t *createCairo() {return NULL;} // we need this since otherwise the class would be abstract
00047     GdkWindow     * m_win;
00048 };
00049 
00050 class ABI_EXPORT GR_UnixCairoGraphicsBase
00051     : public GR_CairoGraphics
00052 {
00053  public:
00054     ~GR_UnixCairoGraphicsBase();
00055 
00056     virtual GR_Image*   createNewImage(const char* pszName,
00057                                        const UT_ByteBuf* pBB,
00058                                        const std::string& mimetype,
00059                                        UT_sint32 iDisplayWidth,
00060                                        UT_sint32 iDisplayHeight,
00061                                        GR_Image::GRType =GR_Image::GRT_Raster);
00062  protected:
00063     GR_UnixCairoGraphicsBase();
00064     GR_UnixCairoGraphicsBase(cairo_t *cr, UT_uint32 iDeviceResolution);
00065 
00066 };
00067 
00068 
00069 class ABI_EXPORT GR_UnixCairoGraphics
00070     : public GR_UnixCairoGraphicsBase
00071 {
00072 public:
00073     ~GR_UnixCairoGraphics();
00074     static UT_uint32       s_getClassId() {return GRID_UNIX_PANGO;}
00075     virtual UT_uint32      getClassId() {return s_getClassId();}
00076 
00077     static const char *    graphicsDescriptor(){return "Unix Cairo Pango";}
00078     static GR_Graphics *   graphicsAllocator(GR_AllocInfo&);
00079     GdkWindow *  getWindow () {return m_pWin;}
00080 
00081     virtual GR_Font * getGUIFont(void);
00082 
00083     virtual void        setCursor(GR_Graphics::Cursor c);
00084     virtual void        scroll(UT_sint32, UT_sint32);
00085     virtual void        scroll(UT_sint32 x_dest, UT_sint32 y_dest,
00086                            UT_sint32 x_src, UT_sint32 y_src,
00087                            UT_sint32 width, UT_sint32 height);
00088     virtual GR_Image *  genImageFromRectangle(const UT_Rect & r);
00089 
00090     void                init3dColors(GtkWidget* w);
00091 #if !GTK_CHECK_VERSION(3,0,0)
00092     void                init3dColors(GtkStyle* pStyle);
00093 #endif
00094     void                initWidget(GtkWidget *widget);
00095     virtual bool        queryProperties(GR_Graphics::Properties gp) const;
00096 
00097 protected:
00098     virtual void        _resetClip(void);
00099     static void     widget_size_allocate (GtkWidget        *widget,
00100                                       GtkAllocation    *allocation,
00101                                       GR_UnixCairoGraphics *me);
00102     static void     widget_destroy (GtkWidget        *widget,
00103                                       GR_UnixCairoGraphics *me);
00104     GR_UnixCairoGraphics(GdkWindow * win = NULL, bool double_buffered=false);
00105     virtual GdkWindow * _getWindow(void)
00106     {  return m_pWin;}
00107 
00108     virtual void _beginPaint();
00109     virtual void _endPaint();
00110 
00111 private:
00112     GdkWindow *m_pWin;
00113     bool m_double_buffered;
00114     bool m_CairoCreated;
00115     bool m_Painting;
00116     gulong m_Signal, m_DestroySignal;
00117     GtkWidget *m_Widget;
00118 };
00119 
00120 
00121 #endif
00122 

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1