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_FXFA_APP_XFA_FFTEXTEDIT_H_
8 #define XFA_FXFA_APP_XFA_FFTEXTEDIT_H_
9 
10 #include <vector>
11 
12 #include "xfa/fxfa/app/xfa_fffield.h"
13 
14 class CXFA_FFTextEdit : public CXFA_FFField {
15  public:
16   explicit CXFA_FFTextEdit(CXFA_WidgetAcc* pDataAcc);
17   ~CXFA_FFTextEdit() override;
18 
19   // CXFA_FFField
20   bool LoadWidget() override;
21   void UpdateWidgetProperty() override;
22   bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override;
23   bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override;
24   bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override;
25   bool OnSetFocus(CXFA_FFWidget* pOldWidget) override;
26   bool OnKillFocus(CXFA_FFWidget* pNewWidget) override;
27   void OnProcessMessage(CFWL_Message* pMessage) override;
28   void OnProcessEvent(CFWL_Event* pEvent) override;
29   void OnDrawWidget(CFX_Graphics* pGraphics,
30                     const CFX_Matrix* pMatrix = nullptr) override;
31 
32   void OnTextChanged(CFWL_Widget* pWidget,
33                      const CFX_WideString& wsChanged,
34                      const CFX_WideString& wsPrevText);
35   void OnTextFull(CFWL_Widget* pWidget);
36   bool CheckWord(const CFX_ByteStringC& sWord);
37 
38  protected:
39   bool CommitData() override;
40   bool UpdateFWLData() override;
41   bool IsDataChanged() override;
42 
43   uint32_t GetAlignment();
44   void ValidateNumberField(const CFX_WideString& wsText);
45 
46   IFWL_WidgetDelegate* m_pOldDelegate;
47 };
48 
49 class CXFA_FFNumericEdit : public CXFA_FFTextEdit {
50  public:
51   explicit CXFA_FFNumericEdit(CXFA_WidgetAcc* pDataAcc);
52   ~CXFA_FFNumericEdit() override;
53 
54   // CXFA_FFTextEdit
55   bool LoadWidget() override;
56   void UpdateWidgetProperty() override;
57   void OnProcessEvent(CFWL_Event* pEvent) override;
58 
59  public:
60   bool OnValidate(CFWL_Widget* pWidget, CFX_WideString& wsText);
61 };
62 
63 class CXFA_FFPasswordEdit : public CXFA_FFTextEdit {
64  public:
65   explicit CXFA_FFPasswordEdit(CXFA_WidgetAcc* pDataAcc);
66   ~CXFA_FFPasswordEdit() override;
67 
68   // CXFA_FFTextEdit
69   bool LoadWidget() override;
70   void UpdateWidgetProperty() override;
71 
72  protected:
73 };
74 
75 enum XFA_DATETIMETYPE {
76   XFA_DATETIMETYPE_Date = 0,
77   XFA_DATETIMETYPE_Time,
78   XFA_DATETIMETYPE_DateAndTime
79 };
80 
81 class CXFA_FFDateTimeEdit : public CXFA_FFTextEdit {
82  public:
83   explicit CXFA_FFDateTimeEdit(CXFA_WidgetAcc* pDataAcc);
84   ~CXFA_FFDateTimeEdit() override;
85 
86   // CXFA_FFTextEdit
87   CFX_RectF GetBBox(uint32_t dwStatus, bool bDrawFocus = false) override;
88   bool LoadWidget() override;
89   void UpdateWidgetProperty() override;
90   void OnProcessEvent(CFWL_Event* pEvent) override;
91 
92   void OnSelectChanged(CFWL_Widget* pWidget,
93                        int32_t iYear,
94                        int32_t iMonth,
95                        int32_t iDay);
96 
97  protected:
98   bool PtInActiveRect(const CFX_PointF& point) override;
99   bool CommitData() override;
100   bool UpdateFWLData() override;
101   bool IsDataChanged() override;
102 
103   uint32_t GetAlignment();
104 };
105 
106 #endif  // XFA_FXFA_APP_XFA_FFTEXTEDIT_H_
107