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