blob: c74869c77c33ddc6005e5f6464362c76b9f25090 [file] [log] [blame]
jaepark98e10192016-08-15 10:51:11 -07001// 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
dsinclair114e46a2016-09-29 17:18:21 -07007#ifndef FPDFSDK_CPDFSDK_WIDGETHANDLER_H_
8#define FPDFSDK_CPDFSDK_WIDGETHANDLER_H_
jaepark98e10192016-08-15 10:51:11 -07009
dsinclaira52ab742016-09-29 13:59:29 -070010#include "core/fxcrt/fx_coordinates.h"
Dan Sinclairaee0db02017-09-21 16:53:58 -040011#include "core/fxcrt/unowned_ptr.h"
dsinclair114e46a2016-09-29 17:18:21 -070012#include "fpdfsdk/ipdfsdk_annothandler.h"
jaepark98e10192016-08-15 10:51:11 -070013
dsinclairb94d7c92016-09-21 12:07:00 -070014class CFFL_InteractiveFormFiller;
jaepark98e10192016-08-15 10:51:11 -070015class CFX_Matrix;
16class CFX_RenderDevice;
17class CPDF_Annot;
jaepark98e10192016-08-15 10:51:11 -070018class CPDFSDK_Annot;
dsinclair735606d2016-10-05 15:47:02 -070019class CPDFSDK_FormFillEnvironment;
jaepark98e10192016-08-15 10:51:11 -070020class CPDFSDK_PageView;
21
22#ifdef PDF_ENABLE_XFA
23class CXFA_FFWidget;
24#endif // PDF_ENABLE_XFA
25
Tom Sepez55865452018-08-27 20:18:04 +000026class CPDFSDK_WidgetHandler final : public IPDFSDK_AnnotHandler {
jaepark98e10192016-08-15 10:51:11 -070027 public:
dsinclair735606d2016-10-05 15:47:02 -070028 explicit CPDFSDK_WidgetHandler(CPDFSDK_FormFillEnvironment* pApp);
jaepark8c541822016-08-30 13:43:05 -070029 ~CPDFSDK_WidgetHandler() override;
jaepark98e10192016-08-15 10:51:11 -070030
tsepez4cf55152016-11-02 14:37:54 -070031 bool CanAnswer(CPDFSDK_Annot* pAnnot) override;
jaepark98e10192016-08-15 10:51:11 -070032 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;
jaepark98e10192016-08-15 10:51:11 -070038 CFX_FloatRect GetViewBBox(CPDFSDK_PageView* pPageView,
39 CPDFSDK_Annot* pAnnot) override;
Lei Zhanga4c7ac42018-04-17 15:12:58 +000040 WideString GetText(CPDFSDK_Annot* pAnnot) override;
Ryan Harrison275e2602017-09-18 14:23:18 -040041 WideString GetSelectedText(CPDFSDK_Annot* pAnnot) override;
42 void ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text) override;
Lei Zhangee967722018-04-19 20:55:54 +000043 bool CanUndo(CPDFSDK_Annot* pAnnot) override;
44 bool CanRedo(CPDFSDK_Annot* pAnnot) override;
45 bool Undo(CPDFSDK_Annot* pAnnot) override;
46 bool Redo(CPDFSDK_Annot* pAnnot) override;
tsepez4cf55152016-11-02 14:37:54 -070047 bool HitTest(CPDFSDK_PageView* pPageView,
48 CPDFSDK_Annot* pAnnot,
Dan Sinclairf528eee2017-02-14 11:52:07 -050049 const CFX_PointF& point) override;
jaepark98e10192016-08-15 10:51:11 -070050 void OnDraw(CPDFSDK_PageView* pPageView,
51 CPDFSDK_Annot* pAnnot,
52 CFX_RenderDevice* pDevice,
Lei Zhang09ee0872018-10-09 19:13:55 +000053 const CFX_Matrix& mtUser2Device,
jaepark75f84a52016-09-09 15:39:09 -070054 bool bDrawAnnots) override;
jaepark98e10192016-08-15 10:51:11 -070055 void OnLoad(CPDFSDK_Annot* pAnnot) override;
tsepezf8074ce2016-09-27 14:29:57 -070056
jaepark98e10192016-08-15 10:51:11 -070057 void OnMouseEnter(CPDFSDK_PageView* pPageView,
tsepezf8074ce2016-09-27 14:29:57 -070058 CPDFSDK_Annot::ObservedPtr* pAnnot,
jaepark98e10192016-08-15 10:51:11 -070059 uint32_t nFlag) override;
60 void OnMouseExit(CPDFSDK_PageView* pPageView,
tsepezf8074ce2016-09-27 14:29:57 -070061 CPDFSDK_Annot::ObservedPtr* pAnnot,
jaepark98e10192016-08-15 10:51:11 -070062 uint32_t nFlag) override;
tsepez4cf55152016-11-02 14:37:54 -070063 bool OnLButtonDown(CPDFSDK_PageView* pPageView,
64 CPDFSDK_Annot::ObservedPtr* pAnnot,
65 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -050066 const CFX_PointF& point) override;
tsepez4cf55152016-11-02 14:37:54 -070067 bool OnLButtonUp(CPDFSDK_PageView* pPageView,
68 CPDFSDK_Annot::ObservedPtr* pAnnot,
69 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -050070 const CFX_PointF& point) override;
tsepez4cf55152016-11-02 14:37:54 -070071 bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
tsepezf8074ce2016-09-27 14:29:57 -070072 CPDFSDK_Annot::ObservedPtr* pAnnot,
jaepark98e10192016-08-15 10:51:11 -070073 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -050074 const CFX_PointF& point) override;
tsepez4cf55152016-11-02 14:37:54 -070075 bool OnMouseMove(CPDFSDK_PageView* pPageView,
76 CPDFSDK_Annot::ObservedPtr* pAnnot,
77 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -050078 const CFX_PointF& point) override;
tsepez4cf55152016-11-02 14:37:54 -070079 bool OnMouseWheel(CPDFSDK_PageView* pPageView,
80 CPDFSDK_Annot::ObservedPtr* pAnnot,
81 uint32_t nFlags,
82 short zDelta,
Dan Sinclairf528eee2017-02-14 11:52:07 -050083 const CFX_PointF& point) override;
tsepez4cf55152016-11-02 14:37:54 -070084 bool OnRButtonDown(CPDFSDK_PageView* pPageView,
85 CPDFSDK_Annot::ObservedPtr* pAnnot,
86 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -050087 const CFX_PointF& point) override;
tsepez4cf55152016-11-02 14:37:54 -070088 bool OnRButtonUp(CPDFSDK_PageView* pPageView,
89 CPDFSDK_Annot::ObservedPtr* pAnnot,
90 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -050091 const CFX_PointF& point) override;
tsepez4cf55152016-11-02 14:37:54 -070092 bool OnRButtonDblClk(CPDFSDK_PageView* pPageView,
93 CPDFSDK_Annot::ObservedPtr* pAnnot,
94 uint32_t nFlags,
Dan Sinclairf528eee2017-02-14 11:52:07 -050095 const CFX_PointF& point) override;
tsepez4cf55152016-11-02 14:37:54 -070096 bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) override;
97 bool OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) override;
98 bool OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) override;
99 bool OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, uint32_t nFlag) override;
100 bool OnKillFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, uint32_t nFlag) override;
jaepark98e10192016-08-15 10:51:11 -0700101#ifdef PDF_ENABLE_XFA
tsepez4cf55152016-11-02 14:37:54 -0700102 bool OnXFAChangedFocus(CPDFSDK_Annot::ObservedPtr* pOldAnnot,
103 CPDFSDK_Annot::ObservedPtr* pNewAnnot) override;
jaepark98e10192016-08-15 10:51:11 -0700104#endif // PDF_ENABLE_XFA
105
Tom Sepezd0409af2017-05-25 15:53:57 -0700106 CFFL_InteractiveFormFiller* GetFormFiller() const {
107 return m_pFormFiller.Get();
108 }
jaepark98e10192016-08-15 10:51:11 -0700109
110 private:
Dan Sinclairaee0db02017-09-21 16:53:58 -0400111 UnownedPtr<CPDFSDK_FormFillEnvironment> const m_pFormFillEnv;
112 UnownedPtr<CFFL_InteractiveFormFiller> const m_pFormFiller;
jaepark98e10192016-08-15 10:51:11 -0700113};
114
dsinclair114e46a2016-09-29 17:18:21 -0700115#endif // FPDFSDK_CPDFSDK_WIDGETHANDLER_H_