• 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 
IFWL_ThemeProvider(cppgc::Heap * pHeap)22 IFWL_ThemeProvider::IFWL_ThemeProvider(cppgc::Heap* pHeap)
23     : m_pCheckBoxTP(cppgc::MakeGarbageCollected<CFWL_CheckBoxTP>(
24           pHeap->GetAllocationHandle())),
25       m_pListBoxTP(cppgc::MakeGarbageCollected<CFWL_ListBoxTP>(
26           pHeap->GetAllocationHandle())),
27       m_pPictureBoxTP(cppgc::MakeGarbageCollected<CFWL_PictureBoxTP>(
28           pHeap->GetAllocationHandle())),
29       m_pSrollBarTP(cppgc::MakeGarbageCollected<CFWL_ScrollBarTP>(
30           pHeap->GetAllocationHandle())),
31       m_pEditTP(cppgc::MakeGarbageCollected<CFWL_EditTP>(
32           pHeap->GetAllocationHandle())),
33       m_pComboBoxTP(cppgc::MakeGarbageCollected<CFWL_ComboBoxTP>(
34           pHeap->GetAllocationHandle())),
35       m_pMonthCalendarTP(cppgc::MakeGarbageCollected<CFWL_MonthCalendarTP>(
36           pHeap->GetAllocationHandle())),
37       m_pDateTimePickerTP(cppgc::MakeGarbageCollected<CFWL_DateTimePickerTP>(
38           pHeap->GetAllocationHandle())),
39       m_pPushButtonTP(cppgc::MakeGarbageCollected<CFWL_PushButtonTP>(
40           pHeap->GetAllocationHandle())),
41       m_pCaretTP(cppgc::MakeGarbageCollected<CFWL_CaretTP>(
42           pHeap->GetAllocationHandle())),
43       m_pBarcodeTP(cppgc::MakeGarbageCollected<CFWL_BarcodeTP>(
44           pHeap->GetAllocationHandle())) {}
45 
46 IFWL_ThemeProvider::~IFWL_ThemeProvider() = default;
47 
Trace(cppgc::Visitor * visitor) const48 void IFWL_ThemeProvider::Trace(cppgc::Visitor* visitor) const {
49   visitor->Trace(m_pCheckBoxTP);
50   visitor->Trace(m_pListBoxTP);
51   visitor->Trace(m_pPictureBoxTP);
52   visitor->Trace(m_pSrollBarTP);
53   visitor->Trace(m_pEditTP);
54   visitor->Trace(m_pComboBoxTP);
55   visitor->Trace(m_pMonthCalendarTP);
56   visitor->Trace(m_pDateTimePickerTP);
57   visitor->Trace(m_pPushButtonTP);
58   visitor->Trace(m_pCaretTP);
59   visitor->Trace(m_pBarcodeTP);
60 }
61 
GetTheme(const CFWL_Widget * pWidget) const62 CFWL_WidgetTP* IFWL_ThemeProvider::GetTheme(const CFWL_Widget* pWidget) const {
63   switch (pWidget->GetClassID()) {
64     case FWL_Type::CheckBox:
65       return m_pCheckBoxTP;
66     case FWL_Type::ListBox:
67       return m_pListBoxTP;
68     case FWL_Type::PictureBox:
69       return m_pPictureBoxTP;
70     case FWL_Type::ScrollBar:
71       return m_pSrollBarTP;
72     case FWL_Type::Edit:
73       return m_pEditTP;
74     case FWL_Type::ComboBox:
75       return m_pComboBoxTP;
76     case FWL_Type::MonthCalendar:
77       return m_pMonthCalendarTP;
78     case FWL_Type::DateTimePicker:
79       return m_pDateTimePickerTP;
80     case FWL_Type::PushButton:
81       return m_pPushButtonTP;
82     case FWL_Type::Caret:
83       return m_pCaretTP;
84     case FWL_Type::Barcode:
85       return m_pBarcodeTP;
86     default:
87       return nullptr;
88   }
89 }
90