OLD | NEW |
(Empty) | |
| 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_INCLUDE_CPDFSDK_PAGEVIEW_H_ |
| 8 #define FPDFSDK_INCLUDE_CPDFSDK_PAGEVIEW_H_ |
| 9 |
| 10 #include <memory> |
| 11 #include <vector> |
| 12 |
| 13 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
| 14 #include "core/fxcrt/include/fx_system.h" |
| 15 #include "fpdfsdk/include/cpdfsdk_document.h" |
| 16 |
| 17 class CFX_RenderDevice; |
| 18 class CPDF_AnnotList; |
| 19 class CPDF_RenderOptions; |
| 20 |
| 21 class CPDFSDK_PageView final : public CPDF_Page::View { |
| 22 public: |
| 23 CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page); |
| 24 ~CPDFSDK_PageView(); |
| 25 |
| 26 #ifdef PDF_ENABLE_XFA |
| 27 void PageView_OnDraw(CFX_RenderDevice* pDevice, |
| 28 CFX_Matrix* pUser2Device, |
| 29 CPDF_RenderOptions* pOptions, |
| 30 const FX_RECT& pClip); |
| 31 #else // PDF_ENABLE_XFA |
| 32 void PageView_OnDraw(CFX_RenderDevice* pDevice, |
| 33 CFX_Matrix* pUser2Device, |
| 34 CPDF_RenderOptions* pOptions); |
| 35 #endif // PDF_ENABLE_XFA |
| 36 |
| 37 const CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); |
| 38 CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); |
| 39 const CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); |
| 40 CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); |
| 41 CPDFSDK_Annot* GetFocusAnnot(); |
| 42 void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot, FX_UINT nFlag = 0) { |
| 43 m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag); |
| 44 } |
| 45 FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0) { |
| 46 return m_pSDKDoc->KillFocusAnnot(nFlag); |
| 47 } |
| 48 void KillFocusAnnotIfNeeded(); |
| 49 |
| 50 CPDFSDK_Annot* AddAnnot(CPDF_Dictionary* pDict); |
| 51 CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType, CPDF_Dictionary* pDict); |
| 52 CPDFSDK_Annot* AddAnnot(CPDF_Annot* pPDFAnnot); |
| 53 |
| 54 FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot); |
| 55 size_t CountAnnots() const; |
| 56 CPDFSDK_Annot* GetAnnot(size_t nIndex); |
| 57 CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary* pDict); |
| 58 |
| 59 #ifdef PDF_ENABLE_XFA |
| 60 CPDFSDK_Annot* AddAnnot(CXFA_FFWidget* pPDFAnnot); |
| 61 CPDFSDK_Annot* GetAnnotByXFAWidget(CXFA_FFWidget* hWidget); |
| 62 CPDFXFA_Page* GetPDFXFAPage() { return m_page; } |
| 63 #endif // PDF_ENABLE_XFA |
| 64 |
| 65 CPDF_Page* GetPDFPage() const; |
| 66 CPDF_Document* GetPDFDocument(); |
| 67 CPDFSDK_Document* GetSDKDocument() { return m_pSDKDoc; } |
| 68 FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, FX_UINT nFlag); |
| 69 FX_BOOL OnLButtonUp(const CFX_FloatPoint& point, FX_UINT nFlag); |
| 70 #ifdef PDF_ENABLE_XFA |
| 71 FX_BOOL OnRButtonDown(const CFX_FloatPoint& point, FX_UINT nFlag); |
| 72 FX_BOOL OnRButtonUp(const CFX_FloatPoint& point, FX_UINT nFlag); |
| 73 #endif // PDF_ENABLE_XFA |
| 74 FX_BOOL OnChar(int nChar, FX_UINT nFlag); |
| 75 FX_BOOL OnKeyDown(int nKeyCode, int nFlag); |
| 76 FX_BOOL OnKeyUp(int nKeyCode, int nFlag); |
| 77 |
| 78 FX_BOOL OnMouseMove(const CFX_FloatPoint& point, int nFlag); |
| 79 FX_BOOL OnMouseWheel(double deltaX, |
| 80 double deltaY, |
| 81 const CFX_FloatPoint& point, |
| 82 int nFlag); |
| 83 bool IsValidAnnot(const CPDF_Annot* p) const; |
| 84 void GetCurrentMatrix(CFX_Matrix& matrix) { matrix = m_curMatrix; } |
| 85 void UpdateRects(const std::vector<CFX_FloatRect>& rects); |
| 86 void UpdateView(CPDFSDK_Annot* pAnnot); |
| 87 const std::vector<CPDFSDK_Annot*>& GetAnnotList() const { |
| 88 return m_fxAnnotArray; |
| 89 } |
| 90 |
| 91 int GetPageIndex() const; |
| 92 void LoadFXAnnots(); |
| 93 void ClearFXAnnots(); |
| 94 void SetValid(FX_BOOL bValid) { m_bValid = bValid; } |
| 95 FX_BOOL IsValid() { return m_bValid; } |
| 96 void SetLock(FX_BOOL bLocked) { m_bLocked = bLocked; } |
| 97 FX_BOOL IsLocked() { return m_bLocked; } |
| 98 #ifndef PDF_ENABLE_XFA |
| 99 bool OwnsPage() const { return m_bOwnsPage; } |
| 100 void TakePageOwnership() { m_bOwnsPage = true; } |
| 101 #endif // PDF_ENABLE_XFA |
| 102 |
| 103 private: |
| 104 int GetPageIndexForStaticPDF() const; |
| 105 |
| 106 CFX_Matrix m_curMatrix; |
| 107 UnderlyingPageType* const m_page; |
| 108 std::unique_ptr<CPDF_AnnotList> m_pAnnotList; |
| 109 std::vector<CPDFSDK_Annot*> m_fxAnnotArray; |
| 110 CPDFSDK_Document* const m_pSDKDoc; |
| 111 CPDFSDK_Annot* m_CaptureWidget; |
| 112 #ifndef PDF_ENABLE_XFA |
| 113 bool m_bOwnsPage; |
| 114 #endif // PDF_ENABLE_XFA |
| 115 FX_BOOL m_bEnterWidget; |
| 116 FX_BOOL m_bExitWidget; |
| 117 FX_BOOL m_bOnWidget; |
| 118 FX_BOOL m_bValid; |
| 119 FX_BOOL m_bLocked; |
| 120 }; |
| 121 |
| 122 #endif // FPDFSDK_INCLUDE_CPDFSDK_PAGEVIEW_H_ |
OLD | NEW |