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 FPDFSDK_INCLUDE_FXEDIT_FX_EDIT_H_
8 #define FPDFSDK_INCLUDE_FXEDIT_FX_EDIT_H_
9 
10 #include "core/include/fpdfapi/fpdf_parser.h"
11 #include "core/include/fxcrt/fx_basic.h"
12 #include "core/include/fxge/fx_dib.h"
13 
14 class CFX_RenderDevice;
15 class CPDF_Font;
16 class CFX_Matrix;
17 class CPDF_PageObjects;
18 class CPDF_Point;
19 class CPDF_TextObject;
20 class IFX_Edit;
21 class IFX_Edit_FontMap;
22 class IFX_Edit_Iterator;
23 class IFX_Edit_Notify;
24 class IFX_Edit_UndoItem;
25 class IFX_List;
26 class IFX_List_Notify;
27 class IFX_SystemHandler;
28 class IPDF_VariableText;
29 class IPDF_VariableText_Provider;
30 struct CPVT_Line;
31 struct CPVT_SecProps;
32 struct CPVT_Section;
33 struct CPVT_Word;
34 struct CPVT_WordPlace;
35 struct CPVT_WordProps;
36 struct CPVT_WordRange;
37 
38 #define PVTWORD_STYLE_NORMAL 0x0000L
39 #define PVTWORD_STYLE_HIGHLIGHT 0x0001L
40 #define PVTWORD_STYLE_UNDERLINE 0x0002L
41 #define PVTWORD_STYLE_CROSSOUT 0x0004L
42 #define PVTWORD_STYLE_SQUIGGLY 0x0008L
43 #define PVTWORD_STYLE_DUALCROSSOUT 0x0010L
44 #define PVTWORD_STYLE_BOLD 0x0020L
45 #define PVTWORD_STYLE_ITALIC 0x0040L
46 
47 #define FX_EDIT_ISLATINWORD(u)                  \
48   (u == 0x2D || (u <= 0x005A && u >= 0x0041) || \
49    (u <= 0x007A && u >= 0x0061) || (u <= 0x02AF && u >= 0x00C0))
50 
51 #ifndef DEFAULT_CHARSET
52 #define DEFAULT_CHARSET 1
53 #endif
54 
55 class IFX_Edit_FontMap {
56  public:
~IFX_Edit_FontMap()57   virtual ~IFX_Edit_FontMap() {}
58   // map a fontindex to pdf font.
59   virtual CPDF_Font* GetPDFFont(int32_t nFontIndex) = 0;
60   // get the alias of a pdf font.
61   virtual CFX_ByteString GetPDFFontAlias(int32_t nFontIndex) = 0;
62   // get the index of a font that can show a word.
63   virtual int32_t GetWordFontIndex(FX_WORD word,
64                                    int32_t charset,
65                                    int32_t nFontIndex) = 0;
66   // get the charcode of word from unicode
67   virtual int32_t CharCodeFromUnicode(int32_t nFontIndex, FX_WORD word) = 0;
68   // get the charset of unicode
69   virtual int32_t CharSetFromUnicode(FX_WORD word, int32_t nOldCharset) = 0;
70 };
71 
72 class IFX_Edit_Notify {
73  public:
~IFX_Edit_Notify()74   virtual ~IFX_Edit_Notify() {}
75   // set the horizontal scrollbar information.
76   virtual void IOnSetScrollInfoX(FX_FLOAT fPlateMin,
77                                  FX_FLOAT fPlateMax,
78                                  FX_FLOAT fContentMin,
79                                  FX_FLOAT fContentMax,
80                                  FX_FLOAT fSmallStep,
81                                  FX_FLOAT fBigStep) = 0;
82   // set the vertical scrollbar information.
83   virtual void IOnSetScrollInfoY(FX_FLOAT fPlateMin,
84                                  FX_FLOAT fPlateMax,
85                                  FX_FLOAT fContentMin,
86                                  FX_FLOAT fContentMax,
87                                  FX_FLOAT fSmallStep,
88                                  FX_FLOAT fBigStep) = 0;
89   // set the position of horizontal scrollbar.
90   virtual void IOnSetScrollPosX(FX_FLOAT fx) = 0;
91   // set the position of vertical scrollbar.
92   virtual void IOnSetScrollPosY(FX_FLOAT fy) = 0;
93   // set the caret information.
94   virtual void IOnSetCaret(FX_BOOL bVisible,
95                            const CPDF_Point& ptHead,
96                            const CPDF_Point& ptFoot,
97                            const CPVT_WordPlace& place) = 0;
98   // if the caret position is changed ,send the information of current postion
99   // to user.
100   virtual void IOnCaretChange(const CPVT_SecProps& secProps,
101                               const CPVT_WordProps& wordProps) = 0;
102   // if the text area is changed, send the information to user.
103   virtual void IOnContentChange(const CPDF_Rect& rcContent) = 0;
104   // Invalidate the rectangle relative to the bounding box of edit.
105   virtual void IOnInvalidateRect(CPDF_Rect* pRect) = 0;
106 };
107 
108 class IFX_Edit_OprNotify {
109  public:
~IFX_Edit_OprNotify()110   virtual ~IFX_Edit_OprNotify() {}
111 
112   // OprType: 0
113   virtual void OnInsertWord(const CPVT_WordPlace& place,
114                             const CPVT_WordPlace& oldplace) = 0;
115   // OprType: 1
116   virtual void OnInsertReturn(const CPVT_WordPlace& place,
117                               const CPVT_WordPlace& oldplace) = 0;
118   // OprType: 2
119   virtual void OnBackSpace(const CPVT_WordPlace& place,
120                            const CPVT_WordPlace& oldplace) = 0;
121   // OprType: 3
122   virtual void OnDelete(const CPVT_WordPlace& place,
123                         const CPVT_WordPlace& oldplace) = 0;
124   // OprType: 4
125   virtual void OnClear(const CPVT_WordPlace& place,
126                        const CPVT_WordPlace& oldplace) = 0;
127   // OprType: 5
128   virtual void OnInsertText(const CPVT_WordPlace& place,
129                             const CPVT_WordPlace& oldplace) = 0;
130   // OprType: 6
131   virtual void OnSetText(const CPVT_WordPlace& place,
132                          const CPVT_WordPlace& oldplace) = 0;
133   //
134   virtual void OnAddUndo(IFX_Edit_UndoItem* pUndoItem) = 0;
135 };
136 
137 class IFX_Edit_Iterator {
138  public:
~IFX_Edit_Iterator()139   virtual ~IFX_Edit_Iterator() {}
140 
141  public:
142   // move the current position to the next word.
143   virtual FX_BOOL NextWord() = 0;
144   // move the current position to the next line.
145   virtual FX_BOOL NextLine() = 0;
146   // move the current position to the next section.
147   virtual FX_BOOL NextSection() = 0;
148 
149   // move the current position to the previous word.
150   virtual FX_BOOL PrevWord() = 0;
151   // move the current position to the previous line.
152   virtual FX_BOOL PrevLine() = 0;
153   // move the current position to the previous section.
154   virtual FX_BOOL PrevSection() = 0;
155 
156   // get the information of the current word.
157   virtual FX_BOOL GetWord(CPVT_Word& word) const = 0;
158   // get the information of the current line.
159   virtual FX_BOOL GetLine(CPVT_Line& line) const = 0;
160   // get the information of the current section.
161   virtual FX_BOOL GetSection(CPVT_Section& section) const = 0;
162   // set the current position.
163   virtual void SetAt(int32_t nWordIndex) = 0;
164   // set the current position.
165   virtual void SetAt(const CPVT_WordPlace& place) = 0;
166   // get the current position.
167   virtual const CPVT_WordPlace& GetAt() const = 0;
168 
169   // get the edit which this iterator belongs to
170   virtual IFX_Edit* GetEdit() const = 0;
171 };
172 
173 class IFX_Edit_UndoItem {
174  public:
~IFX_Edit_UndoItem()175   virtual ~IFX_Edit_UndoItem() {}
176 
177   virtual void Undo() = 0;
178   virtual void Redo() = 0;
179   virtual CFX_WideString GetUndoTitle() = 0;
180 };
181 
182 class IFX_Edit {
183  public:
184   static IFX_Edit* NewEdit();
185   static void DelEdit(IFX_Edit* pEdit);
186 
187   // set a IFX_Edit_FontMap pointer implemented by user.
188   virtual void SetFontMap(IFX_Edit_FontMap* pFontMap) = 0;
189   // if user don't like to use FontMap, implement VTProvider and set it
190   // directly.
191   virtual void SetVTProvider(IPDF_VariableText_Provider* pProvider) = 0;
192   // set a IFX_Edit_Notify pointer implemented by user.
193   virtual void SetNotify(IFX_Edit_Notify* pNotify) = 0;
194   virtual void SetOprNotify(IFX_Edit_OprNotify* pOprNotify) = 0;
195   // get a pointer allocated by CPDF_Edit, by this pointer, user can iterate the
196   // contents of edit, but don't need to release.
197   virtual IFX_Edit_Iterator* GetIterator() = 0;
198   // get a VT pointer relative to this edit.
199   virtual IPDF_VariableText* GetVariableText() = 0;
200   // get the IFX_Edit_FontMap pointer set by user.
201   virtual IFX_Edit_FontMap* GetFontMap() = 0;
202 
203   // initialize the edit.
204   virtual void Initialize() = 0;
205 
206   // set the bounding box of the text area.
207   virtual void SetPlateRect(const CPDF_Rect& rect, FX_BOOL bPaint = TRUE) = 0;
208   // set the scroll origin
209   virtual void SetScrollPos(const CPDF_Point& point) = 0;
210 
211   // set the horizontal text alignment in text box, nFormat (0:left 1:middle
212   // 2:right).
213   virtual void SetAlignmentH(int32_t nFormat = 0, FX_BOOL bPaint = TRUE) = 0;
214   // set the vertical text alignment in text box, nFormat (0:top 1:center
215   // 2:bottom).
216   virtual void SetAlignmentV(int32_t nFormat = 0, FX_BOOL bPaint = TRUE) = 0;
217   // if the text is shown in secret , set a character for substitute.
218   virtual void SetPasswordChar(FX_WORD wSubWord = '*',
219                                FX_BOOL bPaint = TRUE) = 0;
220   // set the maximal count of words of the text.
221   virtual void SetLimitChar(int32_t nLimitChar = 0, FX_BOOL bPaint = TRUE) = 0;
222   // if set the count of charArray , then all words is shown in equal space.
223   virtual void SetCharArray(int32_t nCharArray = 0, FX_BOOL bPaint = TRUE) = 0;
224   // set the space of two characters.
225   virtual void SetCharSpace(FX_FLOAT fCharSpace = 0.0f,
226                             FX_BOOL bPaint = TRUE) = 0;
227   // set the horizontal scale of all characters.
228   virtual void SetHorzScale(int32_t nHorzScale = 100,
229                             FX_BOOL bPaint = TRUE) = 0;
230   // set the leading of all lines
231   virtual void SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint = TRUE) = 0;
232   // if set, CRLF is allowed.
233   virtual void SetMultiLine(FX_BOOL bMultiLine = TRUE,
234                             FX_BOOL bPaint = TRUE) = 0;
235   // if set, all words auto fit the width of the bounding box.
236   virtual void SetAutoReturn(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) = 0;
237   // if set, a font size is calculated to full fit the bounding box.
238   virtual void SetAutoFontSize(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) = 0;
239   // is set, the text is allowed to scroll.
240   virtual void SetAutoScroll(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) = 0;
241   // set the font size of all words.
242   virtual void SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint = TRUE) = 0;
243   // the text is allowed to auto-scroll, allow the text overflow?
244   virtual void SetTextOverflow(FX_BOOL bAllowed = FALSE,
245                                FX_BOOL bPaint = TRUE) = 0;
246 
247   // query if the edit is richedit.
248   virtual FX_BOOL IsRichText() const = 0;
249   // set the edit is richedit.
250   virtual void SetRichText(FX_BOOL bRichText = TRUE, FX_BOOL bPaint = TRUE) = 0;
251   // set the fontsize of selected text.
252   virtual FX_BOOL SetRichFontSize(FX_FLOAT fFontSize) = 0;
253   // set the fontindex of selected text, user can change the font of selected
254   // text.
255   virtual FX_BOOL SetRichFontIndex(int32_t nFontIndex) = 0;
256   // set the textcolor of selected text.
257   virtual FX_BOOL SetRichTextColor(FX_COLORREF dwColor) = 0;
258   // set the text script type of selected text. (0:normal 1:superscript
259   // 2:subscript)
260   virtual FX_BOOL SetRichTextScript(int32_t nScriptType) = 0;
261   // set the bold font style of selected text.
262   virtual FX_BOOL SetRichTextBold(FX_BOOL bBold = TRUE) = 0;
263   // set the italic font style of selected text.
264   virtual FX_BOOL SetRichTextItalic(FX_BOOL bItalic = TRUE) = 0;
265   // set the underline style of selected text.
266   virtual FX_BOOL SetRichTextUnderline(FX_BOOL bUnderline = TRUE) = 0;
267   // set the crossout style of selected text.
268   virtual FX_BOOL SetRichTextCrossout(FX_BOOL bCrossout = TRUE) = 0;
269   // set the charspace of selected text, in user coordinate.
270   virtual FX_BOOL SetRichTextCharSpace(FX_FLOAT fCharSpace) = 0;
271   // set the horizontal scale of selected text, default value is 100.
272   virtual FX_BOOL SetRichTextHorzScale(int32_t nHorzScale = 100) = 0;
273   // set the leading of selected section, in user coordinate.
274   virtual FX_BOOL SetRichTextLineLeading(FX_FLOAT fLineLeading) = 0;
275   // set the indent of selected section, in user coordinate.
276   virtual FX_BOOL SetRichTextLineIndent(FX_FLOAT fLineIndent) = 0;
277   // set the alignment of selected section, nAlignment(0:left 1:middle 2:right)
278   virtual FX_BOOL SetRichTextAlignment(int32_t nAlignment) = 0;
279 
280   // set the selected range of text.
281   // if nStartChar == 0 and nEndChar == -1, select all the text.
282   virtual void SetSel(int32_t nStartChar, int32_t nEndChar) = 0;
283   // get the selected range of text.
284   virtual void GetSel(int32_t& nStartChar, int32_t& nEndChar) const = 0;
285   // select all the text.
286   virtual void SelectAll() = 0;
287   // set text is not selected.
288   virtual void SelectNone() = 0;
289   // get the caret position.
290   virtual int32_t GetCaret() const = 0;
291   virtual CPVT_WordPlace GetCaretWordPlace() const = 0;
292   // get the string of selected text.
293   virtual CFX_WideString GetSelText() const = 0;
294   // get the text conent
295   virtual CFX_WideString GetText() const = 0;
296   // query if any text is selected.
297   virtual FX_BOOL IsSelected() const = 0;
298   // get the scroll origin
299   virtual CPDF_Point GetScrollPos() const = 0;
300   // get the bounding box of the text area.
301   virtual CPDF_Rect GetPlateRect() const = 0;
302   // get the fact area of the text.
303   virtual CPDF_Rect GetContentRect() const = 0;
304   // get the visible word range
305   virtual CPVT_WordRange GetVisibleWordRange() const = 0;
306   // get the whole word range
307   virtual CPVT_WordRange GetWholeWordRange() const = 0;
308   // get the word range of select text
309   virtual CPVT_WordRange GetSelectWordRange() const = 0;
310 
311   // send the mousedown message to edit for response.
312   // if Shift key is hold, bShift is TRUE, is Ctrl key is hold, bCtrl is TRUE.
313   virtual void OnMouseDown(const CPDF_Point& point,
314                            FX_BOOL bShift,
315                            FX_BOOL bCtrl) = 0;
316   // send the mousemove message to edit when mouse down is TRUE.
317   virtual void OnMouseMove(const CPDF_Point& point,
318                            FX_BOOL bShift,
319                            FX_BOOL bCtrl) = 0;
320   // send the UP key message to edit.
321   virtual void OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) = 0;
322   // send the DOWN key message to edit.
323   virtual void OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) = 0;
324   // send the LEFT key message to edit.
325   virtual void OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) = 0;
326   // send the RIGHT key message to edit.
327   virtual void OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl) = 0;
328   // send the HOME key message to edit.
329   virtual void OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl) = 0;
330   // send the END key message to edit.
331   virtual void OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl) = 0;
332 
333   // put text into edit.
334   virtual void SetText(const FX_WCHAR* text,
335                        int32_t charset = DEFAULT_CHARSET,
336                        const CPVT_SecProps* pSecProps = NULL,
337                        const CPVT_WordProps* pWordProps = NULL) = 0;
338   // insert a word into the edit.
339   virtual FX_BOOL InsertWord(FX_WORD word,
340                              int32_t charset = DEFAULT_CHARSET,
341                              const CPVT_WordProps* pWordProps = NULL) = 0;
342   // insert a return into the edit.
343   virtual FX_BOOL InsertReturn(const CPVT_SecProps* pSecProps = NULL,
344                                const CPVT_WordProps* pWordProps = NULL) = 0;
345   // insert text into the edit.
346   virtual FX_BOOL InsertText(const FX_WCHAR* text,
347                              int32_t charset = DEFAULT_CHARSET,
348                              const CPVT_SecProps* pSecProps = NULL,
349                              const CPVT_WordProps* pWordProps = NULL) = 0;
350   // do backspace operation.
351   virtual FX_BOOL Backspace() = 0;
352   // do delete operation.
353   virtual FX_BOOL Delete() = 0;
354   // delete the selected text.
355   virtual FX_BOOL Clear() = 0;
356 
357   // do Redo operation.
358   virtual FX_BOOL Redo() = 0;
359   // do Undo operation.
360   virtual FX_BOOL Undo() = 0;
361   // move caret
362   virtual void SetCaret(int32_t nPos) = 0;
363 
364   // arrange all words over again
365   virtual void Paint() = 0;
366 
367   // allow to refresh screen?
368   virtual void EnableRefresh(FX_BOOL bRefresh) = 0;
369 
370   virtual void RefreshWordRange(const CPVT_WordRange& wr) = 0;
371 
372   // allow undo/redo?
373   virtual void EnableUndo(FX_BOOL bUndo) = 0;
374 
375   // allow notify?
376   virtual void EnableNotify(FX_BOOL bNotify) = 0;
377 
378   // allow opr notify?
379   virtual void EnableOprNotify(FX_BOOL bNotify) = 0;
380 
381   // map word place to word index.
382   virtual int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const = 0;
383   // map word index to word place.
384   virtual CPVT_WordPlace WordIndexToWordPlace(int32_t index) const = 0;
385 
386   // get the beginning position of a line
387   virtual CPVT_WordPlace GetLineBeginPlace(
388       const CPVT_WordPlace& place) const = 0;
389 
390   // get the ending position of a line
391   virtual CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const = 0;
392 
393   // get the beginning position of a section
394   virtual CPVT_WordPlace GetSectionBeginPlace(
395       const CPVT_WordPlace& place) const = 0;
396 
397   // get the ending position of a section
398   virtual CPVT_WordPlace GetSectionEndPlace(
399       const CPVT_WordPlace& place) const = 0;
400 
401   // search a wordplace form point
402   virtual CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const = 0;
403 
404   // get the font size of non_rich text or default font size of richtext.
405   virtual FX_FLOAT GetFontSize() const = 0;
406   // get the mask character.
407   virtual FX_WORD GetPasswordChar() const = 0;
408   // get the count of charArray
409   virtual int32_t GetCharArray() const = 0;
410   // get the horizontal scale of all characters
411   virtual int32_t GetHorzScale() const = 0;
412   // get the space of two characters
413   virtual FX_FLOAT GetCharSpace() const = 0;
414   // get the latin words of specified range
415   virtual CFX_WideString GetRangeText(const CPVT_WordRange& range) const = 0;
416   // is the text full in bounding box
417   virtual FX_BOOL IsTextFull() const = 0;
418   virtual FX_BOOL CanUndo() const = 0;
419   virtual FX_BOOL CanRedo() const = 0;
420   // if the content is changed after settext?
421   virtual FX_BOOL IsModified() const = 0;
422   // get the total words in edit
423   virtual int32_t GetTotalWords() const = 0;
424 
425   virtual void AddUndoItem(IFX_Edit_UndoItem* pUndoItem) = 0;
426 
427   static CFX_ByteString GetEditAppearanceStream(
428       IFX_Edit* pEdit,
429       const CPDF_Point& ptOffset,
430       const CPVT_WordRange* pRange = NULL,
431       FX_BOOL bContinuous = TRUE,
432       FX_WORD SubWord = 0);
433   static CFX_ByteString GetSelectAppearanceStream(
434       IFX_Edit* pEdit,
435       const CPDF_Point& ptOffset,
436       const CPVT_WordRange* pRange = NULL);
437   static void DrawEdit(CFX_RenderDevice* pDevice,
438                        CFX_Matrix* pUser2Device,
439                        IFX_Edit* pEdit,
440                        FX_COLORREF crTextFill,
441                        FX_COLORREF crTextStroke,
442                        const CPDF_Rect& rcClip,
443                        const CPDF_Point& ptOffset,
444                        const CPVT_WordRange* pRange,
445                        IFX_SystemHandler* pSystemHandler,
446                        void* pFFLData);
447   static void DrawUnderline(CFX_RenderDevice* pDevice,
448                             CFX_Matrix* pUser2Device,
449                             IFX_Edit* pEdit,
450                             FX_COLORREF color,
451                             const CPDF_Rect& rcClip,
452                             const CPDF_Point& ptOffset,
453                             const CPVT_WordRange* pRange);
454   static void DrawRichEdit(CFX_RenderDevice* pDevice,
455                            CFX_Matrix* pUser2Device,
456                            IFX_Edit* pEdit,
457                            const CPDF_Rect& rcClip,
458                            const CPDF_Point& ptOffset,
459                            const CPVT_WordRange* pRange);
460   static void GeneratePageObjects(
461       CPDF_PageObjects* pPageObjects,
462       IFX_Edit* pEdit,
463       const CPDF_Point& ptOffset,
464       const CPVT_WordRange* pRange,
465       FX_COLORREF crText,
466       CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray);
467   static void GenerateRichPageObjects(
468       CPDF_PageObjects* pPageObjects,
469       IFX_Edit* pEdit,
470       const CPDF_Point& ptOffset,
471       const CPVT_WordRange* pRange,
472       CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray);
473   static void GenerateUnderlineObjects(CPDF_PageObjects* pPageObjects,
474                                        IFX_Edit* pEdit,
475                                        const CPDF_Point& ptOffset,
476                                        const CPVT_WordRange* pRange,
477                                        FX_COLORREF color);
478 
479  protected:
~IFX_Edit()480   virtual ~IFX_Edit() {}
481 };
482 
483 class IFX_List_Notify {
484  public:
485   // set the horizontal scrollbar information.
486   virtual void IOnSetScrollInfoX(FX_FLOAT fPlateMin,
487                                  FX_FLOAT fPlateMax,
488                                  FX_FLOAT fContentMin,
489                                  FX_FLOAT fContentMax,
490                                  FX_FLOAT fSmallStep,
491                                  FX_FLOAT fBigStep) = 0;
492   // set the vertical scrollbar information.
493   virtual void IOnSetScrollInfoY(FX_FLOAT fPlateMin,
494                                  FX_FLOAT fPlateMax,
495                                  FX_FLOAT fContentMin,
496                                  FX_FLOAT fContentMax,
497                                  FX_FLOAT fSmallStep,
498                                  FX_FLOAT fBigStep) = 0;
499   // set the position of horizontal scrollbar.
500   virtual void IOnSetScrollPosX(FX_FLOAT fx) = 0;
501   // set the position of vertical scrollbar.
502   virtual void IOnSetScrollPosY(FX_FLOAT fy) = 0;
503   // Invalidate the rectangle relative to the bounding box of edit.
504   virtual void IOnInvalidateRect(CPDF_Rect* pRect) = 0;
505 
506  protected:
~IFX_List_Notify()507   virtual ~IFX_List_Notify() {}
508 };
509 
510 class IFX_List {
511  public:
512   static IFX_List* NewList();
513   static void DelList(IFX_List* pList);
514 
515   virtual void SetFontMap(IFX_Edit_FontMap* pFontMap) = 0;
516   virtual void SetNotify(IFX_List_Notify* pNotify) = 0;
517 
518   virtual void SetPlateRect(const CPDF_Rect& rect) = 0;
519   virtual void SetFontSize(FX_FLOAT fFontSize) = 0;
520 
521   virtual CPDF_Rect GetPlateRect() const = 0;
522   virtual CPDF_Rect GetContentRect() const = 0;
523 
524   virtual FX_FLOAT GetFontSize() const = 0;
525   virtual IFX_Edit* GetItemEdit(int32_t nIndex) const = 0;
526   virtual int32_t GetCount() const = 0;
527   virtual FX_BOOL IsItemSelected(int32_t nIndex) const = 0;
528   virtual FX_FLOAT GetFirstHeight() const = 0;
529 
530   virtual void SetMultipleSel(FX_BOOL bMultiple) = 0;
531   virtual FX_BOOL IsMultipleSel() const = 0;
532   virtual FX_BOOL IsValid(int32_t nItemIndex) const = 0;
533   virtual int32_t FindNext(int32_t nIndex, FX_WCHAR nChar) const = 0;
534 
535   virtual void SetScrollPos(const CPDF_Point& point) = 0;
536   virtual void ScrollToListItem(int32_t nItemIndex) = 0;
537   virtual CPDF_Rect GetItemRect(int32_t nIndex) const = 0;
538   virtual int32_t GetCaret() const = 0;
539   virtual int32_t GetSelect() const = 0;
540   virtual int32_t GetTopItem() const = 0;
541   virtual int32_t GetItemIndex(const CPDF_Point& point) const = 0;
542   virtual int32_t GetFirstSelected() const = 0;
543 
544   virtual void AddString(const FX_WCHAR* string) = 0;
545   virtual void SetTopItem(int32_t nIndex) = 0;
546   virtual void Select(int32_t nItemIndex) = 0;
547   virtual void SetCaret(int32_t nItemIndex) = 0;
548   virtual void Empty() = 0;
549   virtual void Cancel() = 0;
550   virtual CFX_WideString GetText() const = 0;
551 
552   virtual void OnMouseDown(const CPDF_Point& point,
553                            FX_BOOL bShift,
554                            FX_BOOL bCtrl) = 0;
555   virtual void OnMouseMove(const CPDF_Point& point,
556                            FX_BOOL bShift,
557                            FX_BOOL bCtrl) = 0;
558   virtual void OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) = 0;
559   virtual void OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) = 0;
560   virtual void OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) = 0;
561   virtual void OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl) = 0;
562   virtual void OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl) = 0;
563   virtual void OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl) = 0;
564   virtual void OnVK(int32_t nItemIndex, FX_BOOL bShift, FX_BOOL bCtrl) = 0;
565   virtual FX_BOOL OnChar(FX_WORD nChar, FX_BOOL bShift, FX_BOOL bCtrl) = 0;
566 
567  protected:
~IFX_List()568   virtual ~IFX_List() {}
569 };
570 
571 CFX_ByteString GetPDFWordString(IFX_Edit_FontMap* pFontMap,
572                                 int32_t nFontIndex,
573                                 FX_WORD Word,
574                                 FX_WORD SubWord);
575 
576 #endif  // FPDFSDK_INCLUDE_FXEDIT_FX_EDIT_H_
577