• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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 FPDFSDK_CPDFSDK_WIDGETHANDLER_H_
8 #define FPDFSDK_CPDFSDK_WIDGETHANDLER_H_
9 
10 #include <memory>
11 
12 #include "core/fxcrt/fx_coordinates.h"
13 #include "core/fxcrt/unowned_ptr.h"
14 #include "fpdfsdk/ipdfsdk_annothandler.h"
15 
16 class CFFL_InteractiveFormFiller;
17 class CFX_Matrix;
18 class CFX_RenderDevice;
19 class CPDF_Annot;
20 class CPDFSDK_Annot;
21 class CPDFSDK_FormFillEnvironment;
22 class CPDFSDK_PageView;
23 
24 class CPDFSDK_WidgetHandler final : public IPDFSDK_AnnotHandler {
25  public:
26   CPDFSDK_WidgetHandler();
27   ~CPDFSDK_WidgetHandler() override;
28 
29   void SetFormFillEnvironment(
30       CPDFSDK_FormFillEnvironment* pFormFillEnv) override;
31   bool CanAnswer(CPDFSDK_Annot* pAnnot) override;
32   CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) override;
33   void ReleaseAnnot(std::unique_ptr<CPDFSDK_Annot> pAnnot) override;
34   CFX_FloatRect GetViewBBox(CPDFSDK_PageView* pPageView,
35                             CPDFSDK_Annot* pAnnot) override;
36   WideString GetText(CPDFSDK_Annot* pAnnot) override;
37   WideString GetSelectedText(CPDFSDK_Annot* pAnnot) override;
38   void ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text) override;
39   bool CanUndo(CPDFSDK_Annot* pAnnot) override;
40   bool CanRedo(CPDFSDK_Annot* pAnnot) override;
41   bool Undo(CPDFSDK_Annot* pAnnot) override;
42   bool Redo(CPDFSDK_Annot* pAnnot) override;
43   bool HitTest(CPDFSDK_PageView* pPageView,
44                CPDFSDK_Annot* pAnnot,
45                const CFX_PointF& point) override;
46   void OnDraw(CPDFSDK_PageView* pPageView,
47               CPDFSDK_Annot* pAnnot,
48               CFX_RenderDevice* pDevice,
49               const CFX_Matrix& mtUser2Device,
50               bool bDrawAnnots) override;
51   void OnLoad(CPDFSDK_Annot* pAnnot) override;
52 
53   void OnMouseEnter(CPDFSDK_PageView* pPageView,
54                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
55                     uint32_t nFlag) override;
56   void OnMouseExit(CPDFSDK_PageView* pPageView,
57                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
58                    uint32_t nFlag) override;
59   bool OnLButtonDown(CPDFSDK_PageView* pPageView,
60                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
61                      uint32_t nFlags,
62                      const CFX_PointF& point) override;
63   bool OnLButtonUp(CPDFSDK_PageView* pPageView,
64                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
65                    uint32_t nFlags,
66                    const CFX_PointF& point) override;
67   bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
68                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
69                        uint32_t nFlags,
70                        const CFX_PointF& point) override;
71   bool OnMouseMove(CPDFSDK_PageView* pPageView,
72                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
73                    uint32_t nFlags,
74                    const CFX_PointF& point) override;
75   bool OnMouseWheel(CPDFSDK_PageView* pPageView,
76                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
77                     uint32_t nFlags,
78                     short zDelta,
79                     const CFX_PointF& point) override;
80   bool OnRButtonDown(CPDFSDK_PageView* pPageView,
81                      ObservedPtr<CPDFSDK_Annot>* pAnnot,
82                      uint32_t nFlags,
83                      const CFX_PointF& point) override;
84   bool OnRButtonUp(CPDFSDK_PageView* pPageView,
85                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
86                    uint32_t nFlags,
87                    const CFX_PointF& point) override;
88   bool OnRButtonDblClk(CPDFSDK_PageView* pPageView,
89                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
90                        uint32_t nFlags,
91                        const CFX_PointF& point) override;
92   bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) override;
93   bool OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) override;
94   bool OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) override;
95   bool OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, uint32_t nFlag) override;
96   bool OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot, uint32_t nFlag) override;
97   bool SetIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
98                         int index,
99                         bool selected) override;
100   bool IsIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot, int index) override;
101 
102  private:
103   UnownedPtr<CPDFSDK_FormFillEnvironment> m_pFormFillEnv;
104   UnownedPtr<CFFL_InteractiveFormFiller> m_pFormFiller;
105 };
106 
107 #endif  // FPDFSDK_CPDFSDK_WIDGETHANDLER_H_
108