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

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

Issue 2436103002: Remove FWL globals. (Closed)
Patch Set: fix mac Created 4 years, 2 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
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/core/cfwl_widget.h" 7 #include "xfa/fwl/core/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/cfwl_widgetmgr.h" 11 #include "xfa/fwl/core/cfwl_widgetmgr.h"
12 #include "xfa/fwl/core/fwl_noteimp.h" 12 #include "xfa/fwl/core/fwl_noteimp.h"
13 #include "xfa/fwl/core/fwl_noteimp.h" 13 #include "xfa/fwl/core/fwl_noteimp.h"
14 #include "xfa/fwl/core/ifwl_app.h" 14 #include "xfa/fwl/core/ifwl_app.h"
15 #include "xfa/fwl/core/ifwl_themeprovider.h" 15 #include "xfa/fwl/core/ifwl_themeprovider.h"
16 16
17 #define FWL_WGT_CalcHeight 2048 17 #define FWL_WGT_CalcHeight 2048
18 #define FWL_WGT_CalcWidth 2048 18 #define FWL_WGT_CalcWidth 2048
19 #define FWL_WGT_CalcMultiLineDefWidth 120.0f 19 #define FWL_WGT_CalcMultiLineDefWidth 120.0f
20 20
21 CFWL_Widget::CFWL_Widget() 21 CFWL_Widget::CFWL_Widget(const IFWL_App* app)
22 : m_pDelegate(nullptr), 22 : m_pApp(app),
23 m_pWidgetMgr(CFWL_WidgetMgr::GetInstance()), 23 m_pDelegate(nullptr),
24 m_pWidgetMgr(app->GetWidgetMgr()),
24 m_pProperties(new CFWL_WidgetProperties) { 25 m_pProperties(new CFWL_WidgetProperties) {
25 ASSERT(m_pWidgetMgr); 26 ASSERT(m_pWidgetMgr);
26 } 27 }
27 28
28 CFWL_Widget::~CFWL_Widget() { 29 CFWL_Widget::~CFWL_Widget() {
29 if (m_pIface) 30 if (m_pIface)
30 m_pIface->Finalize(); 31 m_pIface->Finalize();
31 } 32 }
32 33
34 void CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) {
35 ASSERT(m_pIface);
36 m_pIface->SetAssociateWidget(this);
37 }
38
33 IFWL_Widget* CFWL_Widget::GetWidget() { 39 IFWL_Widget* CFWL_Widget::GetWidget() {
34 return m_pIface.get(); 40 return m_pIface.get();
35 } 41 }
36 42
37 const IFWL_Widget* CFWL_Widget::GetWidget() const { 43 const IFWL_Widget* CFWL_Widget::GetWidget() const {
38 return m_pIface.get(); 44 return m_pIface.get();
39 } 45 }
40 46
41 FWL_Error CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) {
42 if (!m_pIface)
43 return FWL_Error::Indefinite;
44 m_pIface->SetAssociateWidget(this);
45 return FWL_Error::Succeeded;
46 }
47
48 FWL_Error CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { 47 FWL_Error CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
49 if (!m_pIface) 48 if (!m_pIface)
50 return FWL_Error::Indefinite; 49 return FWL_Error::Indefinite;
51 return m_pIface->GetWidgetRect(rect, bAutoSize); 50 return m_pIface->GetWidgetRect(rect, bAutoSize);
52 } 51 }
53 52
54 FWL_Error CFWL_Widget::GetGlobalRect(CFX_RectF& rect) { 53 FWL_Error CFWL_Widget::GetGlobalRect(CFX_RectF& rect) {
55 if (!m_pIface) 54 if (!m_pIface)
56 return FWL_Error::Indefinite; 55 return FWL_Error::Indefinite;
57 return m_pIface->GetGlobalRect(rect); 56 return m_pIface->GetGlobalRect(rect);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 return m_pIface->DrawWidget(pGraphics, pMatrix); 131 return m_pIface->DrawWidget(pGraphics, pMatrix);
133 } 132 }
134 133
135 IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { 134 IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) {
136 if (!m_pIface) 135 if (!m_pIface)
137 return nullptr; 136 return nullptr;
138 137
139 m_pDelegate = m_pIface->SetDelegate(pDelegate); 138 m_pDelegate = m_pIface->SetDelegate(pDelegate);
140 return m_pDelegate; 139 return m_pDelegate;
141 } 140 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698