OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fwl/core/ifwl_picturebox.h" | 7 #include "xfa/fwl/core/ifwl_picturebox.h" |
8 | 8 |
| 9 #include "third_party/base/ptr_util.h" |
9 #include "xfa/fwl/core/cfwl_picturebox.h" | 10 #include "xfa/fwl/core/cfwl_picturebox.h" |
10 #include "xfa/fwl/core/fwl_noteimp.h" | 11 #include "xfa/fwl/core/fwl_noteimp.h" |
11 | 12 |
12 IFWL_PictureBox::IFWL_PictureBox(const IFWL_App* app, | 13 IFWL_PictureBox::IFWL_PictureBox(const IFWL_App* app, |
13 const CFWL_WidgetImpProperties& properties) | 14 const CFWL_WidgetImpProperties& properties) |
14 : IFWL_Widget(app, properties, nullptr), | 15 : IFWL_Widget(app, properties, nullptr), |
15 m_bTop(FALSE), | 16 m_bTop(FALSE), |
16 m_bVCenter(FALSE), | 17 m_bVCenter(FALSE), |
17 m_bButton(FALSE) { | 18 m_bButton(FALSE) { |
18 m_rtClient.Reset(); | 19 m_rtClient.Reset(); |
19 m_rtImage.Reset(); | 20 m_rtImage.Reset(); |
20 m_matrix.SetIdentity(); | 21 m_matrix.SetIdentity(); |
| 22 |
| 23 SetDelegate(pdfium::MakeUnique<CFWL_PictureBoxImpDelegate>(this)); |
21 } | 24 } |
22 | 25 |
23 IFWL_PictureBox::~IFWL_PictureBox() {} | 26 IFWL_PictureBox::~IFWL_PictureBox() {} |
24 | 27 |
25 void IFWL_PictureBox::Initialize() { | |
26 IFWL_Widget::Initialize(); | |
27 m_pDelegate = new CFWL_PictureBoxImpDelegate(this); | |
28 } | |
29 | |
30 void IFWL_PictureBox::Finalize() { | |
31 delete m_pDelegate; | |
32 m_pDelegate = nullptr; | |
33 IFWL_Widget::Finalize(); | |
34 } | |
35 | |
36 FWL_Type IFWL_PictureBox::GetClassID() const { | 28 FWL_Type IFWL_PictureBox::GetClassID() const { |
37 return FWL_Type::PictureBox; | 29 return FWL_Type::PictureBox; |
38 } | 30 } |
39 | 31 |
40 FWL_Error IFWL_PictureBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 32 FWL_Error IFWL_PictureBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
41 if (bAutoSize) { | 33 if (bAutoSize) { |
42 rect.Set(0, 0, 0, 0); | 34 rect.Set(0, 0, 0, 0); |
43 if (!m_pProperties->m_pDataProvider) | 35 if (!m_pProperties->m_pDataProvider) |
44 return FWL_Error::Indefinite; | 36 return FWL_Error::Indefinite; |
45 CFX_DIBitmap* pBitmap = | 37 CFX_DIBitmap* pBitmap = |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 return false; | 119 return false; |
128 } | 120 } |
129 | 121 |
130 CFWL_PictureBoxImpDelegate::CFWL_PictureBoxImpDelegate(IFWL_PictureBox* pOwner) | 122 CFWL_PictureBoxImpDelegate::CFWL_PictureBoxImpDelegate(IFWL_PictureBox* pOwner) |
131 : m_pOwner(pOwner) {} | 123 : m_pOwner(pOwner) {} |
132 | 124 |
133 void CFWL_PictureBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 125 void CFWL_PictureBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
134 const CFX_Matrix* pMatrix) { | 126 const CFX_Matrix* pMatrix) { |
135 m_pOwner->DrawWidget(pGraphics, pMatrix); | 127 m_pOwner->DrawWidget(pGraphics, pMatrix); |
136 } | 128 } |
OLD | NEW |