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