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

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

Issue 1921853006: More FWL interface cleanup. (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_tooltip.cpp ('k') | xfa/fwl/theme/cfwl_widgettp.cpp » ('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_targetimp.h"
14 #include "xfa/fwl/core/fwl_widgetimp.h" 13 #include "xfa/fwl/core/fwl_widgetimp.h"
15 #include "xfa/fwl/core/fwl_widgetmgrimp.h" 14 #include "xfa/fwl/core/fwl_widgetmgrimp.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 #include "xfa/fwl/core/ifwl_thread.h"
18 17
19 IFWL_Widget* CFWL_Widget::GetWidget() { 18 IFWL_Widget* CFWL_Widget::GetWidget() {
20 return m_pIface; 19 return m_pIface;
21 } 20 }
22 21
23 FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const { 22 FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const {
24 if (!m_pIface) 23 if (!m_pIface)
25 return FWL_ERR_Indefinite; 24 return FWL_ERR_Indefinite;
26 return m_pIface->GetClassName(wsClass); 25 return m_pIface->GetClassName(wsClass);
27 } 26 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 if (!m_pIface) 207 if (!m_pIface)
209 return NULL; 208 return NULL;
210 m_pDelegate = m_pIface->SetDelegate(pDelegate); 209 m_pDelegate = m_pIface->SetDelegate(pDelegate);
211 return m_pDelegate; 210 return m_pDelegate;
212 } 211 }
213 212
214 CFWL_Widget::CFWL_Widget() 213 CFWL_Widget::CFWL_Widget()
215 : m_pIface(NULL), m_pDelegate(NULL), m_pProperties(NULL) { 214 : m_pIface(NULL), m_pDelegate(NULL), m_pProperties(NULL) {
216 m_pProperties = new CFWL_WidgetProperties; 215 m_pProperties = new CFWL_WidgetProperties;
217 m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); 216 m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
218 ASSERT(m_pWidgetMgr != NULL); 217 ASSERT(m_pWidgetMgr);
219 } 218 }
220 219
221 CFWL_Widget::~CFWL_Widget() { 220 CFWL_Widget::~CFWL_Widget() {
222 delete m_pProperties; 221 delete m_pProperties;
223 if (m_pIface) { 222 if (m_pIface) {
224 m_pIface->Finalize(); 223 m_pIface->Finalize();
225 delete m_pIface; 224 delete m_pIface;
226 } 225 }
227 } 226 }
228 227
229 FWL_ERR CFWL_Widget::Repaint(const CFX_RectF* pRect) { 228 FWL_ERR CFWL_Widget::Repaint(const CFX_RectF* pRect) {
230 if (!m_pIface) 229 if (!m_pIface)
231 return FWL_ERR_Indefinite; 230 return FWL_ERR_Indefinite;
232 CFX_RectF rect; 231 CFX_RectF rect;
233 if (pRect) { 232 if (pRect) {
234 rect = *pRect; 233 rect = *pRect;
235 } else { 234 } else {
236 m_pIface->GetWidgetRect(rect); 235 m_pIface->GetWidgetRect(rect);
237 rect.left = rect.top = 0; 236 rect.left = rect.top = 0;
238 } 237 }
239 return m_pWidgetMgr->RepaintWidget(m_pIface, &rect); 238 return m_pWidgetMgr->RepaintWidget(m_pIface, &rect);
240 } 239 }
241 240
242 FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) { 241 FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) {
243 if (!m_pIface) 242 if (!m_pIface)
244 return FWL_ERR_Indefinite; 243 return FWL_ERR_Indefinite;
245 IFWL_Thread* pThread = m_pIface->GetOwnerThread(); 244
246 if (!pThread) 245 IFWL_App* pApp = m_pIface->GetOwnerApp();
246 if (!pApp)
247 return FWL_ERR_Indefinite; 247 return FWL_ERR_Indefinite;
248 IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); 248
249 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
249 if (!pDriver) 250 if (!pDriver)
250 return FWL_ERR_Indefinite; 251 return FWL_ERR_Indefinite;
252
251 if (bFocus) { 253 if (bFocus) {
252 pDriver->SetFocus(m_pIface); 254 pDriver->SetFocus(m_pIface);
253 } else { 255 } else {
254 if (pDriver->GetFocus() == m_pIface) { 256 if (pDriver->GetFocus() == m_pIface) {
255 pDriver->SetFocus(NULL); 257 pDriver->SetFocus(NULL);
256 } 258 }
257 } 259 }
258 return FWL_ERR_Succeeded; 260 return FWL_ERR_Succeeded;
259 } 261 }
260 262
261 FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) { 263 FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) {
262 if (!m_pIface) 264 if (!m_pIface)
263 return FWL_ERR_Indefinite; 265 return FWL_ERR_Indefinite;
264 IFWL_Thread* pThread = m_pIface->GetOwnerThread(); 266
265 if (!pThread) 267 IFWL_App* pApp = m_pIface->GetOwnerApp();
268 if (!pApp)
266 return FWL_ERR_Indefinite; 269 return FWL_ERR_Indefinite;
267 IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); 270
271 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
268 if (!pDriver) 272 if (!pDriver)
269 return FWL_ERR_Indefinite; 273 return FWL_ERR_Indefinite;
274
270 pDriver->SetGrab(m_pIface, bSet); 275 pDriver->SetGrab(m_pIface, bSet);
271 return FWL_ERR_Succeeded; 276 return FWL_ERR_Succeeded;
272 } 277 }
273 278
274 void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource, 279 void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource,
275 uint32_t dwFilter) { 280 uint32_t dwFilter) {
276 if (!m_pIface) 281 if (!m_pIface)
277 return; 282 return;
278 IFWL_Thread* pThread = m_pIface->GetOwnerThread(); 283
279 if (!pThread) 284 IFWL_App* pApp = m_pIface->GetOwnerApp();
285 if (!pApp)
280 return; 286 return;
281 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); 287
288 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver();
282 if (!pNoteDriver) 289 if (!pNoteDriver)
283 return; 290 return;
291
284 IFWL_Widget* pEventSourceImp = 292 IFWL_Widget* pEventSourceImp =
285 !pEventSource ? NULL : pEventSource->GetWidget(); 293 !pEventSource ? NULL : pEventSource->GetWidget();
286 pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter); 294 pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter);
287 } 295 }
288 296
289 void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { 297 void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) {
290 if (!m_pIface) 298 if (!m_pIface)
291 return; 299 return;
292 if (m_pIface->GetOuter()) { 300 if (m_pIface->GetOuter()) {
293 return; 301 return;
294 } 302 }
295 IFWL_Thread* pThread = m_pIface->GetOwnerThread(); 303 IFWL_App* pApp = m_pIface->GetOwnerApp();
296 if (!pThread) 304 if (!pApp)
297 return; 305 return;
298 IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); 306 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver();
299 if (!pNoteDriver) 307 if (!pNoteDriver)
300 return; 308 return;
301 pNoteDriver->SendEvent(pEvent); 309 pNoteDriver->SendEvent(pEvent);
302 } 310 }
303 311
304 #define FWL_WGT_CalcHeight 2048 312 #define FWL_WGT_CalcHeight 2048
305 #define FWL_WGT_CalcWidth 2048 313 #define FWL_WGT_CalcWidth 2048
306 #define FWL_WGT_CalcMultiLineDefWidth 120.0f 314 #define FWL_WGT_CalcMultiLineDefWidth 120.0f
307 315
308 CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText, 316 CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText,
(...skipping 13 matching lines...) Expand all
322 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; 330 calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft;
323 CFX_RectF rect; 331 CFX_RectF rect;
324 FX_FLOAT fWidth = bMultiLine 332 FX_FLOAT fWidth = bMultiLine
325 ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth 333 ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth
326 : FWL_WGT_CalcMultiLineDefWidth) 334 : FWL_WGT_CalcMultiLineDefWidth)
327 : FWL_WGT_CalcWidth; 335 : FWL_WGT_CalcWidth;
328 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); 336 rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight);
329 pTheme->CalcTextRect(&calPart, rect); 337 pTheme->CalcTextRect(&calPart, rect);
330 return CFX_SizeF(rect.width, rect.height); 338 return CFX_SizeF(rect.width, rect.height);
331 } 339 }
OLDNEW
« no previous file with comments | « xfa/fwl/lightwidget/cfwl_tooltip.cpp ('k') | xfa/fwl/theme/cfwl_widgettp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698