OLD | NEW |
| (Empty) |
1 // Copyright 2014 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #include "xfa/fwl/core/fwl_appimp.h" | |
8 | |
9 #include "xfa/fwl/core/cfwl_widgetmgr.h" | |
10 #include "xfa/fwl/core/fwl_noteimp.h" | |
11 #include "xfa/fwl/core/ifwl_app.h" | |
12 #include "xfa/fwl/core/ifwl_widget.h" | |
13 #include "xfa/fxfa/app/xfa_fwladapter.h" | |
14 | |
15 IFWL_App* IFWL_App::Create(CXFA_FFApp* pAdapter) { | |
16 IFWL_App* pApp = new IFWL_App; | |
17 pApp->SetImpl(new CFWL_AppImp(pApp, pAdapter)); | |
18 return pApp; | |
19 } | |
20 | |
21 IFWL_App::IFWL_App() {} | |
22 | |
23 IFWL_App::~IFWL_App() {} | |
24 | |
25 void IFWL_App::Release() {} | |
26 | |
27 FWL_Error IFWL_App::Initialize() { | |
28 return static_cast<CFWL_AppImp*>(GetImpl())->Initialize(); | |
29 } | |
30 | |
31 FWL_Error IFWL_App::Finalize() { | |
32 return static_cast<CFWL_AppImp*>(GetImpl())->Finalize(); | |
33 } | |
34 | |
35 CXFA_FFApp* IFWL_App::GetAdapterNative() { | |
36 return static_cast<CFWL_AppImp*>(GetImpl())->GetAdapterNative(); | |
37 } | |
38 | |
39 CFWL_WidgetMgr* IFWL_App::GetWidgetMgr() { | |
40 return static_cast<CFWL_AppImp*>(GetImpl())->GetWidgetMgr(); | |
41 } | |
42 | |
43 IFWL_ThemeProvider* IFWL_App::GetThemeProvider() { | |
44 return static_cast<CFWL_AppImp*>(GetImpl())->GetThemeProvider(); | |
45 } | |
46 | |
47 void IFWL_App::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | |
48 static_cast<CFWL_AppImp*>(GetImpl())->SetThemeProvider(pThemeProvider); | |
49 } | |
50 | |
51 void IFWL_App::Exit(int32_t iExitCode) { | |
52 static_cast<CFWL_AppImp*>(GetImpl())->Exit(iExitCode); | |
53 } | |
54 | |
55 CFWL_NoteDriver* IFWL_App::GetNoteDriver() const { | |
56 return static_cast<CFWL_AppImp*>(GetImpl())->GetNoteDriver(); | |
57 } | |
58 | |
59 CFWL_AppImp::CFWL_AppImp(IFWL_App* pIface, CXFA_FFApp* pAdapter) | |
60 : m_pAdapterNative(pAdapter), | |
61 m_pThemeProvider(nullptr), | |
62 m_pNoteDriver(new CFWL_NoteDriver), | |
63 m_pIface(pIface) {} | |
64 | |
65 CFWL_AppImp::~CFWL_AppImp() { | |
66 CFWL_ToolTipContainer::DeleteInstance(); | |
67 } | |
68 | |
69 FWL_Error CFWL_AppImp::Initialize() { | |
70 if (!m_pWidgetMgr) { | |
71 m_pWidgetMgr.reset(new CFWL_WidgetMgr(m_pAdapterNative)); | |
72 } | |
73 return FWL_Error::Succeeded; | |
74 } | |
75 FWL_Error CFWL_AppImp::Finalize() { | |
76 m_pWidgetMgr.reset(); | |
77 return FWL_Error::Succeeded; | |
78 } | |
79 CXFA_FFApp* CFWL_AppImp::GetAdapterNative() const { | |
80 return m_pAdapterNative; | |
81 } | |
82 CXFA_FWLAdapterWidgetMgr* FWL_GetAdapterWidgetMgr() { | |
83 return CFWL_WidgetMgr::GetInstance()->GetAdapterWidgetMgr(); | |
84 } | |
85 CFWL_WidgetMgr* CFWL_AppImp::GetWidgetMgr() const { | |
86 return m_pWidgetMgr.get(); | |
87 } | |
88 | |
89 void CFWL_AppImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | |
90 m_pThemeProvider = pThemeProvider; | |
91 } | |
92 | |
93 void CFWL_AppImp::Exit(int32_t iExitCode) { | |
94 while (m_pNoteDriver->PopNoteLoop()) { | |
95 continue; | |
96 } | |
97 } | |
98 | |
99 IFWL_ThemeProvider* CFWL_AppImp::GetThemeProvider() const { | |
100 return m_pThemeProvider; | |
101 } | |
102 | |
103 CXFA_FFApp* FWL_GetAdapterNative() { | |
104 IFWL_App* pApp = FWL_GetApp(); | |
105 if (!pApp) | |
106 return nullptr; | |
107 return pApp->GetAdapterNative(); | |
108 } | |
109 | |
110 static IFWL_App* g_theApp = nullptr; | |
111 IFWL_App* FWL_GetApp() { | |
112 return g_theApp; | |
113 } | |
114 | |
115 void FWL_SetApp(IFWL_App* pApp) { | |
116 g_theApp = pApp; | |
117 } | |
OLD | NEW |