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

gr_Abi_RenderingContext.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 2004 Luca Padovani <lpadovan@cs.unibo.it>
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301 USA.
00018  */
00019 
00020 #ifndef __gr_Abi_RenderingContext_h__
00021 #define __gr_Abi_RenderingContext_h__
00022 
00023 #include <MathView/scaled.hh>
00024 #include <MathView/BoundingBox.hh>
00025 #include <MathView/RGBColor.hh>
00026 #include <MathView/RenderingContext.hh>
00027 
00028 #include "ut_color.h"
00029 #include "ut_units.h" // for UT_LAYOUT_RESOLUTION
00030 
00031 class GR_Abi_RenderingContext : public RenderingContext
00032 {
00033 public:
00034   GR_Abi_RenderingContext(class GR_Graphics*);
00035   virtual ~GR_Abi_RenderingContext();
00036 
00037   class GR_Graphics* getGraphics(void) const { return m_pGraphics; }
00038 
00039   void setColor(const RGBColor& c) { setColor(toAbiColor(c)); }
00040   void setColor(const UT_RGBColor&);
00041   // the return value is passed as an argument so that
00042   // we can use overloading
00043   void getColor(RGBColor&) const;
00044   void getColor(UT_RGBColor&) const;
00045 
00046   void fill(const scaled&, const scaled&, const BoundingBox&) const;
00047   void fill(const UT_RGBColor&, const scaled&, const scaled&, const BoundingBox&) const;
00048   void fill(const RGBColor& c, const scaled& x, const scaled& y, const BoundingBox& box) const
00049   { fill(toAbiColor(c), x, y, box); }
00050 
00051   void drawGlyph(const scaled&, const scaled&, class GR_Font*, UT_uint32) const;
00052   void drawChar(const scaled&, const scaled&, class GR_Font*, UT_UCS4Char) const;
00053   void drawBox(const scaled&, const scaled&, const BoundingBox&) const;
00054 
00055   // AbiWord layout units:
00056   // 1 inch = UT_LAYOUT_RESOLUTION dots
00057   // 1 inch = 72.27 points
00058   // 72.27 points = UT_LAYOUT_RESOLUTION dots
00059   // 1 point = UT_LAYOUT_RESOLUTION / 72.27 dots
00060   // 1 dot = 72.27 / UT_LAYOUT_RESOLUTION points
00061   UT_sint32 toAbiLayoutUnits(const scaled& s) const;
00062   scaled fromAbiLayoutUnits(UT_sint32 s) const;
00063 
00064   UT_sint32 toAbiX(const scaled& x) const;
00065   UT_sint32 toAbiY(const scaled& y) const;
00066 
00067 
00068   scaled fromAbiX(UT_sint32 x) const;
00069   scaled fromAbiY(UT_sint32 y) const;
00070 
00071 
00072   static RGBColor fromAbiColor(const UT_RGBColor& c)
00073   { return RGBColor(c.m_red, c.m_grn, c.m_blu, c.m_bIsTransparent); }
00074   static UT_RGBColor toAbiColor(const RGBColor& c)
00075   { return UT_RGBColor(c.red, c.green, c.blue, c.transparent()); }
00076 
00077 private:
00078   class GR_Graphics* m_pGraphics;
00079 };
00080 
00081 #endif // __gr_Abi_RenderingContext_h__

Generated on Wed Mar 5 2014 for AbiWord by  doxygen 1.7.1