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 "core/fxcrt/unowned_ptr.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  public:
24   explicit CXFA_FFTextEdit(CXFA_Node* pNode);
25   ~CXFA_FFTextEdit() override;
26 
27   // CXFA_FFField
28   bool LoadWidget() override;
29   void UpdateWidgetProperty() override;
30   bool AcceptsFocusOnButtonDown(uint32_t dwFlags,
31                                 const CFX_PointF& point,
32                                 FWL_MouseCommand command) override;
33   bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override;
34   bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override;
35   bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override;
36   bool OnSetFocus(CXFA_FFWidget* pOldWidget) override WARN_UNUSED_RESULT;
37   bool OnKillFocus(CXFA_FFWidget* pNewWidget) override WARN_UNUSED_RESULT;
38   void OnProcessMessage(CFWL_Message* pMessage) override;
39   void OnProcessEvent(CFWL_Event* pEvent) override;
40   void OnDrawWidget(CXFA_Graphics* pGraphics,
41                     const CFX_Matrix& matrix) override;
42 
43   void OnTextWillChange(CFWL_Widget* pWidget, CFWL_EventTextWillChange* change);
44   void OnTextFull(CFWL_Widget* pWidget);
45 
46   // CXFA_FFWidget
47   bool CanUndo() override;
48   bool CanRedo() override;
49   bool Undo() override;
50   bool Redo() override;
51   bool CanCopy() override;
52   bool CanCut() override;
53   bool CanPaste() override;
54   bool CanSelectAll() override;
55   Optional<WideString> Copy() override;
56   Optional<WideString> Cut() override;
57   bool Paste(const WideString& wsPaste) override;
58   void SelectAll() override;
59   void Delete() override;
60   void DeSelect() override;
61   WideString GetText() override;
62   FormFieldType GetFormFieldType() override;
63 
64  protected:
65   uint32_t GetAlignment();
66 
67   UnownedPtr<IFWL_WidgetDelegate> m_pOldDelegate;
68 
69  private:
70   bool CommitData() override;
71   bool UpdateFWLData() override;
72   bool IsDataChanged() override;
73   void ValidateNumberField(const WideString& wsText);
74 };
75 
76 #endif  // XFA_FXFA_CXFA_FFTEXTEDIT_H_
77