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

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

Issue 2209153002: Use virtual function to retrieve interface pointer (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comment Created 4 years, 4 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
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/lightwidget/cfwl_picturebox.h" 7 #include "xfa/fwl/lightwidget/cfwl_picturebox.h"
8 8
9 #include <memory> 9 #include <memory>
10 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
11 CFWL_PictureBox* CFWL_PictureBox::Create() { 19 CFWL_PictureBox* CFWL_PictureBox::Create() {
12 return new CFWL_PictureBox; 20 return new CFWL_PictureBox;
13 } 21 }
14 22
15 FWL_Error CFWL_PictureBox::Initialize( 23 FWL_Error CFWL_PictureBox::Initialize(
16 const CFWL_WidgetProperties* pProperties) { 24 const CFWL_WidgetProperties* pProperties) {
17 if (m_pIface) 25 if (m_pIface)
18 return FWL_Error::Indefinite; 26 return FWL_Error::Indefinite;
19 if (pProperties) { 27 if (pProperties) {
20 *m_pProperties = *pProperties; 28 *m_pProperties = *pProperties;
21 } 29 }
22 std::unique_ptr<IFWL_PictureBox> pPictureBox(IFWL_PictureBox::Create( 30 std::unique_ptr<IFWL_PictureBox> pPictureBox(IFWL_PictureBox::Create(
23 m_pProperties->MakeWidgetImpProperties(&m_PictureBoxDP), nullptr)); 31 m_pProperties->MakeWidgetImpProperties(&m_PictureBoxDP), nullptr));
24 FWL_Error ret = pPictureBox->Initialize(); 32 FWL_Error ret = pPictureBox->Initialize();
25 if (ret != FWL_Error::Succeeded) { 33 if (ret != FWL_Error::Succeeded) {
26 return ret; 34 return ret;
27 } 35 }
28 m_pIface = pPictureBox.release(); 36 m_pIface = std::move(pPictureBox);
29 CFWL_Widget::Initialize(); 37 CFWL_Widget::Initialize();
30 return FWL_Error::Succeeded; 38 return FWL_Error::Succeeded;
31 } 39 }
32 40
33 CFX_DIBitmap* CFWL_PictureBox::GetPicture() { 41 CFX_DIBitmap* CFWL_PictureBox::GetPicture() {
34 return m_PictureBoxDP.m_pBitmap; 42 return m_PictureBoxDP.m_pBitmap;
35 } 43 }
36 44
37 FWL_Error CFWL_PictureBox::SetPicture(CFX_DIBitmap* pBitmap) { 45 FWL_Error CFWL_PictureBox::SetPicture(CFX_DIBitmap* pBitmap) {
38 m_PictureBoxDP.m_pBitmap = pBitmap; 46 m_PictureBoxDP.m_pBitmap = pBitmap;
39 return FWL_Error::Succeeded; 47 return FWL_Error::Succeeded;
40 } 48 }
41 49
42 FX_FLOAT CFWL_PictureBox::GetRotation() { 50 FX_FLOAT CFWL_PictureBox::GetRotation() {
43 return m_PictureBoxDP.m_fRotation; 51 return m_PictureBoxDP.m_fRotation;
44 } 52 }
45 53
46 FWL_Error CFWL_PictureBox::SetRotation(FX_FLOAT fRotation) { 54 FWL_Error CFWL_PictureBox::SetRotation(FX_FLOAT fRotation) {
47 m_PictureBoxDP.m_fRotation = fRotation; 55 m_PictureBoxDP.m_fRotation = fRotation;
48 return FWL_Error::Succeeded; 56 return FWL_Error::Succeeded;
49 } 57 }
50 58
51 int32_t CFWL_PictureBox::GetFlipMode() { 59 int32_t CFWL_PictureBox::GetFlipMode() {
52 return m_PictureBoxDP.GetFlipMode(m_pIface); 60 return m_PictureBoxDP.GetFlipMode(m_pIface.get());
53 } 61 }
54 62
55 FWL_Error CFWL_PictureBox::SetFlipMode(int32_t iFlipMode) { 63 FWL_Error CFWL_PictureBox::SetFlipMode(int32_t iFlipMode) {
56 m_PictureBoxDP.m_iFlipMode = iFlipMode; 64 m_PictureBoxDP.m_iFlipMode = iFlipMode;
57 return FWL_Error::Succeeded; 65 return FWL_Error::Succeeded;
58 } 66 }
59 67
60 int32_t CFWL_PictureBox::GetOpacity() { 68 int32_t CFWL_PictureBox::GetOpacity() {
61 return m_PictureBoxDP.GetOpacity(m_pIface); 69 return m_PictureBoxDP.GetOpacity(m_pIface.get());
62 } 70 }
63 71
64 FWL_Error CFWL_PictureBox::SetOpacity(int32_t iOpacity) { 72 FWL_Error CFWL_PictureBox::SetOpacity(int32_t iOpacity) {
65 m_PictureBoxDP.m_iOpacity = iOpacity; 73 m_PictureBoxDP.m_iOpacity = iOpacity;
66 return FWL_Error::Succeeded; 74 return FWL_Error::Succeeded;
67 } 75 }
68 76
69 FWL_Error CFWL_PictureBox::GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY) { 77 FWL_Error CFWL_PictureBox::GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY) {
70 CFX_Matrix matrix; 78 CFX_Matrix matrix;
71 m_PictureBoxDP.GetMatrix(m_pIface, matrix); 79 m_PictureBoxDP.GetMatrix(m_pIface.get(), matrix);
72 matrix.Scale(fScaleX, fScaleY); 80 matrix.Scale(fScaleX, fScaleY);
73 return FWL_Error::Succeeded; 81 return FWL_Error::Succeeded;
74 } 82 }
75 83
76 FWL_Error CFWL_PictureBox::SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY) { 84 FWL_Error CFWL_PictureBox::SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY) {
77 m_PictureBoxDP.m_fScaleX = fScaleX; 85 m_PictureBoxDP.m_fScaleX = fScaleX;
78 m_PictureBoxDP.m_fScaleY = fScaleY; 86 m_PictureBoxDP.m_fScaleY = fScaleY;
79 return FWL_Error::Succeeded; 87 return FWL_Error::Succeeded;
80 } 88 }
81 89
82 FWL_Error CFWL_PictureBox::GetOffset(FX_FLOAT& fx, FX_FLOAT& fy) { 90 FWL_Error CFWL_PictureBox::GetOffset(FX_FLOAT& fx, FX_FLOAT& fy) {
83 CFX_Matrix matrix; 91 CFX_Matrix matrix;
84 m_PictureBoxDP.GetMatrix(m_pIface, matrix); 92 m_PictureBoxDP.GetMatrix(m_pIface.get(), matrix);
85 fx = matrix.e; 93 fx = matrix.e;
86 fy = matrix.f; 94 fy = matrix.f;
87 return FWL_Error::Succeeded; 95 return FWL_Error::Succeeded;
88 } 96 }
89 97
90 FWL_Error CFWL_PictureBox::SetOffset(FX_FLOAT fx, FX_FLOAT fy) { 98 FWL_Error CFWL_PictureBox::SetOffset(FX_FLOAT fx, FX_FLOAT fy) {
91 m_PictureBoxDP.m_fOffSetX = fx; 99 m_PictureBoxDP.m_fOffSetX = fx;
92 m_PictureBoxDP.m_fOffSetY = fy; 100 m_PictureBoxDP.m_fOffSetY = fy;
93 return FWL_Error::Succeeded; 101 return FWL_Error::Succeeded;
94 } 102 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 matrix.Rotate(m_fRotation); 151 matrix.Rotate(m_fRotation);
144 matrix.Translate(fLen, fWid); 152 matrix.Translate(fLen, fWid);
145 matrix.Scale(m_fScaleX, m_fScaleY); 153 matrix.Scale(m_fScaleX, m_fScaleY);
146 matrix.Translate(m_fOffSetX, m_fOffSetY); 154 matrix.Translate(m_fOffSetX, m_fOffSetY);
147 return FWL_Error::Succeeded; 155 return FWL_Error::Succeeded;
148 } 156 }
149 157
150 int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetFlipMode(IFWL_Widget* pWidget) { 158 int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetFlipMode(IFWL_Widget* pWidget) {
151 return m_iFlipMode; 159 return m_iFlipMode;
152 } 160 }
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