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/include/fwl/lightwidget/theme.h" | |
8 | |
9 #include <algorithm> | |
10 | |
11 #include "xfa/include/fwl/theme/barcodetp.h" | |
12 #include "xfa/include/fwl/theme/carettp.h" | |
13 #include "xfa/include/fwl/theme/checkboxtp.h" | |
14 #include "xfa/include/fwl/theme/comboboxtp.h" | |
15 #include "xfa/include/fwl/theme/datetimepickertp.h" | |
16 #include "xfa/include/fwl/theme/edittp.h" | |
17 #include "xfa/include/fwl/theme/formtp.h" | |
18 #include "xfa/include/fwl/theme/listboxtp.h" | |
19 #include "xfa/include/fwl/theme/monthcalendartp.h" | |
20 #include "xfa/include/fwl/theme/pictureboxtp.h" | |
21 #include "xfa/include/fwl/theme/pushbuttontp.h" | |
22 #include "xfa/include/fwl/theme/scrollbartp.h" | |
23 | |
24 CFWL_Theme::CFWL_Theme() { | |
25 m_ThemesArray.push_back(std::unique_ptr<CFWL_WidgetTP>(new CFWL_FormTP)); | |
26 m_ThemesArray.push_back( | |
27 std::unique_ptr<CFWL_WidgetTP>(new CFWL_PushButtonTP)); | |
28 m_ThemesArray.push_back(std::unique_ptr<CFWL_WidgetTP>(new CFWL_CheckBoxTP)); | |
29 m_ThemesArray.push_back(std::unique_ptr<CFWL_WidgetTP>(new CFWL_ListBoxTP)); | |
30 m_ThemesArray.push_back( | |
31 std::unique_ptr<CFWL_WidgetTP>(new CFWL_PictureBoxTP)); | |
32 m_ThemesArray.push_back(std::unique_ptr<CFWL_WidgetTP>(new CFWL_ScrollBarTP)); | |
33 m_ThemesArray.push_back(std::unique_ptr<CFWL_WidgetTP>(new CFWL_EditTP)); | |
34 m_ThemesArray.push_back(std::unique_ptr<CFWL_WidgetTP>(new CFWL_ComboBoxTP)); | |
35 m_ThemesArray.push_back(std::unique_ptr<CFWL_WidgetTP>(new CFWL_BarcodeTP)); | |
36 m_ThemesArray.push_back( | |
37 std::unique_ptr<CFWL_WidgetTP>(new CFWL_DateTimePickerTP)); | |
38 m_ThemesArray.push_back( | |
39 std::unique_ptr<CFWL_WidgetTP>(new CFWL_MonthCalendarTP)); | |
40 m_ThemesArray.push_back(std::unique_ptr<CFWL_WidgetTP>(new CFWL_CaretTP)); | |
41 } | |
42 | |
43 CFWL_Theme::~CFWL_Theme() {} | |
44 | |
45 FX_BOOL CFWL_Theme::IsValidWidget(IFWL_Widget* pWidget) { | |
46 return !!GetTheme(pWidget); | |
47 } | |
48 | |
49 FX_DWORD CFWL_Theme::GetThemeID(IFWL_Widget* pWidget) { | |
50 return GetTheme(pWidget)->GetThemeID(pWidget); | |
51 } | |
52 | |
53 FX_DWORD CFWL_Theme::SetThemeID(IFWL_Widget* pWidget, | |
54 FX_DWORD dwThemeID, | |
55 FX_BOOL bChildren) { | |
56 FX_DWORD dwID; | |
57 for (const auto& pTheme : m_ThemesArray) { | |
58 dwID = pTheme->GetThemeID(pWidget); | |
59 pTheme->SetThemeID(pWidget, dwThemeID, FALSE); | |
60 } | |
61 return dwID; | |
62 } | |
63 | |
64 FWL_ERR CFWL_Theme::GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) { | |
65 return FWL_ERR_Succeeded; | |
66 } | |
67 | |
68 FWL_ERR CFWL_Theme::SetThemeMatrix(IFWL_Widget* pWidget, | |
69 const CFX_Matrix& matrix) { | |
70 return FWL_ERR_Succeeded; | |
71 } | |
72 | |
73 FX_BOOL CFWL_Theme::DrawBackground(CFWL_ThemeBackground* pParams) { | |
74 return GetTheme(pParams->m_pWidget)->DrawBackground(pParams); | |
75 } | |
76 | |
77 FX_BOOL CFWL_Theme::DrawText(CFWL_ThemeText* pParams) { | |
78 return GetTheme(pParams->m_pWidget)->DrawText(pParams); | |
79 } | |
80 | |
81 void* CFWL_Theme::GetCapacity(CFWL_ThemePart* pThemePart, FX_DWORD dwCapacity) { | |
82 return GetTheme(pThemePart->m_pWidget)->GetCapacity(pThemePart, dwCapacity); | |
83 } | |
84 | |
85 FX_BOOL CFWL_Theme::IsCustomizedLayout(IFWL_Widget* pWidget) { | |
86 return GetTheme(pWidget)->IsCustomizedLayout(pWidget); | |
87 } | |
88 | |
89 FWL_ERR CFWL_Theme::GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart) { | |
90 return GetTheme(pThemePart->m_pWidget)->GetPartRect(pThemePart, rtPart); | |
91 } | |
92 | |
93 FX_BOOL CFWL_Theme::IsInPart(CFWL_ThemePart* pThemePart, | |
94 FX_FLOAT fx, | |
95 FX_FLOAT fy) { | |
96 return GetTheme(pThemePart->m_pWidget)->IsInPart(pThemePart, fx, fy); | |
97 } | |
98 | |
99 FX_BOOL CFWL_Theme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { | |
100 return GetTheme(pParams->m_pWidget)->CalcTextRect(pParams, rect); | |
101 } | |
102 | |
103 FWL_ERR CFWL_Theme::Initialize() { | |
104 for (const auto& pTheme : m_ThemesArray) | |
105 pTheme->Initialize(); | |
106 | |
107 FWLTHEME_Init(); | |
108 return FWL_ERR_Succeeded; | |
109 } | |
110 | |
111 FWL_ERR CFWL_Theme::Finalize() { | |
112 for (const auto& pTheme : m_ThemesArray) | |
113 pTheme->Finalize(); | |
114 | |
115 FWLTHEME_Release(); | |
116 return FWL_ERR_Succeeded; | |
117 } | |
118 | |
119 FWL_ERR CFWL_Theme::SetFont(IFWL_Widget* pWidget, | |
120 const FX_WCHAR* strFont, | |
121 FX_FLOAT fFontSize, | |
122 FX_ARGB rgbFont) { | |
123 for (const auto& pTheme : m_ThemesArray) | |
124 pTheme->SetFont(pWidget, strFont, fFontSize, rgbFont); | |
125 | |
126 return FWL_ERR_Succeeded; | |
127 } | |
128 | |
129 CFWL_WidgetTP* CFWL_Theme::GetTheme(IFWL_Widget* pWidget) { | |
130 for (const auto& pTheme : m_ThemesArray) { | |
131 if (pTheme->IsValidWidget(pWidget)) | |
132 return pTheme.get(); | |
133 } | |
134 return nullptr; | |
135 } | |
OLD | NEW |