| 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 "../fxedit/fx_edit.h" | 11 #include "../fxedit/fx_edit.h" |
| 12 #include "PWL_Wnd.h" | 12 #include "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 | 21 enum PWL_EDIT_ALIGNFORMAT_H { PEAH_LEFT = 0, PEAH_MIDDLE, PEAH_RIGHT }; |
| 22 { | 22 |
| 23 » PEAH_LEFT = 0, | 23 enum PWL_EDIT_ALIGNFORMAT_V { PEAV_TOP = 0, PEAV_CENTER, PEAV_BOTTOM }; |
| 24 » PEAH_MIDDLE, | 24 |
| 25 » PEAH_RIGHT | 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 CPDF_Rect& 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) {} |
| 26 }; | 53 }; |
| 27 | 54 |
| 28 enum PWL_EDIT_ALIGNFORMAT_V | 55 class CPWL_EditCtrl : public CPWL_Wnd, public IFX_Edit_Notify { |
| 29 { | 56 friend class CPWL_Edit_Notify; |
| 30 » PEAV_TOP = 0, | |
| 31 » PEAV_CENTER, | |
| 32 » PEAV_BOTTOM | |
| 33 }; | |
| 34 | 57 |
| 35 class IPWL_Edit_Notify | 58 public: |
| 36 { | 59 CPWL_EditCtrl(); |
| 37 public: | 60 virtual ~CPWL_EditCtrl(); |
| 38 virtual ~IPWL_Edit_Notify() { } | |
| 39 » //when the position of caret is changed in edit | |
| 40 » virtual void» » » » » OnCaretMove(int32_t x1,
int32_t y1, int32_t x2, int32_t y2) {} | |
| 41 » virtual void» » » » » OnContentChange(const CP
DF_Rect& rcContent){} | |
| 42 » //OprType: 0 InsertWord | |
| 43 » //1 InsertReturn | |
| 44 » //2 BackSpace | |
| 45 » //3 Delete | |
| 46 » //4 Clear | |
| 47 » //5 InsertText | |
| 48 » //6 SetText | |
| 49 » virtual void» » » » » OnInsertWord(const CPVT_
WordPlace& place, const CPVT_WordPlace& oldplace){} | |
| 50 » virtual void» » » » » OnInsertReturn(const CPV
T_WordPlace& place, const CPVT_WordPlace& oldplace){} | |
| 51 » virtual void» » » » » OnBackSpace(const CPVT_W
ordPlace& place, const CPVT_WordPlace& oldplace){} | |
| 52 » virtual void» » » » » OnDelete(const CPVT_Word
Place& place, const CPVT_WordPlace& oldplace){} | |
| 53 » virtual void» » » » » OnClear(const CPVT_WordP
lace& place, const CPVT_WordPlace& oldplace){} | |
| 54 » virtual void» » » » » OnInsertText(const CPVT_
WordPlace& place, const CPVT_WordPlace& oldplace){} | |
| 55 » virtual void» » » » » OnSetText(const CPVT_Wor
dPlace& place, const CPVT_WordPlace& oldplace){} | |
| 56 » virtual void» » » » » OnAddUndo(CPWL_Edit* pEd
it) {} | |
| 57 }; | |
| 58 | 61 |
| 59 class CPWL_EditCtrl : public CPWL_Wnd, public IFX_Edit_Notify | 62 public: |
| 60 { | 63 virtual void OnCreate(PWL_CREATEPARAM& cp); |
| 61 » friend class CPWL_Edit_Notify; | 64 virtual void OnCreated(); |
| 62 | 65 |
| 63 public: | 66 virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); |
| 64 » CPWL_EditCtrl(); | 67 virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); |
| 65 » virtual ~CPWL_EditCtrl(); | 68 virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); |
| 69 virtual FX_BOOL OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag); |
| 70 virtual FX_BOOL OnMouseMove(const CPDF_Point& point, FX_DWORD nFlag); |
| 71 virtual void OnNotify(CPWL_Wnd* pWnd, |
| 72 FX_DWORD msg, |
| 73 intptr_t wParam = 0, |
| 74 intptr_t lParam = 0); |
| 66 | 75 |
| 67 public: | 76 virtual void CreateChildWnd(const PWL_CREATEPARAM& cp); |
| 68 » virtual void» » » » » OnCreate(PWL_CREATEPARAM
& cp); | 77 virtual void RePosChildWnd(); |
| 69 » virtual void» » » » » OnCreated(); | 78 virtual void SetFontSize(FX_FLOAT fFontSize); |
| 79 virtual FX_FLOAT GetFontSize() const; |
| 70 | 80 |
| 71 » virtual FX_BOOL»» » » » OnKeyDown(FX_WORD nChar,
FX_DWORD nFlag); | 81 public: |
| 72 » virtual FX_BOOL»» » » » OnChar(FX_WORD nChar, FX
_DWORD nFlag); | 82 virtual void SetText(const FX_WCHAR* csText); |
| 73 » virtual FX_BOOL»» » » » OnLButtonDown(const CPDF
_Point & point, FX_DWORD nFlag); | |
| 74 » virtual FX_BOOL»» » » » OnLButtonUp(const CPDF_P
oint & point, FX_DWORD nFlag); | |
| 75 » virtual FX_BOOL»» » » » OnMouseMove(const CPDF_P
oint & point, FX_DWORD nFlag); | |
| 76 » virtual void» » » » » OnNotify(CPWL_Wnd* pWnd,
FX_DWORD msg, intptr_t wParam = 0, intptr_t lParam = 0); | |
| 77 | 83 |
| 78 » virtual void» » » » » CreateChildWnd(const PWL
_CREATEPARAM & cp); | 84 virtual void CopyText(); |
| 79 » virtual void» » » » » RePosChildWnd(); | 85 virtual void PasteText(); |
| 80 » virtual void» » » » » SetFontSize(FX_FLOAT fFo
ntSize); | 86 virtual void CutText(); |
| 81 » virtual FX_FLOAT» » » » GetFontSize() const; | |
| 82 | 87 |
| 83 public: | 88 CPDF_Rect GetContentRect() const; |
| 84 » virtual void» » » » » SetText(const FX_WCHAR*
csText); | 89 void GetCaretPos(int32_t& x, int32_t& y) const; |
| 90 FX_BOOL IsModified() const; |
| 85 | 91 |
| 86 » virtual void» » » » » CopyText(); | 92 CFX_WideString GetText() const; |
| 87 » virtual void» » » » » PasteText(); | 93 void SetSel(int32_t nStartChar, int32_t nEndChar); |
| 88 » virtual void » » » » » CutText(); | 94 void GetSel(int32_t& nStartChar, int32_t& nEndChar) const; |
| 95 void GetTextRange(const CPDF_Rect& rect, |
| 96 int32_t& nStartChar, |
| 97 int32_t& nEndChar) const; |
| 98 CFX_WideString GetText(int32_t& nStartChar, int32_t& nEndChar) const; |
| 99 void Clear(); |
| 100 void SelectAll(); |
| 89 | 101 |
| 90 » CPDF_Rect» » » » » » GetContentRect()
const; | 102 int32_t GetCaret() const; |
| 91 » void» » » » » » » GetCaretPos(int3
2_t& x, int32_t& y) const; | 103 void SetCaret(int32_t nPos); |
| 92 » FX_BOOL»» » » » » » IsModified() con
st; | 104 int32_t GetTotalWords() const; |
| 93 | 105 |
| 94 » CFX_WideString» » » » » GetText() const; | 106 void Paint(); |
| 95 » void» » » » » » » SetSel(int32_t n
StartChar,int32_t nEndChar); | |
| 96 » void» » » » » » » GetSel(int32_t &
nStartChar, int32_t & nEndChar ) const; | |
| 97 » void» » » » » » » GetTextRange(con
st CPDF_Rect& rect, int32_t & nStartChar, int32_t & nEndChar) const; | |
| 98 » CFX_WideString» » » » » GetText(int32_t & nStart
Char, int32_t & nEndChar) const; | |
| 99 » void» » » » » » » Clear(); | |
| 100 » void» » » » » » » SelectAll(); | |
| 101 | 107 |
| 102 » int32_t»» » » » » GetCaret() const; | 108 void EnableRefresh(FX_BOOL bRefresh); |
| 103 » void» » » » » » » SetCaret(int32_t
nPos); | 109 CPDF_Point GetScrollPos() const; |
| 104 » int32_t»» » » » » GetTotalWords() const; | 110 void SetScrollPos(const CPDF_Point& point); |
| 105 | 111 |
| 106 » void» » » » » » » Paint(); | 112 void SetEditNotify(IPWL_Edit_Notify* pNotify) { m_pEditNotify = pNotify; } |
| 107 | 113 |
| 108 » void» » » » » » » EnableRefresh(FX
_BOOL bRefresh); | 114 void SetCharSet(uint8_t nCharSet) { m_nCharSet = nCharSet; } |
| 109 » CPDF_Point» » » » » » GetScrollPos() c
onst; | 115 int32_t GetCharSet() const; |
| 110 » void» » » » » » » SetScrollPos(con
st CPDF_Point& point); | |
| 111 | 116 |
| 112 » void» » » » » » » SetEditNotify(IP
WL_Edit_Notify* pNotify) {m_pEditNotify = pNotify;} | 117 void SetCodePage(int32_t nCodePage) { m_nCodePage = nCodePage; } |
| 118 int32_t GetCodePage() const { return m_nCodePage; } |
| 113 | 119 |
| 114 » void» » » » » » » SetCharSet(uint8
_t nCharSet){m_nCharSet = nCharSet;} | 120 CPDF_Font* GetCaretFont() const; |
| 115 » int32_t»» » » » » GetCharSet() const; | 121 FX_FLOAT GetCaretFontSize() const; |
| 116 | 122 |
| 117 » void» » » » » » » SetCodePage(int3
2_t nCodePage){m_nCodePage = nCodePage;} | 123 FX_BOOL CanUndo() const; |
| 118 » int32_t»» » » » » GetCodePage() const {ret
urn m_nCodePage;} | 124 FX_BOOL CanRedo() const; |
| 125 void Redo(); |
| 126 void Undo(); |
| 119 | 127 |
| 120 » CPDF_Font *» » » » » » GetCaretFont() c
onst; | 128 void SetReadyToInput(); |
| 121 » FX_FLOAT» » » » » » GetCaretFontSize
() const; | |
| 122 | 129 |
| 123 » FX_BOOL»» » » » » » CanUndo() const; | 130 protected: |
| 124 » FX_BOOL»» » » » » » CanRedo() const; | 131 virtual void ShowVScrollBar(FX_BOOL bShow); |
| 125 » void» » » » » » » Redo(); | |
| 126 » void» » » » » » » Undo(); | |
| 127 | 132 |
| 128 » void» » » » » » » SetReadyToInput(
); | 133 virtual void InsertWord(FX_WORD word, int32_t nCharset); |
| 129 protected: | 134 virtual void InsertReturn(); |
| 130 » virtual void» » » » » ShowVScrollBar(FX_BOOL b
Show); | 135 virtual void InsertText(const FX_WCHAR* csText); |
| 131 | 136 |
| 132 » virtual void» » » » » InsertWord(FX_WORD word,
int32_t nCharset); | 137 virtual void SetCursor(); |
| 133 » virtual void» » » » » InsertReturn(); | 138 FX_BOOL IsWndHorV(); |
| 134 » virtual void» » » » » InsertText(const FX_WCHA
R* csText); | |
| 135 | 139 |
| 136 » virtual void» » » » » SetCursor(); | 140 void Delete(); |
| 137 » FX_BOOL»» » » » » » IsWndHorV(); | 141 void Backspace(); |
| 138 | 142 |
| 139 » void» » » » » » » Delete(); | 143 protected: |
| 140 » void» » » » » » » Backspace(); | 144 void GetCaretInfo(CPDF_Point& ptHead, CPDF_Point& ptFoot) const; |
| 145 void SetCaret(FX_BOOL bVisible, |
| 146 const CPDF_Point& ptHead, |
| 147 const CPDF_Point& ptFoot); |
| 141 | 148 |
| 142 protected: | 149 void SetEditCaret(FX_BOOL bVisible); |
| 143 » void» » » » » » » GetCaretInfo(CPD
F_Point & ptHead, CPDF_Point & ptFoot) const; | |
| 144 » void» » » » » » » SetCaret(FX_BOOL
bVisible, const CPDF_Point & ptHead, const CPDF_Point & ptFoot); | |
| 145 | 150 |
| 146 » void» » » » » » » SetEditCaret(FX_
BOOL bVisible); | 151 protected: |
| 152 virtual void IOnSetScrollInfoX(FX_FLOAT fPlateMin, |
| 153 FX_FLOAT fPlateMax, |
| 154 FX_FLOAT fContentMin, |
| 155 FX_FLOAT fContentMax, |
| 156 FX_FLOAT fSmallStep, |
| 157 FX_FLOAT fBigStep) {} |
| 158 virtual void IOnSetScrollInfoY(FX_FLOAT fPlateMin, |
| 159 FX_FLOAT fPlateMax, |
| 160 FX_FLOAT fContentMin, |
| 161 FX_FLOAT fContentMax, |
| 162 FX_FLOAT fSmallStep, |
| 163 FX_FLOAT fBigStep); |
| 164 virtual void IOnSetScrollPosX(FX_FLOAT fx) {} |
| 165 virtual void IOnSetScrollPosY(FX_FLOAT fy); |
| 166 virtual void IOnSetCaret(FX_BOOL bVisible, |
| 167 const CPDF_Point& ptHead, |
| 168 const CPDF_Point& ptFoot, |
| 169 const CPVT_WordPlace& place); |
| 170 virtual void IOnCaretChange(const CPVT_SecProps& secProps, |
| 171 const CPVT_WordProps& wordProps); |
| 172 virtual void IOnContentChange(const CPDF_Rect& rcContent); |
| 173 virtual void IOnInvalidateRect(CPDF_Rect* pRect); |
| 147 | 174 |
| 148 protected: | 175 private: |
| 149 » virtual void» » » » » IOnSetScrollInfoX(FX_FLO
AT fPlateMin, FX_FLOAT fPlateMax, | 176 void CreateEditCaret(const PWL_CREATEPARAM& cp); |
| 150 » » » » » » » » » »
» » FX_FLOAT fContentMin, FX_FLOAT fContentMax, | |
| 151 » » » » » » » » » »
» » FX_FLOAT fSmallStep, FX_FLOAT fBigStep){} | |
| 152 » virtual void» » » » » IOnSetScrollInfoY(FX_FLO
AT fPlateMin, FX_FLOAT fPlateMax, | |
| 153 » » » » » » » » » »
» » FX_FLOAT fContentMin, FX_FLOAT fContentMax, | |
| 154 » » » » » » » » » »
» » FX_FLOAT fSmallStep, FX_FLOAT fBigStep); | |
| 155 » virtual void» » » » » IOnSetScrollPosX(FX_FLOA
T fx){} | |
| 156 » virtual void» » » » » IOnSetScrollPosY(FX_FLOA
T fy); | |
| 157 » virtual void» » » » » IOnSetCaret(FX_BOOL bVis
ible,const CPDF_Point & ptHead,const CPDF_Point & ptFoot, const CPVT_WordPlace&
place); | |
| 158 » virtual void» » » » » IOnCaretChange(const CPV
T_SecProps & secProps, const CPVT_WordProps & wordProps); | |
| 159 » virtual void» » » » » IOnContentChange(const C
PDF_Rect& rcContent); | |
| 160 » virtual void» » » » » IOnInvalidateRect(CPDF_R
ect * pRect); | |
| 161 | 177 |
| 162 private: | 178 protected: |
| 163 » void» » » » » » » CreateEditCaret(
const PWL_CREATEPARAM & cp); | 179 IFX_Edit* m_pEdit; |
| 180 CPWL_Caret* m_pEditCaret; |
| 181 FX_BOOL m_bMouseDown; |
| 182 IPWL_Edit_Notify* m_pEditNotify; |
| 164 | 183 |
| 165 protected: | 184 private: |
| 166 » IFX_Edit*» » » » » » m_pEdit; | 185 int32_t m_nCharSet; |
| 167 » CPWL_Caret*» » » » » » m_pEditCaret; | 186 int32_t m_nCodePage; |
| 168 » FX_BOOL»» » » » » » m_bMouseDown; | |
| 169 » IPWL_Edit_Notify*» » » » m_pEditNotify; | |
| 170 | |
| 171 private: | |
| 172 » int32_t»» » » » » m_nCharSet; | |
| 173 » int32_t»» » » » » m_nCodePage; | |
| 174 }; | 187 }; |
| 175 | 188 |
| 176 #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_EDITCTRL_H_ | 189 #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_EDITCTRL_H_ |
| OLD | NEW |