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_BASEWIDGET_FWL_EDITIMP_H_ | 7 #ifndef XFA_FWL_CORE_IFWL_EDIT_H_ |
8 #define XFA_FWL_BASEWIDGET_FWL_EDITIMP_H_ | 8 #define XFA_FWL_CORE_IFWL_EDIT_H_ |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
11 #include <memory> | 11 #include <memory> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "xfa/fde/ifde_txtedtdorecord.h" | 14 #include "xfa/fde/ifde_txtedtdorecord.h" |
15 #include "xfa/fde/ifde_txtedtengine.h" | 15 #include "xfa/fde/ifde_txtedtengine.h" |
16 #include "xfa/fwl/basewidget/ifwl_scrollbar.h" | 16 #include "xfa/fwl/core/cfwl_event.h" |
17 #include "xfa/fwl/core/fwl_widgetimp.h" | 17 #include "xfa/fwl/core/ifwl_dataprovider.h" |
| 18 #include "xfa/fwl/core/ifwl_scrollbar.h" |
| 19 #include "xfa/fwl/lightwidget/cfwl_widget.h" |
18 #include "xfa/fxgraphics/cfx_path.h" | 20 #include "xfa/fxgraphics/cfx_path.h" |
19 | 21 |
20 class CFWL_EditImp; | 22 #define FWL_CLASS_Edit L"FWL_EDIT" |
| 23 #define FWL_STYLEEXT_EDT_ReadOnly (1L << 0) |
| 24 #define FWL_STYLEEXT_EDT_MultiLine (1L << 1) |
| 25 #define FWL_STYLEEXT_EDT_WantReturn (1L << 2) |
| 26 #define FWL_STYLEEXT_EDT_NoHideSel (1L << 3) |
| 27 #define FWL_STYLEEXT_EDT_AutoHScroll (1L << 4) |
| 28 #define FWL_STYLEEXT_EDT_AutoVScroll (1L << 5) |
| 29 #define FWL_STYLEEXT_EDT_NoRedoUndo (1L << 6) |
| 30 #define FWL_STYLEEXT_EDT_Validate (1L << 7) |
| 31 #define FWL_STYLEEXT_EDT_Password (1L << 8) |
| 32 #define FWL_STYLEEXT_EDT_Number (1L << 9) |
| 33 #define FWL_STYLEEXT_EDT_HSelfAdaption (1L << 10) |
| 34 #define FWL_STYLEEXT_EDT_VSelfAdaption (1L << 11) |
| 35 #define FWL_STYLEEXT_EDT_VerticalLayout (1L << 12) |
| 36 #define FWL_STYLEEXT_EDT_VerticalChars (1L << 13) |
| 37 #define FWL_STYLEEXT_EDT_ReverseLine (1L << 14) |
| 38 #define FWL_STYLEEXT_EDT_ArabicShapes (1L << 15) |
| 39 #define FWL_STYLEEXT_EDT_ExpandTab (1L << 16) |
| 40 #define FWL_STYLEEXT_EDT_CombText (1L << 17) |
| 41 #define FWL_STYLEEXT_EDT_HNear (0L << 18) |
| 42 #define FWL_STYLEEXT_EDT_HCenter (1L << 18) |
| 43 #define FWL_STYLEEXT_EDT_HFar (2L << 18) |
| 44 #define FWL_STYLEEXT_EDT_VNear (0L << 20) |
| 45 #define FWL_STYLEEXT_EDT_VCenter (1L << 20) |
| 46 #define FWL_STYLEEXT_EDT_VFar (2L << 20) |
| 47 #define FWL_STYLEEXT_EDT_Justified (1L << 22) |
| 48 #define FWL_STYLEEXT_EDT_Distributed (2L << 22) |
| 49 #define FWL_STYLEEXT_EDT_HAlignMask (3L << 18) |
| 50 #define FWL_STYLEEXT_EDT_VAlignMask (3L << 20) |
| 51 #define FWL_STYLEEXT_EDT_HAlignModeMask (3L << 22) |
| 52 #define FWL_STYLEEXT_EDT_InnerCaret (1L << 24) |
| 53 #define FWL_STYLEEXT_EDT_ShowScrollbarFocus (1L << 25) |
| 54 #define FWL_STYLEEXT_EDT_OuterScrollbar (1L << 26) |
| 55 #define FWL_STYLEEXT_EDT_LastLineHeight (1L << 27) |
| 56 |
| 57 enum FWL_EDT_TEXTCHANGED { |
| 58 FWL_EDT_TEXTCHANGED_Insert = 0, |
| 59 FWL_EDT_TEXTCHANGED_Delete, |
| 60 FWL_EDT_TEXTCHANGED_Replace, |
| 61 }; |
| 62 |
| 63 FWL_EVENT_DEF(CFWL_EvtEdtTextChanged, |
| 64 CFWL_EventType::TextChanged, |
| 65 int32_t nChangeType; |
| 66 CFX_WideString wsInsert; |
| 67 CFX_WideString wsDelete; |
| 68 CFX_WideString wsPrevText;) |
| 69 |
| 70 FWL_EVENT_DEF(CFWL_EvtEdtTextFull, CFWL_EventType::TextFull) |
| 71 |
| 72 FWL_EVENT_DEF(CFWL_EvtEdtPreSelfAdaption, |
| 73 CFWL_EventType::PreSelfAdaption, |
| 74 FX_BOOL bHSelfAdaption; |
| 75 FX_BOOL bVSelfAdaption; |
| 76 CFX_RectF rtAfterChange;) |
| 77 |
| 78 FWL_EVENT_DEF(CFWL_EvtEdtValidate, |
| 79 CFWL_EventType::Validate, |
| 80 IFWL_Widget* pDstWidget; |
| 81 CFX_WideString wsInsert; |
| 82 FX_BOOL bValidate;) |
| 83 |
| 84 FWL_EVENT_DEF(CFWL_EvtEdtCheckWord, |
| 85 CFWL_EventType::CheckWord, |
| 86 CFX_ByteString bsWord; |
| 87 FX_BOOL bCheckWord;) |
| 88 |
| 89 FWL_EVENT_DEF(CFWL_EvtEdtGetSuggestWords, |
| 90 CFWL_EventType::GetSuggestedWords, |
| 91 FX_BOOL bSuggestWords; |
| 92 CFX_ByteString bsWord; |
| 93 std::vector<CFX_ByteString> bsArraySuggestWords;) |
| 94 |
| 95 class CFWL_WidgetImpProperties; |
| 96 class IFDE_TxtEdtDoRecord; |
| 97 class IFWL_Edit; |
21 class CFWL_EditImpDelegate; | 98 class CFWL_EditImpDelegate; |
22 class CFWL_MsgActivate; | 99 class CFWL_MsgActivate; |
23 class CFWL_MsgDeactivate; | 100 class CFWL_MsgDeactivate; |
24 class CFWL_MsgMouse; | 101 class CFWL_MsgMouse; |
25 class CFWL_WidgetImpDelegate; | 102 class CFWL_WidgetImpDelegate; |
26 class CFWL_WidgetImpProperties; | 103 class CFWL_WidgetImpProperties; |
27 class IFWL_Caret; | 104 class IFWL_Caret; |
28 | 105 |
29 class CFWL_EditImp : public CFWL_WidgetImp { | 106 class IFWL_EditDP : public IFWL_DataProvider {}; |
| 107 |
| 108 class IFWL_Edit : public IFWL_Widget { |
30 public: | 109 public: |
31 CFWL_EditImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); | 110 static IFWL_Edit* Create(const CFWL_WidgetImpProperties& properties, |
32 ~CFWL_EditImp() override; | 111 IFWL_Widget* pOuter); |
33 | 112 |
34 // CFWL_WidgetImp: | 113 IFWL_Edit(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); |
| 114 ~IFWL_Edit() override; |
| 115 |
| 116 // IFWL_Widget: |
35 FWL_Error GetClassName(CFX_WideString& wsClass) const override; | 117 FWL_Error GetClassName(CFX_WideString& wsClass) const override; |
36 FWL_Type GetClassID() const override; | 118 FWL_Type GetClassID() const override; |
37 FWL_Error Initialize() override; | 119 FWL_Error Initialize() override; |
38 FWL_Error Finalize() override; | 120 FWL_Error Finalize() override; |
39 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override; | 121 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override; |
40 FWL_Error SetWidgetRect(const CFX_RectF& rect) override; | 122 FWL_Error SetWidgetRect(const CFX_RectF& rect) override; |
41 FWL_Error Update() override; | 123 FWL_Error Update() override; |
42 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; | 124 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; |
43 void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE) override; | 125 void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE) override; |
44 FWL_Error DrawWidget(CFX_Graphics* pGraphics, | 126 FWL_Error DrawWidget(CFX_Graphics* pGraphics, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 uint32_t m_backColor; | 252 uint32_t m_backColor; |
171 FX_BOOL m_updateBackColor; | 253 FX_BOOL m_updateBackColor; |
172 CFX_WideString m_wsFont; | 254 CFX_WideString m_wsFont; |
173 std::deque<std::unique_ptr<IFDE_TxtEdtDoRecord>> m_DoRecords; | 255 std::deque<std::unique_ptr<IFDE_TxtEdtDoRecord>> m_DoRecords; |
174 int32_t m_iCurRecord; | 256 int32_t m_iCurRecord; |
175 int32_t m_iMaxRecord; | 257 int32_t m_iMaxRecord; |
176 }; | 258 }; |
177 | 259 |
178 class CFWL_EditImpDelegate : public CFWL_WidgetImpDelegate { | 260 class CFWL_EditImpDelegate : public CFWL_WidgetImpDelegate { |
179 public: | 261 public: |
180 CFWL_EditImpDelegate(CFWL_EditImp* pOwner); | 262 CFWL_EditImpDelegate(IFWL_Edit* pOwner); |
181 void OnProcessMessage(CFWL_Message* pMessage) override; | 263 void OnProcessMessage(CFWL_Message* pMessage) override; |
182 void OnProcessEvent(CFWL_Event* pEvent) override; | 264 void OnProcessEvent(CFWL_Event* pEvent) override; |
183 void OnDrawWidget(CFX_Graphics* pGraphics, | 265 void OnDrawWidget(CFX_Graphics* pGraphics, |
184 const CFX_Matrix* pMatrix = nullptr) override; | 266 const CFX_Matrix* pMatrix = nullptr) override; |
185 | 267 |
186 protected: | 268 protected: |
187 void DoActivate(CFWL_MsgActivate* pMsg); | 269 void DoActivate(CFWL_MsgActivate* pMsg); |
188 void DoDeactivate(CFWL_MsgDeactivate* pMsg); | 270 void DoDeactivate(CFWL_MsgDeactivate* pMsg); |
189 void DoButtonDown(CFWL_MsgMouse* pMsg); | 271 void DoButtonDown(CFWL_MsgMouse* pMsg); |
190 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); | 272 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); |
191 void OnLButtonDown(CFWL_MsgMouse* pMsg); | 273 void OnLButtonDown(CFWL_MsgMouse* pMsg); |
192 void OnLButtonUp(CFWL_MsgMouse* pMsg); | 274 void OnLButtonUp(CFWL_MsgMouse* pMsg); |
193 void OnButtonDblClk(CFWL_MsgMouse* pMsg); | 275 void OnButtonDblClk(CFWL_MsgMouse* pMsg); |
194 void OnMouseMove(CFWL_MsgMouse* pMsg); | 276 void OnMouseMove(CFWL_MsgMouse* pMsg); |
195 void OnKeyDown(CFWL_MsgKey* pMsg); | 277 void OnKeyDown(CFWL_MsgKey* pMsg); |
196 void OnChar(CFWL_MsgKey* pMsg); | 278 void OnChar(CFWL_MsgKey* pMsg); |
197 FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, uint32_t dwCode, FX_FLOAT fPos); | 279 FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, uint32_t dwCode, FX_FLOAT fPos); |
198 void DoCursor(CFWL_MsgMouse* pMsg); | 280 void DoCursor(CFWL_MsgMouse* pMsg); |
199 CFWL_EditImp* m_pOwner; | 281 IFWL_Edit* m_pOwner; |
200 }; | 282 }; |
201 | 283 |
202 #endif // XFA_FWL_BASEWIDGET_FWL_EDITIMP_H_ | 284 #endif // XFA_FWL_CORE_IFWL_EDIT_H_ |
OLD | NEW |