• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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 FPDFSDK_FPDFXFA_CPDFXFA_WIDGET_H_
8 #define FPDFSDK_FPDFXFA_CPDFXFA_WIDGET_H_
9 
10 #include "core/fxcrt/fx_coordinates.h"
11 #include "fpdfsdk/cpdfsdk_annot.h"
12 #include "v8/include/cppgc/persistent.h"
13 #include "xfa/fxfa/cxfa_ffwidget.h"
14 
15 class CPDFSDK_PageView;
16 class CXFA_FFDocView;
17 class CXFA_FFWidgetHandler;
18 
19 class CPDFXFA_Widget final : public CPDFSDK_Annot,
20                              CPDFSDK_Annot::UnsafeInputHandlers {
21  public:
22   CPDFXFA_Widget(CXFA_FFWidget* pXFAFFWidget, CPDFSDK_PageView* pPageView);
23   ~CPDFXFA_Widget() override;
24 
25   // CPDFSDK_Annot:
26   CPDFXFA_Widget* AsXFAWidget() override;
27   CPDFSDK_Annot::UnsafeInputHandlers* GetUnsafeInputHandlers() override;
28   CPDF_Annot::Subtype GetAnnotSubtype() const override;
29   CFX_FloatRect GetRect() const override;
30   void OnDraw(CFX_RenderDevice* pDevice,
31               const CFX_Matrix& mtUser2Device,
32               bool bDrawAnnots) override;
33   bool DoHitTest(const CFX_PointF& point) override;
34   CFX_FloatRect GetViewBBox() override;
35   bool CanUndo() override;
36   bool CanRedo() override;
37   bool Undo() override;
38   bool Redo() override;
39   WideString GetText() override;
40   WideString GetSelectedText() override;
41   void ReplaceAndKeepSelection(const WideString& text) override;
42   void ReplaceSelection(const WideString& text) override;
43   bool SelectAllText() override;
44   bool SetIndexSelected(int index, bool selected) override;
45   bool IsIndexSelected(int index) override;
46 
GetXFAFFWidget()47   CXFA_FFWidget* GetXFAFFWidget() const { return m_pXFAFFWidget.Get(); }
48 
49   bool OnChangedFocus();
50 
51  private:
52   // CPDFSDK_Annot::UnsafeInputHandlers:
53   void OnMouseEnter(Mask<FWL_EVENTFLAG> nFlags) override;
54   void OnMouseExit(Mask<FWL_EVENTFLAG> nFlags) override;
55   bool OnLButtonDown(Mask<FWL_EVENTFLAG> nFlags,
56                      const CFX_PointF& point) override;
57   bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlags,
58                    const CFX_PointF& point) override;
59   bool OnLButtonDblClk(Mask<FWL_EVENTFLAG> nFlags,
60                        const CFX_PointF& point) override;
61   bool OnMouseMove(Mask<FWL_EVENTFLAG> nFlags,
62                    const CFX_PointF& point) override;
63   bool OnMouseWheel(Mask<FWL_EVENTFLAG> nFlags,
64                     const CFX_PointF& point,
65                     const CFX_Vector& delta) override;
66   bool OnRButtonDown(Mask<FWL_EVENTFLAG> nFlags,
67                      const CFX_PointF& point) override;
68   bool OnRButtonUp(Mask<FWL_EVENTFLAG> nFlags,
69                    const CFX_PointF& point) override;
70   bool OnChar(uint32_t nChar, Mask<FWL_EVENTFLAG> nFlags) override;
71   bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlags) override;
72   bool OnSetFocus(Mask<FWL_EVENTFLAG> nFlags) override;
73   bool OnKillFocus(Mask<FWL_EVENTFLAG> nFlags) override;
74 
75   CXFA_FFDocView* GetDocView();
76   CXFA_FFWidgetHandler* GetWidgetHandler();
77 
78   cppgc::Persistent<CXFA_FFWidget> const m_pXFAFFWidget;
79 };
80 
81 #endif  // FPDFSDK_FPDFXFA_CPDFXFA_WIDGET_H_
82