Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Side by Side Diff: xfa/fwl/lightwidget/cfwl_picturebox.cpp

Issue 2430923006: Move fwl/lightwidget to fwl/core (Closed)
Patch Set: Rebase to master Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fwl/lightwidget/cfwl_picturebox.h ('k') | xfa/fwl/lightwidget/cfwl_pushbutton.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/fwl/lightwidget/cfwl_picturebox.h"
8
9 #include <memory>
10
11 IFWL_PictureBox* CFWL_PictureBox::GetWidget() {
12 return static_cast<IFWL_PictureBox*>(m_pIface.get());
13 }
14
15 const IFWL_PictureBox* CFWL_PictureBox::GetWidget() const {
16 return static_cast<IFWL_PictureBox*>(m_pIface.get());
17 }
18
19 FWL_Error CFWL_PictureBox::Initialize(
20 const CFWL_WidgetProperties* pProperties) {
21 if (m_pIface)
22 return FWL_Error::Indefinite;
23 if (pProperties) {
24 *m_pProperties = *pProperties;
25 }
26 std::unique_ptr<IFWL_PictureBox> pPictureBox(new IFWL_PictureBox(
27 m_pProperties->MakeWidgetImpProperties(&m_PictureBoxDP)));
28 FWL_Error ret = pPictureBox->Initialize();
29 if (ret != FWL_Error::Succeeded) {
30 return ret;
31 }
32 m_pIface = std::move(pPictureBox);
33 CFWL_Widget::Initialize();
34 return FWL_Error::Succeeded;
35 }
36
37 CFX_DIBitmap* CFWL_PictureBox::GetPicture() {
38 return m_PictureBoxDP.m_pBitmap;
39 }
40
41 FWL_Error CFWL_PictureBox::SetPicture(CFX_DIBitmap* pBitmap) {
42 m_PictureBoxDP.m_pBitmap = pBitmap;
43 return FWL_Error::Succeeded;
44 }
45
46 FX_FLOAT CFWL_PictureBox::GetRotation() {
47 return m_PictureBoxDP.m_fRotation;
48 }
49
50 FWL_Error CFWL_PictureBox::SetRotation(FX_FLOAT fRotation) {
51 m_PictureBoxDP.m_fRotation = fRotation;
52 return FWL_Error::Succeeded;
53 }
54
55 int32_t CFWL_PictureBox::GetFlipMode() {
56 return m_PictureBoxDP.GetFlipMode(m_pIface.get());
57 }
58
59 FWL_Error CFWL_PictureBox::SetFlipMode(int32_t iFlipMode) {
60 m_PictureBoxDP.m_iFlipMode = iFlipMode;
61 return FWL_Error::Succeeded;
62 }
63
64 int32_t CFWL_PictureBox::GetOpacity() {
65 return m_PictureBoxDP.GetOpacity(m_pIface.get());
66 }
67
68 FWL_Error CFWL_PictureBox::SetOpacity(int32_t iOpacity) {
69 m_PictureBoxDP.m_iOpacity = iOpacity;
70 return FWL_Error::Succeeded;
71 }
72
73 FWL_Error CFWL_PictureBox::GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY) {
74 CFX_Matrix matrix;
75 m_PictureBoxDP.GetMatrix(m_pIface.get(), matrix);
76 matrix.Scale(fScaleX, fScaleY);
77 return FWL_Error::Succeeded;
78 }
79
80 FWL_Error CFWL_PictureBox::SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY) {
81 m_PictureBoxDP.m_fScaleX = fScaleX;
82 m_PictureBoxDP.m_fScaleY = fScaleY;
83 return FWL_Error::Succeeded;
84 }
85
86 FWL_Error CFWL_PictureBox::GetOffset(FX_FLOAT& fx, FX_FLOAT& fy) {
87 CFX_Matrix matrix;
88 m_PictureBoxDP.GetMatrix(m_pIface.get(), matrix);
89 fx = matrix.e;
90 fy = matrix.f;
91 return FWL_Error::Succeeded;
92 }
93
94 FWL_Error CFWL_PictureBox::SetOffset(FX_FLOAT fx, FX_FLOAT fy) {
95 m_PictureBoxDP.m_fOffSetX = fx;
96 m_PictureBoxDP.m_fOffSetY = fy;
97 return FWL_Error::Succeeded;
98 }
99
100 CFWL_PictureBox::CFWL_PictureBox() {}
101
102 CFWL_PictureBox::~CFWL_PictureBox() {}
103
104 CFWL_PictureBox::CFWL_PictureBoxDP::CFWL_PictureBoxDP()
105 : m_pBitmap(nullptr),
106 m_iOpacity(0),
107 m_iFlipMode(0),
108 m_fRotation(0.0f),
109 m_fScaleX(1.0f),
110 m_fScaleY(1.0f),
111 m_fOffSetX(0.0f),
112 m_fOffSetY(0.0f) {}
113
114 FWL_Error CFWL_PictureBox::CFWL_PictureBoxDP::GetCaption(
115 IFWL_Widget* pWidget,
116 CFX_WideString& wsCaption) {
117 return FWL_Error::Succeeded;
118 }
119
120 CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetPicture(
121 IFWL_Widget* pWidget) {
122 return m_pBitmap;
123 }
124
125 CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetErrorPicture(
126 IFWL_Widget* pWidget) {
127 return m_pBitmap;
128 }
129
130 CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetInitialPicture(
131 IFWL_Widget* pWidget) {
132 return m_pBitmap;
133 }
134
135 int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetOpacity(IFWL_Widget* pWidget) {
136 return m_iOpacity;
137 }
138
139 FWL_Error CFWL_PictureBox::CFWL_PictureBoxDP::GetMatrix(IFWL_Widget* pWidget,
140 CFX_Matrix& matrix) {
141 CFX_RectF rect;
142 pWidget->GetClientRect(rect);
143 FX_FLOAT fLen = rect.width / 2;
144 FX_FLOAT fWid = rect.height / 2;
145 matrix.SetIdentity();
146 matrix.Translate(-fLen, -fWid);
147 matrix.Rotate(m_fRotation);
148 matrix.Translate(fLen, fWid);
149 matrix.Scale(m_fScaleX, m_fScaleY);
150 matrix.Translate(m_fOffSetX, m_fOffSetY);
151 return FWL_Error::Succeeded;
152 }
153
154 int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetFlipMode(IFWL_Widget* pWidget) {
155 return m_iFlipMode;
156 }
OLDNEW
« no previous file with comments | « xfa/fwl/lightwidget/cfwl_picturebox.h ('k') | xfa/fwl/lightwidget/cfwl_pushbutton.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698