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

gr_Win32USPGraphics.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 2004 Tomas Frydrych <tomasfrydrych@yahoo.co.uk>
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_WIN32_GRAPHICS_H
00021 #define GR_WIN32_GRAPHICS_H
00022 
00023 #include "ut_types.h"
00024 #include "gr_Win32Graphics.h"
00025 #include "gr_RenderInfo.h"
00026 #include "gr_Win32Uniscribe.h"
00027 
00028 // we do not want this to be a plugin for now
00029 #define GR_WIN32USP_BUILTIN
00030 
00031 #ifndef GR_WIN32USP_BUILTIN
00032 #define PLUGIN_NAME "Uniscribe graphics class for Win32"
00033 #endif
00034 
00035 /************************************************************************/
00036 /************************************************************************/
00037 
00038 class ABI_EXPORT GR_Win32USPFont : public GR_Win32Font
00039 {
00040   public:
00041     static  GR_Win32USPFont * newFont(LOGFONTW & lf, double fPoints, HDC hdc, HDC printHDC);
00042     virtual ~GR_Win32USPFont();
00043 
00044     SCRIPT_CACHE * getScriptCache() {return &m_sc;}
00045     HDC            getPrintDC() const {return m_printHDC;}
00046     void           setPrintDC(HDC dc) {m_printHDC = dc;}
00047 
00048     UT_sint32      getScreenAscent() const {return m_iScreenAscent;}
00049     void           setScreenAscent(UT_sint32 iA) {m_iScreenAscent = iA;}
00050 
00051   protected:
00052     // all construction has to be done via the graphics class
00053     GR_Win32USPFont(LOGFONTW & lf, double fPoints, HDC hdc, HDC printHDC);
00054 
00055     virtual void _clearAnyCachedInfo();
00056 
00057   private:
00058     SCRIPT_CACHE m_sc;
00059     HDC          m_printHDC;
00060     UT_sint32    m_iScreenAscent;
00061 };
00062 
00063 class GR_Win32USPRenderInfo;
00064 
00065 class ABI_EXPORT GR_Win32USPGraphics : public GR_Win32Graphics
00066 {
00067     // all constructors are protected; instances must be created via
00068     // GR_GraphicsFactory
00069 public:
00070     virtual ~GR_Win32USPGraphics();
00071 
00072     static UT_uint32 s_getClassId() {return GRID_WIN32_UNISCRIBE;}
00073     virtual UT_uint32 getClassId() {return s_getClassId();}
00074 
00075     virtual GR_Capability  getCapability() {return GRCAP_SCREEN_AND_PRINTER;}
00076     static const char *    graphicsDescriptor();
00077     static const char *    getUSPVersion();
00078     static GR_Graphics *   graphicsAllocator(GR_AllocInfo&);
00079 
00080     virtual void           setFont(const GR_Font* pFont);
00081 
00082     virtual void           drawChars(const UT_UCSChar* pChars,
00083                                       int iCharOffset, int iLength,
00084                                       UT_sint32 xoff, UT_sint32 yoff,
00085                                       int * pCharWidth);
00086 
00087     virtual void           drawCharsRelativeToBaseline(const UT_UCSChar* pChars,
00088                                                        int iCharOffset,
00089                                                        int iLength,
00090                                                        UT_sint32 xoff,
00091                                                        UT_sint32 yoff,
00092                                                        int* pCharWidths = NULL);
00093 
00094     virtual UT_uint32       getFontHeight();
00095     virtual UT_uint32       getFontAscent();
00096     virtual UT_uint32       getFontDescent();
00097     virtual UT_uint32       getFontAscent(GR_Font *);
00098     virtual UT_uint32       getFontDescent(GR_Font *);
00099     virtual UT_uint32       getFontHeight(GR_Font *);
00100 
00101     virtual void      setZoomPercentage(UT_uint32 iZoom);
00102 
00104     // complex script processing
00105     //
00106     virtual bool itemize(UT_TextIterator & text, GR_Itemization & I);
00107     virtual bool shape(GR_ShapingInfo & si, GR_RenderInfo *& ri);
00108     virtual void prepareToRenderChars(GR_RenderInfo & ri);
00109     virtual void renderChars(GR_RenderInfo & ri);
00110     virtual void measureRenderedCharWidths(GR_RenderInfo & ri);
00111     virtual void appendRenderedCharsToBuff(GR_RenderInfo & ri, UT_GrowBuf & buf) const;
00112 
00113     virtual bool canBreak(GR_RenderInfo & ri, UT_sint32 &iNext, bool bAfter);
00114 
00115     virtual bool nativeBreakInfoForRightEdge() {return false;}
00116 
00117     virtual UT_sint32 resetJustification(GR_RenderInfo & ri, bool bPermanent);
00118     virtual UT_sint32 countJustificationPoints(const GR_RenderInfo & ri) const;
00119     virtual void      justify(GR_RenderInfo & ri);
00120 
00121     virtual UT_uint32 XYToPosition(const GR_RenderInfo & ri, UT_sint32 x, UT_sint32 y) const;
00122     virtual void      positionToXY(const GR_RenderInfo & ri,
00123                                    UT_sint32& x, UT_sint32& y,
00124                                    UT_sint32& x2, UT_sint32& y2,
00125                                    UT_sint32& height, bool& bDirection) const;
00126 
00127     virtual UT_sint32 getTextWidth(GR_RenderInfo & ri);
00128 
00129     virtual bool      needsSpecialCaretPositioning(GR_RenderInfo & ri);
00130     virtual UT_uint32 adjustCaretPosition(GR_RenderInfo & ri, bool bForward);
00131     virtual void      adjustDeletePosition(GR_RenderInfo & ri);
00132 
00133   protected:
00134     inline bool       _needsSpecialBreaking(GR_Win32USPRenderInfo &ri);
00135     inline bool       _needsSpecialCaretPositioning(GR_Win32USPRenderInfo &ri);
00136     inline bool       _scriptBreak(GR_Win32USPRenderInfo &ri);
00137 
00138   public:
00139     virtual const UT_VersionInfo & getVersion() const {return s_Version;}
00140 
00141     virtual void          setPrintDC(HDC dc);
00142 
00143 
00144   protected:
00145     // all instances have to be created via GR_GraphicsFactory; see gr_Graphics.h
00146     GR_Win32USPGraphics(HDC, HWND);
00147     GR_Win32USPGraphics(HDC, const DOCINFOW *, HGLOBAL hDevMode = NULL);
00148 
00149   private:
00150     bool      _constructorCommonCode();
00151     virtual GR_Win32Font * _newFont(LOGFONTW & lf, double fPoints, HDC hdc, HDC printHDC);
00152 
00153     void   _setupFontOnDC(GR_Win32USPFont *pFont, bool bZoomMe);
00154 
00155     void   _drawChars(const UT_UCSChar* pChars,
00156                       int iCharOffset, int iLength,
00157                       UT_sint32 xoff, UT_sint32 yoff,
00158                       int * pCharWidth);
00159 
00160     bool   m_bConstructorSucceeded;
00161 
00162     static HINSTANCE s_hUniscribe;
00163     static UT_uint32 s_iInstanceCount;
00164     static UT_VersionInfo s_Version;
00165     static const SCRIPT_PROPERTIES **s_ppScriptProperties;
00166     static int s_iMaxScript;
00167     static UT_UTF8String s_sDescription;
00168     static UT_UTF8String s_sUSPVersion;
00169 
00170   protected:
00171     // These are the Uniscribe functions we load from the DLL.  We
00172     // prefix the names with 'f' to avoid clashes with the function
00173     // names defined in usp10.h.
00174     //
00175     // IMPORTANT: All uniscribe functions must be called via these
00176     // pointers since we do not want to link against usp10.dll !!!
00177 
00178     static tScriptItemize       fScriptItemize;
00179     static tScriptShape         fScriptShape;
00180     static tScriptStringOut     fScriptStringOut;
00181     static tScriptStringAnalyse fScriptStringAnalyse;
00182     static tScriptStringFree    fScriptStringFree;
00183     static tScriptTextOut       fScriptTextOut;
00184     static tScriptPlace         fScriptPlace;
00185     static tScriptJustify       fScriptJustify;
00186     static tScriptCPtoX         fScriptCPtoX;
00187     static tScriptXtoCP         fScriptXtoCP;
00188     static tScriptBreak         fScriptBreak;
00189     static tScriptIsComplex     fScriptIsComplex;
00190     static tScriptGetProperties fScriptGetProperties;
00191     static tScriptRecordDigitSubstitution fScriptRecordDigitSubstitution;
00192   public:
00193     // these need to be public so we can g_free various things ...
00194     static tScriptFreeCache   fScriptFreeCache;
00195 };
00196 
00197 #endif

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1