OLD | NEW |
| (Empty) |
1 // Copyright 2014 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #ifndef XFA_SRC_FEE_IFDE_TXTEDTENGINE_H_ | |
8 #define XFA_SRC_FEE_IFDE_TXTEDTENGINE_H_ | |
9 | |
10 #include "core/include/fxge/fx_dib.h" | |
11 #include "xfa/src/fgas/font/fgas_font.h" | |
12 | |
13 class IFDE_TxtEdtPage; | |
14 class IFDE_TxtEdtEngine; | |
15 class IFDE_TxtEdtEventSink; | |
16 class IFDE_TxtEdtParag; | |
17 | |
18 typedef struct FDE_HTXTEDTFIND_ { void* pData; } * FDE_HTXTEDTFIND; | |
19 | |
20 #define FDE_TXTEDT_FIND_FLAGS_Prev (0L << 0) | |
21 #define FDE_TXTEDT_FIND_FLAGS_Next (1L << 0) | |
22 #define FDE_TXTEDT_FIND_FLAGS_WholeWord (1L << 1) | |
23 #define FDE_TXTEDT_FIND_FLAGS_NoCase (1L << 2) | |
24 | |
25 #define FDE_TEXTEDITMODE_MultiLines (1L << 0) | |
26 #define FDE_TEXTEDITMODE_AutoLineWrap (1L << 1) | |
27 #define FDE_TEXTEDITMODE_ReadOnly (1L << 2) | |
28 #define FDE_TEXTEDITMODE_LimitArea_Vert (1L << 3) | |
29 #define FDE_TEXTEDITMODE_LimitArea_Horz (1L << 4) | |
30 #define FDE_TEXTEDITMODE_NoRedoUndo (1L << 5) | |
31 #define FDE_TEXTEDITMODE_FIELD_TAB (1L << 6) | |
32 #define FDE_TEXTEDITMODE_FIELD_AUTO (1L << 7) | |
33 #define FDE_TEXTEDITMODE_Validate (1L << 8) | |
34 #define FDE_TEXTEDITMODE_Password (1L << 9) | |
35 | |
36 #define FDE_TEXTEDITALIGN_Left (0L << 0) | |
37 #define FDE_TEXTEDITALIGN_Center (1L << 0) | |
38 #define FDE_TEXTEDITALIGN_Right (2L << 0) | |
39 #define FDE_TEXTEDITALIGN_Normal (1L << 3) | |
40 #define FDE_TEXTEDITALIGN_Justified (1L << 4) | |
41 #define FDE_TEXTEDITALIGN_Distributed (1L << 5) | |
42 | |
43 #define FDE_TEXTEDITLAYOUT_DocVertical (1L << 0) | |
44 #define FDE_TEXTEDITLAYOUT_CharVertial (1L << 1) | |
45 #define FDE_TEXTEDITLAYOUT_LineReserve (1L << 2) | |
46 #define FDE_TEXTEDITLAYOUT_RTL (1L << 3) | |
47 #define FDE_TEXTEDITLAYOUT_CombText (1L << 4) | |
48 #define FDE_TEXTEDITLAYOUT_ExpandTab (1L << 5) | |
49 #define FDE_TEXTEDITLAYOUT_ArabicContext (1L << 6) | |
50 #define FDE_TEXTEDITLAYOUT_ArabicShapes (1L << 7) | |
51 #define FDE_TEXTEDITLAYOUT_LastLineHeight (1L << 8) | |
52 | |
53 enum FDE_TXTEDTMOVECARET { | |
54 MC_MoveNone = 0, | |
55 MC_Left, | |
56 MC_Right, | |
57 MC_Up, | |
58 MC_Down, | |
59 MC_WordBackward, | |
60 MC_WordForward, | |
61 MC_LineStart, | |
62 MC_LineEnd, | |
63 MC_ParagStart, | |
64 MC_ParagEnd, | |
65 MC_PageUp, | |
66 MC_PageDown, | |
67 MC_Home, | |
68 MC_End, | |
69 }; | |
70 enum FDE_TXTEDT_MODIFY_RET { | |
71 FDE_TXTEDT_MODIFY_RET_F_Tab = -6, | |
72 FDE_TXTEDT_MODIFY_RET_F_Locked = -5, | |
73 FDE_TXTEDT_MODIFY_RET_F_Invalidate = -4, | |
74 FDE_TXTEDT_MODIFY_RET_F_Boundary = -3, | |
75 FDE_TXTEDT_MODIFY_RET_F_Full = -2, | |
76 FDE_TXTEDT_MODIFY_RET_F_Normal = -1, | |
77 FDE_TXTEDT_MODIFY_RET_S_Normal = 0, | |
78 FDE_TXTEDT_MODIFY_RET_S_Full = 1, | |
79 FDE_TXTEDT_MODIFY_RET_S_Part = 2, | |
80 FDE_TXTEDT_MODIFY_RET_S_Empty = 3, | |
81 FDE_TXTEDT_MODIFY_RET_T_Tab = 4, | |
82 }; | |
83 enum FDE_TXTEDIT_LINEEND { | |
84 FDE_TXTEDIT_LINEEND_Auto, | |
85 FDE_TXTEDIT_LINEEND_CRLF, | |
86 FDE_TXTEDIT_LINEEND_CR, | |
87 FDE_TXTEDIT_LINEEND_LF, | |
88 }; | |
89 struct _FDE_TXTEDTPARAMS { | |
90 _FDE_TXTEDTPARAMS() | |
91 : fPlateWidth(0), | |
92 fPlateHeight(0), | |
93 nLineCount(0), | |
94 dwLayoutStyles(0), | |
95 dwAlignment(0), | |
96 dwMode(0), | |
97 pFont(NULL), | |
98 fFontSize(10.0f), | |
99 dwFontColor(0xff000000), | |
100 fLineSpace(10.0f), | |
101 fTabWidth(36), | |
102 bTabEquidistant(FALSE), | |
103 wDefChar(0xFEFF), | |
104 wLineBreakChar('\n'), | |
105 nCharRotation(0), | |
106 nLineEnd(0), | |
107 nHorzScale(100), | |
108 fCharSpace(0), | |
109 pEventSink(NULL) {} | |
110 FX_FLOAT fPlateWidth; | |
111 FX_FLOAT fPlateHeight; | |
112 int32_t nLineCount; | |
113 FX_DWORD dwLayoutStyles; | |
114 FX_DWORD dwAlignment; | |
115 FX_DWORD dwMode; | |
116 IFX_Font* pFont; | |
117 FX_FLOAT fFontSize; | |
118 FX_ARGB dwFontColor; | |
119 FX_FLOAT fLineSpace; | |
120 FX_FLOAT fTabWidth; | |
121 FX_BOOL bTabEquidistant; | |
122 FX_WCHAR wDefChar; | |
123 FX_WCHAR wLineBreakChar; | |
124 int32_t nCharRotation; | |
125 int32_t nLineEnd; | |
126 int32_t nHorzScale; | |
127 FX_FLOAT fCharSpace; | |
128 IFDE_TxtEdtEventSink* pEventSink; | |
129 }; | |
130 typedef _FDE_TXTEDTPARAMS FDE_TXTEDTPARAMS; | |
131 typedef _FDE_TXTEDTPARAMS* FDE_LPTXTEDTPARAMS; | |
132 enum FDE_TXTEDT_TEXTCHANGE_TYPE { | |
133 FDE_TXTEDT_TEXTCHANGE_TYPE_Insert = 0, | |
134 FDE_TXTEDT_TEXTCHANGE_TYPE_Delete, | |
135 FDE_TXTEDT_TEXTCHANGE_TYPE_Replace, | |
136 }; | |
137 struct _FDE_TXTEDT_TEXTCHANGE_INFO { | |
138 int32_t nChangeType; | |
139 CFX_WideString wsInsert; | |
140 CFX_WideString wsDelete; | |
141 CFX_WideString wsPrevText; | |
142 }; | |
143 typedef _FDE_TXTEDT_TEXTCHANGE_INFO FDE_TXTEDT_TEXTCHANGE_INFO; | |
144 typedef _FDE_TXTEDT_TEXTCHANGE_INFO* FDE_LPTXTEDT_TEXTCHANGE_INFO; | |
145 class IFDE_TxtEdtEventSink { | |
146 public: | |
147 virtual ~IFDE_TxtEdtEventSink() {} | |
148 virtual void On_CaretChanged(IFDE_TxtEdtEngine* pEdit, | |
149 int32_t nPage, | |
150 FX_BOOL bVisible = TRUE) = 0; | |
151 virtual void On_TextChanged(IFDE_TxtEdtEngine* pEdit, | |
152 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) = 0; | |
153 virtual void On_PageCountChanged(IFDE_TxtEdtEngine* pEdit) = 0; | |
154 virtual void On_SelChanged(IFDE_TxtEdtEngine* pEdit) = 0; | |
155 virtual FX_BOOL On_PageLoad(IFDE_TxtEdtEngine* pEdit, | |
156 int32_t nPageIndex, | |
157 int32_t nPurpose) = 0; | |
158 virtual FX_BOOL On_PageUnload(IFDE_TxtEdtEngine* pEdit, | |
159 int32_t nPageIndex, | |
160 int32_t nPurpose) = 0; | |
161 virtual FX_BOOL On_PageChange(IFDE_TxtEdtEngine* pEdit, | |
162 int32_t nPageIndex) = 0; | |
163 virtual void On_AddDoRecord(IFDE_TxtEdtEngine* pEdit, | |
164 const CFX_ByteStringC& bsDoRecord) = 0; | |
165 virtual FX_BOOL On_ValidateField(IFDE_TxtEdtEngine* pEdit, | |
166 int32_t nBlockIndex, | |
167 int32_t nFieldIndex, | |
168 const CFX_WideString& wsFieldText, | |
169 int32_t nCharIndex) = 0; | |
170 virtual FX_BOOL On_ValidateBlock(IFDE_TxtEdtEngine* pEdit, | |
171 int32_t nBlockIndex) = 0; | |
172 virtual FX_BOOL On_GetBlockFormatText(IFDE_TxtEdtEngine* pEdit, | |
173 int32_t nBlockIndex, | |
174 CFX_WideString& wsBlockText) = 0; | |
175 virtual FX_BOOL On_Validate(IFDE_TxtEdtEngine* pEdit, | |
176 CFX_WideString& wsText) = 0; | |
177 }; | |
178 class IFX_CharIter { | |
179 public: | |
180 virtual ~IFX_CharIter() {} | |
181 virtual void Release() = 0; | |
182 virtual FX_BOOL Next(FX_BOOL bPrev = FALSE) = 0; | |
183 virtual FX_WCHAR GetChar() = 0; | |
184 virtual void SetAt(int32_t nIndex) = 0; | |
185 virtual int32_t GetAt() const = 0; | |
186 virtual FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const = 0; | |
187 virtual IFX_CharIter* Clone() = 0; | |
188 }; | |
189 class IFDE_TxtEdtEngine { | |
190 public: | |
191 static IFDE_TxtEdtEngine* Create(); | |
192 | |
193 virtual ~IFDE_TxtEdtEngine() {} | |
194 virtual void Release() = 0; | |
195 virtual void SetEditParams(const FDE_TXTEDTPARAMS& params) = 0; | |
196 virtual const FDE_TXTEDTPARAMS* GetEditParams() const = 0; | |
197 | |
198 virtual int32_t CountPages() const = 0; | |
199 virtual IFDE_TxtEdtPage* GetPage(int32_t nIndex) = 0; | |
200 virtual FX_BOOL SetBufChunkSize(int32_t nChunkSize) = 0; | |
201 virtual void SetTextByStream(IFX_Stream* pStream) = 0; | |
202 virtual void SetText(const CFX_WideString& wsText) = 0; | |
203 virtual int32_t GetTextLength() const = 0; | |
204 virtual void GetText(CFX_WideString& wsText, | |
205 int32_t nStart, | |
206 int32_t nCount = -1) = 0; | |
207 virtual void ClearText() = 0; | |
208 | |
209 virtual int32_t GetCaretRect(CFX_RectF& rtCaret) const = 0; | |
210 virtual int32_t GetCaretPos() const = 0; | |
211 virtual int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore = TRUE) = 0; | |
212 virtual int32_t MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret, | |
213 FX_BOOL bShift = FALSE, | |
214 FX_BOOL bCtrl = FALSE) = 0; | |
215 | |
216 virtual void Lock() = 0; | |
217 virtual void Unlock() = 0; | |
218 virtual FX_BOOL IsLocked() const = 0; | |
219 | |
220 virtual int32_t Insert(int32_t nStart, | |
221 const FX_WCHAR* lpText, | |
222 int32_t nLength) = 0; | |
223 virtual int32_t Delete(int32_t nStart, FX_BOOL bBackspace = FALSE) = 0; | |
224 virtual int32_t DeleteRange(int32_t nStart, int32_t nCount = -1) = 0; | |
225 virtual int32_t Replace(int32_t nStart, | |
226 int32_t nLength, | |
227 const CFX_WideString& wsReplace) = 0; | |
228 virtual void SetLimit(int32_t nLimit) = 0; | |
229 virtual void SetAliasChar(FX_WCHAR wAlias) = 0; | |
230 virtual void AddSelRange(int32_t nStart, int32_t nCount = -1) = 0; | |
231 virtual int32_t CountSelRanges() = 0; | |
232 virtual int32_t GetSelRange(int32_t nIndex, int32_t& nStart) = 0; | |
233 virtual void ClearSelection() = 0; | |
234 | |
235 virtual FX_BOOL Redo(const CFX_ByteStringC& bsRedo) = 0; | |
236 virtual FX_BOOL Undo(const CFX_ByteStringC& bsUndo) = 0; | |
237 | |
238 virtual int32_t StartLayout() = 0; | |
239 virtual int32_t DoLayout(IFX_Pause* pPause) = 0; | |
240 virtual void EndLayout() = 0; | |
241 | |
242 virtual FX_BOOL Optimize(IFX_Pause* pPause = NULL) = 0; | |
243 virtual int32_t CountParags() const = 0; | |
244 virtual IFDE_TxtEdtParag* GetParag(int32_t nParagIndex) const = 0; | |
245 virtual IFX_CharIter* CreateCharIter() = 0; | |
246 }; | |
247 class IFDE_TxtEdtParag { | |
248 public: | |
249 virtual ~IFDE_TxtEdtParag() {} | |
250 virtual int32_t GetTextLength() const = 0; | |
251 virtual int32_t GetStartIndex() const = 0; | |
252 virtual int32_t CountLines() const = 0; | |
253 virtual void GetLineRange(int32_t nLineIndex, | |
254 int32_t& nStart, | |
255 int32_t& nCount) const = 0; | |
256 }; | |
257 | |
258 #endif // XFA_SRC_FEE_IFDE_TXTEDTENGINE_H_ | |
OLD | NEW |