| 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 XFA_SRC_FWL_BASEWIDGET_FWL_EDITIMP_H_ | |
| 8 #define XFA_SRC_FWL_BASEWIDGET_FWL_EDITIMP_H_ | |
| 9 | |
| 10 #include <memory> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "xfa/include/fwl/basewidget/fwl_scrollbar.h" | |
| 14 #include "xfa/src/fee/ifde_txtedtengine.h" | |
| 15 #include "xfa/src/fwl/core/fwl_widgetimp.h" | |
| 16 | |
| 17 class CFWL_WidgetImpProperties; | |
| 18 class CFWL_WidgetImpDelegate; | |
| 19 class IFWL_Caret; | |
| 20 class CFWL_EditImp; | |
| 21 class CFWL_EditImpDelegate; | |
| 22 | |
| 23 class CFWL_EditImp : public CFWL_WidgetImp, public IFDE_TxtEdtEventSink { | |
| 24 public: | |
| 25 CFWL_EditImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); | |
| 26 ~CFWL_EditImp() override; | |
| 27 | |
| 28 // CFWL_WidgetImp: | |
| 29 FWL_ERR GetClassName(CFX_WideString& wsClass) const override; | |
| 30 FX_DWORD GetClassID() const override; | |
| 31 FWL_ERR Initialize() override; | |
| 32 FWL_ERR Finalize() override; | |
| 33 FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override; | |
| 34 FWL_ERR SetWidgetRect(const CFX_RectF& rect) override; | |
| 35 FWL_ERR Update() override; | |
| 36 FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy) override; | |
| 37 FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE) override; | |
| 38 FWL_ERR DrawWidget(CFX_Graphics* pGraphics, | |
| 39 const CFX_Matrix* pMatrix = NULL) override; | |
| 40 FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override; | |
| 41 | |
| 42 virtual FWL_ERR SetText(const CFX_WideString& wsText); | |
| 43 virtual int32_t GetTextLength() const; | |
| 44 virtual FWL_ERR GetText(CFX_WideString& wsText, | |
| 45 int32_t nStart = 0, | |
| 46 int32_t nCount = -1) const; | |
| 47 virtual FWL_ERR ClearText(); | |
| 48 virtual int32_t GetCaretPos() const; | |
| 49 virtual int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore = TRUE); | |
| 50 virtual FWL_ERR AddSelRange(int32_t nStart, int32_t nCount = -1); | |
| 51 virtual int32_t CountSelRanges(); | |
| 52 virtual int32_t GetSelRange(int32_t nIndex, int32_t& nStart); | |
| 53 virtual FWL_ERR ClearSelections(); | |
| 54 virtual int32_t GetLimit(); | |
| 55 virtual FWL_ERR SetLimit(int32_t nLimit); | |
| 56 virtual FWL_ERR SetAliasChar(FX_WCHAR wAlias); | |
| 57 virtual FWL_ERR Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen); | |
| 58 virtual FWL_ERR DeleteSelections(); | |
| 59 virtual FWL_ERR DeleteRange(int32_t nStart, int32_t nCount = -1); | |
| 60 virtual FWL_ERR ReplaceSelections(const CFX_WideStringC& wsReplace); | |
| 61 virtual FWL_ERR Replace(int32_t nStart, | |
| 62 int32_t nLen, | |
| 63 const CFX_WideStringC& wsReplace); | |
| 64 virtual FWL_ERR DoClipboard(int32_t iCmd); | |
| 65 virtual FX_BOOL Copy(CFX_WideString& wsCopy); | |
| 66 virtual FX_BOOL Cut(CFX_WideString& wsCut); | |
| 67 virtual FX_BOOL Paste(const CFX_WideString& wsPaste); | |
| 68 virtual FX_BOOL Delete(); | |
| 69 virtual FX_BOOL Redo(const CFX_ByteStringC& bsRecord); | |
| 70 virtual FX_BOOL Undo(const CFX_ByteStringC& bsRecord); | |
| 71 virtual FX_BOOL Undo(); | |
| 72 virtual FX_BOOL Redo(); | |
| 73 virtual FX_BOOL CanUndo(); | |
| 74 virtual FX_BOOL CanRedo(); | |
| 75 virtual FWL_ERR SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant); | |
| 76 virtual FWL_ERR SetOuter(IFWL_Widget* pOuter); | |
| 77 virtual FWL_ERR SetNumberRange(int32_t iMin, int32_t iMax); | |
| 78 void On_CaretChanged(IFDE_TxtEdtEngine* pEdit, | |
| 79 int32_t nPage, | |
| 80 FX_BOOL bVisible = true) override; | |
| 81 void On_TextChanged(IFDE_TxtEdtEngine* pEdit, | |
| 82 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) override; | |
| 83 void On_PageCountChanged(IFDE_TxtEdtEngine* pEdit) override {} | |
| 84 void On_SelChanged(IFDE_TxtEdtEngine* pEdit) override; | |
| 85 FX_BOOL On_PageLoad(IFDE_TxtEdtEngine* pEdit, | |
| 86 int32_t nPageIndex, | |
| 87 int32_t nPurpose) override; | |
| 88 FX_BOOL On_PageUnload(IFDE_TxtEdtEngine* pEdit, | |
| 89 int32_t nPageIndex, | |
| 90 int32_t nPurpose) override; | |
| 91 FX_BOOL On_PageChange(IFDE_TxtEdtEngine* pEdit, int32_t nPageIndex) override { | |
| 92 return TRUE; | |
| 93 } | |
| 94 void On_AddDoRecord(IFDE_TxtEdtEngine* pEdit, | |
| 95 const CFX_ByteStringC& bsDoRecord) override; | |
| 96 FX_BOOL On_ValidateField(IFDE_TxtEdtEngine* pEdit, | |
| 97 int32_t nBlockIndex, | |
| 98 int32_t nFieldIndex, | |
| 99 const CFX_WideString& wsFieldText, | |
| 100 int32_t nCharIndex) override; | |
| 101 FX_BOOL On_ValidateBlock(IFDE_TxtEdtEngine* pEdit, | |
| 102 int32_t nBlockIndex) override; | |
| 103 FX_BOOL On_GetBlockFormatText(IFDE_TxtEdtEngine* pEdit, | |
| 104 int32_t nBlockIndex, | |
| 105 CFX_WideString& wsBlockText) override; | |
| 106 FX_BOOL On_Validate(IFDE_TxtEdtEngine* pEdit, | |
| 107 CFX_WideString& wsText) override; | |
| 108 virtual FWL_ERR SetBackgroundColor(FX_DWORD color); | |
| 109 virtual FWL_ERR SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize); | |
| 110 void SetScrollOffset(FX_FLOAT fScrollOffset); | |
| 111 FX_BOOL GetSuggestWords(CFX_PointF pointf, | |
| 112 std::vector<CFX_ByteString>& sSuggest); | |
| 113 FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, | |
| 114 const CFX_ByteStringC& bsReplace); | |
| 115 | |
| 116 protected: | |
| 117 void DrawTextBk(CFX_Graphics* pGraphics, | |
| 118 IFWL_ThemeProvider* pTheme, | |
| 119 const CFX_Matrix* pMatrix = NULL); | |
| 120 void DrawContent(CFX_Graphics* pGraphics, | |
| 121 IFWL_ThemeProvider* pTheme, | |
| 122 const CFX_Matrix* pMatrix = NULL); | |
| 123 void UpdateEditEngine(); | |
| 124 void UpdateEditParams(); | |
| 125 void UpdateEditLayout(); | |
| 126 FX_BOOL UpdateOffset(); | |
| 127 FX_BOOL UpdateOffset(IFWL_ScrollBar* pScrollBar, FX_FLOAT fPosChanged); | |
| 128 void UpdateVAlignment(); | |
| 129 void UpdateCaret(); | |
| 130 IFWL_ScrollBar* UpdateScroll(); | |
| 131 void Layout(); | |
| 132 void LayoutScrollBar(); | |
| 133 void DeviceToEngine(CFX_PointF& pt); | |
| 134 void InitScrollBar(FX_BOOL bVert = TRUE); | |
| 135 void InitEngine(); | |
| 136 virtual void ShowCaret(FX_BOOL bVisible, CFX_RectF* pRect = NULL); | |
| 137 FX_BOOL ValidateNumberChar(FX_WCHAR cNum); | |
| 138 void InitCaret(); | |
| 139 void ClearRecord(); | |
| 140 FX_BOOL IsShowScrollBar(FX_BOOL bVert); | |
| 141 FX_BOOL IsContentHeightOverflow(); | |
| 142 int32_t AddDoRecord(const CFX_ByteStringC& bsDoRecord); | |
| 143 void ProcessInsertError(int32_t iError); | |
| 144 | |
| 145 void DrawSpellCheck(CFX_Graphics* pGraphics, | |
| 146 const CFX_Matrix* pMatrix = NULL); | |
| 147 void AddSpellCheckObj(CFX_Path& PathData, | |
| 148 int32_t nStart, | |
| 149 int32_t nCount, | |
| 150 FX_FLOAT fOffSetX, | |
| 151 FX_FLOAT fOffSetY); | |
| 152 int32_t GetWordAtPoint(CFX_PointF pointf, int32_t& nCount); | |
| 153 CFX_RectF m_rtClient; | |
| 154 CFX_RectF m_rtEngine; | |
| 155 CFX_RectF m_rtStatic; | |
| 156 FX_FLOAT m_fVAlignOffset; | |
| 157 FX_FLOAT m_fScrollOffsetX; | |
| 158 FX_FLOAT m_fScrollOffsetY; | |
| 159 IFDE_TxtEdtEngine* m_pEdtEngine; | |
| 160 FX_BOOL m_bLButtonDown; | |
| 161 int32_t m_nSelStart; | |
| 162 int32_t m_nLimit; | |
| 163 FX_FLOAT m_fSpaceAbove; | |
| 164 FX_FLOAT m_fSpaceBelow; | |
| 165 FX_FLOAT m_fFontSize; | |
| 166 FX_ARGB m_argbSel; | |
| 167 FX_BOOL m_bSetRange; | |
| 168 int32_t m_iMin; | |
| 169 int32_t m_iMax; | |
| 170 std::unique_ptr<IFWL_ScrollBar> m_pVertScrollBar; | |
| 171 std::unique_ptr<IFWL_ScrollBar> m_pHorzScrollBar; | |
| 172 std::unique_ptr<IFWL_Caret> m_pCaret; | |
| 173 CFX_WideString m_wsCache; | |
| 174 friend class CFWL_TxtEdtEventSink; | |
| 175 friend class CFWL_EditImpDelegate; | |
| 176 FX_DWORD m_backColor; | |
| 177 FX_BOOL m_updateBackColor; | |
| 178 CFX_WideString m_wsFont; | |
| 179 CFX_ByteStringArray m_RecordArr; | |
| 180 int32_t m_iCurRecord; | |
| 181 int32_t m_iMaxRecord; | |
| 182 }; | |
| 183 | |
| 184 class CFWL_EditImpDelegate : public CFWL_WidgetImpDelegate { | |
| 185 public: | |
| 186 CFWL_EditImpDelegate(CFWL_EditImp* pOwner); | |
| 187 int32_t OnProcessMessage(CFWL_Message* pMessage) override; | |
| 188 FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override; | |
| 189 FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics, | |
| 190 const CFX_Matrix* pMatrix = NULL) override; | |
| 191 | |
| 192 protected: | |
| 193 void DoActivate(CFWL_MsgActivate* pMsg); | |
| 194 void DoDeactivate(CFWL_MsgDeactivate* pMsg); | |
| 195 void DoButtonDown(CFWL_MsgMouse* pMsg); | |
| 196 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); | |
| 197 void OnLButtonDown(CFWL_MsgMouse* pMsg); | |
| 198 void OnLButtonUp(CFWL_MsgMouse* pMsg); | |
| 199 void OnButtonDblClk(CFWL_MsgMouse* pMsg); | |
| 200 void OnMouseMove(CFWL_MsgMouse* pMsg); | |
| 201 void OnKeyDown(CFWL_MsgKey* pMsg); | |
| 202 void OnChar(CFWL_MsgKey* pMsg); | |
| 203 FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, FX_DWORD dwCode, FX_FLOAT fPos); | |
| 204 void DoCursor(CFWL_MsgMouse* pMsg); | |
| 205 CFWL_EditImp* m_pOwner; | |
| 206 }; | |
| 207 | |
| 208 #endif // XFA_SRC_FWL_BASEWIDGET_FWL_EDITIMP_H_ | |
| OLD | NEW |