summaryrefslogtreecommitdiff
path: root/xfa/fwl/core/fwl_appimp.cpp
blob: 95ed0c90cc0bff5d23db87de9dccc2bbb1c06c03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#include "xfa/fwl/core/fwl_appimp.h"

#include "xfa/fwl/core/fwl_noteimp.h"
#include "xfa/fwl/core/fwl_targetimp.h"
#include "xfa/fwl/core/fwl_threadimp.h"
#include "xfa/fwl/core/fwl_widgetmgrimp.h"
#include "xfa/fwl/core/ifwl_adapterwidgetmgr.h"
#include "xfa/fwl/core/ifwl_app.h"
#include "xfa/fwl/core/ifwl_widget.h"

IFWL_App* IFWL_App::Create(IFWL_AdapterNative* pAdapter) {
  IFWL_App* pApp = new IFWL_App;
  pApp->SetImpl(new CFWL_AppImp(pApp, pAdapter));
  return pApp;
}
FWL_ERR IFWL_App::Initialize() {
  return static_cast<CFWL_AppImp*>(GetImpl())->Initialize();
}
FWL_ERR IFWL_App::Finalize() {
  return static_cast<CFWL_AppImp*>(GetImpl())->Finalize();
}
IFWL_AdapterNative* IFWL_App::GetAdapterNative() {
  return static_cast<CFWL_AppImp*>(GetImpl())->GetAdapterNative();
}
IFWL_WidgetMgr* IFWL_App::GetWidgetMgr() {
  return static_cast<CFWL_AppImp*>(GetImpl())->GetWidgetMgr();
}
IFWL_ThemeProvider* IFWL_App::GetThemeProvider() {
  return static_cast<CFWL_AppImp*>(GetImpl())->GetThemeProvider();
}
FWL_ERR IFWL_App::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
  return static_cast<CFWL_AppImp*>(GetImpl())->SetThemeProvider(pThemeProvider);
}
FWL_ERR IFWL_App::Exit(int32_t iExitCode) {
  return static_cast<CFWL_AppImp*>(GetImpl())->Exit(iExitCode);
}

CFWL_AppImp::CFWL_AppImp(IFWL_App* pIface, IFWL_AdapterNative* pAdapter)
    : CFWL_ThreadImp(pIface),
      m_pAdapterNative(pAdapter),
      m_pThemeProvider(nullptr) {}

CFWL_AppImp::~CFWL_AppImp() {
  CFWL_ToolTipContainer::DeleteInstance();
}

FWL_ERR CFWL_AppImp::Initialize() {
  if (!m_pWidgetMgr) {
    m_pWidgetMgr.reset(new CFWL_WidgetMgr(m_pAdapterNative));
  }
  return FWL_ERR_Succeeded;
}
FWL_ERR CFWL_AppImp::Finalize() {
  m_pWidgetMgr.reset();
  return FWL_ERR_Succeeded;
}
IFWL_AdapterNative* CFWL_AppImp::GetAdapterNative() const {
  return m_pAdapterNative;
}
IFWL_AdapterWidgetMgr* FWL_GetAdapterWidgetMgr() {
  return static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr())
      ->GetAdapterWidgetMgr();
}
IFWL_WidgetMgr* CFWL_AppImp::GetWidgetMgr() const {
  return m_pWidgetMgr.get();
}
FWL_ERR CFWL_AppImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
  m_pThemeProvider = pThemeProvider;
  return FWL_ERR_Succeeded;
}
FWL_ERR CFWL_AppImp::Exit(int32_t iExitCode) {
  while (m_pNoteDriver->PopNoteLoop()) {
    continue;
  }
  return m_pWidgetMgr->GetAdapterWidgetMgr()->Exit(0);
}
IFWL_ThemeProvider* CFWL_AppImp::GetThemeProvider() const {
  return m_pThemeProvider;
}
IFWL_AdapterNative* FWL_GetAdapterNative() {
  IFWL_App* pApp = FWL_GetApp();
  if (!pApp)
    return NULL;
  return pApp->GetAdapterNative();
}
static IFWL_App* _theApp = NULL;
IFWL_App* FWL_GetApp() {
  return _theApp;
}
void FWL_SetApp(IFWL_App* pApp) {
  _theApp = pApp;
}