blob: bcd5177c1a7ce07f53bb8439864e5a86673bd10b [file] [log] [blame]
dsinclairf34518b2016-09-13 12:03:48 -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_PAGEVIEW_H_
8#define FPDFSDK_CPDFSDK_PAGEVIEW_H_
dsinclairf34518b2016-09-13 12:03:48 -07009
10#include <memory>
11#include <vector>
12
dsinclair41872fa2016-10-04 11:29:35 -070013#include "core/fpdfapi/page/cpdf_page.h"
dsinclaira52ab742016-09-29 13:59:29 -070014#include "core/fxcrt/fx_system.h"
dsinclair114e46a2016-09-29 17:18:21 -070015#include "fpdfsdk/cpdfsdk_annot.h"
dsinclairf34518b2016-09-13 12:03:48 -070016
17class CFX_RenderDevice;
18class CPDF_AnnotList;
19class CPDF_RenderOptions;
20
21class CPDFSDK_PageView final : public CPDF_Page::View {
22 public:
dsinclairb402b172016-10-11 09:26:32 -070023 CPDFSDK_PageView(CPDFSDK_FormFillEnvironment* pFormFillEnv,
24 UnderlyingPageType* page);
dsinclairf34518b2016-09-13 12:03:48 -070025 ~CPDFSDK_PageView();
26
27#ifdef PDF_ENABLE_XFA
28 void PageView_OnDraw(CFX_RenderDevice* pDevice,
29 CFX_Matrix* pUser2Device,
30 CPDF_RenderOptions* pOptions,
31 const FX_RECT& pClip);
32#else // PDF_ENABLE_XFA
33 void PageView_OnDraw(CFX_RenderDevice* pDevice,
34 CFX_Matrix* pUser2Device,
35 CPDF_RenderOptions* pOptions);
36#endif // PDF_ENABLE_XFA
37
dsinclair8afe15a2016-10-05 12:00:34 -070038 void LoadFXAnnots();
dsinclairf34518b2016-09-13 12:03:48 -070039 CPDFSDK_Annot* GetFocusAnnot();
dsinclair8afe15a2016-10-05 12:00:34 -070040 bool IsValidAnnot(const CPDF_Annot* p) const;
41 bool IsValidSDKAnnot(const CPDFSDK_Annot* p) const;
dsinclairf34518b2016-09-13 12:03:48 -070042
dsinclair8afe15a2016-10-05 12:00:34 -070043 const std::vector<CPDFSDK_Annot*>& GetAnnotList() const {
44 return m_SDKAnnotArray;
45 }
dsinclairf34518b2016-09-13 12:03:48 -070046 CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary* pDict);
47
48#ifdef PDF_ENABLE_XFA
tsepez4cf55152016-11-02 14:37:54 -070049 bool DeleteAnnot(CPDFSDK_Annot* pAnnot);
dsinclairf34518b2016-09-13 12:03:48 -070050 CPDFSDK_Annot* AddAnnot(CXFA_FFWidget* pPDFAnnot);
51 CPDFSDK_Annot* GetAnnotByXFAWidget(CXFA_FFWidget* hWidget);
dsinclair8afe15a2016-10-05 12:00:34 -070052
dsinclairf34518b2016-09-13 12:03:48 -070053 CPDFXFA_Page* GetPDFXFAPage() { return m_page; }
54#endif // PDF_ENABLE_XFA
55
56 CPDF_Page* GetPDFPage() const;
57 CPDF_Document* GetPDFDocument();
dsinclairb402b172016-10-11 09:26:32 -070058 CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { return m_pFormFillEnv; }
Dan Sinclairf528eee2017-02-14 11:52:07 -050059 bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag);
60 bool OnLButtonUp(const CFX_PointF& point, uint32_t nFlag);
dsinclairf34518b2016-09-13 12:03:48 -070061#ifdef PDF_ENABLE_XFA
Dan Sinclairf528eee2017-02-14 11:52:07 -050062 bool OnRButtonDown(const CFX_PointF& point, uint32_t nFlag);
63 bool OnRButtonUp(const CFX_PointF& point, uint32_t nFlag);
dsinclairf34518b2016-09-13 12:03:48 -070064#endif // PDF_ENABLE_XFA
tsepez4cf55152016-11-02 14:37:54 -070065 bool OnChar(int nChar, uint32_t nFlag);
66 bool OnKeyDown(int nKeyCode, int nFlag);
67 bool OnKeyUp(int nKeyCode, int nFlag);
dsinclairf34518b2016-09-13 12:03:48 -070068
Dan Sinclairf528eee2017-02-14 11:52:07 -050069 bool OnMouseMove(const CFX_PointF& point, int nFlag);
tsepez4cf55152016-11-02 14:37:54 -070070 bool OnMouseWheel(double deltaX,
71 double deltaY,
Dan Sinclairf528eee2017-02-14 11:52:07 -050072 const CFX_PointF& point,
tsepez4cf55152016-11-02 14:37:54 -070073 int nFlag);
dsinclair8afe15a2016-10-05 12:00:34 -070074
dsinclairf34518b2016-09-13 12:03:48 -070075 void GetCurrentMatrix(CFX_Matrix& matrix) { matrix = m_curMatrix; }
76 void UpdateRects(const std::vector<CFX_FloatRect>& rects);
77 void UpdateView(CPDFSDK_Annot* pAnnot);
dsinclairf34518b2016-09-13 12:03:48 -070078
79 int GetPageIndex() const;
dsinclaire5393582016-10-03 11:25:00 -070080
tsepez4cf55152016-11-02 14:37:54 -070081 void SetValid(bool bValid) { m_bValid = bValid; }
82 bool IsValid() { return m_bValid; }
dsinclaire5393582016-10-03 11:25:00 -070083
tsepez4cf55152016-11-02 14:37:54 -070084 void SetLock(bool bLocked) { m_bLocked = bLocked; }
85 bool IsLocked() { return m_bLocked; }
dsinclairbcf46232016-10-03 13:02:27 -070086
87 void SetBeingDestroyed() { m_bBeingDestroyed = true; }
88 bool IsBeingDestroyed() const { return m_bBeingDestroyed; }
89
dsinclairf34518b2016-09-13 12:03:48 -070090#ifndef PDF_ENABLE_XFA
91 bool OwnsPage() const { return m_bOwnsPage; }
92 void TakePageOwnership() { m_bOwnsPage = true; }
93#endif // PDF_ENABLE_XFA
94
95 private:
Dan Sinclairb45ea1f2017-02-21 14:27:59 -050096 CPDFSDK_Annot* GetFXAnnotAtPoint(const CFX_PointF& point);
97 CPDFSDK_Annot* GetFXWidgetAtPoint(const CFX_PointF& point);
98
dsinclairf34518b2016-09-13 12:03:48 -070099 int GetPageIndexForStaticPDF() const;
100
101 CFX_Matrix m_curMatrix;
102 UnderlyingPageType* const m_page;
103 std::unique_ptr<CPDF_AnnotList> m_pAnnotList;
dsinclair8afe15a2016-10-05 12:00:34 -0700104 std::vector<CPDFSDK_Annot*> m_SDKAnnotArray;
dsinclairb402b172016-10-11 09:26:32 -0700105 CPDFSDK_FormFillEnvironment* const m_pFormFillEnv; // Not owned.
tsepezf8074ce2016-09-27 14:29:57 -0700106 CPDFSDK_Annot::ObservedPtr m_pCaptureWidget;
dsinclairf34518b2016-09-13 12:03:48 -0700107#ifndef PDF_ENABLE_XFA
108 bool m_bOwnsPage;
109#endif // PDF_ENABLE_XFA
tsepez4cf55152016-11-02 14:37:54 -0700110 bool m_bEnterWidget;
111 bool m_bExitWidget;
112 bool m_bOnWidget;
113 bool m_bValid;
114 bool m_bLocked;
dsinclairbcf46232016-10-03 13:02:27 -0700115 bool m_bBeingDestroyed;
dsinclairf34518b2016-09-13 12:03:48 -0700116};
117
dsinclair114e46a2016-09-29 17:18:21 -0700118#endif // FPDFSDK_CPDFSDK_PAGEVIEW_H_