1 // Copyright 2017 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_FXFA_CXFA_FFTEXTEDIT_H_ 8 #define XFA_FXFA_CXFA_FFTEXTEDIT_H_ 9 10 #include "core/fxcrt/fx_coordinates.h" 11 #include "core/fxcrt/fx_string.h" 12 #include "xfa/fxfa/cxfa_fffield.h" 13 14 class CFWL_Event; 15 class CFWL_EventTextWillChange; 16 class CFWL_Widget; 17 class CFX_Matrix; 18 class CXFA_FFWidget; 19 class IFWL_WidgetDelegate; 20 21 class CXFA_FFTextEdit : public CXFA_FFField { 22 public: 23 CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED; 24 ~CXFA_FFTextEdit() override; 25 26 void PreFinalize() override; 27 void Trace(cppgc::Visitor* visitor) const override; 28 29 // CXFA_FFField 30 bool LoadWidget() override; 31 void UpdateWidgetProperty() override; 32 bool AcceptsFocusOnButtonDown(uint32_t dwFlags, 33 const CFX_PointF& point, 34 FWL_MouseCommand command) override; 35 bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; 36 bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override; 37 bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override; 38 bool OnSetFocus(CXFA_FFWidget* pOldWidget) override WARN_UNUSED_RESULT; 39 bool OnKillFocus(CXFA_FFWidget* pNewWidget) override WARN_UNUSED_RESULT; 40 void OnProcessMessage(CFWL_Message* pMessage) override; 41 void OnProcessEvent(CFWL_Event* pEvent) override; 42 void OnDrawWidget(CFGAS_GEGraphics* pGraphics, 43 const CFX_Matrix& matrix) override; 44 45 void OnTextWillChange(CFWL_Widget* pWidget, CFWL_EventTextWillChange* change); 46 void OnTextFull(CFWL_Widget* pWidget); 47 48 // CXFA_FFWidget 49 bool CanUndo() override; 50 bool CanRedo() override; 51 bool CanCopy() override; 52 bool CanCut() override; 53 bool CanPaste() override; 54 bool CanSelectAll() override; 55 bool Undo() override; 56 bool Redo() override; 57 Optional<WideString> Copy() override; 58 Optional<WideString> Cut() override; 59 bool Paste(const WideString& wsPaste) override; 60 void SelectAll() override; 61 void Delete() override; 62 void DeSelect() override; 63 WideString GetText() override; 64 FormFieldType GetFormFieldType() override; 65 66 protected: 67 explicit CXFA_FFTextEdit(CXFA_Node* pNode); 68 uint32_t GetAlignment(); 69 70 cppgc::Member<IFWL_WidgetDelegate> m_pOldDelegate; 71 72 private: 73 bool CommitData() override; 74 bool UpdateFWLData() override; 75 bool IsDataChanged() override; 76 void ValidateNumberField(const WideString& wsText); 77 }; 78 79 #endif // XFA_FXFA_CXFA_FFTEXTEDIT_H_ 80