| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 FWL_Type IFWL_PictureBox::GetClassID() const { | 24 FWL_Type IFWL_PictureBox::GetClassID() const { |
| 25 return FWL_Type::PictureBox; | 25 return FWL_Type::PictureBox; |
| 26 } | 26 } |
| 27 | 27 |
| 28 void IFWL_PictureBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { | 28 void IFWL_PictureBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { |
| 29 if (bAutoSize) { | 29 if (bAutoSize) { |
| 30 rect.Set(0, 0, 0, 0); | 30 rect.Set(0, 0, 0, 0); |
| 31 if (!m_pProperties->m_pDataProvider) | 31 if (!m_pProperties->m_pDataProvider) |
| 32 return; | 32 return; |
| 33 CFX_DIBitmap* pBitmap = | |
| 34 static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider) | |
| 35 ->GetPicture(this); | |
| 36 if (pBitmap) { | |
| 37 rect.Set(0, 0, (FX_FLOAT)pBitmap->GetWidth(), | |
| 38 (FX_FLOAT)pBitmap->GetHeight()); | |
| 39 } | |
| 40 IFWL_Widget::GetWidgetRect(rect, true); | 33 IFWL_Widget::GetWidgetRect(rect, true); |
| 41 } else { | 34 } else { |
| 42 rect = m_pProperties->m_rtWidget; | 35 rect = m_pProperties->m_rtWidget; |
| 43 } | 36 } |
| 44 } | 37 } |
| 45 | 38 |
| 46 void IFWL_PictureBox::Update() { | 39 void IFWL_PictureBox::Update() { |
| 47 if (IsLocked()) { | 40 if (IsLocked()) { |
| 48 return; | 41 return; |
| 49 } | 42 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 65 } | 58 } |
| 66 if (HasEdge()) { | 59 if (HasEdge()) { |
| 67 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 60 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
| 68 } | 61 } |
| 69 DrawBkground(pGraphics, pTheme, pMatrix); | 62 DrawBkground(pGraphics, pTheme, pMatrix); |
| 70 } | 63 } |
| 71 | 64 |
| 72 void IFWL_PictureBox::DrawBkground(CFX_Graphics* pGraphics, | 65 void IFWL_PictureBox::DrawBkground(CFX_Graphics* pGraphics, |
| 73 IFWL_ThemeProvider* pTheme, | 66 IFWL_ThemeProvider* pTheme, |
| 74 const CFX_Matrix* pMatrix) { | 67 const CFX_Matrix* pMatrix) { |
| 75 IFWL_PictureBoxDP* pPictureDP = | 68 return; |
| 76 static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider); | |
| 77 if (!pPictureDP) | |
| 78 return; | |
| 79 | |
| 80 CFX_DIBitmap* pPicture = pPictureDP->GetPicture(this); | |
| 81 CFX_Matrix matrix; | |
| 82 pPictureDP->GetMatrix(this, matrix); | |
| 83 if (!pPicture) | |
| 84 return; | |
| 85 | |
| 86 matrix.Concat(*pMatrix); | |
| 87 FX_FLOAT fx = (FX_FLOAT)pPicture->GetWidth(); | |
| 88 FX_FLOAT fy = (FX_FLOAT)pPicture->GetHeight(); | |
| 89 if (fx > m_rtClient.width) { | |
| 90 fx = m_rtClient.width; | |
| 91 } | |
| 92 if (fy > m_rtClient.height) { | |
| 93 fy = m_rtClient.height; | |
| 94 } | |
| 95 pGraphics->DrawImage(pPicture, CFX_PointF((m_rtClient.width - fx) / 2, | |
| 96 (m_rtClient.height - fy) / 2), | |
| 97 &matrix); | |
| 98 } | 69 } |
| 99 | 70 |
| 100 void IFWL_PictureBox::OnDrawWidget(CFX_Graphics* pGraphics, | 71 void IFWL_PictureBox::OnDrawWidget(CFX_Graphics* pGraphics, |
| 101 const CFX_Matrix* pMatrix) { | 72 const CFX_Matrix* pMatrix) { |
| 102 DrawWidget(pGraphics, pMatrix); | 73 DrawWidget(pGraphics, pMatrix); |
| 103 } | 74 } |
| OLD | NEW |