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