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/include/fwl/theme/widgettp.h" | 7 #include "xfa/include/fwl/theme/widgettp.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "xfa/fde/tto/fde_textout.h" | 11 #include "xfa/fde/tto/fde_textout.h" |
12 #include "xfa/fwl/core/cfwl_themebackground.h" | 12 #include "xfa/fwl/core/cfwl_themebackground.h" |
13 #include "xfa/fwl/core/cfwl_themepart.h" | 13 #include "xfa/fwl/core/cfwl_themepart.h" |
14 #include "xfa/fwl/core/cfwl_themetext.h" | 14 #include "xfa/fwl/core/cfwl_themetext.h" |
15 #include "xfa/fwl/core/ifwl_themeprovider.h" | 15 #include "xfa/fwl/core/ifwl_themeprovider.h" |
16 #include "xfa/fwl/core/ifwl_widgetmgr.h" | 16 #include "xfa/fwl/core/ifwl_widgetmgr.h" |
17 #include "xfa/fxgraphics/cfx_color.h" | 17 #include "xfa/fxgraphics/cfx_color.h" |
18 #include "xfa/fxgraphics/cfx_path.h" | 18 #include "xfa/fxgraphics/cfx_path.h" |
19 #include "xfa/fxgraphics/cfx_shading.h" | 19 #include "xfa/fxgraphics/cfx_shading.h" |
20 | 20 |
21 static void FWL_SetChildThemeID(IFWL_Widget* pParent, FX_DWORD dwThemeID) { | 21 static void FWL_SetChildThemeID(IFWL_Widget* pParent, uint32_t dwThemeID) { |
22 IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr(); | 22 IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr(); |
23 IFWL_Widget* pChild = | 23 IFWL_Widget* pChild = |
24 pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild); | 24 pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild); |
25 while (pChild) { | 25 while (pChild) { |
26 IFWL_ThemeProvider* pTheme = pChild->GetThemeProvider(); | 26 IFWL_ThemeProvider* pTheme = pChild->GetThemeProvider(); |
27 if (pTheme) { | 27 if (pTheme) { |
28 pTheme->SetThemeID(pChild, dwThemeID, FALSE); | 28 pTheme->SetThemeID(pChild, dwThemeID, FALSE); |
29 } | 29 } |
30 FWL_SetChildThemeID(pChild, dwThemeID); | 30 FWL_SetChildThemeID(pChild, dwThemeID); |
31 pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling); | 31 pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling); |
32 } | 32 } |
33 } | 33 } |
34 FX_BOOL CFWL_WidgetTP::IsValidWidget(IFWL_Widget* pWidget) { | 34 FX_BOOL CFWL_WidgetTP::IsValidWidget(IFWL_Widget* pWidget) { |
35 return FALSE; | 35 return FALSE; |
36 } | 36 } |
37 FX_DWORD CFWL_WidgetTP::GetThemeID(IFWL_Widget* pWidget) { | 37 uint32_t CFWL_WidgetTP::GetThemeID(IFWL_Widget* pWidget) { |
38 return m_dwThemeID; | 38 return m_dwThemeID; |
39 } | 39 } |
40 FX_DWORD CFWL_WidgetTP::SetThemeID(IFWL_Widget* pWidget, | 40 uint32_t CFWL_WidgetTP::SetThemeID(IFWL_Widget* pWidget, |
41 FX_DWORD dwThemeID, | 41 uint32_t dwThemeID, |
42 FX_BOOL bChildren) { | 42 FX_BOOL bChildren) { |
43 FX_DWORD dwOld = m_dwThemeID; | 43 uint32_t dwOld = m_dwThemeID; |
44 m_dwThemeID = dwThemeID; | 44 m_dwThemeID = dwThemeID; |
45 if (CFWL_ArrowData::IsInstance()) { | 45 if (CFWL_ArrowData::IsInstance()) { |
46 CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(dwThemeID)); | 46 CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(dwThemeID)); |
47 } | 47 } |
48 if (bChildren) { | 48 if (bChildren) { |
49 FWL_SetChildThemeID(pWidget, dwThemeID); | 49 FWL_SetChildThemeID(pWidget, dwThemeID); |
50 } | 50 } |
51 return dwOld; | 51 return dwOld; |
52 } | 52 } |
53 FWL_ERR CFWL_WidgetTP::GetThemeMatrix(IFWL_Widget* pWidget, | 53 FWL_ERR CFWL_WidgetTP::GetThemeMatrix(IFWL_Widget* pWidget, |
(...skipping 20 matching lines...) Expand all Loading... |
74 m_pTextOut->SetRenderDevice(pGraphics->GetRenderDevice()); | 74 m_pTextOut->SetRenderDevice(pGraphics->GetRenderDevice()); |
75 m_pTextOut->SetStyles(pParams->m_dwTTOStyles); | 75 m_pTextOut->SetStyles(pParams->m_dwTTOStyles); |
76 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); | 76 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); |
77 CFX_Matrix* pMatrix = &pParams->m_matrix; | 77 CFX_Matrix* pMatrix = &pParams->m_matrix; |
78 pMatrix->Concat(*pGraphics->GetMatrix()); | 78 pMatrix->Concat(*pGraphics->GetMatrix()); |
79 m_pTextOut->SetMatrix(*pMatrix); | 79 m_pTextOut->SetMatrix(*pMatrix); |
80 m_pTextOut->DrawLogicText(pParams->m_wsText, iLen, pParams->m_rtPart); | 80 m_pTextOut->DrawLogicText(pParams->m_wsText, iLen, pParams->m_rtPart); |
81 return TRUE; | 81 return TRUE; |
82 } | 82 } |
83 void* CFWL_WidgetTP::GetCapacity(CFWL_ThemePart* pThemePart, | 83 void* CFWL_WidgetTP::GetCapacity(CFWL_ThemePart* pThemePart, |
84 FX_DWORD dwCapacity) { | 84 uint32_t dwCapacity) { |
85 switch (dwCapacity) { | 85 switch (dwCapacity) { |
86 case FWL_WGTCAPACITY_CXBorder: { | 86 case FWL_WGTCAPACITY_CXBorder: { |
87 m_fValue = FWLTHEME_CAPACITY_CXBorder; | 87 m_fValue = FWLTHEME_CAPACITY_CXBorder; |
88 break; | 88 break; |
89 } | 89 } |
90 case FWL_WGTCAPACITY_CYBorder: { | 90 case FWL_WGTCAPACITY_CYBorder: { |
91 m_fValue = FWLTHEME_CAPACITY_CYBorder; | 91 m_fValue = FWLTHEME_CAPACITY_CYBorder; |
92 break; | 92 break; |
93 } | 93 } |
94 case FWL_WGTCAPACITY_EdgeFlat: { | 94 case FWL_WGTCAPACITY_EdgeFlat: { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 } | 215 } |
216 FX_ERR CFWL_WidgetTP::FinalizeTTO() { | 216 FX_ERR CFWL_WidgetTP::FinalizeTTO() { |
217 if (m_pTextOut) { | 217 if (m_pTextOut) { |
218 m_pTextOut->Release(); | 218 m_pTextOut->Release(); |
219 m_pTextOut = NULL; | 219 m_pTextOut = NULL; |
220 } | 220 } |
221 return FWL_ERR_Succeeded; | 221 return FWL_ERR_Succeeded; |
222 } | 222 } |
223 #ifdef THEME_XPSimilar | 223 #ifdef THEME_XPSimilar |
224 void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, | 224 void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, |
225 FX_DWORD dwStyles, | 225 uint32_t dwStyles, |
226 const CFX_RectF* pRect, | 226 const CFX_RectF* pRect, |
227 CFX_Matrix* pMatrix) { | 227 CFX_Matrix* pMatrix) { |
228 if (!pGraphics) | 228 if (!pGraphics) |
229 return; | 229 return; |
230 if (!pRect) | 230 if (!pRect) |
231 return; | 231 return; |
232 pGraphics->SaveGraphState(); | 232 pGraphics->SaveGraphState(); |
233 CFX_Color crStroke(FWL_GetThemeColor(m_dwThemeID) == 0 | 233 CFX_Color crStroke(FWL_GetThemeColor(m_dwThemeID) == 0 |
234 ? ArgbEncode(255, 127, 157, 185) | 234 ? ArgbEncode(255, 127, 157, 185) |
235 : FWLTHEME_COLOR_Green_BKSelected); | 235 : FWLTHEME_COLOR_Green_BKSelected); |
236 pGraphics->SetStrokeColor(&crStroke); | 236 pGraphics->SetStrokeColor(&crStroke); |
237 CFX_Path path; | 237 CFX_Path path; |
238 path.Create(); | 238 path.Create(); |
239 path.AddRectangle(pRect->left, pRect->top, pRect->width - 1, | 239 path.AddRectangle(pRect->left, pRect->top, pRect->width - 1, |
240 pRect->height - 1); | 240 pRect->height - 1); |
241 pGraphics->StrokePath(&path, pMatrix); | 241 pGraphics->StrokePath(&path, pMatrix); |
242 path.Clear(); | 242 path.Clear(); |
243 crStroke = ArgbEncode(255, 255, 255, 255); | 243 crStroke = ArgbEncode(255, 255, 255, 255); |
244 pGraphics->SetStrokeColor(&crStroke); | 244 pGraphics->SetStrokeColor(&crStroke); |
245 path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 3, | 245 path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 3, |
246 pRect->height - 3); | 246 pRect->height - 3); |
247 pGraphics->StrokePath(&path, pMatrix); | 247 pGraphics->StrokePath(&path, pMatrix); |
248 pGraphics->RestoreGraphState(); | 248 pGraphics->RestoreGraphState(); |
249 } | 249 } |
250 #else | 250 #else |
251 void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, | 251 void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, |
252 FX_DWORD dwStyles, | 252 uint32_t dwStyles, |
253 const CFX_RectF* pRect, | 253 const CFX_RectF* pRect, |
254 CFX_Matrix* pMatrix) { | 254 CFX_Matrix* pMatrix) { |
255 if (!pGraphics) | 255 if (!pGraphics) |
256 return; | 256 return; |
257 if (!pRect) | 257 if (!pRect) |
258 return; | 258 return; |
259 FWLTHEME_EDGE eType; | 259 FWLTHEME_EDGE eType; |
260 FX_FLOAT fWidth; | 260 FX_FLOAT fWidth; |
261 switch (dwStyles & FWL_WGTSTYLE_EdgeMask) { | 261 switch (dwStyles & FWL_WGTSTYLE_EdgeMask) { |
262 case FWL_WGTSTYLE_EdgeRaised: { | 262 case FWL_WGTSTYLE_EdgeRaised: { |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 if (m_pFontMgr) { | 710 if (m_pFontMgr) { |
711 m_pFontMgr->Release(); | 711 m_pFontMgr->Release(); |
712 } | 712 } |
713 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 713 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
714 if (m_pFontSource != NULL) { | 714 if (m_pFontSource != NULL) { |
715 m_pFontSource->Release(); | 715 m_pFontSource->Release(); |
716 } | 716 } |
717 #endif | 717 #endif |
718 } | 718 } |
719 FX_BOOL CFWL_FontData::Equal(const CFX_WideStringC& wsFontFamily, | 719 FX_BOOL CFWL_FontData::Equal(const CFX_WideStringC& wsFontFamily, |
720 FX_DWORD dwFontStyles, | 720 uint32_t dwFontStyles, |
721 uint16_t wCodePage) { | 721 uint16_t wCodePage) { |
722 return m_wsFamily == wsFontFamily && m_dwStyles == dwFontStyles && | 722 return m_wsFamily == wsFontFamily && m_dwStyles == dwFontStyles && |
723 m_dwCodePage == wCodePage; | 723 m_dwCodePage == wCodePage; |
724 } | 724 } |
725 FX_BOOL CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily, | 725 FX_BOOL CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily, |
726 FX_DWORD dwFontStyles, | 726 uint32_t dwFontStyles, |
727 uint16_t dwCodePage) { | 727 uint16_t dwCodePage) { |
728 m_wsFamily = wsFontFamily; | 728 m_wsFamily = wsFontFamily; |
729 m_dwStyles = dwFontStyles; | 729 m_dwStyles = dwFontStyles; |
730 m_dwCodePage = dwCodePage; | 730 m_dwCodePage = dwCodePage; |
731 if (!m_pFontMgr) { | 731 if (!m_pFontMgr) { |
732 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 732 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
733 m_pFontMgr = IFX_FontMgr::Create(FX_GetDefFontEnumerator()); | 733 m_pFontMgr = IFX_FontMgr::Create(FX_GetDefFontEnumerator()); |
734 #else | 734 #else |
735 m_pFontSource = FX_CreateDefaultFontSourceEnum(); | 735 m_pFontSource = FX_CreateDefaultFontSourceEnum(); |
736 m_pFontMgr = IFX_FontMgr::Create(m_pFontSource); | 736 m_pFontMgr = IFX_FontMgr::Create(m_pFontSource); |
(...skipping 10 matching lines...) Expand all Loading... |
747 s_FontManager = new CFWL_FontManager; | 747 s_FontManager = new CFWL_FontManager; |
748 return s_FontManager; | 748 return s_FontManager; |
749 } | 749 } |
750 void CFWL_FontManager::DestroyInstance() { | 750 void CFWL_FontManager::DestroyInstance() { |
751 delete s_FontManager; | 751 delete s_FontManager; |
752 s_FontManager = nullptr; | 752 s_FontManager = nullptr; |
753 } | 753 } |
754 CFWL_FontManager::CFWL_FontManager() {} | 754 CFWL_FontManager::CFWL_FontManager() {} |
755 CFWL_FontManager::~CFWL_FontManager() {} | 755 CFWL_FontManager::~CFWL_FontManager() {} |
756 IFX_Font* CFWL_FontManager::FindFont(const CFX_WideStringC& wsFontFamily, | 756 IFX_Font* CFWL_FontManager::FindFont(const CFX_WideStringC& wsFontFamily, |
757 FX_DWORD dwFontStyles, | 757 uint32_t dwFontStyles, |
758 uint16_t wCodePage) { | 758 uint16_t wCodePage) { |
759 for (const auto& pData : m_FontsArray) { | 759 for (const auto& pData : m_FontsArray) { |
760 if (pData->Equal(wsFontFamily, dwFontStyles, wCodePage)) | 760 if (pData->Equal(wsFontFamily, dwFontStyles, wCodePage)) |
761 return pData->GetFont(); | 761 return pData->GetFont(); |
762 } | 762 } |
763 std::unique_ptr<CFWL_FontData> pFontData(new CFWL_FontData); | 763 std::unique_ptr<CFWL_FontData> pFontData(new CFWL_FontData); |
764 if (!pFontData->LoadFont(wsFontFamily, dwFontStyles, wCodePage)) | 764 if (!pFontData->LoadFont(wsFontFamily, dwFontStyles, wCodePage)) |
765 return nullptr; | 765 return nullptr; |
766 m_FontsArray.push_back(std::move(pFontData)); | 766 m_FontsArray.push_back(std::move(pFontData)); |
767 return m_FontsArray.back()->GetFont(); | 767 return m_FontsArray.back()->GetFont(); |
768 } | 768 } |
769 FX_BOOL FWLTHEME_Init() { | 769 FX_BOOL FWLTHEME_Init() { |
770 return TRUE; | 770 return TRUE; |
771 } | 771 } |
772 void FWLTHEME_Release() { | 772 void FWLTHEME_Release() { |
773 CFWL_ArrowData::DestroyInstance(); | 773 CFWL_ArrowData::DestroyInstance(); |
774 CFWL_FontManager::DestroyInstance(); | 774 CFWL_FontManager::DestroyInstance(); |
775 } | 775 } |
776 FX_DWORD FWL_GetThemeLayout(FX_DWORD dwThemeID) { | 776 uint32_t FWL_GetThemeLayout(uint32_t dwThemeID) { |
777 return 0xffff0000 & dwThemeID; | 777 return 0xffff0000 & dwThemeID; |
778 } | 778 } |
779 FX_DWORD FWL_GetThemeColor(FX_DWORD dwThemeID) { | 779 uint32_t FWL_GetThemeColor(uint32_t dwThemeID) { |
780 return 0x0000ffff & dwThemeID; | 780 return 0x0000ffff & dwThemeID; |
781 } | 781 } |
782 FX_DWORD FWL_MakeThemeID(FX_DWORD dwLayout, FX_DWORD dwColor) { | 782 uint32_t FWL_MakeThemeID(uint32_t dwLayout, uint32_t dwColor) { |
783 return (dwLayout << 16) | (0x0000FFFF & dwColor); | 783 return (dwLayout << 16) | (0x0000FFFF & dwColor); |
784 } | 784 } |
785 CFWL_ArrowData* CFWL_ArrowData::m_pInstance = NULL; | 785 CFWL_ArrowData* CFWL_ArrowData::m_pInstance = NULL; |
786 CFWL_ArrowData* CFWL_ArrowData::GetInstance() { | 786 CFWL_ArrowData* CFWL_ArrowData::GetInstance() { |
787 if (!m_pInstance) { | 787 if (!m_pInstance) { |
788 m_pInstance = new CFWL_ArrowData; | 788 m_pInstance = new CFWL_ArrowData; |
789 } | 789 } |
790 return m_pInstance; | 790 return m_pInstance; |
791 } | 791 } |
792 FX_BOOL CFWL_ArrowData::IsInstance() { | 792 FX_BOOL CFWL_ArrowData::IsInstance() { |
793 return (m_pInstance != NULL); | 793 return (m_pInstance != NULL); |
794 } | 794 } |
795 void CFWL_ArrowData::DestroyInstance() { | 795 void CFWL_ArrowData::DestroyInstance() { |
796 if (m_pInstance) { | 796 if (m_pInstance) { |
797 delete m_pInstance; | 797 delete m_pInstance; |
798 m_pInstance = NULL; | 798 m_pInstance = NULL; |
799 } | 799 } |
800 } | 800 } |
801 CFWL_ArrowData::~CFWL_ArrowData() { | 801 CFWL_ArrowData::~CFWL_ArrowData() { |
802 if (m_pColorData) { | 802 if (m_pColorData) { |
803 delete m_pColorData; | 803 delete m_pColorData; |
804 m_pColorData = NULL; | 804 m_pColorData = NULL; |
805 } | 805 } |
806 } | 806 } |
807 void CFWL_ArrowData::SetColorData(FX_DWORD dwID) { | 807 void CFWL_ArrowData::SetColorData(uint32_t dwID) { |
808 if (!m_pColorData) { | 808 if (!m_pColorData) { |
809 m_pColorData = new CColorData; | 809 m_pColorData = new CColorData; |
810 } | 810 } |
811 if (dwID) { | 811 if (dwID) { |
812 m_pColorData->clrBorder[0] = ArgbEncode(255, 142, 153, 125); | 812 m_pColorData->clrBorder[0] = ArgbEncode(255, 142, 153, 125); |
813 m_pColorData->clrBorder[1] = ArgbEncode(255, 157, 171, 119); | 813 m_pColorData->clrBorder[1] = ArgbEncode(255, 157, 171, 119); |
814 m_pColorData->clrBorder[2] = ArgbEncode(255, 118, 131, 97); | 814 m_pColorData->clrBorder[2] = ArgbEncode(255, 118, 131, 97); |
815 m_pColorData->clrBorder[3] = ArgbEncode(255, 172, 168, 153); | 815 m_pColorData->clrBorder[3] = ArgbEncode(255, 172, 168, 153); |
816 m_pColorData->clrStart[0] = ArgbEncode(255, 203, 215, 186); | 816 m_pColorData->clrStart[0] = ArgbEncode(255, 203, 215, 186); |
817 m_pColorData->clrStart[1] = ArgbEncode(255, 218, 232, 185); | 817 m_pColorData->clrStart[1] = ArgbEncode(255, 218, 232, 185); |
(...skipping 19 matching lines...) Expand all Loading... |
837 m_pColorData->clrEnd[0] = ArgbEncode(255, 175, 204, 251); | 837 m_pColorData->clrEnd[0] = ArgbEncode(255, 175, 204, 251); |
838 m_pColorData->clrEnd[1] = ArgbEncode(255, 185, 218, 251); | 838 m_pColorData->clrEnd[1] = ArgbEncode(255, 185, 218, 251); |
839 m_pColorData->clrEnd[2] = ArgbEncode(255, 210, 222, 235); | 839 m_pColorData->clrEnd[2] = ArgbEncode(255, 210, 222, 235); |
840 m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); | 840 m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); |
841 m_pColorData->clrSign[0] = ArgbEncode(255, 77, 97, 133); | 841 m_pColorData->clrSign[0] = ArgbEncode(255, 77, 97, 133); |
842 m_pColorData->clrSign[1] = ArgbEncode(255, 77, 97, 133); | 842 m_pColorData->clrSign[1] = ArgbEncode(255, 77, 97, 133); |
843 m_pColorData->clrSign[2] = ArgbEncode(255, 77, 97, 133); | 843 m_pColorData->clrSign[2] = ArgbEncode(255, 77, 97, 133); |
844 m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); | 844 m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); |
845 } | 845 } |
846 } | 846 } |
OLD | NEW |