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 "third_party/base/ptr_util.h" |
10 #include "xfa/fwl/core/cfwl_picturebox.h" | 10 #include "xfa/fwl/core/cfwl_picturebox.h" |
11 #include "xfa/fwl/core/fwl_noteimp.h" | 11 #include "xfa/fwl/core/fwl_noteimp.h" |
12 | 12 |
13 IFWL_PictureBox::IFWL_PictureBox(const IFWL_App* app, | 13 IFWL_PictureBox::IFWL_PictureBox(const IFWL_App* app, |
14 const CFWL_WidgetImpProperties& properties) | 14 const CFWL_WidgetImpProperties& properties) |
15 : IFWL_Widget(app, properties, nullptr), | 15 : IFWL_Widget(app, properties, nullptr), |
16 m_bTop(FALSE), | 16 m_bTop(false), |
17 m_bVCenter(FALSE), | 17 m_bVCenter(false), |
18 m_bButton(FALSE) { | 18 m_bButton(false) { |
19 m_rtClient.Reset(); | 19 m_rtClient.Reset(); |
20 m_rtImage.Reset(); | 20 m_rtImage.Reset(); |
21 m_matrix.SetIdentity(); | 21 m_matrix.SetIdentity(); |
22 } | 22 } |
23 | 23 |
24 IFWL_PictureBox::~IFWL_PictureBox() {} | 24 IFWL_PictureBox::~IFWL_PictureBox() {} |
25 | 25 |
26 FWL_Type IFWL_PictureBox::GetClassID() const { | 26 FWL_Type IFWL_PictureBox::GetClassID() const { |
27 return FWL_Type::PictureBox; | 27 return FWL_Type::PictureBox; |
28 } | 28 } |
29 | 29 |
30 FWL_Error IFWL_PictureBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 30 FWL_Error IFWL_PictureBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { |
31 if (bAutoSize) { | 31 if (bAutoSize) { |
32 rect.Set(0, 0, 0, 0); | 32 rect.Set(0, 0, 0, 0); |
33 if (!m_pProperties->m_pDataProvider) | 33 if (!m_pProperties->m_pDataProvider) |
34 return FWL_Error::Indefinite; | 34 return FWL_Error::Indefinite; |
35 CFX_DIBitmap* pBitmap = | 35 CFX_DIBitmap* pBitmap = |
36 static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider) | 36 static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider) |
37 ->GetPicture(this); | 37 ->GetPicture(this); |
38 if (pBitmap) { | 38 if (pBitmap) { |
39 rect.Set(0, 0, (FX_FLOAT)pBitmap->GetWidth(), | 39 rect.Set(0, 0, (FX_FLOAT)pBitmap->GetWidth(), |
40 (FX_FLOAT)pBitmap->GetHeight()); | 40 (FX_FLOAT)pBitmap->GetHeight()); |
41 } | 41 } |
42 IFWL_Widget::GetWidgetRect(rect, TRUE); | 42 IFWL_Widget::GetWidgetRect(rect, true); |
43 } else { | 43 } else { |
44 rect = m_pProperties->m_rtWidget; | 44 rect = m_pProperties->m_rtWidget; |
45 } | 45 } |
46 return FWL_Error::Succeeded; | 46 return FWL_Error::Succeeded; |
47 } | 47 } |
48 | 48 |
49 FWL_Error IFWL_PictureBox::Update() { | 49 FWL_Error IFWL_PictureBox::Update() { |
50 if (IsLocked()) { | 50 if (IsLocked()) { |
51 return FWL_Error::Succeeded; | 51 return FWL_Error::Succeeded; |
52 } | 52 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 fy = m_rtClient.height; | 98 fy = m_rtClient.height; |
99 } | 99 } |
100 pGraphics->DrawImage(pPicture, CFX_PointF((m_rtClient.width - fx) / 2, | 100 pGraphics->DrawImage(pPicture, CFX_PointF((m_rtClient.width - fx) / 2, |
101 (m_rtClient.height - fy) / 2), | 101 (m_rtClient.height - fy) / 2), |
102 &matrix); | 102 &matrix); |
103 } | 103 } |
104 | 104 |
105 bool IFWL_PictureBox::VStyle(uint32_t dwStyle) { | 105 bool IFWL_PictureBox::VStyle(uint32_t dwStyle) { |
106 switch (dwStyle & FWL_STYLEEXT_PTB_VAlignMask) { | 106 switch (dwStyle & FWL_STYLEEXT_PTB_VAlignMask) { |
107 case FWL_STYLEEXT_PTB_Top: | 107 case FWL_STYLEEXT_PTB_Top: |
108 m_bTop = TRUE; | 108 m_bTop = true; |
109 return true; | 109 return true; |
110 case FWL_STYLEEXT_PTB_Vcenter: | 110 case FWL_STYLEEXT_PTB_Vcenter: |
111 m_bVCenter = TRUE; | 111 m_bVCenter = true; |
112 return true; | 112 return true; |
113 case FWL_STYLEEXT_PTB_Bottom: | 113 case FWL_STYLEEXT_PTB_Bottom: |
114 m_bButton = TRUE; | 114 m_bButton = true; |
115 return true; | 115 return true; |
116 } | 116 } |
117 return false; | 117 return false; |
118 } | 118 } |
119 | 119 |
120 void IFWL_PictureBox::OnDrawWidget(CFX_Graphics* pGraphics, | 120 void IFWL_PictureBox::OnDrawWidget(CFX_Graphics* pGraphics, |
121 const CFX_Matrix* pMatrix) { | 121 const CFX_Matrix* pMatrix) { |
122 DrawWidget(pGraphics, pMatrix); | 122 DrawWidget(pGraphics, pMatrix); |
123 } | 123 } |
OLD | NEW |