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_FWL_CORE_IFWL_EDIT_H_ | 7 #ifndef XFA_FWL_CORE_IFWL_EDIT_H_ |
8 #define XFA_FWL_CORE_IFWL_EDIT_H_ | 8 #define XFA_FWL_CORE_IFWL_EDIT_H_ |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 CFWL_EventType::TextChanged, | 63 CFWL_EventType::TextChanged, |
64 int32_t nChangeType; | 64 int32_t nChangeType; |
65 CFX_WideString wsInsert; | 65 CFX_WideString wsInsert; |
66 CFX_WideString wsDelete; | 66 CFX_WideString wsDelete; |
67 CFX_WideString wsPrevText;) | 67 CFX_WideString wsPrevText;) |
68 | 68 |
69 FWL_EVENT_DEF(CFWL_EvtEdtTextFull, CFWL_EventType::TextFull) | 69 FWL_EVENT_DEF(CFWL_EvtEdtTextFull, CFWL_EventType::TextFull) |
70 | 70 |
71 FWL_EVENT_DEF(CFWL_EvtEdtPreSelfAdaption, | 71 FWL_EVENT_DEF(CFWL_EvtEdtPreSelfAdaption, |
72 CFWL_EventType::PreSelfAdaption, | 72 CFWL_EventType::PreSelfAdaption, |
73 FX_BOOL bHSelfAdaption; | 73 bool bHSelfAdaption; |
74 FX_BOOL bVSelfAdaption; | 74 bool bVSelfAdaption; |
75 CFX_RectF rtAfterChange;) | 75 CFX_RectF rtAfterChange;) |
76 | 76 |
77 FWL_EVENT_DEF(CFWL_EvtEdtValidate, | 77 FWL_EVENT_DEF(CFWL_EvtEdtValidate, |
78 CFWL_EventType::Validate, | 78 CFWL_EventType::Validate, |
79 IFWL_Widget* pDstWidget; | 79 IFWL_Widget* pDstWidget; |
80 CFX_WideString wsInsert; | 80 CFX_WideString wsInsert; |
81 FX_BOOL bValidate;) | 81 bool bValidate;) |
82 | 82 |
83 FWL_EVENT_DEF(CFWL_EvtEdtCheckWord, | 83 FWL_EVENT_DEF(CFWL_EvtEdtCheckWord, |
84 CFWL_EventType::CheckWord, | 84 CFWL_EventType::CheckWord, |
85 CFX_ByteString bsWord; | 85 CFX_ByteString bsWord; |
86 FX_BOOL bCheckWord;) | 86 bool bCheckWord;) |
87 | 87 |
88 FWL_EVENT_DEF(CFWL_EvtEdtGetSuggestWords, | 88 FWL_EVENT_DEF(CFWL_EvtEdtGetSuggestWords, |
89 CFWL_EventType::GetSuggestedWords, | 89 CFWL_EventType::GetSuggestedWords, |
90 FX_BOOL bSuggestWords; | 90 bool bSuggestWords; |
91 CFX_ByteString bsWord; | 91 CFX_ByteString bsWord; |
92 std::vector<CFX_ByteString> bsArraySuggestWords;) | 92 std::vector<CFX_ByteString> bsArraySuggestWords;) |
93 | 93 |
94 class CFWL_WidgetImpProperties; | 94 class CFWL_WidgetImpProperties; |
95 class IFDE_TxtEdtDoRecord; | 95 class IFDE_TxtEdtDoRecord; |
96 class IFWL_Edit; | 96 class IFWL_Edit; |
97 class CFWL_MsgActivate; | 97 class CFWL_MsgActivate; |
98 class CFWL_MsgDeactivate; | 98 class CFWL_MsgDeactivate; |
99 class CFWL_MsgMouse; | 99 class CFWL_MsgMouse; |
100 class CFWL_WidgetImpProperties; | 100 class CFWL_WidgetImpProperties; |
101 class IFWL_Caret; | 101 class IFWL_Caret; |
102 | 102 |
103 class IFWL_EditDP : public IFWL_DataProvider {}; | 103 class IFWL_EditDP : public IFWL_DataProvider {}; |
104 | 104 |
105 class IFWL_Edit : public IFWL_Widget { | 105 class IFWL_Edit : public IFWL_Widget { |
106 public: | 106 public: |
107 IFWL_Edit(const IFWL_App* app, | 107 IFWL_Edit(const IFWL_App* app, |
108 const CFWL_WidgetImpProperties& properties, | 108 const CFWL_WidgetImpProperties& properties, |
109 IFWL_Widget* pOuter); | 109 IFWL_Widget* pOuter); |
110 ~IFWL_Edit() override; | 110 ~IFWL_Edit() override; |
111 | 111 |
112 // IFWL_Widget: | 112 // IFWL_Widget: |
113 FWL_Type GetClassID() const override; | 113 FWL_Type GetClassID() const override; |
114 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override; | 114 FWL_Error GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false) override; |
115 FWL_Error SetWidgetRect(const CFX_RectF& rect) override; | 115 FWL_Error SetWidgetRect(const CFX_RectF& rect) override; |
116 FWL_Error Update() override; | 116 FWL_Error Update() override; |
117 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; | 117 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; |
118 void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE) override; | 118 void SetStates(uint32_t dwStates, bool bSet = true) override; |
119 FWL_Error DrawWidget(CFX_Graphics* pGraphics, | 119 FWL_Error DrawWidget(CFX_Graphics* pGraphics, |
120 const CFX_Matrix* pMatrix = nullptr) override; | 120 const CFX_Matrix* pMatrix = nullptr) override; |
121 FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override; | 121 FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override; |
122 void OnProcessMessage(CFWL_Message* pMessage) override; | 122 void OnProcessMessage(CFWL_Message* pMessage) override; |
123 void OnProcessEvent(CFWL_Event* pEvent) override; | 123 void OnProcessEvent(CFWL_Event* pEvent) override; |
124 void OnDrawWidget(CFX_Graphics* pGraphics, | 124 void OnDrawWidget(CFX_Graphics* pGraphics, |
125 const CFX_Matrix* pMatrix) override; | 125 const CFX_Matrix* pMatrix) override; |
126 | 126 |
127 virtual FWL_Error SetText(const CFX_WideString& wsText); | 127 virtual FWL_Error SetText(const CFX_WideString& wsText); |
128 virtual int32_t GetTextLength() const; | 128 virtual int32_t GetTextLength() const; |
129 virtual FWL_Error GetText(CFX_WideString& wsText, | 129 virtual FWL_Error GetText(CFX_WideString& wsText, |
130 int32_t nStart = 0, | 130 int32_t nStart = 0, |
131 int32_t nCount = -1) const; | 131 int32_t nCount = -1) const; |
132 virtual FWL_Error ClearText(); | 132 virtual FWL_Error ClearText(); |
133 virtual int32_t GetCaretPos() const; | 133 virtual int32_t GetCaretPos() const; |
134 virtual int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore = TRUE); | 134 virtual int32_t SetCaretPos(int32_t nIndex, bool bBefore = true); |
135 virtual FWL_Error AddSelRange(int32_t nStart, int32_t nCount = -1); | 135 virtual FWL_Error AddSelRange(int32_t nStart, int32_t nCount = -1); |
136 virtual int32_t CountSelRanges(); | 136 virtual int32_t CountSelRanges(); |
137 virtual int32_t GetSelRange(int32_t nIndex, int32_t& nStart); | 137 virtual int32_t GetSelRange(int32_t nIndex, int32_t& nStart); |
138 virtual FWL_Error ClearSelections(); | 138 virtual FWL_Error ClearSelections(); |
139 virtual int32_t GetLimit(); | 139 virtual int32_t GetLimit(); |
140 virtual FWL_Error SetLimit(int32_t nLimit); | 140 virtual FWL_Error SetLimit(int32_t nLimit); |
141 virtual FWL_Error SetAliasChar(FX_WCHAR wAlias); | 141 virtual FWL_Error SetAliasChar(FX_WCHAR wAlias); |
142 virtual FWL_Error Insert(int32_t nStart, | 142 virtual FWL_Error Insert(int32_t nStart, |
143 const FX_WCHAR* lpText, | 143 const FX_WCHAR* lpText, |
144 int32_t nLen); | 144 int32_t nLen); |
145 virtual FWL_Error DeleteSelections(); | 145 virtual FWL_Error DeleteSelections(); |
146 virtual FWL_Error DeleteRange(int32_t nStart, int32_t nCount = -1); | 146 virtual FWL_Error DeleteRange(int32_t nStart, int32_t nCount = -1); |
147 virtual FWL_Error Replace(int32_t nStart, | 147 virtual FWL_Error Replace(int32_t nStart, |
148 int32_t nLen, | 148 int32_t nLen, |
149 const CFX_WideStringC& wsReplace); | 149 const CFX_WideStringC& wsReplace); |
150 virtual FWL_Error DoClipboard(int32_t iCmd); | 150 virtual FWL_Error DoClipboard(int32_t iCmd); |
151 virtual FX_BOOL Copy(CFX_WideString& wsCopy); | 151 virtual bool Copy(CFX_WideString& wsCopy); |
152 virtual FX_BOOL Cut(CFX_WideString& wsCut); | 152 virtual bool Cut(CFX_WideString& wsCut); |
153 virtual FX_BOOL Paste(const CFX_WideString& wsPaste); | 153 virtual bool Paste(const CFX_WideString& wsPaste); |
154 virtual FX_BOOL Delete(); | 154 virtual bool Delete(); |
155 virtual FX_BOOL Redo(const IFDE_TxtEdtDoRecord* pRecord); | 155 virtual bool Redo(const IFDE_TxtEdtDoRecord* pRecord); |
156 virtual FX_BOOL Undo(const IFDE_TxtEdtDoRecord* pRecord); | 156 virtual bool Undo(const IFDE_TxtEdtDoRecord* pRecord); |
157 virtual FX_BOOL Undo(); | 157 virtual bool Undo(); |
158 virtual FX_BOOL Redo(); | 158 virtual bool Redo(); |
159 virtual FX_BOOL CanUndo(); | 159 virtual bool CanUndo(); |
160 virtual FX_BOOL CanRedo(); | 160 virtual bool CanRedo(); |
161 virtual FWL_Error SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant); | 161 virtual FWL_Error SetTabWidth(FX_FLOAT fTabWidth, bool bEquidistant); |
162 virtual FWL_Error SetOuter(IFWL_Widget* pOuter); | 162 virtual FWL_Error SetOuter(IFWL_Widget* pOuter); |
163 virtual FWL_Error SetNumberRange(int32_t iMin, int32_t iMax); | 163 virtual FWL_Error SetNumberRange(int32_t iMin, int32_t iMax); |
164 virtual FWL_Error SetBackgroundColor(uint32_t color); | 164 virtual FWL_Error SetBackgroundColor(uint32_t color); |
165 virtual FWL_Error SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize); | 165 virtual FWL_Error SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize); |
166 | 166 |
167 void On_CaretChanged(CFDE_TxtEdtEngine* pEdit, | 167 void On_CaretChanged(CFDE_TxtEdtEngine* pEdit, |
168 int32_t nPage, | 168 int32_t nPage, |
169 FX_BOOL bVisible = true); | 169 bool bVisible = true); |
170 void On_TextChanged(CFDE_TxtEdtEngine* pEdit, | 170 void On_TextChanged(CFDE_TxtEdtEngine* pEdit, |
171 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo); | 171 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo); |
172 void On_SelChanged(CFDE_TxtEdtEngine* pEdit); | 172 void On_SelChanged(CFDE_TxtEdtEngine* pEdit); |
173 FX_BOOL On_PageLoad(CFDE_TxtEdtEngine* pEdit, | 173 bool On_PageLoad(CFDE_TxtEdtEngine* pEdit, |
174 int32_t nPageIndex, | 174 int32_t nPageIndex, |
175 int32_t nPurpose); | 175 int32_t nPurpose); |
176 FX_BOOL On_PageUnload(CFDE_TxtEdtEngine* pEdit, | 176 bool On_PageUnload(CFDE_TxtEdtEngine* pEdit, |
177 int32_t nPageIndex, | 177 int32_t nPageIndex, |
178 int32_t nPurpose); | 178 int32_t nPurpose); |
179 void On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, IFDE_TxtEdtDoRecord* pRecord); | 179 void On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, IFDE_TxtEdtDoRecord* pRecord); |
180 FX_BOOL On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText); | 180 bool On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText); |
181 void SetScrollOffset(FX_FLOAT fScrollOffset); | 181 void SetScrollOffset(FX_FLOAT fScrollOffset); |
182 FX_BOOL GetSuggestWords(CFX_PointF pointf, | 182 bool GetSuggestWords(CFX_PointF pointf, |
183 std::vector<CFX_ByteString>& sSuggest); | 183 std::vector<CFX_ByteString>& sSuggest); |
184 FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, | 184 bool ReplaceSpellCheckWord(CFX_PointF pointf, |
185 const CFX_ByteStringC& bsReplace); | 185 const CFX_ByteStringC& bsReplace); |
186 | 186 |
187 protected: | 187 protected: |
188 friend class CFWL_TxtEdtEventSink; | 188 friend class CFWL_TxtEdtEventSink; |
189 | 189 |
190 void DrawTextBk(CFX_Graphics* pGraphics, | 190 void DrawTextBk(CFX_Graphics* pGraphics, |
191 IFWL_ThemeProvider* pTheme, | 191 IFWL_ThemeProvider* pTheme, |
192 const CFX_Matrix* pMatrix = nullptr); | 192 const CFX_Matrix* pMatrix = nullptr); |
193 void DrawContent(CFX_Graphics* pGraphics, | 193 void DrawContent(CFX_Graphics* pGraphics, |
194 IFWL_ThemeProvider* pTheme, | 194 IFWL_ThemeProvider* pTheme, |
195 const CFX_Matrix* pMatrix = nullptr); | 195 const CFX_Matrix* pMatrix = nullptr); |
196 void UpdateEditEngine(); | 196 void UpdateEditEngine(); |
197 void UpdateEditParams(); | 197 void UpdateEditParams(); |
198 void UpdateEditLayout(); | 198 void UpdateEditLayout(); |
199 FX_BOOL UpdateOffset(); | 199 bool UpdateOffset(); |
200 FX_BOOL UpdateOffset(IFWL_ScrollBar* pScrollBar, FX_FLOAT fPosChanged); | 200 bool UpdateOffset(IFWL_ScrollBar* pScrollBar, FX_FLOAT fPosChanged); |
201 void UpdateVAlignment(); | 201 void UpdateVAlignment(); |
202 void UpdateCaret(); | 202 void UpdateCaret(); |
203 IFWL_ScrollBar* UpdateScroll(); | 203 IFWL_ScrollBar* UpdateScroll(); |
204 void Layout(); | 204 void Layout(); |
205 void LayoutScrollBar(); | 205 void LayoutScrollBar(); |
206 void DeviceToEngine(CFX_PointF& pt); | 206 void DeviceToEngine(CFX_PointF& pt); |
207 void InitScrollBar(FX_BOOL bVert = TRUE); | 207 void InitScrollBar(bool bVert = true); |
208 void InitEngine(); | 208 void InitEngine(); |
209 virtual void ShowCaret(FX_BOOL bVisible, CFX_RectF* pRect = nullptr); | 209 virtual void ShowCaret(bool bVisible, CFX_RectF* pRect = nullptr); |
210 FX_BOOL ValidateNumberChar(FX_WCHAR cNum); | 210 bool ValidateNumberChar(FX_WCHAR cNum); |
211 void InitCaret(); | 211 void InitCaret(); |
212 void ClearRecord(); | 212 void ClearRecord(); |
213 FX_BOOL IsShowScrollBar(FX_BOOL bVert); | 213 bool IsShowScrollBar(bool bVert); |
214 FX_BOOL IsContentHeightOverflow(); | 214 bool IsContentHeightOverflow(); |
215 int32_t AddDoRecord(IFDE_TxtEdtDoRecord* pRecord); | 215 int32_t AddDoRecord(IFDE_TxtEdtDoRecord* pRecord); |
216 void ProcessInsertError(int32_t iError); | 216 void ProcessInsertError(int32_t iError); |
217 | 217 |
218 void DrawSpellCheck(CFX_Graphics* pGraphics, | 218 void DrawSpellCheck(CFX_Graphics* pGraphics, |
219 const CFX_Matrix* pMatrix = nullptr); | 219 const CFX_Matrix* pMatrix = nullptr); |
220 void AddSpellCheckObj(CFX_Path& PathData, | 220 void AddSpellCheckObj(CFX_Path& PathData, |
221 int32_t nStart, | 221 int32_t nStart, |
222 int32_t nCount, | 222 int32_t nCount, |
223 FX_FLOAT fOffSetX, | 223 FX_FLOAT fOffSetX, |
224 FX_FLOAT fOffSetY); | 224 FX_FLOAT fOffSetY); |
225 int32_t GetWordAtPoint(CFX_PointF pointf, int32_t& nCount); | 225 int32_t GetWordAtPoint(CFX_PointF pointf, int32_t& nCount); |
226 | 226 |
227 CFX_RectF m_rtClient; | 227 CFX_RectF m_rtClient; |
228 CFX_RectF m_rtEngine; | 228 CFX_RectF m_rtEngine; |
229 CFX_RectF m_rtStatic; | 229 CFX_RectF m_rtStatic; |
230 FX_FLOAT m_fVAlignOffset; | 230 FX_FLOAT m_fVAlignOffset; |
231 FX_FLOAT m_fScrollOffsetX; | 231 FX_FLOAT m_fScrollOffsetX; |
232 FX_FLOAT m_fScrollOffsetY; | 232 FX_FLOAT m_fScrollOffsetY; |
233 std::unique_ptr<CFDE_TxtEdtEngine> m_pEdtEngine; | 233 std::unique_ptr<CFDE_TxtEdtEngine> m_pEdtEngine; |
234 FX_BOOL m_bLButtonDown; | 234 bool m_bLButtonDown; |
235 int32_t m_nSelStart; | 235 int32_t m_nSelStart; |
236 int32_t m_nLimit; | 236 int32_t m_nLimit; |
237 FX_FLOAT m_fSpaceAbove; | 237 FX_FLOAT m_fSpaceAbove; |
238 FX_FLOAT m_fSpaceBelow; | 238 FX_FLOAT m_fSpaceBelow; |
239 FX_FLOAT m_fFontSize; | 239 FX_FLOAT m_fFontSize; |
240 FX_ARGB m_argbSel; | 240 FX_ARGB m_argbSel; |
241 FX_BOOL m_bSetRange; | 241 bool m_bSetRange; |
242 int32_t m_iMin; | 242 int32_t m_iMin; |
243 int32_t m_iMax; | 243 int32_t m_iMax; |
244 std::unique_ptr<IFWL_ScrollBar> m_pVertScrollBar; | 244 std::unique_ptr<IFWL_ScrollBar> m_pVertScrollBar; |
245 std::unique_ptr<IFWL_ScrollBar> m_pHorzScrollBar; | 245 std::unique_ptr<IFWL_ScrollBar> m_pHorzScrollBar; |
246 std::unique_ptr<IFWL_Caret> m_pCaret; | 246 std::unique_ptr<IFWL_Caret> m_pCaret; |
247 CFX_WideString m_wsCache; | 247 CFX_WideString m_wsCache; |
248 uint32_t m_backColor; | 248 uint32_t m_backColor; |
249 FX_BOOL m_updateBackColor; | 249 bool m_updateBackColor; |
250 CFX_WideString m_wsFont; | 250 CFX_WideString m_wsFont; |
251 std::deque<std::unique_ptr<IFDE_TxtEdtDoRecord>> m_DoRecords; | 251 std::deque<std::unique_ptr<IFDE_TxtEdtDoRecord>> m_DoRecords; |
252 int32_t m_iCurRecord; | 252 int32_t m_iCurRecord; |
253 int32_t m_iMaxRecord; | 253 int32_t m_iMaxRecord; |
254 | 254 |
255 private: | 255 private: |
256 void DoActivate(CFWL_MsgActivate* pMsg); | 256 void DoActivate(CFWL_MsgActivate* pMsg); |
257 void DoDeactivate(CFWL_MsgDeactivate* pMsg); | 257 void DoDeactivate(CFWL_MsgDeactivate* pMsg); |
258 void DoButtonDown(CFWL_MsgMouse* pMsg); | 258 void DoButtonDown(CFWL_MsgMouse* pMsg); |
259 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet); | 259 void OnFocusChanged(CFWL_Message* pMsg, bool bSet); |
260 void OnLButtonDown(CFWL_MsgMouse* pMsg); | 260 void OnLButtonDown(CFWL_MsgMouse* pMsg); |
261 void OnLButtonUp(CFWL_MsgMouse* pMsg); | 261 void OnLButtonUp(CFWL_MsgMouse* pMsg); |
262 void OnButtonDblClk(CFWL_MsgMouse* pMsg); | 262 void OnButtonDblClk(CFWL_MsgMouse* pMsg); |
263 void OnMouseMove(CFWL_MsgMouse* pMsg); | 263 void OnMouseMove(CFWL_MsgMouse* pMsg); |
264 void OnKeyDown(CFWL_MsgKey* pMsg); | 264 void OnKeyDown(CFWL_MsgKey* pMsg); |
265 void OnChar(CFWL_MsgKey* pMsg); | 265 void OnChar(CFWL_MsgKey* pMsg); |
266 FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, uint32_t dwCode, FX_FLOAT fPos); | 266 bool OnScroll(IFWL_ScrollBar* pScrollBar, uint32_t dwCode, FX_FLOAT fPos); |
267 }; | 267 }; |
268 | 268 |
269 #endif // XFA_FWL_CORE_IFWL_EDIT_H_ | 269 #endif // XFA_FWL_CORE_IFWL_EDIT_H_ |
OLD | NEW |