OLD | NEW |
| (Empty) |
1 // Copyright 2014 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #include "xfa/include/fwl/lightwidget/picturebox.h" | |
8 | |
9 #include <memory> | |
10 | |
11 CFWL_PictureBox* CFWL_PictureBox::Create() { | |
12 return new CFWL_PictureBox; | |
13 } | |
14 FWL_ERR CFWL_PictureBox::Initialize(const CFWL_WidgetProperties* pProperties) { | |
15 if (m_pIface) | |
16 return FWL_ERR_Indefinite; | |
17 if (pProperties) { | |
18 *m_pProperties = *pProperties; | |
19 } | |
20 std::unique_ptr<IFWL_PictureBox> pPictureBox(IFWL_PictureBox::Create( | |
21 m_pProperties->MakeWidgetImpProperties(&m_PictureBoxDP), nullptr)); | |
22 FWL_ERR ret = pPictureBox->Initialize(); | |
23 if (ret != FWL_ERR_Succeeded) { | |
24 return ret; | |
25 } | |
26 m_pIface = pPictureBox.release(); | |
27 CFWL_Widget::Initialize(); | |
28 return FWL_ERR_Succeeded; | |
29 } | |
30 CFX_DIBitmap* CFWL_PictureBox::GetPicture() { | |
31 return m_PictureBoxDP.m_pBitmap; | |
32 } | |
33 FWL_ERR CFWL_PictureBox::SetPicture(CFX_DIBitmap* pBitmap) { | |
34 m_PictureBoxDP.m_pBitmap = pBitmap; | |
35 return FWL_ERR_Succeeded; | |
36 } | |
37 FX_FLOAT CFWL_PictureBox::GetRotation() { | |
38 return m_PictureBoxDP.m_fRotation; | |
39 } | |
40 FWL_ERR CFWL_PictureBox::SetRotation(FX_FLOAT fRotation) { | |
41 m_PictureBoxDP.m_fRotation = fRotation; | |
42 return FWL_ERR_Succeeded; | |
43 } | |
44 int32_t CFWL_PictureBox::GetFlipMode() { | |
45 return m_PictureBoxDP.GetFlipMode(m_pIface); | |
46 } | |
47 FWL_ERR CFWL_PictureBox::SetFlipMode(int32_t iFlipMode) { | |
48 m_PictureBoxDP.m_iFlipMode = iFlipMode; | |
49 return FWL_ERR_Succeeded; | |
50 } | |
51 int32_t CFWL_PictureBox::GetOpacity() { | |
52 return m_PictureBoxDP.GetOpacity(m_pIface); | |
53 } | |
54 FWL_ERR CFWL_PictureBox::SetOpacity(int32_t iOpacity) { | |
55 m_PictureBoxDP.m_iOpacity = iOpacity; | |
56 return FWL_ERR_Succeeded; | |
57 } | |
58 FWL_ERR CFWL_PictureBox::GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY) { | |
59 CFX_Matrix matrix; | |
60 m_PictureBoxDP.GetMatrix(m_pIface, matrix); | |
61 matrix.Scale(fScaleX, fScaleY); | |
62 return FWL_ERR_Succeeded; | |
63 } | |
64 FWL_ERR CFWL_PictureBox::SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY) { | |
65 m_PictureBoxDP.m_fScaleX = fScaleX; | |
66 m_PictureBoxDP.m_fScaleY = fScaleY; | |
67 return FWL_ERR_Succeeded; | |
68 } | |
69 FWL_ERR CFWL_PictureBox::GetOffset(FX_FLOAT& fx, FX_FLOAT& fy) { | |
70 CFX_Matrix matrix; | |
71 m_PictureBoxDP.GetMatrix(m_pIface, matrix); | |
72 fx = matrix.e; | |
73 fy = matrix.f; | |
74 return FWL_ERR_Succeeded; | |
75 } | |
76 FWL_ERR CFWL_PictureBox::SetOffset(FX_FLOAT fx, FX_FLOAT fy) { | |
77 m_PictureBoxDP.m_fOffSetX = fx; | |
78 m_PictureBoxDP.m_fOffSetY = fy; | |
79 return FWL_ERR_Succeeded; | |
80 } | |
81 CFWL_PictureBox::CFWL_PictureBox() {} | |
82 CFWL_PictureBox::~CFWL_PictureBox() {} | |
83 FWL_ERR CFWL_PictureBox::CFWL_PictureBoxDP::GetCaption( | |
84 IFWL_Widget* pWidget, | |
85 CFX_WideString& wsCaption) { | |
86 return FWL_ERR_Succeeded; | |
87 } | |
88 CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetPicture( | |
89 IFWL_Widget* pWidget) { | |
90 return m_pBitmap; | |
91 } | |
92 CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetErrorPicture( | |
93 IFWL_Widget* pWidget) { | |
94 return m_pBitmap; | |
95 } | |
96 CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetInitialPicture( | |
97 IFWL_Widget* pWidget) { | |
98 return m_pBitmap; | |
99 } | |
100 int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetOpacity(IFWL_Widget* pWidget) { | |
101 return m_iOpacity; | |
102 } | |
103 FWL_ERR CFWL_PictureBox::CFWL_PictureBoxDP::GetMatrix(IFWL_Widget* pWidget, | |
104 CFX_Matrix& matrix) { | |
105 CFX_RectF rect; | |
106 pWidget->GetClientRect(rect); | |
107 FX_FLOAT fLen = rect.width / 2; | |
108 FX_FLOAT fWid = rect.height / 2; | |
109 matrix.SetIdentity(); | |
110 matrix.Translate(-fLen, -fWid); | |
111 matrix.Rotate(m_fRotation); | |
112 matrix.Translate(fLen, fWid); | |
113 matrix.Scale(m_fScaleX, m_fScaleY); | |
114 matrix.Translate(m_fOffSetX, m_fOffSetY); | |
115 return FWL_ERR_Succeeded; | |
116 } | |
117 int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetFlipMode(IFWL_Widget* pWidget) { | |
118 return m_iFlipMode; | |
119 } | |
OLD | NEW |