| 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/basewidget/fwl_pictureboximp.h" | 7 #include "xfa/fwl/basewidget/fwl_pictureboximp.h" |
| 8 | 8 |
| 9 #include "xfa/fwl/core/fwl_noteimp.h" | 9 #include "xfa/fwl/core/fwl_noteimp.h" |
| 10 #include "xfa/fwl/core/fwl_widgetimp.h" | 10 #include "xfa/fwl/core/fwl_widgetimp.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 IFWL_Widget* pOuter) | 28 IFWL_Widget* pOuter) |
| 29 : CFWL_WidgetImp(properties, pOuter), | 29 : CFWL_WidgetImp(properties, pOuter), |
| 30 m_bTop(FALSE), | 30 m_bTop(FALSE), |
| 31 m_bVCenter(FALSE), | 31 m_bVCenter(FALSE), |
| 32 m_bButton(FALSE) { | 32 m_bButton(FALSE) { |
| 33 m_rtClient.Reset(); | 33 m_rtClient.Reset(); |
| 34 m_rtImage.Reset(); | 34 m_rtImage.Reset(); |
| 35 m_matrix.SetIdentity(); | 35 m_matrix.SetIdentity(); |
| 36 } | 36 } |
| 37 CFWL_PictureBoxImp::~CFWL_PictureBoxImp() {} | 37 CFWL_PictureBoxImp::~CFWL_PictureBoxImp() {} |
| 38 FWL_ERR CFWL_PictureBoxImp::GetClassName(CFX_WideString& wsClass) const { | 38 FWL_Error CFWL_PictureBoxImp::GetClassName(CFX_WideString& wsClass) const { |
| 39 wsClass = FWL_CLASS_PictureBox; | 39 wsClass = FWL_CLASS_PictureBox; |
| 40 return FWL_ERR_Succeeded; | 40 return FWL_Error::Succeeded; |
| 41 } | 41 } |
| 42 uint32_t CFWL_PictureBoxImp::GetClassID() const { | 42 uint32_t CFWL_PictureBoxImp::GetClassID() const { |
| 43 return FWL_CLASSHASH_PictureBox; | 43 return FWL_CLASSHASH_PictureBox; |
| 44 } | 44 } |
| 45 FWL_ERR CFWL_PictureBoxImp::Initialize() { | 45 FWL_Error CFWL_PictureBoxImp::Initialize() { |
| 46 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) | 46 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) |
| 47 return FWL_ERR_Indefinite; | 47 return FWL_Error::Indefinite; |
| 48 m_pDelegate = new CFWL_PictureBoxImpDelegate(this); | 48 m_pDelegate = new CFWL_PictureBoxImpDelegate(this); |
| 49 return FWL_ERR_Succeeded; | 49 return FWL_Error::Succeeded; |
| 50 } | 50 } |
| 51 FWL_ERR CFWL_PictureBoxImp::Finalize() { | 51 FWL_Error CFWL_PictureBoxImp::Finalize() { |
| 52 delete m_pDelegate; | 52 delete m_pDelegate; |
| 53 m_pDelegate = nullptr; | 53 m_pDelegate = nullptr; |
| 54 return CFWL_WidgetImp::Finalize(); | 54 return CFWL_WidgetImp::Finalize(); |
| 55 } | 55 } |
| 56 FWL_ERR CFWL_PictureBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 56 FWL_Error CFWL_PictureBoxImp::GetWidgetRect(CFX_RectF& rect, |
| 57 FX_BOOL bAutoSize) { |
| 57 if (bAutoSize) { | 58 if (bAutoSize) { |
| 58 rect.Set(0, 0, 0, 0); | 59 rect.Set(0, 0, 0, 0); |
| 59 if (!m_pProperties->m_pDataProvider) | 60 if (!m_pProperties->m_pDataProvider) |
| 60 return FWL_ERR_Indefinite; | 61 return FWL_Error::Indefinite; |
| 61 CFX_DIBitmap* pBitmap = | 62 CFX_DIBitmap* pBitmap = |
| 62 static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider) | 63 static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider) |
| 63 ->GetPicture(m_pInterface); | 64 ->GetPicture(m_pInterface); |
| 64 if (pBitmap) { | 65 if (pBitmap) { |
| 65 rect.Set(0, 0, (FX_FLOAT)pBitmap->GetWidth(), | 66 rect.Set(0, 0, (FX_FLOAT)pBitmap->GetWidth(), |
| 66 (FX_FLOAT)pBitmap->GetHeight()); | 67 (FX_FLOAT)pBitmap->GetHeight()); |
| 67 } | 68 } |
| 68 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); | 69 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); |
| 69 } else { | 70 } else { |
| 70 rect = m_pProperties->m_rtWidget; | 71 rect = m_pProperties->m_rtWidget; |
| 71 } | 72 } |
| 72 return FWL_ERR_Succeeded; | 73 return FWL_Error::Succeeded; |
| 73 } | 74 } |
| 74 FWL_ERR CFWL_PictureBoxImp::Update() { | 75 FWL_Error CFWL_PictureBoxImp::Update() { |
| 75 if (IsLocked()) { | 76 if (IsLocked()) { |
| 76 return FWL_ERR_Succeeded; | 77 return FWL_Error::Succeeded; |
| 77 } | 78 } |
| 78 if (!m_pProperties->m_pThemeProvider) { | 79 if (!m_pProperties->m_pThemeProvider) { |
| 79 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 80 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 80 } | 81 } |
| 81 GetClientRect(m_rtClient); | 82 GetClientRect(m_rtClient); |
| 82 return FWL_ERR_Succeeded; | 83 return FWL_Error::Succeeded; |
| 83 } | 84 } |
| 84 FWL_ERR CFWL_PictureBoxImp::DrawWidget(CFX_Graphics* pGraphics, | 85 FWL_Error CFWL_PictureBoxImp::DrawWidget(CFX_Graphics* pGraphics, |
| 85 const CFX_Matrix* pMatrix) { | 86 const CFX_Matrix* pMatrix) { |
| 86 if (!pGraphics) | 87 if (!pGraphics) |
| 87 return FWL_ERR_Indefinite; | 88 return FWL_Error::Indefinite; |
| 88 if (!m_pProperties->m_pThemeProvider) | 89 if (!m_pProperties->m_pThemeProvider) |
| 89 return FWL_ERR_Indefinite; | 90 return FWL_Error::Indefinite; |
| 90 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); | 91 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); |
| 91 if (HasBorder()) { | 92 if (HasBorder()) { |
| 92 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); | 93 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
| 93 } | 94 } |
| 94 if (HasEdge()) { | 95 if (HasEdge()) { |
| 95 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 96 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
| 96 } | 97 } |
| 97 DrawBkground(pGraphics, pTheme, pMatrix); | 98 DrawBkground(pGraphics, pTheme, pMatrix); |
| 98 return FWL_ERR_Succeeded; | 99 return FWL_Error::Succeeded; |
| 99 } | 100 } |
| 100 void CFWL_PictureBoxImp::DrawBkground(CFX_Graphics* pGraphics, | 101 void CFWL_PictureBoxImp::DrawBkground(CFX_Graphics* pGraphics, |
| 101 IFWL_ThemeProvider* pTheme, | 102 IFWL_ThemeProvider* pTheme, |
| 102 const CFX_Matrix* pMatrix) { | 103 const CFX_Matrix* pMatrix) { |
| 103 IFWL_PictureBoxDP* pPictureDP = | 104 IFWL_PictureBoxDP* pPictureDP = |
| 104 static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider); | 105 static_cast<IFWL_PictureBoxDP*>(m_pProperties->m_pDataProvider); |
| 105 if (!pPictureDP) | 106 if (!pPictureDP) |
| 106 return; | 107 return; |
| 107 | 108 |
| 108 CFX_DIBitmap* pPicture = pPictureDP->GetPicture(m_pInterface); | 109 CFX_DIBitmap* pPicture = pPictureDP->GetPicture(m_pInterface); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 134 return m_bVCenter = TRUE; | 135 return m_bVCenter = TRUE; |
| 135 break; | 136 break; |
| 136 } | 137 } |
| 137 case FWL_STYLEEXT_PTB_Bottom: { | 138 case FWL_STYLEEXT_PTB_Bottom: { |
| 138 return m_bButton = TRUE; | 139 return m_bButton = TRUE; |
| 139 break; | 140 break; |
| 140 } | 141 } |
| 141 } | 142 } |
| 142 return FALSE; | 143 return FALSE; |
| 143 } | 144 } |
| 145 |
| 144 CFWL_PictureBoxImpDelegate::CFWL_PictureBoxImpDelegate( | 146 CFWL_PictureBoxImpDelegate::CFWL_PictureBoxImpDelegate( |
| 145 CFWL_PictureBoxImp* pOwner) | 147 CFWL_PictureBoxImp* pOwner) |
| 146 : m_pOwner(pOwner) {} | 148 : m_pOwner(pOwner) {} |
| 147 FWL_ERR CFWL_PictureBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 149 |
| 148 const CFX_Matrix* pMatrix) { | 150 void CFWL_PictureBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
| 149 return m_pOwner->DrawWidget(pGraphics, pMatrix); | 151 const CFX_Matrix* pMatrix) { |
| 152 m_pOwner->DrawWidget(pGraphics, pMatrix); |
| 150 } | 153 } |
| OLD | NEW |