| 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_INCLUDE_PDFWINDOW_PWL_EDITCTRL_H_ | 7 #ifndef FPDFSDK_INCLUDE_PDFWINDOW_PWL_EDITCTRL_H_ |
| 8 #define FPDFSDK_INCLUDE_PDFWINDOW_PWL_EDITCTRL_H_ | 8 #define FPDFSDK_INCLUDE_PDFWINDOW_PWL_EDITCTRL_H_ |
| 9 | 9 |
| 10 #include "core/include/fxcrt/fx_string.h" | 10 #include "core/include/fxcrt/fx_string.h" |
| 11 #include "fpdfsdk/include/fxedit/fx_edit.h" | 11 #include "fpdfsdk/include/fxedit/fx_edit.h" |
| 12 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" | 12 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" |
| 13 | 13 |
| 14 class CPWL_Caret; | 14 class CPWL_Caret; |
| 15 class CPWL_Edit; | 15 class CPWL_Edit; |
| 16 class CPWL_EditCtrl; | 16 class CPWL_EditCtrl; |
| 17 class IFX_Edit; | 17 class IFX_Edit; |
| 18 class IPWL_Edit_Notify; | 18 class IPWL_Edit_Notify; |
| 19 struct CPVT_WordPlace; | 19 struct CPVT_WordPlace; |
| 20 | 20 |
| 21 enum PWL_EDIT_ALIGNFORMAT_H { PEAH_LEFT = 0, PEAH_MIDDLE, PEAH_RIGHT }; | 21 enum PWL_EDIT_ALIGNFORMAT_H { PEAH_LEFT = 0, PEAH_MIDDLE, PEAH_RIGHT }; |
| 22 | 22 |
| 23 enum PWL_EDIT_ALIGNFORMAT_V { PEAV_TOP = 0, PEAV_CENTER, PEAV_BOTTOM }; | 23 enum PWL_EDIT_ALIGNFORMAT_V { PEAV_TOP = 0, PEAV_CENTER, PEAV_BOTTOM }; |
| 24 | 24 |
| 25 class IPWL_Edit_Notify { | 25 class IPWL_Edit_Notify { |
| 26 public: | 26 public: |
| 27 virtual ~IPWL_Edit_Notify() {} | 27 virtual ~IPWL_Edit_Notify() {} |
| 28 // when the position of caret is changed in edit | 28 // when the position of caret is changed in edit |
| 29 virtual void OnCaretMove(int32_t x1, int32_t y1, int32_t x2, int32_t y2) {} | 29 virtual void OnCaretMove(int32_t x1, int32_t y1, int32_t x2, int32_t y2) {} |
| 30 virtual void OnContentChange(const CFX_FloatRect& rcContent) {} | 30 virtual void OnContentChange(const CPDF_Rect& rcContent) {} |
| 31 // OprType: 0 InsertWord | 31 // OprType: 0 InsertWord |
| 32 // 1 InsertReturn | 32 // 1 InsertReturn |
| 33 // 2 BackSpace | 33 // 2 BackSpace |
| 34 // 3 Delete | 34 // 3 Delete |
| 35 // 4 Clear | 35 // 4 Clear |
| 36 // 5 InsertText | 36 // 5 InsertText |
| 37 // 6 SetText | 37 // 6 SetText |
| 38 virtual void OnInsertWord(const CPVT_WordPlace& place, | 38 virtual void OnInsertWord(const CPVT_WordPlace& place, |
| 39 const CPVT_WordPlace& oldplace) {} | 39 const CPVT_WordPlace& oldplace) {} |
| 40 virtual void OnInsertReturn(const CPVT_WordPlace& place, | 40 virtual void OnInsertReturn(const CPVT_WordPlace& place, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 52 virtual void OnAddUndo(CPWL_Edit* pEdit) {} | 52 virtual void OnAddUndo(CPWL_Edit* pEdit) {} |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 class CPWL_EditCtrl : public CPWL_Wnd, public IFX_Edit_Notify { | 55 class CPWL_EditCtrl : public CPWL_Wnd, public IFX_Edit_Notify { |
| 56 friend class CPWL_Edit_Notify; | 56 friend class CPWL_Edit_Notify; |
| 57 | 57 |
| 58 public: | 58 public: |
| 59 CPWL_EditCtrl(); | 59 CPWL_EditCtrl(); |
| 60 ~CPWL_EditCtrl() override; | 60 ~CPWL_EditCtrl() override; |
| 61 | 61 |
| 62 CFX_FloatRect GetContentRect() const; | 62 CPDF_Rect GetContentRect() const; |
| 63 void GetCaretPos(int32_t& x, int32_t& y) const; | 63 void GetCaretPos(int32_t& x, int32_t& y) const; |
| 64 | 64 |
| 65 CFX_WideString GetText() const; | 65 CFX_WideString GetText() const; |
| 66 void SetSel(int32_t nStartChar, int32_t nEndChar); | 66 void SetSel(int32_t nStartChar, int32_t nEndChar); |
| 67 void GetSel(int32_t& nStartChar, int32_t& nEndChar) const; | 67 void GetSel(int32_t& nStartChar, int32_t& nEndChar) const; |
| 68 void GetTextRange(const CFX_FloatRect& rect, | 68 void GetTextRange(const CPDF_Rect& rect, |
| 69 int32_t& nStartChar, | 69 int32_t& nStartChar, |
| 70 int32_t& nEndChar) const; | 70 int32_t& nEndChar) const; |
| 71 CFX_WideString GetText(int32_t& nStartChar, int32_t& nEndChar) const; | 71 CFX_WideString GetText(int32_t& nStartChar, int32_t& nEndChar) const; |
| 72 void Clear(); | 72 void Clear(); |
| 73 void SelectAll(); | 73 void SelectAll(); |
| 74 | 74 |
| 75 int32_t GetCaret() const; | 75 int32_t GetCaret() const; |
| 76 void SetCaret(int32_t nPos); | 76 void SetCaret(int32_t nPos); |
| 77 int32_t GetTotalWords() const; | 77 int32_t GetTotalWords() const; |
| 78 | 78 |
| 79 void Paint(); | 79 void Paint(); |
| 80 | 80 |
| 81 void EnableRefresh(FX_BOOL bRefresh); | 81 void EnableRefresh(FX_BOOL bRefresh); |
| 82 CFX_FloatPoint GetScrollPos() const; | 82 CPDF_Point GetScrollPos() const; |
| 83 void SetScrollPos(const CFX_FloatPoint& point); | 83 void SetScrollPos(const CPDF_Point& point); |
| 84 | 84 |
| 85 void SetEditNotify(IPWL_Edit_Notify* pNotify) { m_pEditNotify = pNotify; } | 85 void SetEditNotify(IPWL_Edit_Notify* pNotify) { m_pEditNotify = pNotify; } |
| 86 | 86 |
| 87 void SetCharSet(uint8_t nCharSet) { m_nCharSet = nCharSet; } | 87 void SetCharSet(uint8_t nCharSet) { m_nCharSet = nCharSet; } |
| 88 int32_t GetCharSet() const; | 88 int32_t GetCharSet() const; |
| 89 | 89 |
| 90 void SetCodePage(int32_t nCodePage) { m_nCodePage = nCodePage; } | 90 void SetCodePage(int32_t nCodePage) { m_nCodePage = nCodePage; } |
| 91 int32_t GetCodePage() const { return m_nCodePage; } | 91 int32_t GetCodePage() const { return m_nCodePage; } |
| 92 | 92 |
| 93 CPDF_Font* GetCaretFont() const; | 93 CPDF_Font* GetCaretFont() const; |
| 94 FX_FLOAT GetCaretFontSize() const; | 94 FX_FLOAT GetCaretFontSize() const; |
| 95 | 95 |
| 96 FX_BOOL CanUndo() const; | 96 FX_BOOL CanUndo() const; |
| 97 FX_BOOL CanRedo() const; | 97 FX_BOOL CanRedo() const; |
| 98 void Redo(); | 98 void Redo(); |
| 99 void Undo(); | 99 void Undo(); |
| 100 | 100 |
| 101 void SetReadyToInput(); | 101 void SetReadyToInput(); |
| 102 | 102 |
| 103 // CPWL_Wnd | 103 // CPWL_Wnd |
| 104 void OnCreate(PWL_CREATEPARAM& cp) override; | 104 void OnCreate(PWL_CREATEPARAM& cp) override; |
| 105 void OnCreated() override; | 105 void OnCreated() override; |
| 106 FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) override; | 106 FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) override; |
| 107 FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag) override; | 107 FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag) override; |
| 108 FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, FX_DWORD nFlag) override; | 108 FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) override; |
| 109 FX_BOOL OnLButtonUp(const CFX_FloatPoint& point, FX_DWORD nFlag) override; | 109 FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) override; |
| 110 FX_BOOL OnMouseMove(const CFX_FloatPoint& point, FX_DWORD nFlag) override; | 110 FX_BOOL OnMouseMove(const CPDF_Point& point, FX_DWORD nFlag) override; |
| 111 void OnNotify(CPWL_Wnd* pWnd, | 111 void OnNotify(CPWL_Wnd* pWnd, |
| 112 FX_DWORD msg, | 112 FX_DWORD msg, |
| 113 intptr_t wParam = 0, | 113 intptr_t wParam = 0, |
| 114 intptr_t lParam = 0) override; | 114 intptr_t lParam = 0) override; |
| 115 void CreateChildWnd(const PWL_CREATEPARAM& cp) override; | 115 void CreateChildWnd(const PWL_CREATEPARAM& cp) override; |
| 116 void RePosChildWnd() override; | 116 void RePosChildWnd() override; |
| 117 void SetFontSize(FX_FLOAT fFontSize) override; | 117 void SetFontSize(FX_FLOAT fFontSize) override; |
| 118 FX_FLOAT GetFontSize() const override; | 118 FX_FLOAT GetFontSize() const override; |
| 119 void SetCursor() override; | 119 void SetCursor() override; |
| 120 | 120 |
| 121 protected: | 121 protected: |
| 122 // IFX_Edit_Notify | 122 // IFX_Edit_Notify |
| 123 void IOnSetScrollInfoX(FX_FLOAT fPlateMin, | 123 void IOnSetScrollInfoX(FX_FLOAT fPlateMin, |
| 124 FX_FLOAT fPlateMax, | 124 FX_FLOAT fPlateMax, |
| 125 FX_FLOAT fContentMin, | 125 FX_FLOAT fContentMin, |
| 126 FX_FLOAT fContentMax, | 126 FX_FLOAT fContentMax, |
| 127 FX_FLOAT fSmallStep, | 127 FX_FLOAT fSmallStep, |
| 128 FX_FLOAT fBigStep) override {} | 128 FX_FLOAT fBigStep) override {} |
| 129 void IOnSetScrollInfoY(FX_FLOAT fPlateMin, | 129 void IOnSetScrollInfoY(FX_FLOAT fPlateMin, |
| 130 FX_FLOAT fPlateMax, | 130 FX_FLOAT fPlateMax, |
| 131 FX_FLOAT fContentMin, | 131 FX_FLOAT fContentMin, |
| 132 FX_FLOAT fContentMax, | 132 FX_FLOAT fContentMax, |
| 133 FX_FLOAT fSmallStep, | 133 FX_FLOAT fSmallStep, |
| 134 FX_FLOAT fBigStep) override; | 134 FX_FLOAT fBigStep) override; |
| 135 void IOnSetScrollPosX(FX_FLOAT fx) override {} | 135 void IOnSetScrollPosX(FX_FLOAT fx) override {} |
| 136 void IOnSetScrollPosY(FX_FLOAT fy) override; | 136 void IOnSetScrollPosY(FX_FLOAT fy) override; |
| 137 void IOnSetCaret(FX_BOOL bVisible, | 137 void IOnSetCaret(FX_BOOL bVisible, |
| 138 const CFX_FloatPoint& ptHead, | 138 const CPDF_Point& ptHead, |
| 139 const CFX_FloatPoint& ptFoot, | 139 const CPDF_Point& ptFoot, |
| 140 const CPVT_WordPlace& place) override; | 140 const CPVT_WordPlace& place) override; |
| 141 void IOnCaretChange(const CPVT_SecProps& secProps, | 141 void IOnCaretChange(const CPVT_SecProps& secProps, |
| 142 const CPVT_WordProps& wordProps) override; | 142 const CPVT_WordProps& wordProps) override; |
| 143 void IOnContentChange(const CFX_FloatRect& rcContent) override; | 143 void IOnContentChange(const CPDF_Rect& rcContent) override; |
| 144 void IOnInvalidateRect(CFX_FloatRect* pRect) override; | 144 void IOnInvalidateRect(CPDF_Rect* pRect) override; |
| 145 | 145 |
| 146 void InsertText(const FX_WCHAR* csText); | 146 void InsertText(const FX_WCHAR* csText); |
| 147 void SetText(const FX_WCHAR* csText); | 147 void SetText(const FX_WCHAR* csText); |
| 148 void CopyText(); | 148 void CopyText(); |
| 149 void PasteText(); | 149 void PasteText(); |
| 150 void CutText(); | 150 void CutText(); |
| 151 void ShowVScrollBar(FX_BOOL bShow); | 151 void ShowVScrollBar(FX_BOOL bShow); |
| 152 void InsertWord(FX_WORD word, int32_t nCharset); | 152 void InsertWord(FX_WORD word, int32_t nCharset); |
| 153 void InsertReturn(); | 153 void InsertReturn(); |
| 154 | 154 |
| 155 FX_BOOL IsWndHorV(); | 155 FX_BOOL IsWndHorV(); |
| 156 | 156 |
| 157 void Delete(); | 157 void Delete(); |
| 158 void Backspace(); | 158 void Backspace(); |
| 159 | 159 |
| 160 void GetCaretInfo(CFX_FloatPoint& ptHead, CFX_FloatPoint& ptFoot) const; | 160 void GetCaretInfo(CPDF_Point& ptHead, CPDF_Point& ptFoot) const; |
| 161 void SetCaret(FX_BOOL bVisible, | 161 void SetCaret(FX_BOOL bVisible, |
| 162 const CFX_FloatPoint& ptHead, | 162 const CPDF_Point& ptHead, |
| 163 const CFX_FloatPoint& ptFoot); | 163 const CPDF_Point& ptFoot); |
| 164 | 164 |
| 165 void SetEditCaret(FX_BOOL bVisible); | 165 void SetEditCaret(FX_BOOL bVisible); |
| 166 | 166 |
| 167 private: | 167 private: |
| 168 void CreateEditCaret(const PWL_CREATEPARAM& cp); | 168 void CreateEditCaret(const PWL_CREATEPARAM& cp); |
| 169 | 169 |
| 170 protected: | 170 protected: |
| 171 IFX_Edit* m_pEdit; | 171 IFX_Edit* m_pEdit; |
| 172 CPWL_Caret* m_pEditCaret; | 172 CPWL_Caret* m_pEditCaret; |
| 173 FX_BOOL m_bMouseDown; | 173 FX_BOOL m_bMouseDown; |
| 174 IPWL_Edit_Notify* m_pEditNotify; | 174 IPWL_Edit_Notify* m_pEditNotify; |
| 175 | 175 |
| 176 private: | 176 private: |
| 177 int32_t m_nCharSet; | 177 int32_t m_nCharSet; |
| 178 int32_t m_nCodePage; | 178 int32_t m_nCodePage; |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_EDITCTRL_H_ | 181 #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_EDITCTRL_H_ |
| OLD | NEW |