jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 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 | |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 7 | #ifndef FPDFSDK_CPDFSDK_WIDGETHANDLER_H_ |
| 8 | #define FPDFSDK_CPDFSDK_WIDGETHANDLER_H_ |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 9 | |
dsinclair | a52ab74 | 2016-09-29 13:59:29 -0700 | [diff] [blame] | 10 | #include "core/fxcrt/fx_coordinates.h" |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 11 | #include "core/fxcrt/unowned_ptr.h" |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 12 | #include "fpdfsdk/ipdfsdk_annothandler.h" |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 13 | |
dsinclair | b94d7c9 | 2016-09-21 12:07:00 -0700 | [diff] [blame] | 14 | class CFFL_InteractiveFormFiller; |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 15 | class CFX_Matrix; |
| 16 | class CFX_RenderDevice; |
| 17 | class CPDF_Annot; |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 18 | class CPDFSDK_Annot; |
dsinclair | 735606d | 2016-10-05 15:47:02 -0700 | [diff] [blame] | 19 | class CPDFSDK_FormFillEnvironment; |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 20 | class CPDFSDK_PageView; |
| 21 | |
| 22 | #ifdef PDF_ENABLE_XFA |
| 23 | class CXFA_FFWidget; |
| 24 | #endif // PDF_ENABLE_XFA |
| 25 | |
Tom Sepez | 5586545 | 2018-08-27 20:18:04 +0000 | [diff] [blame] | 26 | class CPDFSDK_WidgetHandler final : public IPDFSDK_AnnotHandler { |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 27 | public: |
dsinclair | 735606d | 2016-10-05 15:47:02 -0700 | [diff] [blame] | 28 | explicit CPDFSDK_WidgetHandler(CPDFSDK_FormFillEnvironment* pApp); |
jaepark | 8c54182 | 2016-08-30 13:43:05 -0700 | [diff] [blame] | 29 | ~CPDFSDK_WidgetHandler() override; |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 30 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 31 | bool CanAnswer(CPDFSDK_Annot* pAnnot) override; |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 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; |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 38 | CFX_FloatRect GetViewBBox(CPDFSDK_PageView* pPageView, |
| 39 | CPDFSDK_Annot* pAnnot) override; |
Lei Zhang | a4c7ac4 | 2018-04-17 15:12:58 +0000 | [diff] [blame] | 40 | WideString GetText(CPDFSDK_Annot* pAnnot) override; |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 41 | WideString GetSelectedText(CPDFSDK_Annot* pAnnot) override; |
| 42 | void ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text) override; |
Lei Zhang | ee96772 | 2018-04-19 20:55:54 +0000 | [diff] [blame] | 43 | 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; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 47 | bool HitTest(CPDFSDK_PageView* pPageView, |
| 48 | CPDFSDK_Annot* pAnnot, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 49 | const CFX_PointF& point) override; |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 50 | void OnDraw(CPDFSDK_PageView* pPageView, |
| 51 | CPDFSDK_Annot* pAnnot, |
| 52 | CFX_RenderDevice* pDevice, |
Lei Zhang | 09ee087 | 2018-10-09 19:13:55 +0000 | [diff] [blame^] | 53 | const CFX_Matrix& mtUser2Device, |
jaepark | 75f84a5 | 2016-09-09 15:39:09 -0700 | [diff] [blame] | 54 | bool bDrawAnnots) override; |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 55 | void OnLoad(CPDFSDK_Annot* pAnnot) override; |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 56 | |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 57 | void OnMouseEnter(CPDFSDK_PageView* pPageView, |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 58 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 59 | uint32_t nFlag) override; |
| 60 | void OnMouseExit(CPDFSDK_PageView* pPageView, |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 61 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 62 | uint32_t nFlag) override; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 63 | bool OnLButtonDown(CPDFSDK_PageView* pPageView, |
| 64 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 65 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 66 | const CFX_PointF& point) override; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 67 | bool OnLButtonUp(CPDFSDK_PageView* pPageView, |
| 68 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 69 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 70 | const CFX_PointF& point) override; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 71 | bool OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
tsepez | f8074ce | 2016-09-27 14:29:57 -0700 | [diff] [blame] | 72 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 73 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 74 | const CFX_PointF& point) override; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 75 | bool OnMouseMove(CPDFSDK_PageView* pPageView, |
| 76 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 77 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 78 | const CFX_PointF& point) override; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 79 | bool OnMouseWheel(CPDFSDK_PageView* pPageView, |
| 80 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 81 | uint32_t nFlags, |
| 82 | short zDelta, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 83 | const CFX_PointF& point) override; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 84 | bool OnRButtonDown(CPDFSDK_PageView* pPageView, |
| 85 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 86 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 87 | const CFX_PointF& point) override; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 88 | bool OnRButtonUp(CPDFSDK_PageView* pPageView, |
| 89 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 90 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 91 | const CFX_PointF& point) override; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 92 | bool OnRButtonDblClk(CPDFSDK_PageView* pPageView, |
| 93 | CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 94 | uint32_t nFlags, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 95 | const CFX_PointF& point) override; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 96 | 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; |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 101 | #ifdef PDF_ENABLE_XFA |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 102 | bool OnXFAChangedFocus(CPDFSDK_Annot::ObservedPtr* pOldAnnot, |
| 103 | CPDFSDK_Annot::ObservedPtr* pNewAnnot) override; |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 104 | #endif // PDF_ENABLE_XFA |
| 105 | |
Tom Sepez | d0409af | 2017-05-25 15:53:57 -0700 | [diff] [blame] | 106 | CFFL_InteractiveFormFiller* GetFormFiller() const { |
| 107 | return m_pFormFiller.Get(); |
| 108 | } |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 109 | |
| 110 | private: |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 111 | UnownedPtr<CPDFSDK_FormFillEnvironment> const m_pFormFillEnv; |
| 112 | UnownedPtr<CFFL_InteractiveFormFiller> const m_pFormFiller; |
jaepark | 98e1019 | 2016-08-15 10:51:11 -0700 | [diff] [blame] | 113 | }; |
| 114 | |
dsinclair | 114e46a | 2016-09-29 17:18:21 -0700 | [diff] [blame] | 115 | #endif // FPDFSDK_CPDFSDK_WIDGETHANDLER_H_ |