Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: xfa/src/fwl/src/lightwidget/theme.cpp

Issue 1672283002: Remove CFX_PtrArray from xfa/include/fwl (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/src/fwl/src/lightwidget/listbox.cpp ('k') | xfa/src/fwl/src/theme/widgettp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <algorithm>
8
7 #include "xfa/src/foxitlib.h" 9 #include "xfa/src/foxitlib.h"
10
11 CFWL_Theme::CFWL_Theme() {
12 m_ThemesArray.push_back(std::unique_ptr<CFWL_WidgetTP>(new CFWL_FormTP));
13 m_ThemesArray.push_back(
14 std::unique_ptr<CFWL_WidgetTP>(new CFWL_PushButtonTP));
15 m_ThemesArray.push_back(std::unique_ptr<CFWL_WidgetTP>(new CFWL_CheckBoxTP));
16 m_ThemesArray.push_back(std::unique_ptr<CFWL_WidgetTP>(new CFWL_ListBoxTP));
17 m_ThemesArray.push_back(
18 std::unique_ptr<CFWL_WidgetTP>(new CFWL_PictureBoxTP));
19 m_ThemesArray.push_back(std::unique_ptr<CFWL_WidgetTP>(new CFWL_ScrollBarTP));
20 m_ThemesArray.push_back(std::unique_ptr<CFWL_WidgetTP>(new CFWL_EditTP));
21 m_ThemesArray.push_back(std::unique_ptr<CFWL_WidgetTP>(new CFWL_ComboBoxTP));
22 m_ThemesArray.push_back(std::unique_ptr<CFWL_WidgetTP>(new CFWL_BarcodeTP));
23 m_ThemesArray.push_back(
24 std::unique_ptr<CFWL_WidgetTP>(new CFWL_DateTimePickerTP));
25 m_ThemesArray.push_back(
26 std::unique_ptr<CFWL_WidgetTP>(new CFWL_MonthCalendarTP));
27 m_ThemesArray.push_back(std::unique_ptr<CFWL_WidgetTP>(new CFWL_CaretTP));
28 }
29
30 CFWL_Theme::~CFWL_Theme() {}
31
8 FX_BOOL CFWL_Theme::IsValidWidget(IFWL_Widget* pWidget) { 32 FX_BOOL CFWL_Theme::IsValidWidget(IFWL_Widget* pWidget) {
9 return !!GetTheme(pWidget); 33 return !!GetTheme(pWidget);
10 } 34 }
35
11 FX_DWORD CFWL_Theme::GetThemeID(IFWL_Widget* pWidget) { 36 FX_DWORD CFWL_Theme::GetThemeID(IFWL_Widget* pWidget) {
12 return GetTheme(pWidget)->GetThemeID(pWidget); 37 return GetTheme(pWidget)->GetThemeID(pWidget);
13 } 38 }
39
14 FX_DWORD CFWL_Theme::SetThemeID(IFWL_Widget* pWidget, 40 FX_DWORD CFWL_Theme::SetThemeID(IFWL_Widget* pWidget,
15 FX_DWORD dwThemeID, 41 FX_DWORD dwThemeID,
16 FX_BOOL bChildren) { 42 FX_BOOL bChildren) {
17 int32_t iCount = m_arrThemes.GetSize();
18 FX_DWORD dwID; 43 FX_DWORD dwID;
19 for (int32_t i = 0; i < iCount; i++) { 44 for (const auto& pTheme : m_ThemesArray) {
20 CFWL_WidgetTP* pTheme = static_cast<CFWL_WidgetTP*>(m_arrThemes[i]);
21 dwID = pTheme->GetThemeID(pWidget); 45 dwID = pTheme->GetThemeID(pWidget);
22 pTheme->SetThemeID(pWidget, dwThemeID, FALSE); 46 pTheme->SetThemeID(pWidget, dwThemeID, FALSE);
23 } 47 }
24 return dwID; 48 return dwID;
25 } 49 }
50
26 FWL_ERR CFWL_Theme::GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) { 51 FWL_ERR CFWL_Theme::GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) {
27 return FWL_ERR_Succeeded; 52 return FWL_ERR_Succeeded;
28 } 53 }
54
29 FWL_ERR CFWL_Theme::SetThemeMatrix(IFWL_Widget* pWidget, 55 FWL_ERR CFWL_Theme::SetThemeMatrix(IFWL_Widget* pWidget,
30 const CFX_Matrix& matrix) { 56 const CFX_Matrix& matrix) {
31 return FWL_ERR_Succeeded; 57 return FWL_ERR_Succeeded;
32 } 58 }
59
33 FX_BOOL CFWL_Theme::DrawBackground(CFWL_ThemeBackground* pParams) { 60 FX_BOOL CFWL_Theme::DrawBackground(CFWL_ThemeBackground* pParams) {
34 CFWL_WidgetTP* pTheme = GetTheme(pParams->m_pWidget); 61 return GetTheme(pParams->m_pWidget)->DrawBackground(pParams);
35 FXSYS_assert(pTheme);
36 return pTheme->DrawBackground(pParams);
37 } 62 }
63
38 FX_BOOL CFWL_Theme::DrawText(CFWL_ThemeText* pParams) { 64 FX_BOOL CFWL_Theme::DrawText(CFWL_ThemeText* pParams) {
39 CFWL_WidgetTP* pTheme = GetTheme(pParams->m_pWidget); 65 return GetTheme(pParams->m_pWidget)->DrawText(pParams);
40 FXSYS_assert(pTheme);
41 return pTheme->DrawText(pParams);
42 } 66 }
67
43 void* CFWL_Theme::GetCapacity(CFWL_ThemePart* pThemePart, FX_DWORD dwCapacity) { 68 void* CFWL_Theme::GetCapacity(CFWL_ThemePart* pThemePart, FX_DWORD dwCapacity) {
44 CFWL_WidgetTP* pTheme = GetTheme(pThemePart->m_pWidget); 69 return GetTheme(pThemePart->m_pWidget)->GetCapacity(pThemePart, dwCapacity);
45 FXSYS_assert(pTheme);
46 return pTheme->GetCapacity(pThemePart, dwCapacity);
47 } 70 }
71
48 FX_BOOL CFWL_Theme::IsCustomizedLayout(IFWL_Widget* pWidget) { 72 FX_BOOL CFWL_Theme::IsCustomizedLayout(IFWL_Widget* pWidget) {
49 CFWL_WidgetTP* pTheme = GetTheme(pWidget); 73 return GetTheme(pWidget)->IsCustomizedLayout(pWidget);
50 FXSYS_assert(pTheme);
51 return pTheme->IsCustomizedLayout(pWidget);
52 } 74 }
75
53 FWL_ERR CFWL_Theme::GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart) { 76 FWL_ERR CFWL_Theme::GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart) {
54 CFWL_WidgetTP* pTheme = GetTheme(pThemePart->m_pWidget); 77 return GetTheme(pThemePart->m_pWidget)->GetPartRect(pThemePart, rtPart);
55 FXSYS_assert(pTheme);
56 return pTheme->GetPartRect(pThemePart, rtPart);
57 } 78 }
79
58 FX_BOOL CFWL_Theme::IsInPart(CFWL_ThemePart* pThemePart, 80 FX_BOOL CFWL_Theme::IsInPart(CFWL_ThemePart* pThemePart,
59 FX_FLOAT fx, 81 FX_FLOAT fx,
60 FX_FLOAT fy) { 82 FX_FLOAT fy) {
61 CFWL_WidgetTP* pTheme = GetTheme(pThemePart->m_pWidget); 83 return GetTheme(pThemePart->m_pWidget)->IsInPart(pThemePart, fx, fy);
62 FXSYS_assert(pTheme);
63 return pTheme->IsInPart(pThemePart, fx, fy);
64 } 84 }
85
65 FX_BOOL CFWL_Theme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { 86 FX_BOOL CFWL_Theme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) {
66 CFWL_WidgetTP* pTheme = GetTheme(pParams->m_pWidget); 87 return GetTheme(pParams->m_pWidget)->CalcTextRect(pParams, rect);
67 FXSYS_assert(pTheme);
68 return pTheme->CalcTextRect(pParams, rect);
69 } 88 }
89
70 FWL_ERR CFWL_Theme::Initialize() { 90 FWL_ERR CFWL_Theme::Initialize() {
71 int32_t iCount = m_arrThemes.GetSize(); 91 for (const auto& pTheme : m_ThemesArray)
72 for (int32_t i = 0; i < iCount; i++) {
73 CFWL_WidgetTP* pTheme = static_cast<CFWL_WidgetTP*>(m_arrThemes[i]);
74 pTheme->Initialize(); 92 pTheme->Initialize();
75 } 93
76 FWLTHEME_Init(); 94 FWLTHEME_Init();
77 return FWL_ERR_Succeeded; 95 return FWL_ERR_Succeeded;
78 } 96 }
97
79 FWL_ERR CFWL_Theme::Finalize() { 98 FWL_ERR CFWL_Theme::Finalize() {
80 int32_t iCount = m_arrThemes.GetSize(); 99 for (const auto& pTheme : m_ThemesArray)
81 for (int32_t i = 0; i < iCount; i++) {
82 CFWL_WidgetTP* pTheme = static_cast<CFWL_WidgetTP*>(m_arrThemes[i]);
83 pTheme->Finalize(); 100 pTheme->Finalize();
84 } 101
85 FWLTHEME_Release(); 102 FWLTHEME_Release();
86 return FWL_ERR_Succeeded; 103 return FWL_ERR_Succeeded;
87 } 104 }
88 CFWL_Theme::CFWL_Theme() { 105
89 CFWL_FormTP* pFormTP = new CFWL_FormTP;
90 CFWL_PushButtonTP* pPushButtonTP = new CFWL_PushButtonTP;
91 CFWL_CheckBoxTP* pCheckBoxTP = new CFWL_CheckBoxTP;
92 CFWL_ListBoxTP* pListBoxTP = new CFWL_ListBoxTP;
93 CFWL_PictureBoxTP* pPictureBoxTP = new CFWL_PictureBoxTP;
94 CFWL_ScrollBarTP* pSrollBarTP = new CFWL_ScrollBarTP;
95 CFWL_EditTP* pEditTP = new CFWL_EditTP;
96 CFWL_ComboBoxTP* pComboBoxTP = new CFWL_ComboBoxTP;
97 CFWL_BarcodeTP* pBarcodeTP = new CFWL_BarcodeTP;
98 CFWL_DateTimePickerTP* pDateTimePickerTP = new CFWL_DateTimePickerTP;
99 CFWL_MonthCalendarTP* pMonthCalendarTP = new CFWL_MonthCalendarTP;
100 CFWL_CaretTP* pCaretTP = new CFWL_CaretTP;
101 m_arrThemes.Add(pFormTP);
102 m_arrThemes.Add(pPushButtonTP);
103 m_arrThemes.Add(pCheckBoxTP);
104 m_arrThemes.Add(pListBoxTP);
105 m_arrThemes.Add(pPictureBoxTP);
106 m_arrThemes.Add(pSrollBarTP);
107 m_arrThemes.Add(pEditTP);
108 m_arrThemes.Add(pComboBoxTP);
109 m_arrThemes.Add(pBarcodeTP);
110 m_arrThemes.Add(pDateTimePickerTP);
111 m_arrThemes.Add(pMonthCalendarTP);
112 m_arrThemes.Add(pCaretTP);
113 }
114 CFWL_Theme::~CFWL_Theme() {
115 for (int32_t i = 0; i < m_arrThemes.GetSize(); i++) {
116 delete static_cast<CFWL_WidgetTP*>(m_arrThemes[i]);
117 }
118 m_arrThemes.RemoveAll();
119 }
120 FWL_ERR CFWL_Theme::SetFont(IFWL_Widget* pWidget, 106 FWL_ERR CFWL_Theme::SetFont(IFWL_Widget* pWidget,
121 const FX_WCHAR* strFont, 107 const FX_WCHAR* strFont,
122 FX_FLOAT fFontSize, 108 FX_FLOAT fFontSize,
123 FX_ARGB rgbFont) { 109 FX_ARGB rgbFont) {
124 int32_t iCount = m_arrThemes.GetSize(); 110 for (const auto& pTheme : m_ThemesArray)
125 for (int32_t i = 0; i < iCount; i++) {
126 CFWL_WidgetTP* pTheme = static_cast<CFWL_WidgetTP*>(m_arrThemes[i]);
127 pTheme->SetFont(pWidget, strFont, fFontSize, rgbFont); 111 pTheme->SetFont(pWidget, strFont, fFontSize, rgbFont);
128 } 112
129 return FWL_ERR_Succeeded; 113 return FWL_ERR_Succeeded;
130 } 114 }
115
131 CFWL_WidgetTP* CFWL_Theme::GetTheme(IFWL_Widget* pWidget) { 116 CFWL_WidgetTP* CFWL_Theme::GetTheme(IFWL_Widget* pWidget) {
132 int32_t iCount = m_arrThemes.GetSize(); 117 for (const auto& pTheme : m_ThemesArray) {
133 for (int32_t i = 0; i < iCount; i++) { 118 if (pTheme->IsValidWidget(pWidget))
134 CFWL_WidgetTP* pTheme = static_cast<CFWL_WidgetTP*>(m_arrThemes[i]); 119 return pTheme.get();
135 if (pTheme->IsValidWidget(pWidget)) {
136 return pTheme;
137 }
138 } 120 }
139 return NULL; 121 return nullptr;
140 } 122 }
OLDNEW
« no previous file with comments | « xfa/src/fwl/src/lightwidget/listbox.cpp ('k') | xfa/src/fwl/src/theme/widgettp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698