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

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

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