OLD | NEW |
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } | 76 } |
77 FWL_Error CFWL_WidgetTP::SetThemeMatrix(IFWL_Widget* pWidget, | 77 FWL_Error CFWL_WidgetTP::SetThemeMatrix(IFWL_Widget* pWidget, |
78 const CFX_Matrix& matrix) { | 78 const CFX_Matrix& matrix) { |
79 _ctm.Set(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f); | 79 _ctm.Set(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f); |
80 return FWL_Error::Succeeded; | 80 return FWL_Error::Succeeded; |
81 } | 81 } |
82 FX_BOOL CFWL_WidgetTP::DrawBackground(CFWL_ThemeBackground* pParams) { | 82 FX_BOOL CFWL_WidgetTP::DrawBackground(CFWL_ThemeBackground* pParams) { |
83 return TRUE; | 83 return TRUE; |
84 } | 84 } |
85 FX_BOOL CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) { | 85 FX_BOOL CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) { |
86 if (!m_pTextOut) { | 86 if (!m_pTextOut) |
87 InitTTO(); | 87 InitTTO(); |
88 } | 88 |
89 int32_t iLen = pParams->m_wsText.GetLength(); | 89 int32_t iLen = pParams->m_wsText.GetLength(); |
90 if (iLen <= 0) | 90 if (iLen <= 0) |
91 return FALSE; | 91 return FALSE; |
92 CFX_Graphics* pGraphics = pParams->m_pGraphics; | 92 CFX_Graphics* pGraphics = pParams->m_pGraphics; |
93 m_pTextOut->SetRenderDevice(pGraphics->GetRenderDevice()); | 93 m_pTextOut->SetRenderDevice(pGraphics->GetRenderDevice()); |
94 m_pTextOut->SetStyles(pParams->m_dwTTOStyles); | 94 m_pTextOut->SetStyles(pParams->m_dwTTOStyles); |
95 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); | 95 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); |
96 CFX_Matrix* pMatrix = &pParams->m_matrix; | 96 CFX_Matrix* pMatrix = &pParams->m_matrix; |
97 pMatrix->Concat(*pGraphics->GetMatrix()); | 97 pMatrix->Concat(*pGraphics->GetMatrix()); |
98 m_pTextOut->SetMatrix(*pMatrix); | 98 m_pTextOut->SetMatrix(*pMatrix); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(), | 176 m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(), |
177 pParams->m_wsText.GetLength(), rect); | 177 pParams->m_wsText.GetLength(), rect); |
178 return TRUE; | 178 return TRUE; |
179 } | 179 } |
180 FWL_Error CFWL_WidgetTP::Initialize() { | 180 FWL_Error CFWL_WidgetTP::Initialize() { |
181 m_dwThemeID = 0; | 181 m_dwThemeID = 0; |
182 _ctm.SetIdentity(); | 182 _ctm.SetIdentity(); |
183 return FWL_Error::Succeeded; | 183 return FWL_Error::Succeeded; |
184 } | 184 } |
185 FWL_Error CFWL_WidgetTP::Finalize() { | 185 FWL_Error CFWL_WidgetTP::Finalize() { |
186 if (!m_pTextOut) { | 186 if (!m_pTextOut) |
187 FinalizeTTO(); | 187 FinalizeTTO(); |
188 } | |
189 return FWL_Error::Succeeded; | 188 return FWL_Error::Succeeded; |
190 } | 189 } |
191 CFWL_WidgetTP::~CFWL_WidgetTP() {} | 190 CFWL_WidgetTP::~CFWL_WidgetTP() {} |
192 FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, | 191 FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, |
193 const FX_WCHAR* strFont, | 192 const FX_WCHAR* strFont, |
194 FX_FLOAT fFontSize, | 193 FX_FLOAT fFontSize, |
195 FX_ARGB rgbFont) { | 194 FX_ARGB rgbFont) { |
196 if (!m_pTextOut) { | 195 if (!m_pTextOut) |
197 return FWL_Error::Succeeded; | 196 return FWL_Error::Succeeded; |
198 } | 197 |
199 m_pFDEFont = CFWL_FontManager::GetInstance()->FindFont(strFont, 0, 0); | 198 m_pFDEFont = CFWL_FontManager::GetInstance()->FindFont(strFont, 0, 0); |
200 m_pTextOut->SetFont(m_pFDEFont); | 199 m_pTextOut->SetFont(m_pFDEFont); |
201 m_pTextOut->SetFontSize(fFontSize); | 200 m_pTextOut->SetFontSize(fFontSize); |
202 m_pTextOut->SetTextColor(rgbFont); | 201 m_pTextOut->SetTextColor(rgbFont); |
203 return FWL_Error::Succeeded; | 202 return FWL_Error::Succeeded; |
204 } | 203 } |
205 FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, | 204 FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, |
206 IFX_Font* pFont, | 205 IFX_Font* pFont, |
207 FX_FLOAT fFontSize, | 206 FX_FLOAT fFontSize, |
208 FX_ARGB rgbFont) { | 207 FX_ARGB rgbFont) { |
209 if (!m_pTextOut) { | 208 if (!m_pTextOut) |
210 return FWL_Error::Succeeded; | 209 return FWL_Error::Succeeded; |
211 } | 210 |
212 m_pTextOut->SetFont(pFont); | 211 m_pTextOut->SetFont(pFont); |
213 m_pTextOut->SetFontSize(fFontSize); | 212 m_pTextOut->SetFontSize(fFontSize); |
214 m_pTextOut->SetTextColor(rgbFont); | 213 m_pTextOut->SetTextColor(rgbFont); |
215 return FWL_Error::Succeeded; | 214 return FWL_Error::Succeeded; |
216 } | 215 } |
217 IFX_Font* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) { | 216 IFX_Font* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) { |
218 return m_pFDEFont; | 217 return m_pFDEFont; |
219 } | 218 } |
| 219 |
220 CFWL_WidgetTP::CFWL_WidgetTP() | 220 CFWL_WidgetTP::CFWL_WidgetTP() |
221 : m_dwRefCount(1), m_pTextOut(NULL), m_pFDEFont(NULL), m_dwThemeID(0) {} | 221 : m_dwRefCount(1), m_pFDEFont(nullptr), m_dwThemeID(0) {} |
| 222 |
222 FWL_Error CFWL_WidgetTP::InitTTO() { | 223 FWL_Error CFWL_WidgetTP::InitTTO() { |
223 if (m_pTextOut) { | 224 if (m_pTextOut) |
224 return FWL_Error::Succeeded; | 225 return FWL_Error::Succeeded; |
225 } | 226 |
226 m_pFDEFont = | 227 m_pFDEFont = |
227 CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0); | 228 CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0); |
228 m_pTextOut = new CFDE_TextOut; | 229 m_pTextOut.reset(new CFDE_TextOut); |
229 m_pTextOut->SetFont(m_pFDEFont); | 230 m_pTextOut->SetFont(m_pFDEFont); |
230 m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); | 231 m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); |
231 m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); | 232 m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); |
232 m_pTextOut->SetEllipsisString(L"..."); | 233 m_pTextOut->SetEllipsisString(L"..."); |
233 return FWL_Error::Succeeded; | 234 return FWL_Error::Succeeded; |
234 } | 235 } |
| 236 |
235 FWL_Error CFWL_WidgetTP::FinalizeTTO() { | 237 FWL_Error CFWL_WidgetTP::FinalizeTTO() { |
236 if (m_pTextOut) { | 238 m_pTextOut.reset(); |
237 m_pTextOut->Release(); | |
238 m_pTextOut = NULL; | |
239 } | |
240 return FWL_Error::Succeeded; | 239 return FWL_Error::Succeeded; |
241 } | 240 } |
242 | 241 |
243 void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, | 242 void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, |
244 uint32_t dwStyles, | 243 uint32_t dwStyles, |
245 const CFX_RectF* pRect, | 244 const CFX_RectF* pRect, |
246 CFX_Matrix* pMatrix) { | 245 CFX_Matrix* pMatrix) { |
247 if (!pGraphics) | 246 if (!pGraphics) |
248 return; | 247 return; |
249 if (!pRect) | 248 if (!pRect) |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 m_pColorData->clrEnd[0] = ArgbEncode(255, 175, 204, 251); | 810 m_pColorData->clrEnd[0] = ArgbEncode(255, 175, 204, 251); |
812 m_pColorData->clrEnd[1] = ArgbEncode(255, 185, 218, 251); | 811 m_pColorData->clrEnd[1] = ArgbEncode(255, 185, 218, 251); |
813 m_pColorData->clrEnd[2] = ArgbEncode(255, 210, 222, 235); | 812 m_pColorData->clrEnd[2] = ArgbEncode(255, 210, 222, 235); |
814 m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); | 813 m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); |
815 m_pColorData->clrSign[0] = ArgbEncode(255, 77, 97, 133); | 814 m_pColorData->clrSign[0] = ArgbEncode(255, 77, 97, 133); |
816 m_pColorData->clrSign[1] = ArgbEncode(255, 77, 97, 133); | 815 m_pColorData->clrSign[1] = ArgbEncode(255, 77, 97, 133); |
817 m_pColorData->clrSign[2] = ArgbEncode(255, 77, 97, 133); | 816 m_pColorData->clrSign[2] = ArgbEncode(255, 77, 97, 133); |
818 m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); | 817 m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); |
819 } | 818 } |
820 } | 819 } |
OLD | NEW |