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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 uint32_t dwOld = m_dwThemeID; | 45 uint32_t dwOld = m_dwThemeID; |
46 m_dwThemeID = dwThemeID; | 46 m_dwThemeID = dwThemeID; |
47 if (CFWL_ArrowData::IsInstance()) { | 47 if (CFWL_ArrowData::IsInstance()) { |
48 CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(dwThemeID)); | 48 CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(dwThemeID)); |
49 } | 49 } |
50 if (bChildren) { | 50 if (bChildren) { |
51 FWL_SetChildThemeID(pWidget, dwThemeID); | 51 FWL_SetChildThemeID(pWidget, dwThemeID); |
52 } | 52 } |
53 return dwOld; | 53 return dwOld; |
54 } | 54 } |
55 FWL_ERR CFWL_WidgetTP::GetThemeMatrix(IFWL_Widget* pWidget, | 55 FWL_Error CFWL_WidgetTP::GetThemeMatrix(IFWL_Widget* pWidget, |
56 CFX_Matrix& matrix) { | 56 CFX_Matrix& matrix) { |
57 matrix.Set(_ctm.a, _ctm.b, _ctm.c, _ctm.d, _ctm.e, _ctm.f); | 57 matrix.Set(_ctm.a, _ctm.b, _ctm.c, _ctm.d, _ctm.e, _ctm.f); |
58 return FWL_ERR_Succeeded; | 58 return FWL_Error::Succeeded; |
59 } | 59 } |
60 FWL_ERR CFWL_WidgetTP::SetThemeMatrix(IFWL_Widget* pWidget, | 60 FWL_Error CFWL_WidgetTP::SetThemeMatrix(IFWL_Widget* pWidget, |
61 const CFX_Matrix& matrix) { | 61 const CFX_Matrix& matrix) { |
62 _ctm.Set(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f); | 62 _ctm.Set(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f); |
63 return FWL_ERR_Succeeded; | 63 return FWL_Error::Succeeded; |
64 } | 64 } |
65 FX_BOOL CFWL_WidgetTP::DrawBackground(CFWL_ThemeBackground* pParams) { | 65 FX_BOOL CFWL_WidgetTP::DrawBackground(CFWL_ThemeBackground* pParams) { |
66 return TRUE; | 66 return TRUE; |
67 } | 67 } |
68 FX_BOOL CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) { | 68 FX_BOOL CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) { |
69 if (!m_pTextOut) { | 69 if (!m_pTextOut) { |
70 InitTTO(); | 70 InitTTO(); |
71 } | 71 } |
72 int32_t iLen = pParams->m_wsText.GetLength(); | 72 int32_t iLen = pParams->m_wsText.GetLength(); |
73 if (iLen <= 0) | 73 if (iLen <= 0) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 m_rtMargin.Set(0, 0, 0, 0); | 133 m_rtMargin.Set(0, 0, 0, 0); |
134 return &m_rtMargin; | 134 return &m_rtMargin; |
135 } | 135 } |
136 default: { return NULL; } | 136 default: { return NULL; } |
137 } | 137 } |
138 return &m_fValue; | 138 return &m_fValue; |
139 } | 139 } |
140 FX_BOOL CFWL_WidgetTP::IsCustomizedLayout(IFWL_Widget* pWidget) { | 140 FX_BOOL CFWL_WidgetTP::IsCustomizedLayout(IFWL_Widget* pWidget) { |
141 return FWL_GetThemeLayout(m_dwThemeID); | 141 return FWL_GetThemeLayout(m_dwThemeID); |
142 } | 142 } |
143 FWL_ERR CFWL_WidgetTP::GetPartRect(CFWL_ThemePart* pThemePart, | 143 FWL_Error CFWL_WidgetTP::GetPartRect(CFWL_ThemePart* pThemePart, |
144 CFX_RectF& rect) { | 144 CFX_RectF& rect) { |
145 return FWL_ERR_Succeeded; | 145 return FWL_Error::Succeeded; |
146 } | 146 } |
147 FX_BOOL CFWL_WidgetTP::IsInPart(CFWL_ThemePart* pThemePart, | 147 FX_BOOL CFWL_WidgetTP::IsInPart(CFWL_ThemePart* pThemePart, |
148 FX_FLOAT fx, | 148 FX_FLOAT fx, |
149 FX_FLOAT fy) { | 149 FX_FLOAT fy) { |
150 return TRUE; | 150 return TRUE; |
151 } | 151 } |
152 FX_BOOL CFWL_WidgetTP::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { | 152 FX_BOOL CFWL_WidgetTP::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { |
153 if (!pParams) | 153 if (!pParams) |
154 return FALSE; | 154 return FALSE; |
155 if (!m_pTextOut) | 155 if (!m_pTextOut) |
156 return FALSE; | 156 return FALSE; |
157 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); | 157 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); |
158 m_pTextOut->SetStyles(pParams->m_dwTTOStyles | FDE_TTOSTYLE_ArabicContext); | 158 m_pTextOut->SetStyles(pParams->m_dwTTOStyles | FDE_TTOSTYLE_ArabicContext); |
159 m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(), | 159 m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(), |
160 pParams->m_wsText.GetLength(), rect); | 160 pParams->m_wsText.GetLength(), rect); |
161 return TRUE; | 161 return TRUE; |
162 } | 162 } |
163 FWL_ERR CFWL_WidgetTP::Initialize() { | 163 FWL_Error CFWL_WidgetTP::Initialize() { |
164 m_dwThemeID = 0; | 164 m_dwThemeID = 0; |
165 _ctm.SetIdentity(); | 165 _ctm.SetIdentity(); |
166 return FWL_ERR_Succeeded; | 166 return FWL_Error::Succeeded; |
167 } | 167 } |
168 FWL_ERR CFWL_WidgetTP::Finalize() { | 168 FWL_Error CFWL_WidgetTP::Finalize() { |
169 if (!m_pTextOut) { | 169 if (!m_pTextOut) { |
170 FinalizeTTO(); | 170 FinalizeTTO(); |
171 } | 171 } |
172 return FWL_ERR_Succeeded; | 172 return FWL_Error::Succeeded; |
173 } | 173 } |
174 CFWL_WidgetTP::~CFWL_WidgetTP() {} | 174 CFWL_WidgetTP::~CFWL_WidgetTP() {} |
175 FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, | 175 FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, |
176 const FX_WCHAR* strFont, | 176 const FX_WCHAR* strFont, |
177 FX_FLOAT fFontSize, | 177 FX_FLOAT fFontSize, |
178 FX_ARGB rgbFont) { | 178 FX_ARGB rgbFont) { |
179 if (!m_pTextOut) { | 179 if (!m_pTextOut) { |
180 return FWL_ERR_Succeeded; | 180 return FWL_Error::Succeeded; |
181 } | 181 } |
182 m_pFDEFont = CFWL_FontManager::GetInstance()->FindFont(strFont, 0, 0); | 182 m_pFDEFont = CFWL_FontManager::GetInstance()->FindFont(strFont, 0, 0); |
183 m_pTextOut->SetFont(m_pFDEFont); | 183 m_pTextOut->SetFont(m_pFDEFont); |
184 m_pTextOut->SetFontSize(fFontSize); | 184 m_pTextOut->SetFontSize(fFontSize); |
185 m_pTextOut->SetTextColor(rgbFont); | 185 m_pTextOut->SetTextColor(rgbFont); |
186 return FWL_ERR_Succeeded; | 186 return FWL_Error::Succeeded; |
187 } | 187 } |
188 FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, | 188 FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, |
189 IFX_Font* pFont, | 189 IFX_Font* pFont, |
190 FX_FLOAT fFontSize, | 190 FX_FLOAT fFontSize, |
191 FX_ARGB rgbFont) { | 191 FX_ARGB rgbFont) { |
192 if (!m_pTextOut) { | 192 if (!m_pTextOut) { |
193 return FWL_ERR_Succeeded; | 193 return FWL_Error::Succeeded; |
194 } | 194 } |
195 m_pTextOut->SetFont(pFont); | 195 m_pTextOut->SetFont(pFont); |
196 m_pTextOut->SetFontSize(fFontSize); | 196 m_pTextOut->SetFontSize(fFontSize); |
197 m_pTextOut->SetTextColor(rgbFont); | 197 m_pTextOut->SetTextColor(rgbFont); |
198 return FWL_ERR_Succeeded; | 198 return FWL_Error::Succeeded; |
199 } | 199 } |
200 IFX_Font* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) { | 200 IFX_Font* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) { |
201 return m_pFDEFont; | 201 return m_pFDEFont; |
202 } | 202 } |
203 CFWL_WidgetTP::CFWL_WidgetTP() | 203 CFWL_WidgetTP::CFWL_WidgetTP() |
204 : m_dwRefCount(1), m_pTextOut(NULL), m_pFDEFont(NULL), m_dwThemeID(0) {} | 204 : m_dwRefCount(1), m_pTextOut(NULL), m_pFDEFont(NULL), m_dwThemeID(0) {} |
205 FX_ERR CFWL_WidgetTP::InitTTO() { | 205 FWL_Error CFWL_WidgetTP::InitTTO() { |
206 if (m_pTextOut) { | 206 if (m_pTextOut) { |
207 return FWL_ERR_Succeeded; | 207 return FWL_Error::Succeeded; |
208 } | 208 } |
209 m_pFDEFont = | 209 m_pFDEFont = |
210 CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0); | 210 CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0); |
211 m_pTextOut = new CFDE_TextOut; | 211 m_pTextOut = new CFDE_TextOut; |
212 m_pTextOut->SetFont(m_pFDEFont); | 212 m_pTextOut->SetFont(m_pFDEFont); |
213 m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); | 213 m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); |
214 m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); | 214 m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); |
215 m_pTextOut->SetEllipsisString(L"..."); | 215 m_pTextOut->SetEllipsisString(L"..."); |
216 return FWL_ERR_Succeeded; | 216 return FWL_Error::Succeeded; |
217 } | 217 } |
218 FX_ERR CFWL_WidgetTP::FinalizeTTO() { | 218 FWL_Error CFWL_WidgetTP::FinalizeTTO() { |
219 if (m_pTextOut) { | 219 if (m_pTextOut) { |
220 m_pTextOut->Release(); | 220 m_pTextOut->Release(); |
221 m_pTextOut = NULL; | 221 m_pTextOut = NULL; |
222 } | 222 } |
223 return FWL_ERR_Succeeded; | 223 return FWL_Error::Succeeded; |
224 } | 224 } |
225 | 225 |
226 void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, | 226 void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, |
227 uint32_t dwStyles, | 227 uint32_t dwStyles, |
228 const CFX_RectF* pRect, | 228 const CFX_RectF* pRect, |
229 CFX_Matrix* pMatrix) { | 229 CFX_Matrix* pMatrix) { |
230 if (!pGraphics) | 230 if (!pGraphics) |
231 return; | 231 return; |
232 if (!pRect) | 232 if (!pRect) |
233 return; | 233 return; |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 m_pColorData->clrEnd[0] = ArgbEncode(255, 175, 204, 251); | 794 m_pColorData->clrEnd[0] = ArgbEncode(255, 175, 204, 251); |
795 m_pColorData->clrEnd[1] = ArgbEncode(255, 185, 218, 251); | 795 m_pColorData->clrEnd[1] = ArgbEncode(255, 185, 218, 251); |
796 m_pColorData->clrEnd[2] = ArgbEncode(255, 210, 222, 235); | 796 m_pColorData->clrEnd[2] = ArgbEncode(255, 210, 222, 235); |
797 m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); | 797 m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); |
798 m_pColorData->clrSign[0] = ArgbEncode(255, 77, 97, 133); | 798 m_pColorData->clrSign[0] = ArgbEncode(255, 77, 97, 133); |
799 m_pColorData->clrSign[1] = ArgbEncode(255, 77, 97, 133); | 799 m_pColorData->clrSign[1] = ArgbEncode(255, 77, 97, 133); |
800 m_pColorData->clrSign[2] = ArgbEncode(255, 77, 97, 133); | 800 m_pColorData->clrSign[2] = ArgbEncode(255, 77, 97, 133); |
801 m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); | 801 m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); |
802 } | 802 } |
803 } | 803 } |
OLD | NEW |