• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The PDFium Authors
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/ifwl_themeprovider.h"
8 
9 #include "xfa/fwl/cfwl_widget.h"
10 #include "xfa/fwl/theme/cfwl_barcodetp.h"
11 #include "xfa/fwl/theme/cfwl_carettp.h"
12 #include "xfa/fwl/theme/cfwl_checkboxtp.h"
13 #include "xfa/fwl/theme/cfwl_comboboxtp.h"
14 #include "xfa/fwl/theme/cfwl_datetimepickertp.h"
15 #include "xfa/fwl/theme/cfwl_edittp.h"
16 #include "xfa/fwl/theme/cfwl_listboxtp.h"
17 #include "xfa/fwl/theme/cfwl_monthcalendartp.h"
18 #include "xfa/fwl/theme/cfwl_pictureboxtp.h"
19 #include "xfa/fwl/theme/cfwl_pushbuttontp.h"
20 #include "xfa/fwl/theme/cfwl_scrollbartp.h"
21 
22 namespace pdfium {
23 
IFWL_ThemeProvider(cppgc::Heap * pHeap)24 IFWL_ThemeProvider::IFWL_ThemeProvider(cppgc::Heap* pHeap)
25     : m_pCheckBoxTP(cppgc::MakeGarbageCollected<CFWL_CheckBoxTP>(
26           pHeap->GetAllocationHandle())),
27       m_pListBoxTP(cppgc::MakeGarbageCollected<CFWL_ListBoxTP>(
28           pHeap->GetAllocationHandle())),
29       m_pPictureBoxTP(cppgc::MakeGarbageCollected<CFWL_PictureBoxTP>(
30           pHeap->GetAllocationHandle())),
31       m_pSrollBarTP(cppgc::MakeGarbageCollected<CFWL_ScrollBarTP>(
32           pHeap->GetAllocationHandle())),
33       m_pEditTP(cppgc::MakeGarbageCollected<CFWL_EditTP>(
34           pHeap->GetAllocationHandle())),
35       m_pComboBoxTP(cppgc::MakeGarbageCollected<CFWL_ComboBoxTP>(
36           pHeap->GetAllocationHandle())),
37       m_pMonthCalendarTP(cppgc::MakeGarbageCollected<CFWL_MonthCalendarTP>(
38           pHeap->GetAllocationHandle())),
39       m_pDateTimePickerTP(cppgc::MakeGarbageCollected<CFWL_DateTimePickerTP>(
40           pHeap->GetAllocationHandle())),
41       m_pPushButtonTP(cppgc::MakeGarbageCollected<CFWL_PushButtonTP>(
42           pHeap->GetAllocationHandle())),
43       m_pCaretTP(cppgc::MakeGarbageCollected<CFWL_CaretTP>(
44           pHeap->GetAllocationHandle())),
45       m_pBarcodeTP(cppgc::MakeGarbageCollected<CFWL_BarcodeTP>(
46           pHeap->GetAllocationHandle())) {}
47 
48 IFWL_ThemeProvider::~IFWL_ThemeProvider() = default;
49 
Trace(cppgc::Visitor * visitor) const50 void IFWL_ThemeProvider::Trace(cppgc::Visitor* visitor) const {
51   visitor->Trace(m_pCheckBoxTP);
52   visitor->Trace(m_pListBoxTP);
53   visitor->Trace(m_pPictureBoxTP);
54   visitor->Trace(m_pSrollBarTP);
55   visitor->Trace(m_pEditTP);
56   visitor->Trace(m_pComboBoxTP);
57   visitor->Trace(m_pMonthCalendarTP);
58   visitor->Trace(m_pDateTimePickerTP);
59   visitor->Trace(m_pPushButtonTP);
60   visitor->Trace(m_pCaretTP);
61   visitor->Trace(m_pBarcodeTP);
62 }
63 
GetTheme(const CFWL_Widget * pWidget) const64 CFWL_WidgetTP* IFWL_ThemeProvider::GetTheme(const CFWL_Widget* pWidget) const {
65   switch (pWidget->GetClassID()) {
66     case FWL_Type::CheckBox:
67       return m_pCheckBoxTP;
68     case FWL_Type::ListBox:
69       return m_pListBoxTP;
70     case FWL_Type::PictureBox:
71       return m_pPictureBoxTP;
72     case FWL_Type::ScrollBar:
73       return m_pSrollBarTP;
74     case FWL_Type::Edit:
75       return m_pEditTP;
76     case FWL_Type::ComboBox:
77       return m_pComboBoxTP;
78     case FWL_Type::MonthCalendar:
79       return m_pMonthCalendarTP;
80     case FWL_Type::DateTimePicker:
81       return m_pDateTimePickerTP;
82     case FWL_Type::PushButton:
83       return m_pPushButtonTP;
84     case FWL_Type::Caret:
85       return m_pCaretTP;
86     case FWL_Type::Barcode:
87       return m_pBarcodeTP;
88     default:
89       return nullptr;
90   }
91 }
92 
93 }  // namespace pdfium
94