OLD | NEW |
---|---|
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef XFA_FDE_TTO_FDE_TEXTOUT_H_ | 7 #ifndef XFA_FDE_TTO_FDE_TEXTOUT_H_ |
8 #define XFA_FDE_TTO_FDE_TEXTOUT_H_ | 8 #define XFA_FDE_TTO_FDE_TEXTOUT_H_ |
9 | 9 |
10 #include "core/fxge/include/fx_dib.h" | 10 #include "core/fxge/include/fx_dib.h" |
11 #include "core/fxge/include/fx_ge.h" | 11 #include "core/fxge/include/fx_ge.h" |
12 #include "xfa/fde/fde_object.h" | |
13 #include "xfa/fgas/crt/fgas_utils.h" | |
12 #include "xfa/fgas/font/fgas_font.h" | 14 #include "xfa/fgas/font/fgas_font.h" |
15 #include "xfa/fgas/layout/fgas_textbreak.h" | |
13 | 16 |
14 #define FDE_TTOSTYLE_Underline 0x0001 | 17 #define FDE_TTOSTYLE_Underline 0x0001 |
15 #define FDE_TTOSTYLE_Strikeout 0x0002 | 18 #define FDE_TTOSTYLE_Strikeout 0x0002 |
16 #define FDE_TTOSTYLE_VerticalLayout 0x0004 | 19 #define FDE_TTOSTYLE_VerticalLayout 0x0004 |
17 #define FDE_TTOSTYLE_SingleLine 0x0010 | 20 #define FDE_TTOSTYLE_SingleLine 0x0010 |
18 #define FDE_TTOSTYLE_ExpandTab 0x0020 | 21 #define FDE_TTOSTYLE_ExpandTab 0x0020 |
19 #define FDE_TTOSTYLE_HotKey 0x0040 | 22 #define FDE_TTOSTYLE_HotKey 0x0040 |
20 #define FDE_TTOSTYLE_Ellipsis 0x0080 | 23 #define FDE_TTOSTYLE_Ellipsis 0x0080 |
21 #define FDE_TTOSTYLE_LineWrap 0x0100 | 24 #define FDE_TTOSTYLE_LineWrap 0x0100 |
22 #define FDE_TTOSTYLE_ArabicShapes 0x0200 | 25 #define FDE_TTOSTYLE_ArabicShapes 0x0200 |
23 #define FDE_TTOSTYLE_RTL 0x0400 | 26 #define FDE_TTOSTYLE_RTL 0x0400 |
24 #define FDE_TTOSTYLE_ArabicContext 0x0800 | 27 #define FDE_TTOSTYLE_ArabicContext 0x0800 |
25 #define FDE_TTOSTYLE_LastLineHeight 0x1000 | 28 #define FDE_TTOSTYLE_LastLineHeight 0x1000 |
26 #define FDE_TTOALIGNMENT_TopLeft 0 | 29 #define FDE_TTOALIGNMENT_TopLeft 0 |
27 #define FDE_TTOALIGNMENT_TopCenter 1 | 30 #define FDE_TTOALIGNMENT_TopCenter 1 |
28 #define FDE_TTOALIGNMENT_TopRight 2 | 31 #define FDE_TTOALIGNMENT_TopRight 2 |
29 #define FDE_TTOALIGNMENT_TopAuto 3 | 32 #define FDE_TTOALIGNMENT_TopAuto 3 |
30 #define FDE_TTOALIGNMENT_CenterLeft 4 | 33 #define FDE_TTOALIGNMENT_CenterLeft 4 |
31 #define FDE_TTOALIGNMENT_Center 5 | 34 #define FDE_TTOALIGNMENT_Center 5 |
32 #define FDE_TTOALIGNMENT_CenterRight 6 | 35 #define FDE_TTOALIGNMENT_CenterRight 6 |
33 #define FDE_TTOALIGNMENT_CenterAuto 7 | 36 #define FDE_TTOALIGNMENT_CenterAuto 7 |
34 #define FDE_TTOALIGNMENT_BottomLeft 8 | 37 #define FDE_TTOALIGNMENT_BottomLeft 8 |
35 #define FDE_TTOALIGNMENT_BottomCenter 9 | 38 #define FDE_TTOALIGNMENT_BottomCenter 9 |
36 #define FDE_TTOALIGNMENT_BottomRight 10 | 39 #define FDE_TTOALIGNMENT_BottomRight 10 |
37 #define FDE_TTOALIGNMENT_BottomAuto 11 | 40 #define FDE_TTOALIGNMENT_BottomAuto 11 |
38 | 41 |
39 class IFDE_TextOut { | 42 class CFDE_RenderDevice; |
43 class CFX_TxtBreak; | |
44 | |
45 struct FDE_TTOPIECE { | |
40 public: | 46 public: |
Tom Sepez
2016/04/19 19:02:38
nit: public redundant in struct.
dsinclair
2016/04/19 19:20:25
Done.
| |
41 static IFDE_TextOut* Create(); | 47 int32_t iStartChar; |
42 virtual ~IFDE_TextOut() {} | 48 int32_t iChars; |
43 virtual void Release() = 0; | 49 uint32_t dwCharStyles; |
44 virtual void SetFont(IFX_Font* pFont) = 0; | 50 CFX_RectF rtPiece; |
45 virtual void SetFontSize(FX_FLOAT fFontSize) = 0; | 51 }; |
46 virtual void SetTextColor(FX_ARGB color) = 0; | 52 typedef CFX_MassArrayTemplate<FDE_TTOPIECE> CFDE_TTOPieceArray; |
47 virtual void SetStyles(uint32_t dwStyles) = 0; | 53 |
48 virtual void SetTabWidth(FX_FLOAT fTabWidth) = 0; | 54 class CFDE_TTOLine : public CFX_Target { |
49 virtual void SetEllipsisString(const CFX_WideString& wsEllipsis) = 0; | 55 public: |
50 virtual void SetParagraphBreakChar(FX_WCHAR wch) = 0; | 56 CFDE_TTOLine(); |
51 virtual void SetAlignment(int32_t iAlignment) = 0; | 57 CFDE_TTOLine(const CFDE_TTOLine& ttoLine); |
52 virtual void SetLineSpace(FX_FLOAT fLineSpace) = 0; | 58 ~CFDE_TTOLine(); |
53 virtual void SetDIBitmap(CFX_DIBitmap* pDIB) = 0; | 59 int32_t AddPiece(int32_t index, const FDE_TTOPIECE& ttoPiece); |
54 virtual void SetRenderDevice(CFX_RenderDevice* pDevice) = 0; | 60 int32_t GetSize() const; |
55 virtual void SetClipRect(const CFX_Rect& rtClip) = 0; | 61 FDE_TTOPIECE* GetPtrAt(int32_t index); |
56 virtual void SetClipRect(const CFX_RectF& rtClip) = 0; | 62 void RemoveLast(int32_t iCount); |
57 virtual void SetMatrix(const CFX_Matrix& matrix) = 0; | 63 void RemoveAll(FX_BOOL bLeaveMemory); |
58 virtual void SetLineBreakTolerance(FX_FLOAT fTolerance) = 0; | 64 FX_BOOL m_bNewReload; |
Tom Sepez
2016/04/19 19:02:38
nit: blank line between members and methods
dsinclair
2016/04/19 19:20:25
Done.
| |
59 virtual void CalcSize(const FX_WCHAR* pwsStr, | 65 CFDE_TTOPieceArray m_pieces; |
60 int32_t iLength, | 66 |
61 CFX_Size& size) = 0; | 67 protected: |
62 virtual void CalcSize(const FX_WCHAR* pwsStr, | 68 int32_t m_iPieceCount; |
63 int32_t iLength, | 69 }; |
64 CFX_SizeF& size) = 0; | 70 typedef CFX_ObjectMassArrayTemplate<CFDE_TTOLine> CFDE_TTOLineArray; |
65 virtual void CalcSize(const FX_WCHAR* pwsStr, | 71 |
66 int32_t iLength, | 72 class CFDE_TextOut : public CFX_Target { |
67 CFX_Rect& rect) = 0; | 73 public: |
68 virtual void CalcSize(const FX_WCHAR* pwsStr, | 74 CFDE_TextOut(); |
69 int32_t iLength, | 75 ~CFDE_TextOut(); |
70 CFX_RectF& rect) = 0; | 76 |
71 virtual void DrawText(const FX_WCHAR* pwsStr, | 77 void Release() { delete this; } |
72 int32_t iLength, | 78 void SetFont(IFX_Font* pFont); |
73 int32_t x, | 79 void SetFontSize(FX_FLOAT fFontSize); |
74 int32_t y) = 0; | 80 void SetTextColor(FX_ARGB color); |
75 virtual void DrawText(const FX_WCHAR* pwsStr, | 81 void SetStyles(uint32_t dwStyles); |
76 int32_t iLength, | 82 void SetTabWidth(FX_FLOAT fTabWidth); |
77 FX_FLOAT x, | 83 void SetEllipsisString(const CFX_WideString& wsEllipsis); |
78 FX_FLOAT y) = 0; | 84 void SetParagraphBreakChar(FX_WCHAR wch); |
79 virtual void DrawText(const FX_WCHAR* pwsStr, | 85 void SetAlignment(int32_t iAlignment); |
80 int32_t iLength, | 86 void SetLineSpace(FX_FLOAT fLineSpace); |
81 const CFX_Rect& rect) = 0; | 87 void SetDIBitmap(CFX_DIBitmap* pDIB); |
82 virtual void DrawText(const FX_WCHAR* pwsStr, | 88 void SetRenderDevice(CFX_RenderDevice* pDevice); |
83 int32_t iLength, | 89 void SetClipRect(const CFX_Rect& rtClip); |
84 const CFX_RectF& rect) = 0; | 90 void SetClipRect(const CFX_RectF& rtClip); |
85 virtual void SetLogicClipRect(const CFX_RectF& rtClip) = 0; | 91 void SetMatrix(const CFX_Matrix& matrix); |
86 virtual void CalcLogicSize(const FX_WCHAR* pwsStr, | 92 void SetLineBreakTolerance(FX_FLOAT fTolerance); |
87 int32_t iLength, | 93 void CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_Size& size); |
88 CFX_SizeF& size) = 0; | 94 void CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_SizeF& size); |
89 virtual void CalcLogicSize(const FX_WCHAR* pwsStr, | 95 void CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_Rect& rect); |
90 int32_t iLength, | 96 void CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect); |
91 CFX_RectF& rect) = 0; | 97 |
92 virtual void DrawLogicText(const FX_WCHAR* pwsStr, | 98 void DrawText(const FX_WCHAR* pwsStr, int32_t iLength, int32_t x, int32_t y); |
93 int32_t iLength, | 99 void DrawText(const FX_WCHAR* pwsStr, |
94 FX_FLOAT x, | 100 int32_t iLength, |
95 FX_FLOAT y) = 0; | 101 FX_FLOAT x, |
96 virtual void DrawLogicText(const FX_WCHAR* pwsStr, | 102 FX_FLOAT y); |
97 int32_t iLength, | 103 void DrawText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_Rect& rect); |
98 const CFX_RectF& rect) = 0; | 104 void DrawText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect); |
99 virtual int32_t GetTotalLines() = 0; | 105 |
106 void SetLogicClipRect(const CFX_RectF& rtClip); | |
107 void CalcLogicSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_SizeF& size); | |
108 void CalcLogicSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect); | |
109 void DrawLogicText(const FX_WCHAR* pwsStr, | |
110 int32_t iLength, | |
111 FX_FLOAT x, | |
112 FX_FLOAT y); | |
113 void DrawLogicText(const FX_WCHAR* pwsStr, | |
114 int32_t iLength, | |
115 const CFX_RectF& rect); | |
116 int32_t GetTotalLines(); | |
117 | |
118 protected: | |
119 void CalcTextSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect); | |
120 FX_BOOL RetrieveLineWidth(uint32_t dwBreakStatus, | |
121 FX_FLOAT& fStartPos, | |
122 FX_FLOAT& fWidth, | |
123 FX_FLOAT& fHeight); | |
124 void SetLineWidth(CFX_RectF& rect); | |
125 void DrawText(const FX_WCHAR* pwsStr, | |
126 int32_t iLength, | |
127 const CFX_RectF& rect, | |
128 const CFX_RectF& rtClip); | |
129 void LoadText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect); | |
130 void LoadEllipsis(); | |
131 void ExpandBuffer(int32_t iSize, int32_t iType); | |
132 void RetrieveEllPieces(int32_t*& pCharWidths); | |
133 | |
134 void Reload(const CFX_RectF& rect); | |
135 void ReloadLinePiece(CFDE_TTOLine* pLine, const CFX_RectF& rect); | |
136 FX_BOOL RetriecePieces(uint32_t dwBreakStatus, | |
137 int32_t& iStartChar, | |
138 int32_t& iPieceWidths, | |
139 FX_BOOL bReload, | |
140 const CFX_RectF& rect); | |
141 void AppendPiece(const FDE_TTOPIECE& ttoPiece, | |
142 FX_BOOL bNeedReload, | |
143 FX_BOOL bEnd); | |
144 void ReplaceWidthEllipsis(); | |
145 void DoAlignment(const CFX_RectF& rect); | |
146 void OnDraw(const CFX_RectF& rtClip); | |
147 int32_t GetDisplayPos(FDE_TTOPIECE* pPiece); | |
148 int32_t GetCharRects(const FDE_TTOPIECE* pPiece); | |
149 | |
150 void ToTextRun(const FDE_TTOPIECE* pPiece, FX_TXTRUN& tr); | |
151 void DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen*& pPen); | |
152 | |
153 CFX_TxtBreak* m_pTxtBreak; | |
154 IFX_Font* m_pFont; | |
155 FX_FLOAT m_fFontSize; | |
156 FX_FLOAT m_fLineSpace; | |
157 FX_FLOAT m_fLinePos; | |
158 FX_FLOAT m_fTolerance; | |
159 int32_t m_iAlignment; | |
160 int32_t m_iTxtBkAlignment; | |
161 int32_t* m_pCharWidths; | |
162 int32_t m_iChars; | |
163 int32_t* m_pEllCharWidths; | |
164 int32_t m_iEllChars; | |
165 FX_WCHAR m_wParagraphBkChar; | |
166 FX_ARGB m_TxtColor; | |
167 uint32_t m_dwStyles; | |
168 uint32_t m_dwTxtBkStyles; | |
169 CFX_WideString m_wsEllipsis; | |
170 FX_BOOL m_bElliChanged; | |
171 int32_t m_iEllipsisWidth; | |
172 CFX_WideString m_wsText; | |
173 CFX_RectF m_rtClip; | |
174 CFX_RectF m_rtLogicClip; | |
175 CFX_Matrix m_Matrix; | |
176 CFDE_TTOLineArray m_ttoLines; | |
177 int32_t m_iCurLine; | |
178 int32_t m_iCurPiece; | |
179 int32_t m_iTotalLines; | |
180 FXTEXT_CHARPOS* m_pCharPos; | |
181 int32_t m_iCharPosSize; | |
182 CFDE_RenderDevice* m_pRenderDevice; | |
183 CFX_Int32Array m_hotKeys; | |
184 CFX_RectFArray m_rectArray; | |
100 }; | 185 }; |
101 | 186 |
102 #endif // XFA_FDE_TTO_FDE_TEXTOUT_H_ | 187 #endif // XFA_FDE_TTO_FDE_TEXTOUT_H_ |
OLD | NEW |