Merge to XFA: Use stdint.h types throughout PDFium.
[pdfium.git] / xfa / src / fwl / src / core / fwl_appimp.cpp
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #include "../../../foxitlib.h"\r
8 #include "include/fwl_targetimp.h"\r
9 #include "include/fwl_threadimp.h"\r
10 #include "include/fwl_noteimp.h"\r
11 #include "include/fwl_widgetmgrimp.h"\r
12 #include "include/fwl_appimp.h"\r
13 IFWL_App* IFWL_App::Create(IFWL_AdapterNative *pAdapter)\r
14 {\r
15     return (IFWL_App*) FX_NEW CFWL_AppImp(pAdapter);\r
16 }\r
17 CFWL_AppImp::CFWL_AppImp(IFWL_AdapterNative *pAdapter)\r
18     : m_pWidgetMgr(NULL)\r
19     , m_pThemeProvider(NULL)\r
20 {\r
21     if (!pAdapter) {\r
22         pAdapter = FWL_CreateFuelAdapterNative();\r
23         m_bFuelAdapter = TRUE;\r
24     } else {\r
25         m_bFuelAdapter = FALSE;\r
26     }\r
27     m_pAdapterNative = pAdapter;\r
28 }\r
29 CFWL_AppImp::~CFWL_AppImp()\r
30 {\r
31     CFWL_ToolTipContainer::DeleteInstance();\r
32     if (m_bFuelAdapter) {\r
33         FWL_ReleaseFuelAdapterNative(m_pAdapterNative);\r
34         m_pAdapterNative = NULL;\r
35     }\r
36     if (m_pWidgetMgr) {\r
37         delete m_pWidgetMgr;\r
38         m_pWidgetMgr = NULL;\r
39     }\r
40 }\r
41 FWL_ERR CFWL_AppImp::Initialize()\r
42 {\r
43     if (!m_pWidgetMgr) {\r
44         m_pWidgetMgr = FX_NEW CFWL_WidgetMgr(m_pAdapterNative);\r
45     }\r
46     return FWL_ERR_Succeeded;\r
47 }\r
48 FWL_ERR CFWL_AppImp::Finalize()\r
49 {\r
50     if (m_pWidgetMgr) {\r
51         delete m_pWidgetMgr;\r
52         m_pWidgetMgr = NULL;\r
53     }\r
54     return FWL_ERR_Succeeded;\r
55 }\r
56 IFWL_AdapterNative* CFWL_AppImp::GetAdapterNative()\r
57 {\r
58     return m_pAdapterNative;\r
59 }\r
60 IFWL_AdapterWidgetMgr* FWL_GetAdapterWidgetMgr()\r
61 {\r
62     return ((CFWL_WidgetMgr*)FWL_GetWidgetMgr())->GetAdapterWidgetMgr();\r
63 }\r
64 IFWL_WidgetMgr* CFWL_AppImp::GetWidgetMgr()\r
65 {\r
66     return (IFWL_WidgetMgr*)m_pWidgetMgr;\r
67 }\r
68 FWL_ERR CFWL_AppImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider)\r
69 {\r
70     m_pThemeProvider = pThemeProvider;\r
71     return FWL_ERR_Succeeded;\r
72 }\r
73 FWL_ERR CFWL_AppImp::Exit(int32_t iExitCode )\r
74 {\r
75     while (m_pNoteDriver->PopNoteLoop());\r
76     return m_pWidgetMgr->GetAdapterWidgetMgr()->Exit(0);\r
77 }\r
78 IFWL_ThemeProvider*     CFWL_AppImp::GetThemeProvider()\r
79 {\r
80     return m_pThemeProvider;\r
81 }\r
82 IFWL_AdapterNative*     FWL_GetAdapterNative()\r
83 {\r
84     IFWL_App* pApp = FWL_GetApp();\r
85     _FWL_RETURN_VALUE_IF_FAIL(pApp, NULL);\r
86     return pApp->GetAdapterNative();\r
87 }\r
88 IFWL_ThemeProvider*     FWL_GetThemeProvider()\r
89 {\r
90     return NULL;\r
91 }\r
92 static IFWL_App *_theApp = NULL;\r
93 IFWL_App* FWL_GetApp()\r
94 {\r
95     return _theApp;\r
96 }\r
97 void FWL_SetApp(IFWL_App *pApp)\r
98 {\r
99     _theApp = pApp;\r
100 }\r
101 FWL_ERR FWL_SetFullScreen(IFWL_Widget *pWidget, FX_BOOL bFullScreen)\r
102 {\r
103     _FWL_RETURN_VALUE_IF_FAIL(pWidget, FWL_ERR_Succeeded);\r
104     IFWL_NoteThread *pNoteTread = pWidget->GetOwnerThread();\r
105     _FWL_RETURN_VALUE_IF_FAIL(pNoteTread, FWL_ERR_Succeeded);\r
106     CFWL_NoteDriver *pNoteDriver = (CFWL_NoteDriver*)pNoteTread->GetNoteDriver();\r
107     _FWL_RETURN_VALUE_IF_FAIL(pNoteTread, FWL_ERR_Succeeded);\r
108     pNoteDriver->NotifyFullScreenMode(pWidget, bFullScreen);\r
109     return FWL_GetAdapterWidgetMgr()->SetFullScreen(pWidget, bFullScreen);\r
110 }\r