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