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

Side by Side Diff: xfa/fwl/theme/cfwl_widgettp.cpp

Issue 2435603003: Cleanup unused methods and return values in FWL code. (Closed)
Patch Set: Fix typo Created 4 years, 2 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/fwl/theme/cfwl_widgettp.h ('k') | xfa/fxfa/app/xfa_fwltheme.h » ('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 "xfa/fwl/theme/cfwl_widgettp.h" 7 #include "xfa/fwl/theme/cfwl_widgettp.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 46
47 uint32_t CFWL_WidgetTP::SetThemeID(IFWL_Widget* pWidget, uint32_t dwThemeID) { 47 uint32_t CFWL_WidgetTP::SetThemeID(IFWL_Widget* pWidget, uint32_t dwThemeID) {
48 uint32_t dwOld = m_dwThemeID; 48 uint32_t dwOld = m_dwThemeID;
49 m_dwThemeID = dwThemeID; 49 m_dwThemeID = dwThemeID;
50 if (CFWL_ArrowData::HasInstance()) 50 if (CFWL_ArrowData::HasInstance())
51 CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(dwThemeID)); 51 CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(dwThemeID));
52 return dwOld; 52 return dwOld;
53 } 53 }
54 54
55 FWL_Error CFWL_WidgetTP::GetThemeMatrix(IFWL_Widget* pWidget, 55 void CFWL_WidgetTP::DrawBackground(CFWL_ThemeBackground* pParams) {}
56 CFX_Matrix& matrix) {
57 matrix.Set(_ctm.a, _ctm.b, _ctm.c, _ctm.d, _ctm.e, _ctm.f);
58 return FWL_Error::Succeeded;
59 }
60 56
61 FWL_Error CFWL_WidgetTP::SetThemeMatrix(IFWL_Widget* pWidget, 57 void CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) {
62 const CFX_Matrix& matrix) {
63 _ctm.Set(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
64 return FWL_Error::Succeeded;
65 }
66
67 FX_BOOL CFWL_WidgetTP::DrawBackground(CFWL_ThemeBackground* pParams) {
68 return TRUE;
69 }
70
71 FX_BOOL CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) {
72 if (!m_pTextOut) 58 if (!m_pTextOut)
73 InitTTO(); 59 InitTTO();
74 60
75 int32_t iLen = pParams->m_wsText.GetLength(); 61 int32_t iLen = pParams->m_wsText.GetLength();
76 if (iLen <= 0) 62 if (iLen <= 0)
77 return FALSE; 63 return;
64
78 CFX_Graphics* pGraphics = pParams->m_pGraphics; 65 CFX_Graphics* pGraphics = pParams->m_pGraphics;
79 m_pTextOut->SetRenderDevice(pGraphics->GetRenderDevice()); 66 m_pTextOut->SetRenderDevice(pGraphics->GetRenderDevice());
80 m_pTextOut->SetStyles(pParams->m_dwTTOStyles); 67 m_pTextOut->SetStyles(pParams->m_dwTTOStyles);
81 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); 68 m_pTextOut->SetAlignment(pParams->m_iTTOAlign);
82 CFX_Matrix* pMatrix = &pParams->m_matrix; 69 CFX_Matrix* pMatrix = &pParams->m_matrix;
83 pMatrix->Concat(*pGraphics->GetMatrix()); 70 pMatrix->Concat(*pGraphics->GetMatrix());
84 m_pTextOut->SetMatrix(*pMatrix); 71 m_pTextOut->SetMatrix(*pMatrix);
85 m_pTextOut->DrawLogicText(pParams->m_wsText.c_str(), iLen, pParams->m_rtPart); 72 m_pTextOut->DrawLogicText(pParams->m_wsText.c_str(), iLen, pParams->m_rtPart);
86 return TRUE;
87 } 73 }
88 74
89 void* CFWL_WidgetTP::GetCapacity(CFWL_ThemePart* pThemePart, 75 void* CFWL_WidgetTP::GetCapacity(CFWL_ThemePart* pThemePart,
90 CFWL_WidgetCapacity dwCapacity) { 76 CFWL_WidgetCapacity dwCapacity) {
91 switch (dwCapacity) { 77 switch (dwCapacity) {
92 case CFWL_WidgetCapacity::CXBorder: { 78 case CFWL_WidgetCapacity::CXBorder: {
93 m_fValue = kCXBorder; 79 m_fValue = kCXBorder;
94 break; 80 break;
95 } 81 }
96 case CFWL_WidgetCapacity::CYBorder: { 82 case CFWL_WidgetCapacity::CYBorder: {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return &m_dwValue; 116 return &m_dwValue;
131 } 117 }
132 case CFWL_WidgetCapacity::LineHeight: { 118 case CFWL_WidgetCapacity::LineHeight: {
133 m_fValue = kLineHeight; 119 m_fValue = kLineHeight;
134 break; 120 break;
135 } 121 }
136 case CFWL_WidgetCapacity::UIMargin: { 122 case CFWL_WidgetCapacity::UIMargin: {
137 m_rtMargin.Set(0, 0, 0, 0); 123 m_rtMargin.Set(0, 0, 0, 0);
138 return &m_rtMargin; 124 return &m_rtMargin;
139 } 125 }
140 default: { return nullptr; } 126 default:
127 return nullptr;
141 } 128 }
142 return &m_fValue; 129 return &m_fValue;
143 } 130 }
144 131
145 FX_BOOL CFWL_WidgetTP::IsCustomizedLayout(IFWL_Widget* pWidget) { 132 bool CFWL_WidgetTP::IsCustomizedLayout(IFWL_Widget* pWidget) {
146 return FWL_GetThemeLayout(m_dwThemeID); 133 return !!FWL_GetThemeLayout(m_dwThemeID);
147 } 134 }
148 135
149 FX_BOOL CFWL_WidgetTP::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { 136 void CFWL_WidgetTP::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) {
150 if (!pParams) 137 if (!pParams || !m_pTextOut)
151 return FALSE; 138 return;
152 if (!m_pTextOut) 139
153 return FALSE;
154 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); 140 m_pTextOut->SetAlignment(pParams->m_iTTOAlign);
155 m_pTextOut->SetStyles(pParams->m_dwTTOStyles | FDE_TTOSTYLE_ArabicContext); 141 m_pTextOut->SetStyles(pParams->m_dwTTOStyles | FDE_TTOSTYLE_ArabicContext);
156 m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(), 142 m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(),
157 pParams->m_wsText.GetLength(), rect); 143 pParams->m_wsText.GetLength(), rect);
158 return TRUE;
159 } 144 }
160 145
161 FWL_Error CFWL_WidgetTP::Initialize() { 146 void CFWL_WidgetTP::Initialize() {
162 m_dwThemeID = 0; 147 m_dwThemeID = 0;
163 _ctm.SetIdentity();
164 return FWL_Error::Succeeded;
165 } 148 }
166 149
167 FWL_Error CFWL_WidgetTP::Finalize() { 150 void CFWL_WidgetTP::Finalize() {
168 if (!m_pTextOut) 151 if (!m_pTextOut)
169 FinalizeTTO(); 152 FinalizeTTO();
170 return FWL_Error::Succeeded;
171 } 153 }
172 154
173 CFWL_WidgetTP::~CFWL_WidgetTP() {} 155 CFWL_WidgetTP::~CFWL_WidgetTP() {}
174 156
175 FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, 157 void CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget,
176 const FX_WCHAR* strFont, 158 const FX_WCHAR* strFont,
177 FX_FLOAT fFontSize, 159 FX_FLOAT fFontSize,
178 FX_ARGB rgbFont) { 160 FX_ARGB rgbFont) {
179 if (!m_pTextOut) 161 if (!m_pTextOut)
180 return FWL_Error::Succeeded; 162 return;
181 163
182 m_pFDEFont = CFWL_FontManager::GetInstance()->FindFont(strFont, 0, 0); 164 m_pFDEFont = CFWL_FontManager::GetInstance()->FindFont(strFont, 0, 0);
183 m_pTextOut->SetFont(m_pFDEFont); 165 m_pTextOut->SetFont(m_pFDEFont);
184 m_pTextOut->SetFontSize(fFontSize); 166 m_pTextOut->SetFontSize(fFontSize);
185 m_pTextOut->SetTextColor(rgbFont); 167 m_pTextOut->SetTextColor(rgbFont);
186 return FWL_Error::Succeeded;
187 } 168 }
188 169
189 FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, 170 void CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget,
190 CFGAS_GEFont* pFont, 171 CFGAS_GEFont* pFont,
191 FX_FLOAT fFontSize, 172 FX_FLOAT fFontSize,
192 FX_ARGB rgbFont) { 173 FX_ARGB rgbFont) {
193 if (!m_pTextOut) 174 if (!m_pTextOut)
194 return FWL_Error::Succeeded; 175 return;
195 176
196 m_pTextOut->SetFont(pFont); 177 m_pTextOut->SetFont(pFont);
197 m_pTextOut->SetFontSize(fFontSize); 178 m_pTextOut->SetFontSize(fFontSize);
198 m_pTextOut->SetTextColor(rgbFont); 179 m_pTextOut->SetTextColor(rgbFont);
199 return FWL_Error::Succeeded;
200 } 180 }
201 181
202 CFGAS_GEFont* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) { 182 CFGAS_GEFont* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) {
203 return m_pFDEFont; 183 return m_pFDEFont;
204 } 184 }
205 185
206 CFWL_WidgetTP::CFWL_WidgetTP() 186 CFWL_WidgetTP::CFWL_WidgetTP()
207 : m_dwRefCount(1), m_pFDEFont(nullptr), m_dwThemeID(0) {} 187 : m_dwRefCount(1), m_pFDEFont(nullptr), m_dwThemeID(0) {}
208 188
209 FWL_Error CFWL_WidgetTP::InitTTO() { 189 void CFWL_WidgetTP::InitTTO() {
210 if (m_pTextOut) 190 if (m_pTextOut)
211 return FWL_Error::Succeeded; 191 return;
212 192
213 m_pFDEFont = 193 m_pFDEFont =
214 CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0); 194 CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0);
215 m_pTextOut.reset(new CFDE_TextOut); 195 m_pTextOut.reset(new CFDE_TextOut);
216 m_pTextOut->SetFont(m_pFDEFont); 196 m_pTextOut->SetFont(m_pFDEFont);
217 m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); 197 m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize);
218 m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); 198 m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor);
219 m_pTextOut->SetEllipsisString(L"..."); 199 m_pTextOut->SetEllipsisString(L"...");
220 return FWL_Error::Succeeded;
221 } 200 }
222 201
223 FWL_Error CFWL_WidgetTP::FinalizeTTO() { 202 void CFWL_WidgetTP::FinalizeTTO() {
224 m_pTextOut.reset(); 203 m_pTextOut.reset();
225 return FWL_Error::Succeeded;
226 } 204 }
227 205
228 void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, 206 void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics,
229 uint32_t dwStyles, 207 uint32_t dwStyles,
230 const CFX_RectF* pRect, 208 const CFX_RectF* pRect,
231 CFX_Matrix* pMatrix) { 209 CFX_Matrix* pMatrix) {
232 if (!pGraphics) 210 if (!pGraphics)
233 return; 211 return;
234 if (!pRect) 212 if (!pRect)
235 return; 213 return;
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 CFWL_FontManager::DestroyInstance(); 710 CFWL_FontManager::DestroyInstance();
733 } 711 }
734 712
735 uint32_t FWL_GetThemeLayout(uint32_t dwThemeID) { 713 uint32_t FWL_GetThemeLayout(uint32_t dwThemeID) {
736 return 0xffff0000 & dwThemeID; 714 return 0xffff0000 & dwThemeID;
737 } 715 }
738 716
739 uint32_t FWL_GetThemeColor(uint32_t dwThemeID) { 717 uint32_t FWL_GetThemeColor(uint32_t dwThemeID) {
740 return 0x0000ffff & dwThemeID; 718 return 0x0000ffff & dwThemeID;
741 } 719 }
OLDNEW
« no previous file with comments | « xfa/fwl/theme/cfwl_widgettp.h ('k') | xfa/fxfa/app/xfa_fwltheme.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698