| 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_BASEWIDGET_FWL_EDITIMP_H_ |
| 8 #define XFA_FWL_BASEWIDGET_FWL_EDITIMP_H_ | 8 #define XFA_FWL_BASEWIDGET_FWL_EDITIMP_H_ |
| 9 | 9 |
| 10 #include <deque> |
| 10 #include <memory> | 11 #include <memory> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "xfa/fee/ifde_txtedtengine.h" | 14 #include "xfa/fee/ifde_txtedtengine.h" |
| 14 #include "xfa/fwl/basewidget/ifwl_scrollbar.h" | 15 #include "xfa/fwl/basewidget/ifwl_scrollbar.h" |
| 15 #include "xfa/fwl/core/fwl_widgetimp.h" | 16 #include "xfa/fwl/core/fwl_widgetimp.h" |
| 16 #include "xfa/fxgraphics/cfx_path.h" | 17 #include "xfa/fxgraphics/cfx_path.h" |
| 17 | 18 |
| 19 class CFWL_EditImp; |
| 20 class CFWL_EditImpDelegate; |
| 18 class CFWL_MsgActivate; | 21 class CFWL_MsgActivate; |
| 19 class CFWL_MsgDeactivate; | 22 class CFWL_MsgDeactivate; |
| 20 class CFWL_MsgMouse; | 23 class CFWL_MsgMouse; |
| 24 class CFWL_WidgetImpDelegate; |
| 21 class CFWL_WidgetImpProperties; | 25 class CFWL_WidgetImpProperties; |
| 22 class CFWL_WidgetImpDelegate; | 26 class IFDE_TxtEdtDoRecord; |
| 23 class IFWL_Caret; | 27 class IFWL_Caret; |
| 24 class CFWL_EditImp; | |
| 25 class CFWL_EditImpDelegate; | |
| 26 | 28 |
| 27 class CFWL_EditImp : public CFWL_WidgetImp { | 29 class CFWL_EditImp : public CFWL_WidgetImp { |
| 28 public: | 30 public: |
| 29 CFWL_EditImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); | 31 CFWL_EditImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); |
| 30 ~CFWL_EditImp() override; | 32 ~CFWL_EditImp() override; |
| 31 | 33 |
| 32 // CFWL_WidgetImp: | 34 // CFWL_WidgetImp: |
| 33 FWL_Error GetClassName(CFX_WideString& wsClass) const override; | 35 FWL_Error GetClassName(CFX_WideString& wsClass) const override; |
| 34 FWL_Type GetClassID() const override; | 36 FWL_Type GetClassID() const override; |
| 35 FWL_Error Initialize() override; | 37 FWL_Error Initialize() override; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 64 virtual FWL_Error DeleteSelections(); | 66 virtual FWL_Error DeleteSelections(); |
| 65 virtual FWL_Error DeleteRange(int32_t nStart, int32_t nCount = -1); | 67 virtual FWL_Error DeleteRange(int32_t nStart, int32_t nCount = -1); |
| 66 virtual FWL_Error Replace(int32_t nStart, | 68 virtual FWL_Error Replace(int32_t nStart, |
| 67 int32_t nLen, | 69 int32_t nLen, |
| 68 const CFX_WideStringC& wsReplace); | 70 const CFX_WideStringC& wsReplace); |
| 69 virtual FWL_Error DoClipboard(int32_t iCmd); | 71 virtual FWL_Error DoClipboard(int32_t iCmd); |
| 70 virtual FX_BOOL Copy(CFX_WideString& wsCopy); | 72 virtual FX_BOOL Copy(CFX_WideString& wsCopy); |
| 71 virtual FX_BOOL Cut(CFX_WideString& wsCut); | 73 virtual FX_BOOL Cut(CFX_WideString& wsCut); |
| 72 virtual FX_BOOL Paste(const CFX_WideString& wsPaste); | 74 virtual FX_BOOL Paste(const CFX_WideString& wsPaste); |
| 73 virtual FX_BOOL Delete(); | 75 virtual FX_BOOL Delete(); |
| 74 virtual FX_BOOL Redo(const CFX_ByteStringC& bsRecord); | 76 virtual FX_BOOL Redo(const IFDE_TxtEdtDoRecord* pRecord); |
| 75 virtual FX_BOOL Undo(const CFX_ByteStringC& bsRecord); | 77 virtual FX_BOOL Undo(const IFDE_TxtEdtDoRecord* pRecord); |
| 76 virtual FX_BOOL Undo(); | 78 virtual FX_BOOL Undo(); |
| 77 virtual FX_BOOL Redo(); | 79 virtual FX_BOOL Redo(); |
| 78 virtual FX_BOOL CanUndo(); | 80 virtual FX_BOOL CanUndo(); |
| 79 virtual FX_BOOL CanRedo(); | 81 virtual FX_BOOL CanRedo(); |
| 80 virtual FWL_Error SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant); | 82 virtual FWL_Error SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant); |
| 81 virtual FWL_Error SetOuter(IFWL_Widget* pOuter); | 83 virtual FWL_Error SetOuter(IFWL_Widget* pOuter); |
| 82 virtual FWL_Error SetNumberRange(int32_t iMin, int32_t iMax); | 84 virtual FWL_Error SetNumberRange(int32_t iMin, int32_t iMax); |
| 83 virtual FWL_Error SetBackgroundColor(uint32_t color); | 85 virtual FWL_Error SetBackgroundColor(uint32_t color); |
| 84 virtual FWL_Error SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize); | 86 virtual FWL_Error SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize); |
| 85 | 87 |
| 86 void On_CaretChanged(CFDE_TxtEdtEngine* pEdit, | 88 void On_CaretChanged(CFDE_TxtEdtEngine* pEdit, |
| 87 int32_t nPage, | 89 int32_t nPage, |
| 88 FX_BOOL bVisible = true); | 90 FX_BOOL bVisible = true); |
| 89 void On_TextChanged(CFDE_TxtEdtEngine* pEdit, | 91 void On_TextChanged(CFDE_TxtEdtEngine* pEdit, |
| 90 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo); | 92 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo); |
| 91 void On_SelChanged(CFDE_TxtEdtEngine* pEdit); | 93 void On_SelChanged(CFDE_TxtEdtEngine* pEdit); |
| 92 FX_BOOL On_PageLoad(CFDE_TxtEdtEngine* pEdit, | 94 FX_BOOL On_PageLoad(CFDE_TxtEdtEngine* pEdit, |
| 93 int32_t nPageIndex, | 95 int32_t nPageIndex, |
| 94 int32_t nPurpose); | 96 int32_t nPurpose); |
| 95 FX_BOOL On_PageUnload(CFDE_TxtEdtEngine* pEdit, | 97 FX_BOOL On_PageUnload(CFDE_TxtEdtEngine* pEdit, |
| 96 int32_t nPageIndex, | 98 int32_t nPageIndex, |
| 97 int32_t nPurpose); | 99 int32_t nPurpose); |
| 98 void On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, | 100 void On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, IFDE_TxtEdtDoRecord* pRecord); |
| 99 const CFX_ByteStringC& bsDoRecord); | |
| 100 FX_BOOL On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText); | 101 FX_BOOL On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText); |
| 101 void SetScrollOffset(FX_FLOAT fScrollOffset); | 102 void SetScrollOffset(FX_FLOAT fScrollOffset); |
| 102 FX_BOOL GetSuggestWords(CFX_PointF pointf, | 103 FX_BOOL GetSuggestWords(CFX_PointF pointf, |
| 103 std::vector<CFX_ByteString>& sSuggest); | 104 std::vector<CFX_ByteString>& sSuggest); |
| 104 FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, | 105 FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, |
| 105 const CFX_ByteStringC& bsReplace); | 106 const CFX_ByteStringC& bsReplace); |
| 106 | 107 |
| 107 protected: | 108 protected: |
| 109 friend class CFWL_TxtEdtEventSink; |
| 110 friend class CFWL_EditImpDelegate; |
| 111 |
| 108 void DrawTextBk(CFX_Graphics* pGraphics, | 112 void DrawTextBk(CFX_Graphics* pGraphics, |
| 109 IFWL_ThemeProvider* pTheme, | 113 IFWL_ThemeProvider* pTheme, |
| 110 const CFX_Matrix* pMatrix = NULL); | 114 const CFX_Matrix* pMatrix = NULL); |
| 111 void DrawContent(CFX_Graphics* pGraphics, | 115 void DrawContent(CFX_Graphics* pGraphics, |
| 112 IFWL_ThemeProvider* pTheme, | 116 IFWL_ThemeProvider* pTheme, |
| 113 const CFX_Matrix* pMatrix = NULL); | 117 const CFX_Matrix* pMatrix = NULL); |
| 114 void UpdateEditEngine(); | 118 void UpdateEditEngine(); |
| 115 void UpdateEditParams(); | 119 void UpdateEditParams(); |
| 116 void UpdateEditLayout(); | 120 void UpdateEditLayout(); |
| 117 FX_BOOL UpdateOffset(); | 121 FX_BOOL UpdateOffset(); |
| 118 FX_BOOL UpdateOffset(IFWL_ScrollBar* pScrollBar, FX_FLOAT fPosChanged); | 122 FX_BOOL UpdateOffset(IFWL_ScrollBar* pScrollBar, FX_FLOAT fPosChanged); |
| 119 void UpdateVAlignment(); | 123 void UpdateVAlignment(); |
| 120 void UpdateCaret(); | 124 void UpdateCaret(); |
| 121 IFWL_ScrollBar* UpdateScroll(); | 125 IFWL_ScrollBar* UpdateScroll(); |
| 122 void Layout(); | 126 void Layout(); |
| 123 void LayoutScrollBar(); | 127 void LayoutScrollBar(); |
| 124 void DeviceToEngine(CFX_PointF& pt); | 128 void DeviceToEngine(CFX_PointF& pt); |
| 125 void InitScrollBar(FX_BOOL bVert = TRUE); | 129 void InitScrollBar(FX_BOOL bVert = TRUE); |
| 126 void InitEngine(); | 130 void InitEngine(); |
| 127 virtual void ShowCaret(FX_BOOL bVisible, CFX_RectF* pRect = NULL); | 131 virtual void ShowCaret(FX_BOOL bVisible, CFX_RectF* pRect = NULL); |
| 128 FX_BOOL ValidateNumberChar(FX_WCHAR cNum); | 132 FX_BOOL ValidateNumberChar(FX_WCHAR cNum); |
| 129 void InitCaret(); | 133 void InitCaret(); |
| 130 void ClearRecord(); | 134 void ClearRecord(); |
| 131 FX_BOOL IsShowScrollBar(FX_BOOL bVert); | 135 FX_BOOL IsShowScrollBar(FX_BOOL bVert); |
| 132 FX_BOOL IsContentHeightOverflow(); | 136 FX_BOOL IsContentHeightOverflow(); |
| 133 int32_t AddDoRecord(const CFX_ByteStringC& bsDoRecord); | 137 int32_t AddDoRecord(IFDE_TxtEdtDoRecord* pRecord); |
| 134 void ProcessInsertError(int32_t iError); | 138 void ProcessInsertError(int32_t iError); |
| 135 | 139 |
| 136 void DrawSpellCheck(CFX_Graphics* pGraphics, | 140 void DrawSpellCheck(CFX_Graphics* pGraphics, |
| 137 const CFX_Matrix* pMatrix = NULL); | 141 const CFX_Matrix* pMatrix = NULL); |
| 138 void AddSpellCheckObj(CFX_Path& PathData, | 142 void AddSpellCheckObj(CFX_Path& PathData, |
| 139 int32_t nStart, | 143 int32_t nStart, |
| 140 int32_t nCount, | 144 int32_t nCount, |
| 141 FX_FLOAT fOffSetX, | 145 FX_FLOAT fOffSetX, |
| 142 FX_FLOAT fOffSetY); | 146 FX_FLOAT fOffSetY); |
| 143 int32_t GetWordAtPoint(CFX_PointF pointf, int32_t& nCount); | 147 int32_t GetWordAtPoint(CFX_PointF pointf, int32_t& nCount); |
| 148 |
| 144 CFX_RectF m_rtClient; | 149 CFX_RectF m_rtClient; |
| 145 CFX_RectF m_rtEngine; | 150 CFX_RectF m_rtEngine; |
| 146 CFX_RectF m_rtStatic; | 151 CFX_RectF m_rtStatic; |
| 147 FX_FLOAT m_fVAlignOffset; | 152 FX_FLOAT m_fVAlignOffset; |
| 148 FX_FLOAT m_fScrollOffsetX; | 153 FX_FLOAT m_fScrollOffsetX; |
| 149 FX_FLOAT m_fScrollOffsetY; | 154 FX_FLOAT m_fScrollOffsetY; |
| 150 CFDE_TxtEdtEngine* m_pEdtEngine; | 155 CFDE_TxtEdtEngine* m_pEdtEngine; |
| 151 FX_BOOL m_bLButtonDown; | 156 FX_BOOL m_bLButtonDown; |
| 152 int32_t m_nSelStart; | 157 int32_t m_nSelStart; |
| 153 int32_t m_nLimit; | 158 int32_t m_nLimit; |
| 154 FX_FLOAT m_fSpaceAbove; | 159 FX_FLOAT m_fSpaceAbove; |
| 155 FX_FLOAT m_fSpaceBelow; | 160 FX_FLOAT m_fSpaceBelow; |
| 156 FX_FLOAT m_fFontSize; | 161 FX_FLOAT m_fFontSize; |
| 157 FX_ARGB m_argbSel; | 162 FX_ARGB m_argbSel; |
| 158 FX_BOOL m_bSetRange; | 163 FX_BOOL m_bSetRange; |
| 159 int32_t m_iMin; | 164 int32_t m_iMin; |
| 160 int32_t m_iMax; | 165 int32_t m_iMax; |
| 161 std::unique_ptr<IFWL_ScrollBar> m_pVertScrollBar; | 166 std::unique_ptr<IFWL_ScrollBar> m_pVertScrollBar; |
| 162 std::unique_ptr<IFWL_ScrollBar> m_pHorzScrollBar; | 167 std::unique_ptr<IFWL_ScrollBar> m_pHorzScrollBar; |
| 163 std::unique_ptr<IFWL_Caret> m_pCaret; | 168 std::unique_ptr<IFWL_Caret> m_pCaret; |
| 164 CFX_WideString m_wsCache; | 169 CFX_WideString m_wsCache; |
| 165 friend class CFWL_TxtEdtEventSink; | |
| 166 friend class CFWL_EditImpDelegate; | |
| 167 uint32_t m_backColor; | 170 uint32_t m_backColor; |
| 168 FX_BOOL m_updateBackColor; | 171 FX_BOOL m_updateBackColor; |
| 169 CFX_WideString m_wsFont; | 172 CFX_WideString m_wsFont; |
| 170 CFX_ByteStringArray m_RecordArr; | 173 std::deque<std::unique_ptr<IFDE_TxtEdtDoRecord>> m_DoRecords; |
| 171 int32_t m_iCurRecord; | 174 int32_t m_iCurRecord; |
| 172 int32_t m_iMaxRecord; | 175 int32_t m_iMaxRecord; |
| 173 }; | 176 }; |
| 174 | 177 |
| 175 class CFWL_EditImpDelegate : public CFWL_WidgetImpDelegate { | 178 class CFWL_EditImpDelegate : public CFWL_WidgetImpDelegate { |
| 176 public: | 179 public: |
| 177 CFWL_EditImpDelegate(CFWL_EditImp* pOwner); | 180 CFWL_EditImpDelegate(CFWL_EditImp* pOwner); |
| 178 void OnProcessMessage(CFWL_Message* pMessage) override; | 181 void OnProcessMessage(CFWL_Message* pMessage) override; |
| 179 void OnProcessEvent(CFWL_Event* pEvent) override; | 182 void OnProcessEvent(CFWL_Event* pEvent) override; |
| 180 void OnDrawWidget(CFX_Graphics* pGraphics, | 183 void OnDrawWidget(CFX_Graphics* pGraphics, |
| 181 const CFX_Matrix* pMatrix = NULL) override; | 184 const CFX_Matrix* pMatrix = NULL) override; |
| 182 | 185 |
| 183 protected: | 186 protected: |
| 184 void DoActivate(CFWL_MsgActivate* pMsg); | 187 void DoActivate(CFWL_MsgActivate* pMsg); |
| 185 void DoDeactivate(CFWL_MsgDeactivate* pMsg); | 188 void DoDeactivate(CFWL_MsgDeactivate* pMsg); |
| 186 void DoButtonDown(CFWL_MsgMouse* pMsg); | 189 void DoButtonDown(CFWL_MsgMouse* pMsg); |
| 187 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); | 190 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); |
| 188 void OnLButtonDown(CFWL_MsgMouse* pMsg); | 191 void OnLButtonDown(CFWL_MsgMouse* pMsg); |
| 189 void OnLButtonUp(CFWL_MsgMouse* pMsg); | 192 void OnLButtonUp(CFWL_MsgMouse* pMsg); |
| 190 void OnButtonDblClk(CFWL_MsgMouse* pMsg); | 193 void OnButtonDblClk(CFWL_MsgMouse* pMsg); |
| 191 void OnMouseMove(CFWL_MsgMouse* pMsg); | 194 void OnMouseMove(CFWL_MsgMouse* pMsg); |
| 192 void OnKeyDown(CFWL_MsgKey* pMsg); | 195 void OnKeyDown(CFWL_MsgKey* pMsg); |
| 193 void OnChar(CFWL_MsgKey* pMsg); | 196 void OnChar(CFWL_MsgKey* pMsg); |
| 194 FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, uint32_t dwCode, FX_FLOAT fPos); | 197 FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, uint32_t dwCode, FX_FLOAT fPos); |
| 195 void DoCursor(CFWL_MsgMouse* pMsg); | 198 void DoCursor(CFWL_MsgMouse* pMsg); |
| 196 CFWL_EditImp* m_pOwner; | 199 CFWL_EditImp* m_pOwner; |
| 197 }; | 200 }; |
| 198 | 201 |
| 199 #endif // XFA_FWL_BASEWIDGET_FWL_EDITIMP_H_ | 202 #endif // XFA_FWL_BASEWIDGET_FWL_EDITIMP_H_ |
| OLD | NEW |