| 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 10 matching lines...) Expand all Loading... |
| 21 m_rtImage.Reset(); | 21 m_rtImage.Reset(); |
| 22 m_matrix.SetIdentity(); | 22 m_matrix.SetIdentity(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 IFWL_PictureBox::~IFWL_PictureBox() {} | 25 IFWL_PictureBox::~IFWL_PictureBox() {} |
| 26 | 26 |
| 27 FWL_Type IFWL_PictureBox::GetClassID() const { | 27 FWL_Type IFWL_PictureBox::GetClassID() const { |
| 28 return FWL_Type::PictureBox; | 28 return FWL_Type::PictureBox; |
| 29 } | 29 } |
| 30 | 30 |
| 31 FWL_Error IFWL_PictureBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { | 31 void IFWL_PictureBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { |
| 32 if (bAutoSize) { | 32 if (bAutoSize) { |
| 33 rect.Set(0, 0, 0, 0); | 33 rect.Set(0, 0, 0, 0); |
| 34 if (!m_pProperties->m_pDataProvider) | 34 if (!m_pProperties->m_pDataProvider) |
| 35 return FWL_Error::Indefinite; | 35 return; |
| 36 CFX_DIBitmap* pBitmap = | 36 CFX_DIBitmap* pBitmap = |
| 37 static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider) | 37 static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider) |
| 38 ->GetPicture(this); | 38 ->GetPicture(this); |
| 39 if (pBitmap) { | 39 if (pBitmap) { |
| 40 rect.Set(0, 0, (FX_FLOAT)pBitmap->GetWidth(), | 40 rect.Set(0, 0, (FX_FLOAT)pBitmap->GetWidth(), |
| 41 (FX_FLOAT)pBitmap->GetHeight()); | 41 (FX_FLOAT)pBitmap->GetHeight()); |
| 42 } | 42 } |
| 43 IFWL_Widget::GetWidgetRect(rect, true); | 43 IFWL_Widget::GetWidgetRect(rect, true); |
| 44 } else { | 44 } else { |
| 45 rect = m_pProperties->m_rtWidget; | 45 rect = m_pProperties->m_rtWidget; |
| 46 } | 46 } |
| 47 return FWL_Error::Succeeded; | |
| 48 } | 47 } |
| 49 | 48 |
| 50 FWL_Error IFWL_PictureBox::Update() { | 49 void IFWL_PictureBox::Update() { |
| 51 if (IsLocked()) { | 50 if (IsLocked()) { |
| 52 return FWL_Error::Succeeded; | 51 return; |
| 53 } | 52 } |
| 54 if (!m_pProperties->m_pThemeProvider) { | 53 if (!m_pProperties->m_pThemeProvider) { |
| 55 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 54 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 56 } | 55 } |
| 57 GetClientRect(m_rtClient); | 56 GetClientRect(m_rtClient); |
| 58 return FWL_Error::Succeeded; | |
| 59 } | 57 } |
| 60 | 58 |
| 61 FWL_Error IFWL_PictureBox::DrawWidget(CFX_Graphics* pGraphics, | 59 void IFWL_PictureBox::DrawWidget(CFX_Graphics* pGraphics, |
| 62 const CFX_Matrix* pMatrix) { | 60 const CFX_Matrix* pMatrix) { |
| 63 if (!pGraphics) | 61 if (!pGraphics) |
| 64 return FWL_Error::Indefinite; | 62 return; |
| 65 if (!m_pProperties->m_pThemeProvider) | 63 if (!m_pProperties->m_pThemeProvider) |
| 66 return FWL_Error::Indefinite; | 64 return; |
| 67 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); | 65 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); |
| 68 if (HasBorder()) { | 66 if (HasBorder()) { |
| 69 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); | 67 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
| 70 } | 68 } |
| 71 if (HasEdge()) { | 69 if (HasEdge()) { |
| 72 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 70 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
| 73 } | 71 } |
| 74 DrawBkground(pGraphics, pTheme, pMatrix); | 72 DrawBkground(pGraphics, pTheme, pMatrix); |
| 75 return FWL_Error::Succeeded; | |
| 76 } | 73 } |
| 77 | 74 |
| 78 void IFWL_PictureBox::DrawBkground(CFX_Graphics* pGraphics, | 75 void IFWL_PictureBox::DrawBkground(CFX_Graphics* pGraphics, |
| 79 IFWL_ThemeProvider* pTheme, | 76 IFWL_ThemeProvider* pTheme, |
| 80 const CFX_Matrix* pMatrix) { | 77 const CFX_Matrix* pMatrix) { |
| 81 IFWL_PictureBoxDP* pPictureDP = | 78 IFWL_PictureBoxDP* pPictureDP = |
| 82 static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider); | 79 static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider); |
| 83 if (!pPictureDP) | 80 if (!pPictureDP) |
| 84 return; | 81 return; |
| 85 | 82 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 115 m_bButton = true; | 112 m_bButton = true; |
| 116 return true; | 113 return true; |
| 117 } | 114 } |
| 118 return false; | 115 return false; |
| 119 } | 116 } |
| 120 | 117 |
| 121 void IFWL_PictureBox::OnDrawWidget(CFX_Graphics* pGraphics, | 118 void IFWL_PictureBox::OnDrawWidget(CFX_Graphics* pGraphics, |
| 122 const CFX_Matrix* pMatrix) { | 119 const CFX_Matrix* pMatrix) { |
| 123 DrawWidget(pGraphics, pMatrix); | 120 DrawWidget(pGraphics, pMatrix); |
| 124 } | 121 } |
| OLD | NEW |