Initial commit.
[pdfium.git] / fpdfsdk / include / pdfwindow / PWL_Edit.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4  \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _PWL_EDIT_H_\r
8 #define _PWL_EDIT_H_\r
9 \r
10 class IPWL_Filler_Notify;\r
11 class CPWL_Edit;\r
12 class IPWL_SpellCheck;\r
13 \r
14 class IPWL_Filler_Notify\r
15 {\r
16 public:\r
17         virtual void                                    QueryWherePopup(void* pPrivateData, FX_FLOAT fPopupMin,FX_FLOAT fPopupMax, \r
18                                                                                 FX_INT32 & nRet, FX_FLOAT & fPopupRet) = 0; //nRet: (0:bottom 1:top)\r
19         virtual void                                    OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_INT32 nKeyCode,\r
20                                                                                 CFX_WideString & strChange, const CFX_WideString& strChangeEx, \r
21                                                                                 int nSelStart, int nSelEnd,\r
22                                                                                 FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag) = 0;\r
23         virtual void                                    OnAfterKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_BOOL & bExit, FX_DWORD nFlag) = 0;\r
24 };\r
25 \r
26 class PWL_CLASS CPWL_Edit : public CPWL_EditCtrl, public IFX_Edit_OprNotify\r
27 {\r
28 public:\r
29         CPWL_Edit();\r
30         virtual ~CPWL_Edit();\r
31 \r
32 public:\r
33         virtual CFX_ByteString                  GetClassName() const;\r
34         virtual void                                    OnDestroy();\r
35         virtual void                                    OnCreated();\r
36         virtual void                                    RePosChildWnd();\r
37         virtual CPDF_Rect                               GetClientRect() const;\r
38 \r
39         virtual void                                    GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream);\r
40         virtual void                                    DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device);\r
41 \r
42         virtual FX_BOOL                                 OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag);\r
43         virtual FX_BOOL                                 OnLButtonDblClk(const CPDF_Point & point, FX_DWORD nFlag);\r
44         virtual FX_BOOL                                 OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag);\r
45         virtual FX_BOOL                                 OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag);\r
46 \r
47         virtual FX_BOOL                                 OnKeyDown(FX_WORD nChar, FX_DWORD nFlag);\r
48         virtual FX_BOOL                                 OnChar(FX_WORD nChar, FX_DWORD nFlag);\r
49 \r
50         virtual CPDF_Rect                               GetFocusRect() const;\r
51 \r
52 public:         \r
53         void                                                    SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat = PEAH_LEFT, FX_BOOL bPaint = TRUE);     //0:left 1:right 2:middle \r
54         void                                                    SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat = PEAV_TOP, FX_BOOL bPaint = TRUE);      //0:top 1:bottom 2:center\r
55 \r
56         void                                                    SetCharArray(FX_INT32 nCharArray);\r
57         void                                                    SetLimitChar(FX_INT32 nLimitChar);\r
58 \r
59         void                                                    SetHorzScale(FX_INT32 nHorzScale, FX_BOOL bPaint = TRUE);\r
60         void                                                    SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint = TRUE);\r
61 \r
62         void                                                    SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint = TRUE);\r
63 \r
64         void                                                    EnableSpellCheck(FX_BOOL bEnabled);\r
65 \r
66         FX_BOOL                                                 CanSelectAll() const;\r
67         FX_BOOL                                                 CanClear() const;\r
68         FX_BOOL                                                 CanCopy() const;\r
69         FX_BOOL                                                 CanCut() const;\r
70         FX_BOOL                                                 CanPaste() const;\r
71 \r
72         virtual void                                    CopyText();\r
73         virtual void                                    PasteText();\r
74         virtual void                                    CutText();\r
75 \r
76         virtual void                                    SetText(FX_LPCWSTR csText);\r
77         void                                                    ReplaceSel(FX_LPCWSTR csText);\r
78 \r
79         CFX_ByteString                                  GetTextAppearanceStream(const CPDF_Point & ptOffset) const;\r
80         CFX_ByteString                                  GetCaretAppearanceStream(const CPDF_Point & ptOffset) const;    \r
81         CFX_ByteString                                  GetSelectAppearanceStream(const CPDF_Point & ptOffset) const;\r
82 \r
83         FX_BOOL                                                 IsTextFull() const;     \r
84 \r
85         static FX_FLOAT                                 GetCharArrayAutoFontSize(CPDF_Font* pFont, const CPDF_Rect& rcPlate, FX_INT32 nCharArray);\r
86 \r
87         void                                                    SetFillerNotify(IPWL_Filler_Notify* pNotify) {m_pFillerNotify = pNotify;}\r
88 \r
89         void                                                    GeneratePageObjects(CPDF_PageObjects* pPageObjects, \r
90                                                                                 const CPDF_Point& ptOffset, CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray);\r
91         void                                                    GeneratePageObjects(CPDF_PageObjects* pPageObjects, \r
92                                                                                 const CPDF_Point& ptOffset);\r
93 \r
94 protected:\r
95         virtual void                                    OnSetFocus();\r
96         virtual void                                    OnKillFocus();\r
97 \r
98 protected:\r
99         virtual void                                    OnInsertWord(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace);\r
100         virtual void                                    OnInsertReturn(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace);\r
101         virtual void                                    OnBackSpace(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace);\r
102         virtual void                                    OnDelete(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace);\r
103         virtual void                                    OnClear(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace);\r
104         virtual void                                    OnSetText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace);\r
105         virtual void                                    OnInsertText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace);\r
106         virtual void                                    OnAddUndo(IFX_Edit_UndoItem* pUndoItem);\r
107 \r
108 private:        \r
109         CPVT_WordRange                                  GetSelectWordRange() const;\r
110         virtual void                                    ShowVScrollBar(FX_BOOL bShow);\r
111         FX_BOOL                                                 IsVScrollBarVisible() const;\r
112         void                                                    SetParamByFlag();\r
113 \r
114         FX_FLOAT                                                GetCharArrayAutoFontSize(FX_INT32 nCharArray);\r
115         CPDF_Point                                              GetWordRightBottomPoint(const CPVT_WordPlace& wpWord);\r
116 \r
117         CPVT_WordRange                                  CombineWordRange(const CPVT_WordRange& wr1, const CPVT_WordRange& wr2);\r
118         CPVT_WordRange                                  GetLatinWordsRange(const CPDF_Point & point) const;\r
119         CPVT_WordRange                                  GetLatinWordsRange(const CPVT_WordPlace & place) const;\r
120         CPVT_WordRange                                  GetArabicWordsRange(const CPVT_WordPlace & place) const;\r
121         CPVT_WordRange                                  GetSameWordsRange(const CPVT_WordPlace & place, FX_BOOL bLatin, FX_BOOL bArabic) const;\r
122 \r
123         void                                                    AjustArabicWords(const CPVT_WordRange& wr);\r
124 public:\r
125         FX_BOOL                                                 IsProceedtoOnChar(FX_WORD nKeyCode, FX_DWORD nFlag);\r
126 private:\r
127         IPWL_Filler_Notify*                             m_pFillerNotify;\r
128         IPWL_SpellCheck*                                m_pSpellCheck;\r
129         FX_BOOL                                                 m_bFocus;\r
130         CPDF_Rect                                               m_rcOldWindow;\r
131 public:\r
132         void                                                    AttachFFLData(void* pData) {m_pFormFiller = pData;}\r
133 private:\r
134         void*                                                   m_pFormFiller;\r
135 };\r
136 \r
137 #endif \r
138 \r