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