| 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 FPDFSDK_PDFWINDOW_PWL_EDITCTRL_H_ | 7 #ifndef FPDFSDK_PDFWINDOW_PWL_EDITCTRL_H_ |
| 8 #define FPDFSDK_PDFWINDOW_PWL_EDITCTRL_H_ | 8 #define FPDFSDK_PDFWINDOW_PWL_EDITCTRL_H_ |
| 9 | 9 |
| 10 #include "core/fxcrt/include/fx_string.h" | 10 #include "core/fxcrt/include/fx_string.h" |
| 11 #include "fpdfsdk/fxedit/include/fx_edit.h" | 11 #include "fpdfsdk/fxedit/include/fx_edit.h" |
| 12 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" | 12 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" |
| 13 | 13 |
| 14 class CFX_Edit; | 14 class CFX_Edit; |
| 15 class CPWL_Caret; | 15 class CPWL_Caret; |
| 16 class CPWL_Edit; | 16 class CPWL_Edit; |
| 17 class CPWL_EditCtrl; | 17 class CPWL_EditCtrl; |
| 18 class IPWL_Edit_Notify; | |
| 19 struct CPVT_SecProps; | 18 struct CPVT_SecProps; |
| 20 struct CPVT_WordPlace; | 19 struct CPVT_WordPlace; |
| 21 struct CPVT_WordProps; | 20 struct CPVT_WordProps; |
| 22 struct CPVT_WordRange; | 21 struct CPVT_WordRange; |
| 23 | 22 |
| 24 enum PWL_EDIT_ALIGNFORMAT_H { PEAH_LEFT = 0, PEAH_MIDDLE, PEAH_RIGHT }; | 23 enum PWL_EDIT_ALIGNFORMAT_H { PEAH_LEFT = 0, PEAH_MIDDLE, PEAH_RIGHT }; |
| 25 | 24 |
| 26 enum PWL_EDIT_ALIGNFORMAT_V { PEAV_TOP = 0, PEAV_CENTER, PEAV_BOTTOM }; | 25 enum PWL_EDIT_ALIGNFORMAT_V { PEAV_TOP = 0, PEAV_CENTER, PEAV_BOTTOM }; |
| 27 | 26 |
| 28 class IPWL_Edit_Notify { | |
| 29 public: | |
| 30 virtual ~IPWL_Edit_Notify() {} | |
| 31 // when the position of caret is changed in edit | |
| 32 virtual void OnCaretMove(int32_t x1, int32_t y1, int32_t x2, int32_t y2) {} | |
| 33 virtual void OnContentChange(const CFX_FloatRect& rcContent) {} | |
| 34 // OprType: 0 InsertWord | |
| 35 // 1 InsertReturn | |
| 36 // 2 BackSpace | |
| 37 // 3 Delete | |
| 38 // 4 Clear | |
| 39 // 5 InsertText | |
| 40 // 6 SetText | |
| 41 virtual void OnInsertWord(const CPVT_WordPlace& place, | |
| 42 const CPVT_WordPlace& oldplace) {} | |
| 43 virtual void OnInsertReturn(const CPVT_WordPlace& place, | |
| 44 const CPVT_WordPlace& oldplace) {} | |
| 45 virtual void OnBackSpace(const CPVT_WordPlace& place, | |
| 46 const CPVT_WordPlace& oldplace) {} | |
| 47 virtual void OnDelete(const CPVT_WordPlace& place, | |
| 48 const CPVT_WordPlace& oldplace) {} | |
| 49 virtual void OnClear(const CPVT_WordPlace& place, | |
| 50 const CPVT_WordPlace& oldplace) {} | |
| 51 virtual void OnInsertText(const CPVT_WordPlace& place, | |
| 52 const CPVT_WordPlace& oldplace) {} | |
| 53 virtual void OnSetText(const CPVT_WordPlace& place, | |
| 54 const CPVT_WordPlace& oldplace) {} | |
| 55 virtual void OnAddUndo(CPWL_Edit* pEdit) {} | |
| 56 }; | |
| 57 | |
| 58 class CPWL_EditCtrl : public CPWL_Wnd { | 27 class CPWL_EditCtrl : public CPWL_Wnd { |
| 59 friend class CPWL_Edit_Notify; | 28 friend class CPWL_Edit_Notify; |
| 60 | 29 |
| 61 public: | 30 public: |
| 62 CPWL_EditCtrl(); | 31 CPWL_EditCtrl(); |
| 63 ~CPWL_EditCtrl() override; | 32 ~CPWL_EditCtrl() override; |
| 64 | 33 |
| 65 CFX_FloatRect GetContentRect() const; | 34 CFX_FloatRect GetContentRect() const; |
| 66 void GetCaretPos(int32_t& x, int32_t& y) const; | 35 void GetCaretPos(int32_t& x, int32_t& y) const; |
| 67 | 36 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 78 int32_t GetCaret() const; | 47 int32_t GetCaret() const; |
| 79 void SetCaret(int32_t nPos); | 48 void SetCaret(int32_t nPos); |
| 80 int32_t GetTotalWords() const; | 49 int32_t GetTotalWords() const; |
| 81 | 50 |
| 82 void Paint(); | 51 void Paint(); |
| 83 | 52 |
| 84 void EnableRefresh(FX_BOOL bRefresh); | 53 void EnableRefresh(FX_BOOL bRefresh); |
| 85 CFX_FloatPoint GetScrollPos() const; | 54 CFX_FloatPoint GetScrollPos() const; |
| 86 void SetScrollPos(const CFX_FloatPoint& point); | 55 void SetScrollPos(const CFX_FloatPoint& point); |
| 87 | 56 |
| 88 void SetEditNotify(IPWL_Edit_Notify* pNotify) { m_pEditNotify = pNotify; } | |
| 89 | |
| 90 void SetCharSet(uint8_t nCharSet) { m_nCharSet = nCharSet; } | 57 void SetCharSet(uint8_t nCharSet) { m_nCharSet = nCharSet; } |
| 91 int32_t GetCharSet() const; | 58 int32_t GetCharSet() const; |
| 92 | 59 |
| 93 void SetCodePage(int32_t nCodePage) { m_nCodePage = nCodePage; } | 60 void SetCodePage(int32_t nCodePage) { m_nCodePage = nCodePage; } |
| 94 int32_t GetCodePage() const { return m_nCodePage; } | 61 int32_t GetCodePage() const { return m_nCodePage; } |
| 95 | 62 |
| 96 CPDF_Font* GetCaretFont() const; | 63 CPDF_Font* GetCaretFont() const; |
| 97 FX_FLOAT GetCaretFontSize() const; | 64 FX_FLOAT GetCaretFontSize() const; |
| 98 | 65 |
| 99 FX_BOOL CanUndo() const; | 66 FX_BOOL CanUndo() const; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 void GetCaretInfo(CFX_FloatPoint& ptHead, CFX_FloatPoint& ptFoot) const; | 122 void GetCaretInfo(CFX_FloatPoint& ptHead, CFX_FloatPoint& ptFoot) const; |
| 156 void SetCaret(FX_BOOL bVisible, | 123 void SetCaret(FX_BOOL bVisible, |
| 157 const CFX_FloatPoint& ptHead, | 124 const CFX_FloatPoint& ptHead, |
| 158 const CFX_FloatPoint& ptFoot); | 125 const CFX_FloatPoint& ptFoot); |
| 159 | 126 |
| 160 void SetEditCaret(FX_BOOL bVisible); | 127 void SetEditCaret(FX_BOOL bVisible); |
| 161 | 128 |
| 162 std::unique_ptr<CFX_Edit> m_pEdit; | 129 std::unique_ptr<CFX_Edit> m_pEdit; |
| 163 CPWL_Caret* m_pEditCaret; | 130 CPWL_Caret* m_pEditCaret; |
| 164 FX_BOOL m_bMouseDown; | 131 FX_BOOL m_bMouseDown; |
| 165 IPWL_Edit_Notify* m_pEditNotify; | |
| 166 | 132 |
| 167 private: | 133 private: |
| 168 void CreateEditCaret(const PWL_CREATEPARAM& cp); | 134 void CreateEditCaret(const PWL_CREATEPARAM& cp); |
| 169 | 135 |
| 170 int32_t m_nCharSet; | 136 int32_t m_nCharSet; |
| 171 int32_t m_nCodePage; | 137 int32_t m_nCodePage; |
| 172 }; | 138 }; |
| 173 | 139 |
| 174 #endif // FPDFSDK_PDFWINDOW_PWL_EDITCTRL_H_ | 140 #endif // FPDFSDK_PDFWINDOW_PWL_EDITCTRL_H_ |
| OLD | NEW |