• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FFFIELD_H_
8 #define XFA_FXFA_APP_XFA_FFFIELD_H_
9 
10 #include "xfa/fwl/cfwl_widget.h"
11 #include "xfa/fwl/ifwl_widgetdelegate.h"
12 #include "xfa/fxfa/xfa_ffpageview.h"
13 #include "xfa/fxfa/xfa_ffwidget.h"
14 
15 #define XFA_MINUI_HEIGHT 4.32f
16 #define XFA_DEFAULTUI_HEIGHT 2.0f
17 
18 class CXFA_FFField : public CXFA_FFWidget, public IFWL_WidgetDelegate {
19  public:
20   explicit CXFA_FFField(CXFA_WidgetAcc* pDataAcc);
21   ~CXFA_FFField() override;
22 
23   // CXFA_FFWidget
24   CFX_RectF GetBBox(uint32_t dwStatus, bool bDrawFocus = false) override;
25   void RenderWidget(CFX_Graphics* pGS,
26                     CFX_Matrix* pMatrix,
27                     uint32_t dwStatus) override;
28   bool IsLoaded() override;
29   bool LoadWidget() override;
30   void UnloadWidget() override;
31   bool PerformLayout() override;
32   bool OnMouseEnter() override;
33   bool OnMouseExit() override;
34   bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) override;
35   bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) override;
36   bool OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) override;
37   bool OnMouseMove(uint32_t dwFlags, const CFX_PointF& point) override;
38   bool OnMouseWheel(uint32_t dwFlags,
39                     int16_t zDelta,
40                     const CFX_PointF& point) override;
41   bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) override;
42   bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override;
43   bool OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point) override;
44 
45   bool OnSetFocus(CXFA_FFWidget* pOldWidget) override;
46   bool OnKillFocus(CXFA_FFWidget* pNewWidget) override;
47   bool OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) override;
48   bool OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) override;
49   bool OnChar(uint32_t dwChar, uint32_t dwFlags) override;
50   FWL_WidgetHit OnHitTest(const CFX_PointF& point) override;
51   bool OnSetCursor(const CFX_PointF& point) override;
52 
53   // IFWL_WidgetDelegate
54   void OnProcessMessage(CFWL_Message* pMessage) override;
55   void OnProcessEvent(CFWL_Event* pEvent) override;
56   void OnDrawWidget(CFX_Graphics* pGraphics,
57                     const CFX_Matrix* pMatrix = nullptr) override;
58 
59   void UpdateFWL();
60   uint32_t UpdateUIProperty();
61 
62  protected:
63   bool PtInActiveRect(const CFX_PointF& point) override;
64 
65   virtual void SetFWLRect();
66   void SetFWLThemeProvider();
GetNormalWidget()67   CFWL_Widget* GetNormalWidget() { return m_pNormalWidget; }
68   CFX_PointF FWLToClient(const CFX_PointF& point);
69   void LayoutCaption();
70   void RenderCaption(CFX_Graphics* pGS, CFX_Matrix* pMatrix = nullptr);
71 
72   int32_t CalculateOverride();
73   int32_t CalculateWidgetAcc(CXFA_WidgetAcc* pAcc);
74   bool ProcessCommittedData();
75   virtual bool CommitData();
76   virtual bool IsDataChanged();
77   void DrawHighlight(CFX_Graphics* pGS,
78                      CFX_Matrix* pMatrix,
79                      uint32_t dwStatus,
80                      bool bEllipse = false);
81   void DrawFocus(CFX_Graphics* pGS, CFX_Matrix* pMatrix);
82   void TranslateFWLMessage(CFWL_Message* pMessage);
83   void CapPlacement();
84   void CapTopBottomPlacement(CXFA_Caption caption,
85                              const CFX_RectF& rtWidget,
86                              int32_t iCapPlacement);
87   void CapLeftRightPlacement(CXFA_Caption caption,
88                              const CFX_RectF& rtWidget,
89                              int32_t iCapPlacement);
90   void SetEditScrollOffset();
91 
92   CFWL_Widget* m_pNormalWidget;
93   CFX_RectF m_rtUI;
94   CFX_RectF m_rtCaption;
95 };
96 
97 #endif  // XFA_FXFA_APP_XFA_FFFIELD_H_
98