| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 uint32_t dwOld = m_dwThemeID; | 59 uint32_t dwOld = m_dwThemeID; |
| 60 m_dwThemeID = dwThemeID; | 60 m_dwThemeID = dwThemeID; |
| 61 if (CFWL_ArrowData::IsInstance()) { | 61 if (CFWL_ArrowData::IsInstance()) { |
| 62 CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(dwThemeID)); | 62 CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(dwThemeID)); |
| 63 } | 63 } |
| 64 if (bChildren) { | 64 if (bChildren) { |
| 65 FWL_SetChildThemeID(pWidget, dwThemeID); | 65 FWL_SetChildThemeID(pWidget, dwThemeID); |
| 66 } | 66 } |
| 67 return dwOld; | 67 return dwOld; |
| 68 } | 68 } |
| 69 FWL_ERR CFWL_WidgetTP::GetThemeMatrix(IFWL_Widget* pWidget, | 69 FWL_Error CFWL_WidgetTP::GetThemeMatrix(IFWL_Widget* pWidget, |
| 70 CFX_Matrix& matrix) { | 70 CFX_Matrix& matrix) { |
| 71 matrix.Set(_ctm.a, _ctm.b, _ctm.c, _ctm.d, _ctm.e, _ctm.f); | 71 matrix.Set(_ctm.a, _ctm.b, _ctm.c, _ctm.d, _ctm.e, _ctm.f); |
| 72 return FWL_ERR_Succeeded; | 72 return FWL_Error::Succeeded; |
| 73 } | 73 } |
| 74 FWL_ERR CFWL_WidgetTP::SetThemeMatrix(IFWL_Widget* pWidget, | 74 FWL_Error CFWL_WidgetTP::SetThemeMatrix(IFWL_Widget* pWidget, |
| 75 const CFX_Matrix& matrix) { | 75 const CFX_Matrix& matrix) { |
| 76 _ctm.Set(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f); | 76 _ctm.Set(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f); |
| 77 return FWL_ERR_Succeeded; | 77 return FWL_Error::Succeeded; |
| 78 } | 78 } |
| 79 FX_BOOL CFWL_WidgetTP::DrawBackground(CFWL_ThemeBackground* pParams) { | 79 FX_BOOL CFWL_WidgetTP::DrawBackground(CFWL_ThemeBackground* pParams) { |
| 80 return TRUE; | 80 return TRUE; |
| 81 } | 81 } |
| 82 FX_BOOL CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) { | 82 FX_BOOL CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) { |
| 83 if (!m_pTextOut) { | 83 if (!m_pTextOut) { |
| 84 InitTTO(); | 84 InitTTO(); |
| 85 } | 85 } |
| 86 int32_t iLen = pParams->m_wsText.GetLength(); | 86 int32_t iLen = pParams->m_wsText.GetLength(); |
| 87 if (iLen <= 0) | 87 if (iLen <= 0) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 m_rtMargin.Set(0, 0, 0, 0); | 147 m_rtMargin.Set(0, 0, 0, 0); |
| 148 return &m_rtMargin; | 148 return &m_rtMargin; |
| 149 } | 149 } |
| 150 default: { return NULL; } | 150 default: { return NULL; } |
| 151 } | 151 } |
| 152 return &m_fValue; | 152 return &m_fValue; |
| 153 } | 153 } |
| 154 FX_BOOL CFWL_WidgetTP::IsCustomizedLayout(IFWL_Widget* pWidget) { | 154 FX_BOOL CFWL_WidgetTP::IsCustomizedLayout(IFWL_Widget* pWidget) { |
| 155 return FWL_GetThemeLayout(m_dwThemeID); | 155 return FWL_GetThemeLayout(m_dwThemeID); |
| 156 } | 156 } |
| 157 FWL_ERR CFWL_WidgetTP::GetPartRect(CFWL_ThemePart* pThemePart, | 157 FWL_Error CFWL_WidgetTP::GetPartRect(CFWL_ThemePart* pThemePart, |
| 158 CFX_RectF& rect) { | 158 CFX_RectF& rect) { |
| 159 return FWL_ERR_Succeeded; | 159 return FWL_Error::Succeeded; |
| 160 } | 160 } |
| 161 FX_BOOL CFWL_WidgetTP::IsInPart(CFWL_ThemePart* pThemePart, | 161 FX_BOOL CFWL_WidgetTP::IsInPart(CFWL_ThemePart* pThemePart, |
| 162 FX_FLOAT fx, | 162 FX_FLOAT fx, |
| 163 FX_FLOAT fy) { | 163 FX_FLOAT fy) { |
| 164 return TRUE; | 164 return TRUE; |
| 165 } | 165 } |
| 166 FX_BOOL CFWL_WidgetTP::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { | 166 FX_BOOL CFWL_WidgetTP::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { |
| 167 if (!pParams) | 167 if (!pParams) |
| 168 return FALSE; | 168 return FALSE; |
| 169 if (!m_pTextOut) | 169 if (!m_pTextOut) |
| 170 return FALSE; | 170 return FALSE; |
| 171 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); | 171 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); |
| 172 m_pTextOut->SetStyles(pParams->m_dwTTOStyles | FDE_TTOSTYLE_ArabicContext); | 172 m_pTextOut->SetStyles(pParams->m_dwTTOStyles | FDE_TTOSTYLE_ArabicContext); |
| 173 m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(), | 173 m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(), |
| 174 pParams->m_wsText.GetLength(), rect); | 174 pParams->m_wsText.GetLength(), rect); |
| 175 return TRUE; | 175 return TRUE; |
| 176 } | 176 } |
| 177 FWL_ERR CFWL_WidgetTP::Initialize() { | 177 FWL_Error CFWL_WidgetTP::Initialize() { |
| 178 m_dwThemeID = 0; | 178 m_dwThemeID = 0; |
| 179 _ctm.SetIdentity(); | 179 _ctm.SetIdentity(); |
| 180 return FWL_ERR_Succeeded; | 180 return FWL_Error::Succeeded; |
| 181 } | 181 } |
| 182 FWL_ERR CFWL_WidgetTP::Finalize() { | 182 FWL_Error CFWL_WidgetTP::Finalize() { |
| 183 if (!m_pTextOut) { | 183 if (!m_pTextOut) { |
| 184 FinalizeTTO(); | 184 FinalizeTTO(); |
| 185 } | 185 } |
| 186 return FWL_ERR_Succeeded; | 186 return FWL_Error::Succeeded; |
| 187 } | 187 } |
| 188 CFWL_WidgetTP::~CFWL_WidgetTP() {} | 188 CFWL_WidgetTP::~CFWL_WidgetTP() {} |
| 189 FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, | 189 FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, |
| 190 const FX_WCHAR* strFont, | 190 const FX_WCHAR* strFont, |
| 191 FX_FLOAT fFontSize, | 191 FX_FLOAT fFontSize, |
| 192 FX_ARGB rgbFont) { | 192 FX_ARGB rgbFont) { |
| 193 if (!m_pTextOut) { | 193 if (!m_pTextOut) { |
| 194 return FWL_ERR_Succeeded; | 194 return FWL_Error::Succeeded; |
| 195 } | 195 } |
| 196 m_pFDEFont = CFWL_FontManager::GetInstance()->FindFont(strFont, 0, 0); | 196 m_pFDEFont = CFWL_FontManager::GetInstance()->FindFont(strFont, 0, 0); |
| 197 m_pTextOut->SetFont(m_pFDEFont); | 197 m_pTextOut->SetFont(m_pFDEFont); |
| 198 m_pTextOut->SetFontSize(fFontSize); | 198 m_pTextOut->SetFontSize(fFontSize); |
| 199 m_pTextOut->SetTextColor(rgbFont); | 199 m_pTextOut->SetTextColor(rgbFont); |
| 200 return FWL_ERR_Succeeded; | 200 return FWL_Error::Succeeded; |
| 201 } | 201 } |
| 202 FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, | 202 FWL_Error CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, |
| 203 IFX_Font* pFont, | 203 IFX_Font* pFont, |
| 204 FX_FLOAT fFontSize, | 204 FX_FLOAT fFontSize, |
| 205 FX_ARGB rgbFont) { | 205 FX_ARGB rgbFont) { |
| 206 if (!m_pTextOut) { | 206 if (!m_pTextOut) { |
| 207 return FWL_ERR_Succeeded; | 207 return FWL_Error::Succeeded; |
| 208 } | 208 } |
| 209 m_pTextOut->SetFont(pFont); | 209 m_pTextOut->SetFont(pFont); |
| 210 m_pTextOut->SetFontSize(fFontSize); | 210 m_pTextOut->SetFontSize(fFontSize); |
| 211 m_pTextOut->SetTextColor(rgbFont); | 211 m_pTextOut->SetTextColor(rgbFont); |
| 212 return FWL_ERR_Succeeded; | 212 return FWL_Error::Succeeded; |
| 213 } | 213 } |
| 214 IFX_Font* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) { | 214 IFX_Font* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) { |
| 215 return m_pFDEFont; | 215 return m_pFDEFont; |
| 216 } | 216 } |
| 217 CFWL_WidgetTP::CFWL_WidgetTP() | 217 CFWL_WidgetTP::CFWL_WidgetTP() |
| 218 : m_dwRefCount(1), m_pTextOut(NULL), m_pFDEFont(NULL), m_dwThemeID(0) {} | 218 : m_dwRefCount(1), m_pTextOut(NULL), m_pFDEFont(NULL), m_dwThemeID(0) {} |
| 219 FX_ERR CFWL_WidgetTP::InitTTO() { | 219 FWL_Error CFWL_WidgetTP::InitTTO() { |
| 220 if (m_pTextOut) { | 220 if (m_pTextOut) { |
| 221 return FWL_ERR_Succeeded; | 221 return FWL_Error::Succeeded; |
| 222 } | 222 } |
| 223 m_pFDEFont = | 223 m_pFDEFont = |
| 224 CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0); | 224 CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0); |
| 225 m_pTextOut = new CFDE_TextOut; | 225 m_pTextOut = new CFDE_TextOut; |
| 226 m_pTextOut->SetFont(m_pFDEFont); | 226 m_pTextOut->SetFont(m_pFDEFont); |
| 227 m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); | 227 m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); |
| 228 m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); | 228 m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); |
| 229 m_pTextOut->SetEllipsisString(L"..."); | 229 m_pTextOut->SetEllipsisString(L"..."); |
| 230 return FWL_ERR_Succeeded; | 230 return FWL_Error::Succeeded; |
| 231 } | 231 } |
| 232 FX_ERR CFWL_WidgetTP::FinalizeTTO() { | 232 FWL_Error CFWL_WidgetTP::FinalizeTTO() { |
| 233 if (m_pTextOut) { | 233 if (m_pTextOut) { |
| 234 m_pTextOut->Release(); | 234 m_pTextOut->Release(); |
| 235 m_pTextOut = NULL; | 235 m_pTextOut = NULL; |
| 236 } | 236 } |
| 237 return FWL_ERR_Succeeded; | 237 return FWL_Error::Succeeded; |
| 238 } | 238 } |
| 239 | 239 |
| 240 void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, | 240 void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, |
| 241 uint32_t dwStyles, | 241 uint32_t dwStyles, |
| 242 const CFX_RectF* pRect, | 242 const CFX_RectF* pRect, |
| 243 CFX_Matrix* pMatrix) { | 243 CFX_Matrix* pMatrix) { |
| 244 if (!pGraphics) | 244 if (!pGraphics) |
| 245 return; | 245 return; |
| 246 if (!pRect) | 246 if (!pRect) |
| 247 return; | 247 return; |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 m_pColorData->clrEnd[0] = ArgbEncode(255, 175, 204, 251); | 808 m_pColorData->clrEnd[0] = ArgbEncode(255, 175, 204, 251); |
| 809 m_pColorData->clrEnd[1] = ArgbEncode(255, 185, 218, 251); | 809 m_pColorData->clrEnd[1] = ArgbEncode(255, 185, 218, 251); |
| 810 m_pColorData->clrEnd[2] = ArgbEncode(255, 210, 222, 235); | 810 m_pColorData->clrEnd[2] = ArgbEncode(255, 210, 222, 235); |
| 811 m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); | 811 m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); |
| 812 m_pColorData->clrSign[0] = ArgbEncode(255, 77, 97, 133); | 812 m_pColorData->clrSign[0] = ArgbEncode(255, 77, 97, 133); |
| 813 m_pColorData->clrSign[1] = ArgbEncode(255, 77, 97, 133); | 813 m_pColorData->clrSign[1] = ArgbEncode(255, 77, 97, 133); |
| 814 m_pColorData->clrSign[2] = ArgbEncode(255, 77, 97, 133); | 814 m_pColorData->clrSign[2] = ArgbEncode(255, 77, 97, 133); |
| 815 m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); | 815 m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); |
| 816 } | 816 } |
| 817 } | 817 } |
| OLD | NEW |