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/src/fwl/core/fwl_appimp.h" | |
8 | |
9 #include "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h" | |
10 #include "xfa/include/fwl/core/fwl_app.h" | |
11 #include "xfa/include/fwl/core/fwl_widget.h" | |
12 #include "xfa/src/fwl/core/fwl_noteimp.h" | |
13 #include "xfa/src/fwl/core/fwl_targetimp.h" | |
14 #include "xfa/src/fwl/core/fwl_threadimp.h" | |
15 #include "xfa/src/fwl/core/fwl_widgetmgrimp.h" | |
16 | |
17 IFWL_App* IFWL_App::Create(IFWL_AdapterNative* pAdapter) { | |
18 IFWL_App* pApp = new IFWL_App; | |
19 pApp->SetImpl(new CFWL_AppImp(pApp, pAdapter)); | |
20 return pApp; | |
21 } | |
22 FWL_ERR IFWL_App::Initialize() { | |
23 return static_cast<CFWL_AppImp*>(GetImpl())->Initialize(); | |
24 } | |
25 FWL_ERR IFWL_App::Finalize() { | |
26 return static_cast<CFWL_AppImp*>(GetImpl())->Finalize(); | |
27 } | |
28 IFWL_AdapterNative* IFWL_App::GetAdapterNative() { | |
29 return static_cast<CFWL_AppImp*>(GetImpl())->GetAdapterNative(); | |
30 } | |
31 IFWL_WidgetMgr* IFWL_App::GetWidgetMgr() { | |
32 return static_cast<CFWL_AppImp*>(GetImpl())->GetWidgetMgr(); | |
33 } | |
34 IFWL_ThemeProvider* IFWL_App::GetThemeProvider() { | |
35 return static_cast<CFWL_AppImp*>(GetImpl())->GetThemeProvider(); | |
36 } | |
37 FWL_ERR IFWL_App::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | |
38 return static_cast<CFWL_AppImp*>(GetImpl())->SetThemeProvider(pThemeProvider); | |
39 } | |
40 FWL_ERR IFWL_App::Exit(int32_t iExitCode) { | |
41 return static_cast<CFWL_AppImp*>(GetImpl())->Exit(iExitCode); | |
42 } | |
43 | |
44 CFWL_AppImp::CFWL_AppImp(IFWL_App* pIface, IFWL_AdapterNative* pAdapter) | |
45 : CFWL_NoteThreadImp(pIface), | |
46 m_pAdapterNative(pAdapter), | |
47 m_pThemeProvider(nullptr) {} | |
48 | |
49 CFWL_AppImp::~CFWL_AppImp() { | |
50 CFWL_ToolTipContainer::DeleteInstance(); | |
51 } | |
52 | |
53 FWL_ERR CFWL_AppImp::Initialize() { | |
54 if (!m_pWidgetMgr) { | |
55 m_pWidgetMgr.reset(new CFWL_WidgetMgr(m_pAdapterNative)); | |
56 } | |
57 return FWL_ERR_Succeeded; | |
58 } | |
59 FWL_ERR CFWL_AppImp::Finalize() { | |
60 m_pWidgetMgr.reset(); | |
61 return FWL_ERR_Succeeded; | |
62 } | |
63 IFWL_AdapterNative* CFWL_AppImp::GetAdapterNative() const { | |
64 return m_pAdapterNative; | |
65 } | |
66 IFWL_AdapterWidgetMgr* FWL_GetAdapterWidgetMgr() { | |
67 return static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()) | |
68 ->GetAdapterWidgetMgr(); | |
69 } | |
70 IFWL_WidgetMgr* CFWL_AppImp::GetWidgetMgr() const { | |
71 return m_pWidgetMgr.get(); | |
72 } | |
73 FWL_ERR CFWL_AppImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { | |
74 m_pThemeProvider = pThemeProvider; | |
75 return FWL_ERR_Succeeded; | |
76 } | |
77 FWL_ERR CFWL_AppImp::Exit(int32_t iExitCode) { | |
78 while (m_pNoteDriver->PopNoteLoop()) { | |
79 continue; | |
80 } | |
81 return m_pWidgetMgr->GetAdapterWidgetMgr()->Exit(0); | |
82 } | |
83 IFWL_ThemeProvider* CFWL_AppImp::GetThemeProvider() const { | |
84 return m_pThemeProvider; | |
85 } | |
86 IFWL_AdapterNative* FWL_GetAdapterNative() { | |
87 IFWL_App* pApp = FWL_GetApp(); | |
88 if (!pApp) | |
89 return NULL; | |
90 return pApp->GetAdapterNative(); | |
91 } | |
92 IFWL_ThemeProvider* FWL_GetThemeProvider() { | |
93 return NULL; | |
94 } | |
95 static IFWL_App* _theApp = NULL; | |
96 IFWL_App* FWL_GetApp() { | |
97 return _theApp; | |
98 } | |
99 void FWL_SetApp(IFWL_App* pApp) { | |
100 _theApp = pApp; | |
101 } | |
102 FWL_ERR FWL_SetFullScreen(IFWL_Widget* pWidget, FX_BOOL bFullScreen) { | |
103 if (!pWidget) | |
104 return FWL_ERR_Succeeded; | |
105 IFWL_NoteThread* pNoteTread = pWidget->GetOwnerThread(); | |
106 if (!pNoteTread) | |
107 return FWL_ERR_Succeeded; | |
108 CFWL_NoteDriver* pNoteDriver = | |
109 static_cast<CFWL_NoteDriver*>(pNoteTread->GetNoteDriver()); | |
110 if (!pNoteTread) | |
111 return FWL_ERR_Succeeded; | |
112 pNoteDriver->NotifyFullScreenMode(pWidget, bFullScreen); | |
113 return FWL_GetAdapterWidgetMgr()->SetFullScreen(pWidget, bFullScreen); | |
114 } | |
OLD | NEW |