| 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/cfwl_picturebox.h" | 7 #include "xfa/fwl/core/cfwl_picturebox.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "third_party/base/ptr_util.h" | 11 #include "third_party/base/ptr_util.h" |
| 12 | 12 |
| 13 CFWL_PictureBox::CFWL_PictureBox(const IFWL_App* app) : CFWL_Widget(app) {} | 13 CFWL_PictureBox::CFWL_PictureBox(const IFWL_App* app) |
| 14 : CFWL_Widget(app), |
| 15 m_pBitmap(nullptr), |
| 16 m_iOpacity(0), |
| 17 m_iFlipMode(0), |
| 18 m_fRotation(0.0f), |
| 19 m_fScaleX(1.0f), |
| 20 m_fScaleY(1.0f), |
| 21 m_fOffSetX(0.0f), |
| 22 m_fOffSetY(0.0f) {} |
| 14 | 23 |
| 15 CFWL_PictureBox::~CFWL_PictureBox() {} | 24 CFWL_PictureBox::~CFWL_PictureBox() {} |
| 16 | 25 |
| 17 void CFWL_PictureBox::Initialize() { | 26 void CFWL_PictureBox::Initialize() { |
| 18 ASSERT(!m_pIface); | 27 ASSERT(!m_pIface); |
| 19 | 28 |
| 20 m_pIface = pdfium::MakeUnique<IFWL_PictureBox>( | 29 m_pIface = pdfium::MakeUnique<IFWL_PictureBox>( |
| 21 m_pApp, pdfium::MakeUnique<CFWL_WidgetProperties>(&m_PictureBoxDP)); | 30 m_pApp, pdfium::MakeUnique<CFWL_WidgetProperties>(this)); |
| 22 | 31 |
| 23 CFWL_Widget::Initialize(); | 32 CFWL_Widget::Initialize(); |
| 24 } | 33 } |
| 25 | 34 |
| 26 CFX_DIBitmap* CFWL_PictureBox::GetPicture() { | 35 CFX_DIBitmap* CFWL_PictureBox::GetPicture() { |
| 27 return m_PictureBoxDP.m_pBitmap; | 36 return m_pBitmap; |
| 28 } | 37 } |
| 29 | 38 |
| 30 FWL_Error CFWL_PictureBox::SetPicture(CFX_DIBitmap* pBitmap) { | 39 FWL_Error CFWL_PictureBox::SetPicture(CFX_DIBitmap* pBitmap) { |
| 31 m_PictureBoxDP.m_pBitmap = pBitmap; | 40 m_pBitmap = pBitmap; |
| 32 return FWL_Error::Succeeded; | 41 return FWL_Error::Succeeded; |
| 33 } | 42 } |
| 34 | 43 |
| 35 FX_FLOAT CFWL_PictureBox::GetRotation() { | 44 FX_FLOAT CFWL_PictureBox::GetRotation() { |
| 36 return m_PictureBoxDP.m_fRotation; | 45 return m_fRotation; |
| 37 } | 46 } |
| 38 | 47 |
| 39 FWL_Error CFWL_PictureBox::SetRotation(FX_FLOAT fRotation) { | 48 FWL_Error CFWL_PictureBox::SetRotation(FX_FLOAT fRotation) { |
| 40 m_PictureBoxDP.m_fRotation = fRotation; | 49 m_fRotation = fRotation; |
| 41 return FWL_Error::Succeeded; | 50 return FWL_Error::Succeeded; |
| 42 } | 51 } |
| 43 | 52 |
| 44 int32_t CFWL_PictureBox::GetFlipMode() { | 53 int32_t CFWL_PictureBox::GetFlipMode() { |
| 45 return m_PictureBoxDP.GetFlipMode(m_pIface.get()); | 54 return GetFlipMode(m_pIface.get()); |
| 46 } | 55 } |
| 47 | 56 |
| 48 FWL_Error CFWL_PictureBox::SetFlipMode(int32_t iFlipMode) { | 57 FWL_Error CFWL_PictureBox::SetFlipMode(int32_t iFlipMode) { |
| 49 m_PictureBoxDP.m_iFlipMode = iFlipMode; | 58 m_iFlipMode = iFlipMode; |
| 50 return FWL_Error::Succeeded; | 59 return FWL_Error::Succeeded; |
| 51 } | 60 } |
| 52 | 61 |
| 53 int32_t CFWL_PictureBox::GetOpacity() { | 62 int32_t CFWL_PictureBox::GetOpacity() { |
| 54 return m_PictureBoxDP.GetOpacity(m_pIface.get()); | 63 return GetOpacity(m_pIface.get()); |
| 55 } | 64 } |
| 56 | 65 |
| 57 FWL_Error CFWL_PictureBox::SetOpacity(int32_t iOpacity) { | 66 FWL_Error CFWL_PictureBox::SetOpacity(int32_t iOpacity) { |
| 58 m_PictureBoxDP.m_iOpacity = iOpacity; | 67 m_iOpacity = iOpacity; |
| 59 return FWL_Error::Succeeded; | 68 return FWL_Error::Succeeded; |
| 60 } | 69 } |
| 61 | 70 |
| 62 FWL_Error CFWL_PictureBox::GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY) { | 71 FWL_Error CFWL_PictureBox::GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY) { |
| 63 CFX_Matrix matrix; | 72 CFX_Matrix matrix; |
| 64 m_PictureBoxDP.GetMatrix(m_pIface.get(), matrix); | 73 GetMatrix(m_pIface.get(), matrix); |
| 65 matrix.Scale(fScaleX, fScaleY); | 74 matrix.Scale(fScaleX, fScaleY); |
| 66 return FWL_Error::Succeeded; | 75 return FWL_Error::Succeeded; |
| 67 } | 76 } |
| 68 | 77 |
| 69 FWL_Error CFWL_PictureBox::SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY) { | 78 FWL_Error CFWL_PictureBox::SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY) { |
| 70 m_PictureBoxDP.m_fScaleX = fScaleX; | 79 m_fScaleX = fScaleX; |
| 71 m_PictureBoxDP.m_fScaleY = fScaleY; | 80 m_fScaleY = fScaleY; |
| 72 return FWL_Error::Succeeded; | 81 return FWL_Error::Succeeded; |
| 73 } | 82 } |
| 74 | 83 |
| 75 FWL_Error CFWL_PictureBox::GetOffset(FX_FLOAT& fx, FX_FLOAT& fy) { | 84 FWL_Error CFWL_PictureBox::GetOffset(FX_FLOAT& fx, FX_FLOAT& fy) { |
| 76 CFX_Matrix matrix; | 85 CFX_Matrix matrix; |
| 77 m_PictureBoxDP.GetMatrix(m_pIface.get(), matrix); | 86 GetMatrix(m_pIface.get(), matrix); |
| 78 fx = matrix.e; | 87 fx = matrix.e; |
| 79 fy = matrix.f; | 88 fy = matrix.f; |
| 80 return FWL_Error::Succeeded; | 89 return FWL_Error::Succeeded; |
| 81 } | 90 } |
| 82 | 91 |
| 83 FWL_Error CFWL_PictureBox::SetOffset(FX_FLOAT fx, FX_FLOAT fy) { | 92 FWL_Error CFWL_PictureBox::SetOffset(FX_FLOAT fx, FX_FLOAT fy) { |
| 84 m_PictureBoxDP.m_fOffSetX = fx; | 93 m_fOffSetX = fx; |
| 85 m_PictureBoxDP.m_fOffSetY = fy; | 94 m_fOffSetY = fy; |
| 86 return FWL_Error::Succeeded; | 95 return FWL_Error::Succeeded; |
| 87 } | 96 } |
| 88 | 97 |
| 89 CFWL_PictureBox::CFWL_PictureBoxDP::CFWL_PictureBoxDP() | 98 FWL_Error CFWL_PictureBox::GetCaption(IFWL_Widget* pWidget, |
| 90 : m_pBitmap(nullptr), | 99 CFX_WideString& wsCaption) { |
| 91 m_iOpacity(0), | |
| 92 m_iFlipMode(0), | |
| 93 m_fRotation(0.0f), | |
| 94 m_fScaleX(1.0f), | |
| 95 m_fScaleY(1.0f), | |
| 96 m_fOffSetX(0.0f), | |
| 97 m_fOffSetY(0.0f) {} | |
| 98 | |
| 99 FWL_Error CFWL_PictureBox::CFWL_PictureBoxDP::GetCaption( | |
| 100 IFWL_Widget* pWidget, | |
| 101 CFX_WideString& wsCaption) { | |
| 102 return FWL_Error::Succeeded; | 100 return FWL_Error::Succeeded; |
| 103 } | 101 } |
| 104 | 102 |
| 105 CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetPicture( | 103 CFX_DIBitmap* CFWL_PictureBox::GetPicture(IFWL_Widget* pWidget) { |
| 106 IFWL_Widget* pWidget) { | |
| 107 return m_pBitmap; | 104 return m_pBitmap; |
| 108 } | 105 } |
| 109 | 106 |
| 110 CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetErrorPicture( | 107 CFX_DIBitmap* CFWL_PictureBox::GetErrorPicture(IFWL_Widget* pWidget) { |
| 111 IFWL_Widget* pWidget) { | |
| 112 return m_pBitmap; | 108 return m_pBitmap; |
| 113 } | 109 } |
| 114 | 110 |
| 115 CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetInitialPicture( | 111 CFX_DIBitmap* CFWL_PictureBox::GetInitialPicture(IFWL_Widget* pWidget) { |
| 116 IFWL_Widget* pWidget) { | |
| 117 return m_pBitmap; | 112 return m_pBitmap; |
| 118 } | 113 } |
| 119 | 114 |
| 120 int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetOpacity(IFWL_Widget* pWidget) { | 115 int32_t CFWL_PictureBox::GetOpacity(IFWL_Widget* pWidget) { |
| 121 return m_iOpacity; | 116 return m_iOpacity; |
| 122 } | 117 } |
| 123 | 118 |
| 124 FWL_Error CFWL_PictureBox::CFWL_PictureBoxDP::GetMatrix(IFWL_Widget* pWidget, | 119 FWL_Error CFWL_PictureBox::GetMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) { |
| 125 CFX_Matrix& matrix) { | |
| 126 CFX_RectF rect; | 120 CFX_RectF rect; |
| 127 pWidget->GetClientRect(rect); | 121 pWidget->GetClientRect(rect); |
| 128 FX_FLOAT fLen = rect.width / 2; | 122 FX_FLOAT fLen = rect.width / 2; |
| 129 FX_FLOAT fWid = rect.height / 2; | 123 FX_FLOAT fWid = rect.height / 2; |
| 130 matrix.SetIdentity(); | 124 matrix.SetIdentity(); |
| 131 matrix.Translate(-fLen, -fWid); | 125 matrix.Translate(-fLen, -fWid); |
| 132 matrix.Rotate(m_fRotation); | 126 matrix.Rotate(m_fRotation); |
| 133 matrix.Translate(fLen, fWid); | 127 matrix.Translate(fLen, fWid); |
| 134 matrix.Scale(m_fScaleX, m_fScaleY); | 128 matrix.Scale(m_fScaleX, m_fScaleY); |
| 135 matrix.Translate(m_fOffSetX, m_fOffSetY); | 129 matrix.Translate(m_fOffSetX, m_fOffSetY); |
| 136 return FWL_Error::Succeeded; | 130 return FWL_Error::Succeeded; |
| 137 } | 131 } |
| 138 | 132 |
| 139 int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetFlipMode(IFWL_Widget* pWidget) { | 133 int32_t CFWL_PictureBox::GetFlipMode(IFWL_Widget* pWidget) { |
| 140 return m_iFlipMode; | 134 return m_iFlipMode; |
| 141 } | 135 } |
| OLD | NEW |