• 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; indent-tabs-mode: t -*- */
00002 /* AbiWord
00003  * Copyright (C) 2004-2006 Tomas Frydrych <dr.tomas@yahoo.co.uk>
00004  * Copyright (C) 2009-2016 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., 51 Franklin Street, Fifth Floor, Boston, MA
00019  * 02110-1301 USA.
00020  */
00021 
00022 
00023 #ifndef __GR_UNIXCAIROGRAPHICS_H__
00024 #define __GR_UNIXCAIROGRAPHICS_H__
00025 
00026 #include "ut_compiler.h"
00027 
00028 ABI_W_NO_CONST_QUAL
00029 #include <gdk/gdk.h>
00030 ABI_W_POP
00031 #include "gr_CairoGraphics.h"
00032 
00033 class ABI_EXPORT GR_UnixCairoAllocInfo : public GR_CairoAllocInfo
00034 {
00035 public:
00036     GR_UnixCairoAllocInfo(GdkWindow * win, bool double_buffered=true)
00037         : GR_CairoAllocInfo(false, false, double_buffered),
00038         m_win(win)
00039         {}
00040     GR_UnixCairoAllocInfo(GtkWidget *widget)
00041         : GR_CairoAllocInfo(false, false, true),
00042           m_win(gtk_widget_get_window(GTK_WIDGET(widget)))
00043     {}
00044 
00045     GR_UnixCairoAllocInfo(bool bPreview)
00046         : GR_CairoAllocInfo(bPreview, true, false),
00047           m_win(NULL){}
00048 
00049     cairo_t *createCairo() {return NULL;} // we need this since otherwise the class would be abstract
00050     GdkWindow     * m_win;
00051 };
00052 
00053 class ABI_EXPORT GR_UnixCairoGraphicsBase
00054     : public GR_CairoGraphics
00055 {
00056  public:
00057     ~GR_UnixCairoGraphicsBase();
00058 
00059     virtual GR_Image*   createNewImage(const char* pszName,
00060                                        const UT_ConstByteBufPtr& pBB,
00061                                        const std::string& mimetype,
00062                                        UT_sint32 iDisplayWidth,
00063                                        UT_sint32 iDisplayHeight,
00064                                        GR_Image::GRType =GR_Image::GRT_Raster);
00065  protected:
00066     GR_UnixCairoGraphicsBase();
00067     GR_UnixCairoGraphicsBase(cairo_t *cr, UT_uint32 iDeviceResolution);
00068 
00069 };
00070 
00071 
00072 class ABI_EXPORT GR_UnixCairoGraphics
00073     : public GR_UnixCairoGraphicsBase
00074 {
00075 public:
00076     ~GR_UnixCairoGraphics();
00077     static UT_uint32       s_getClassId() {return GRID_UNIX_PANGO;}
00078     virtual UT_uint32      getClassId() {return s_getClassId();}
00079 
00080     static const char *    graphicsDescriptor(){return "Unix Cairo Pango";}
00081     static GR_Graphics *   graphicsAllocator(GR_AllocInfo&);
00082     GdkWindow *  getWindow () {return m_pWin;}
00083 
00084     virtual GR_Font * getGUIFont(void);
00085 
00086     virtual void        setCursor(GR_Graphics::Cursor c);
00087     virtual void        scroll(UT_sint32, UT_sint32);
00088     virtual void        scroll(UT_sint32 x_dest, UT_sint32 y_dest,
00089                            UT_sint32 x_src, UT_sint32 y_src,
00090                            UT_sint32 width, UT_sint32 height);
00091     virtual GR_Image *  genImageFromRectangle(const UT_Rect & r);
00092 
00093     void                init3dColors(GtkWidget* w);
00094     void                initWidget(GtkWidget *widget);
00095     virtual bool        queryProperties(GR_Graphics::Properties gp) const;
00096 
00098     virtual bool        getColor3D(GR_Color3D name, UT_RGBColor &color);
00099 
00100     virtual void        fillRect(GR_Color3D c,
00101                                  UT_sint32 x, UT_sint32 y,
00102                                  UT_sint32 w, UT_sint32 h);
00103     virtual void      flush(void);
00104 
00105 protected:
00106     virtual void        _resetClip(void);
00107     static void     widget_size_allocate (GtkWidget        *widget,
00108                                       GtkAllocation    *allocation,
00109                                       GR_UnixCairoGraphics *me);
00110     static void     widget_destroy (GtkWidget        *widget,
00111                                       GR_UnixCairoGraphics *me);
00112     GR_UnixCairoGraphics(GdkWindow * win = NULL, bool double_buffered=true);
00113     virtual GdkWindow * _getWindow(void)
00114     {  return m_pWin;}
00115 
00116     virtual void _beginPaint();
00117     virtual void _endPaint();
00118 
00119 private:
00120     GdkWindow *m_pWin;
00121     bool m_CairoCreated;
00122     bool m_Painting;
00123     gulong m_Signal, m_DestroySignal;
00124     GtkWidget *m_Widget;
00125     GtkStyleContext* m_styleBg;
00126     GtkStyleContext* m_styleHighlight;
00127 };
00128 
00129 
00130 #endif
00131 

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1