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

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

Issue 1952693003: Convert FWL_ERR into an enum class. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 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_widget.h ('k') | xfa/fwl/lightwidget/cfwl_widgetdelegate.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_widget.h" 7 #include "xfa/fwl/lightwidget/cfwl_widget.h"
8 8
9 #include "xfa/fde/tto/fde_textout.h" 9 #include "xfa/fde/tto/fde_textout.h"
10 #include "xfa/fwl/core/cfwl_themetext.h" 10 #include "xfa/fwl/core/cfwl_themetext.h"
11 #include "xfa/fwl/core/fwl_noteimp.h" 11 #include "xfa/fwl/core/fwl_noteimp.h"
12 #include "xfa/fwl/core/fwl_noteimp.h" 12 #include "xfa/fwl/core/fwl_noteimp.h"
13 #include "xfa/fwl/core/fwl_widgetimp.h" 13 #include "xfa/fwl/core/fwl_widgetimp.h"
14 #include "xfa/fwl/core/fwl_widgetmgrimp.h" 14 #include "xfa/fwl/core/fwl_widgetmgrimp.h"
15 #include "xfa/fwl/core/ifwl_app.h" 15 #include "xfa/fwl/core/ifwl_app.h"
16 #include "xfa/fwl/core/ifwl_themeprovider.h" 16 #include "xfa/fwl/core/ifwl_themeprovider.h"
17 17
18 #define FWL_WGT_CalcHeight 2048 18 #define FWL_WGT_CalcHeight 2048
19 #define FWL_WGT_CalcWidth 2048 19 #define FWL_WGT_CalcWidth 2048
20 #define FWL_WGT_CalcMultiLineDefWidth 120.0f 20 #define FWL_WGT_CalcMultiLineDefWidth 120.0f
21 21
22 IFWL_Widget* CFWL_Widget::GetWidget() { 22 IFWL_Widget* CFWL_Widget::GetWidget() {
23 return m_pIface; 23 return m_pIface;
24 } 24 }
25 25
26 FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const { 26 FWL_Error CFWL_Widget::GetClassName(CFX_WideString& wsClass) const {
27 if (!m_pIface) 27 if (!m_pIface)
28 return FWL_ERR_Indefinite; 28 return FWL_Error::Indefinite;
29 return m_pIface->GetClassName(wsClass); 29 return m_pIface->GetClassName(wsClass);
30 } 30 }
31 31
32 uint32_t CFWL_Widget::GetClassID() const { 32 uint32_t CFWL_Widget::GetClassID() const {
33 if (!m_pIface) 33 if (!m_pIface)
34 return 0; 34 return 0;
35 return m_pIface->GetClassID(); 35 return m_pIface->GetClassID();
36 } 36 }
37 37
38 FX_BOOL CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { 38 FX_BOOL CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const {
39 if (!m_pIface) 39 if (!m_pIface)
40 return FALSE; 40 return FALSE;
41 return m_pIface->IsInstance(wsClass); 41 return m_pIface->IsInstance(wsClass);
42 } 42 }
43 43
44 static void* gs_pFWLWidget = (void*)FXBSTR_ID('l', 'i', 'g', 't'); 44 static void* gs_pFWLWidget = (void*)FXBSTR_ID('l', 'i', 'g', 't');
45 45
46 FWL_ERR CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) { 46 FWL_Error CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) {
47 if (!m_pIface) 47 if (!m_pIface)
48 return FWL_ERR_Indefinite; 48 return FWL_Error::Indefinite;
49 return m_pIface->SetPrivateData(gs_pFWLWidget, this, nullptr); 49 return m_pIface->SetPrivateData(gs_pFWLWidget, this, nullptr);
50 } 50 }
51 51
52 FWL_ERR CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { 52 FWL_Error CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
53 if (!m_pIface) 53 if (!m_pIface)
54 return FWL_ERR_Indefinite; 54 return FWL_Error::Indefinite;
55 return m_pIface->GetWidgetRect(rect, bAutoSize); 55 return m_pIface->GetWidgetRect(rect, bAutoSize);
56 } 56 }
57 57
58 FWL_ERR CFWL_Widget::GetGlobalRect(CFX_RectF& rect) { 58 FWL_Error CFWL_Widget::GetGlobalRect(CFX_RectF& rect) {
59 if (!m_pIface) 59 if (!m_pIface)
60 return FWL_ERR_Indefinite; 60 return FWL_Error::Indefinite;
61 return m_pIface->GetGlobalRect(rect); 61 return m_pIface->GetGlobalRect(rect);
62 } 62 }
63 63
64 FWL_ERR CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { 64 FWL_Error CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
65 if (!m_pIface) 65 if (!m_pIface)
66 return FWL_ERR_Indefinite; 66 return FWL_Error::Indefinite;
67 return m_pIface->SetWidgetRect(rect); 67 return m_pIface->SetWidgetRect(rect);
68 } 68 }
69 69
70 FWL_ERR CFWL_Widget::GetClientRect(CFX_RectF& rect) { 70 FWL_Error CFWL_Widget::GetClientRect(CFX_RectF& rect) {
71 if (!m_pIface) 71 if (!m_pIface)
72 return FWL_ERR_Indefinite; 72 return FWL_Error::Indefinite;
73 return m_pIface->GetClientRect(rect); 73 return m_pIface->GetClientRect(rect);
74 } 74 }
75 75
76 CFWL_Widget* CFWL_Widget::GetParent() { 76 CFWL_Widget* CFWL_Widget::GetParent() {
77 if (!m_pIface) 77 if (!m_pIface)
78 return nullptr; 78 return nullptr;
79 79
80 IFWL_Widget* parent = m_pIface->GetParent(); 80 IFWL_Widget* parent = m_pIface->GetParent();
81 if (parent) 81 if (parent)
82 return static_cast<CFWL_Widget*>(parent->GetPrivateData(gs_pFWLWidget)); 82 return static_cast<CFWL_Widget*>(parent->GetPrivateData(gs_pFWLWidget));
83 return nullptr; 83 return nullptr;
84 } 84 }
85 85
86 FWL_ERR CFWL_Widget::SetParent(CFWL_Widget* pParent) { 86 FWL_Error CFWL_Widget::SetParent(CFWL_Widget* pParent) {
87 if (!m_pIface) 87 if (!m_pIface)
88 return FWL_ERR_Indefinite; 88 return FWL_Error::Indefinite;
89 return m_pIface->SetParent(pParent ? pParent->GetWidget() : nullptr); 89 return m_pIface->SetParent(pParent ? pParent->GetWidget() : nullptr);
90 } 90 }
91 91
92 CFWL_Widget* CFWL_Widget::GetOwner() { 92 CFWL_Widget* CFWL_Widget::GetOwner() {
93 return nullptr; 93 return nullptr;
94 } 94 }
95 95
96 FWL_ERR CFWL_Widget::SetOwner(CFWL_Widget* pOwner) { 96 FWL_Error CFWL_Widget::SetOwner(CFWL_Widget* pOwner) {
97 if (!m_pIface) 97 if (!m_pIface)
98 return FWL_ERR_Indefinite; 98 return FWL_Error::Indefinite;
99 return FWL_ERR_Succeeded; 99 return FWL_Error::Succeeded;
100 } 100 }
101 101
102 uint32_t CFWL_Widget::GetStyles() { 102 uint32_t CFWL_Widget::GetStyles() {
103 if (!m_pIface) 103 if (!m_pIface)
104 return 0; 104 return 0;
105 return m_pIface->GetStyles(); 105 return m_pIface->GetStyles();
106 } 106 }
107 107
108 FWL_ERR CFWL_Widget::ModifyStyles(uint32_t dwStylesAdded, 108 FWL_Error CFWL_Widget::ModifyStyles(uint32_t dwStylesAdded,
109 uint32_t dwStylesRemoved) { 109 uint32_t dwStylesRemoved) {
110 if (!m_pIface) 110 if (!m_pIface)
111 return FWL_ERR_Indefinite; 111 return FWL_Error::Indefinite;
112 return m_pIface->ModifyStyles(dwStylesAdded, dwStylesRemoved); 112 return m_pIface->ModifyStyles(dwStylesAdded, dwStylesRemoved);
113 } 113 }
114 114
115 uint32_t CFWL_Widget::GetStylesEx() { 115 uint32_t CFWL_Widget::GetStylesEx() {
116 if (!m_pIface) 116 if (!m_pIface)
117 return 0; 117 return 0;
118 return m_pIface->GetStylesEx(); 118 return m_pIface->GetStylesEx();
119 } 119 }
120 120
121 FWL_ERR CFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded, 121 FWL_Error CFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded,
122 uint32_t dwStylesExRemoved) { 122 uint32_t dwStylesExRemoved) {
123 return m_pIface->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 123 return m_pIface->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
124 } 124 }
125 125
126 uint32_t CFWL_Widget::GetStates() { 126 uint32_t CFWL_Widget::GetStates() {
127 if (!m_pIface) 127 if (!m_pIface)
128 return FWL_ERR_Indefinite; 128 return 0;
129 return m_pIface->GetStates(); 129 return m_pIface->GetStates();
130 } 130 }
131 131
132 void CFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) { 132 void CFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) {
133 if (m_pIface) 133 if (m_pIface)
134 m_pIface->SetStates(dwStates, bSet); 134 m_pIface->SetStates(dwStates, bSet);
135 } 135 }
136 136
137 FWL_ERR CFWL_Widget::SetPrivateData(void* module_id, 137 FWL_Error CFWL_Widget::SetPrivateData(void* module_id,
138 void* pData, 138 void* pData,
139 PD_CALLBACK_FREEDATA callback) { 139 PD_CALLBACK_FREEDATA callback) {
140 if (!m_pIface) 140 if (!m_pIface)
141 return FWL_ERR_Indefinite; 141 return FWL_Error::Indefinite;
142 return m_pIface->SetPrivateData(module_id, pData, callback); 142 return m_pIface->SetPrivateData(module_id, pData, callback);
143 } 143 }
144 144
145 void* CFWL_Widget::GetPrivateData(void* module_id) { 145 void* CFWL_Widget::GetPrivateData(void* module_id) {
146 if (!m_pIface) 146 if (!m_pIface)
147 return nullptr; 147 return nullptr;
148 return m_pIface->GetPrivateData(module_id); 148 return m_pIface->GetPrivateData(module_id);
149 } 149 }
150 150
151 FWL_ERR CFWL_Widget::Update() { 151 FWL_Error CFWL_Widget::Update() {
152 if (!m_pIface) 152 if (!m_pIface)
153 return FWL_ERR_Indefinite; 153 return FWL_Error::Indefinite;
154 return m_pIface->Update(); 154 return m_pIface->Update();
155 } 155 }
156 156
157 FWL_ERR CFWL_Widget::LockUpdate() { 157 FWL_Error CFWL_Widget::LockUpdate() {
158 if (!m_pIface) 158 if (!m_pIface)
159 return FWL_ERR_Indefinite; 159 return FWL_Error::Indefinite;
160 return m_pIface->LockUpdate(); 160 return m_pIface->LockUpdate();
161 } 161 }
162 162
163 FWL_ERR CFWL_Widget::UnlockUpdate() { 163 FWL_Error CFWL_Widget::UnlockUpdate() {
164 if (!m_pIface) 164 if (!m_pIface)
165 return FWL_ERR_Indefinite; 165 return FWL_Error::Indefinite;
166 return m_pIface->UnlockUpdate(); 166 return m_pIface->UnlockUpdate();
167 } 167 }
168 168
169 FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { 169 FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
170 if (!m_pIface) 170 if (!m_pIface)
171 return FWL_WidgetHit::Unknown; 171 return FWL_WidgetHit::Unknown;
172 return m_pIface->HitTest(fx, fy); 172 return m_pIface->HitTest(fx, fy);
173 } 173 }
174 174
175 FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget, 175 FWL_Error CFWL_Widget::TransformTo(CFWL_Widget* pWidget,
176 FX_FLOAT& fx, 176 FX_FLOAT& fx,
177 FX_FLOAT& fy) { 177 FX_FLOAT& fy) {
178 if (!m_pIface) 178 if (!m_pIface)
179 return FWL_ERR_Indefinite; 179 return FWL_Error::Indefinite;
180 return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : nullptr, fx, 180 return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : nullptr, fx,
181 fy); 181 fy);
182 } 182 }
183 183
184 FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt) { 184 FWL_Error CFWL_Widget::TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt) {
185 if (!m_pIface) 185 if (!m_pIface)
186 return FWL_ERR_Indefinite; 186 return FWL_Error::Indefinite;
187 return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : nullptr, rt); 187 return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : nullptr, rt);
188 } 188 }
189 189
190 FWL_ERR CFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) { 190 FWL_Error CFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) {
191 if (!m_pIface) 191 if (!m_pIface)
192 return FWL_ERR_Indefinite; 192 return FWL_Error::Indefinite;
193 return m_pIface->GetMatrix(matrix, bGlobal); 193 return m_pIface->GetMatrix(matrix, bGlobal);
194 } 194 }
195 195
196 FWL_ERR CFWL_Widget::SetMatrix(const CFX_Matrix& matrix) { 196 FWL_Error CFWL_Widget::SetMatrix(const CFX_Matrix& matrix) {
197 if (!m_pIface) 197 if (!m_pIface)
198 return FWL_ERR_Indefinite; 198 return FWL_Error::Indefinite;
199 return m_pIface->SetMatrix(matrix); 199 return m_pIface->SetMatrix(matrix);
200 } 200 }
201 201
202 FWL_ERR CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics, 202 FWL_Error CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics,
203 const CFX_Matrix* pMatrix) { 203 const CFX_Matrix* pMatrix) {
204 if (!m_pIface) 204 if (!m_pIface)
205 return FWL_ERR_Indefinite; 205 return FWL_Error::Indefinite;
206 return m_pIface->DrawWidget(pGraphics, pMatrix); 206 return m_pIface->DrawWidget(pGraphics, pMatrix);
207 } 207 }
208 208
209 IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { 209 IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) {
210 if (!m_pIface) 210 if (!m_pIface)
211 return nullptr; 211 return nullptr;
212 212
213 m_pDelegate = m_pIface->SetDelegate(pDelegate); 213 m_pDelegate = m_pIface->SetDelegate(pDelegate);
214 return m_pDelegate; 214 return m_pDelegate;
215 } 215 }
216 216
217 CFWL_Widget::CFWL_Widget() 217 CFWL_Widget::CFWL_Widget()
218 : m_pIface(nullptr), m_pDelegate(nullptr), m_pProperties(nullptr) { 218 : m_pIface(nullptr), m_pDelegate(nullptr), m_pProperties(nullptr) {
219 m_pProperties = new CFWL_WidgetProperties; 219 m_pProperties = new CFWL_WidgetProperties;
220 m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); 220 m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
221 ASSERT(m_pWidgetMgr); 221 ASSERT(m_pWidgetMgr);
222 } 222 }
223 223
224 CFWL_Widget::~CFWL_Widget() { 224 CFWL_Widget::~CFWL_Widget() {
225 delete m_pProperties; 225 delete m_pProperties;
226 if (m_pIface) { 226 if (m_pIface) {
227 m_pIface->Finalize(); 227 m_pIface->Finalize();
228 delete m_pIface; 228 delete m_pIface;
229 } 229 }
230 } 230 }
231 231
232 FWL_ERR CFWL_Widget::Repaint(const CFX_RectF* pRect) { 232 FWL_Error CFWL_Widget::Repaint(const CFX_RectF* pRect) {
233 if (!m_pIface) 233 if (!m_pIface)
234 return FWL_ERR_Indefinite; 234 return FWL_Error::Indefinite;
235 235
236 CFX_RectF rect; 236 CFX_RectF rect;
237 if (pRect) { 237 if (pRect) {
238 rect = *pRect; 238 rect = *pRect;
239 } else { 239 } else {
240 m_pIface->GetWidgetRect(rect); 240 m_pIface->GetWidgetRect(rect);
241 rect.left = rect.top = 0; 241 rect.left = rect.top = 0;
242 } 242 }
243 return m_pWidgetMgr->RepaintWidget(m_pIface, &rect); 243 return m_pWidgetMgr->RepaintWidget(m_pIface, &rect);
244 } 244 }
245 245
246 FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) { 246 FWL_Error CFWL_Widget::SetFocus(FX_BOOL bFocus) {
247 if (!m_pIface) 247 if (!m_pIface)
248 return FWL_ERR_Indefinite; 248 return FWL_Error::Indefinite;
249 249
250 IFWL_App* pApp = m_pIface->GetOwnerApp(); 250 IFWL_App* pApp = m_pIface->GetOwnerApp();
251 if (!pApp) 251 if (!pApp)
252 return FWL_ERR_Indefinite; 252 return FWL_Error::Indefinite;
253 253
254 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); 254 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
255 if (!pDriver) 255 if (!pDriver)
256 return FWL_ERR_Indefinite; 256 return FWL_Error::Indefinite;
257 257
258 if (bFocus) { 258 if (bFocus) {
259 pDriver->SetFocus(m_pIface); 259 pDriver->SetFocus(m_pIface);
260 } else { 260 } else {
261 if (pDriver->GetFocus() == m_pIface) { 261 if (pDriver->GetFocus() == m_pIface) {
262 pDriver->SetFocus(nullptr); 262 pDriver->SetFocus(nullptr);
263 } 263 }
264 } 264 }
265 return FWL_ERR_Succeeded; 265 return FWL_Error::Succeeded;
266 } 266 }
267 267
268 FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) { 268 FWL_Error CFWL_Widget::SetGrab(FX_BOOL bSet) {
269 if (!m_pIface) 269 if (!m_pIface)
270 return FWL_ERR_Indefinite; 270 return FWL_Error::Indefinite;
271 271
272 IFWL_App* pApp = m_pIface->GetOwnerApp(); 272 IFWL_App* pApp = m_pIface->GetOwnerApp();
273 if (!pApp) 273 if (!pApp)
274 return FWL_ERR_Indefinite; 274 return FWL_Error::Indefinite;
275 275
276 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); 276 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
277 if (!pDriver) 277 if (!pDriver)
278 return FWL_ERR_Indefinite; 278 return FWL_Error::Indefinite;
279 279
280 pDriver->SetGrab(m_pIface, bSet); 280 pDriver->SetGrab(m_pIface, bSet);
281 return FWL_ERR_Succeeded; 281 return FWL_Error::Succeeded;
282 } 282 }
283 283
284 void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource, 284 void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource,
285 uint32_t dwFilter) { 285 uint32_t dwFilter) {
286 if (!m_pIface) 286 if (!m_pIface)
287 return; 287 return;
288 288
289 IFWL_App* pApp = m_pIface->GetOwnerApp(); 289 IFWL_App* pApp = m_pIface->GetOwnerApp();
290 if (!pApp) 290 if (!pApp)
291 return; 291 return;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; 334 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
335 CFX_RectF rect; 335 CFX_RectF rect;
336 FX_FLOAT fWidth = bMultiLine 336 FX_FLOAT fWidth = bMultiLine
337 ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth 337 ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth
338 : FWL_WGT_CalcMultiLineDefWidth) 338 : FWL_WGT_CalcMultiLineDefWidth)
339 : FWL_WGT_CalcWidth; 339 : FWL_WGT_CalcWidth;
340 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); 340 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight);
341 pTheme->CalcTextRect(&calPart, rect); 341 pTheme->CalcTextRect(&calPart, rect);
342 return CFX_SizeF(rect.width, rect.height); 342 return CFX_SizeF(rect.width, rect.height);
343 } 343 }
OLDNEW
« no previous file with comments | « xfa/fwl/lightwidget/cfwl_widget.h ('k') | xfa/fwl/lightwidget/cfwl_widgetdelegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698