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

Side by Side Diff: xfa/src/fwl/src/theme/widgettp.cpp

Issue 1672283002: Remove CFX_PtrArray from xfa/include/fwl (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 10 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/src/fwl/src/lightwidget/theme.cpp ('k') | no next file » | 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "xfa/src/foxitlib.h" 9 #include "xfa/src/foxitlib.h"
10 static void FWL_SetChildThemeID(IFWL_Widget* pParent, FX_DWORD dwThemeID) { 10 static void FWL_SetChildThemeID(IFWL_Widget* pParent, FX_DWORD dwThemeID) {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 return FWL_ERR_Succeeded; 159 return FWL_ERR_Succeeded;
160 } 160 }
161 CFWL_WidgetTP::~CFWL_WidgetTP() {} 161 CFWL_WidgetTP::~CFWL_WidgetTP() {}
162 FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, 162 FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget,
163 const FX_WCHAR* strFont, 163 const FX_WCHAR* strFont,
164 FX_FLOAT fFontSize, 164 FX_FLOAT fFontSize,
165 FX_ARGB rgbFont) { 165 FX_ARGB rgbFont) {
166 if (!m_pTextOut) { 166 if (!m_pTextOut) {
167 return FWL_ERR_Succeeded; 167 return FWL_ERR_Succeeded;
168 } 168 }
169 m_pFDEFont = FWL_GetFontManager()->FindFont(strFont, 0, 0); 169 m_pFDEFont = CFWL_FontManager::GetInstance()->FindFont(strFont, 0, 0);
170 m_pTextOut->SetFont(m_pFDEFont); 170 m_pTextOut->SetFont(m_pFDEFont);
171 m_pTextOut->SetFontSize(fFontSize); 171 m_pTextOut->SetFontSize(fFontSize);
172 m_pTextOut->SetTextColor(rgbFont); 172 m_pTextOut->SetTextColor(rgbFont);
173 return FWL_ERR_Succeeded; 173 return FWL_ERR_Succeeded;
174 } 174 }
175 FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, 175 FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget,
176 IFX_Font* pFont, 176 IFX_Font* pFont,
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_ERR_Succeeded;
181 } 181 }
182 m_pTextOut->SetFont(pFont); 182 m_pTextOut->SetFont(pFont);
183 m_pTextOut->SetFontSize(fFontSize); 183 m_pTextOut->SetFontSize(fFontSize);
184 m_pTextOut->SetTextColor(rgbFont); 184 m_pTextOut->SetTextColor(rgbFont);
185 return FWL_ERR_Succeeded; 185 return FWL_ERR_Succeeded;
186 } 186 }
187 IFX_Font* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) { 187 IFX_Font* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) {
188 return m_pFDEFont; 188 return m_pFDEFont;
189 } 189 }
190 CFWL_WidgetTP::CFWL_WidgetTP() 190 CFWL_WidgetTP::CFWL_WidgetTP()
191 : m_dwRefCount(1), m_pTextOut(NULL), m_pFDEFont(NULL), m_dwThemeID(0) {} 191 : m_dwRefCount(1), m_pTextOut(NULL), m_pFDEFont(NULL), m_dwThemeID(0) {}
192 FX_ERR CFWL_WidgetTP::InitTTO() { 192 FX_ERR CFWL_WidgetTP::InitTTO() {
193 if (m_pTextOut) { 193 if (m_pTextOut) {
194 return FWL_ERR_Succeeded; 194 return FWL_ERR_Succeeded;
195 } 195 }
196 m_pFDEFont = FWL_GetFontManager()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0); 196 m_pFDEFont =
197 CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0);
197 m_pTextOut = IFDE_TextOut::Create(); 198 m_pTextOut = IFDE_TextOut::Create();
198 m_pTextOut->SetFont(m_pFDEFont); 199 m_pTextOut->SetFont(m_pFDEFont);
199 m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); 200 m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize);
200 m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); 201 m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor);
201 m_pTextOut->SetEllipsisString(L"..."); 202 m_pTextOut->SetEllipsisString(L"...");
202 return FWL_ERR_Succeeded; 203 return FWL_ERR_Succeeded;
203 } 204 }
204 FX_ERR CFWL_WidgetTP::FinalizeTTO() { 205 FX_ERR CFWL_WidgetTP::FinalizeTTO() {
205 if (m_pTextOut) { 206 if (m_pTextOut) {
206 m_pTextOut->Release(); 207 m_pTextOut->Release();
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 ((FX_WORD)srcColor.r * n + (FX_WORD)renderColor.r * scale) >> 8); 677 ((FX_WORD)srcColor.r * n + (FX_WORD)renderColor.r * scale) >> 8);
677 dstColor.g = (uint8_t)( 678 dstColor.g = (uint8_t)(
678 ((FX_WORD)srcColor.g * n + (FX_WORD)renderColor.g * scale) >> 8); 679 ((FX_WORD)srcColor.g * n + (FX_WORD)renderColor.g * scale) >> 8);
679 dstColor.b = (uint8_t)( 680 dstColor.b = (uint8_t)(
680 ((FX_WORD)srcColor.b * n + (FX_WORD)renderColor.b * scale) >> 8); 681 ((FX_WORD)srcColor.b * n + (FX_WORD)renderColor.b * scale) >> 8);
681 return dstColor; 682 return dstColor;
682 } 683 }
683 CFWL_ArrowData::CFWL_ArrowData() : m_pColorData(NULL) { 684 CFWL_ArrowData::CFWL_ArrowData() : m_pColorData(NULL) {
684 SetColorData(0); 685 SetColorData(0);
685 } 686 }
686 CFWL_FontManager* FWL_GetFontManager() {
687 static CFWL_FontManager* _fontManager = NULL;
688 if (_fontManager == NULL) {
689 _fontManager = new CFWL_FontManager;
690 }
691 return _fontManager;
692 }
693 void FWL_ReleaseFontManager() {
694 CFWL_FontManager* fontManager = FWL_GetFontManager();
695 delete fontManager;
696 }
697 CFWL_FontData::CFWL_FontData() 687 CFWL_FontData::CFWL_FontData()
698 : m_dwStyles(0), 688 : m_dwStyles(0),
699 m_dwCodePage(0), 689 m_dwCodePage(0),
700 m_pFont(0), 690 m_pFont(0),
701 m_pFontMgr(NULL) 691 m_pFontMgr(NULL)
702 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ 692 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
703 , 693 ,
704 m_pFontSource(NULL) 694 m_pFontSource(NULL)
705 #endif 695 #endif
706 { 696 {
(...skipping 28 matching lines...) Expand all
735 m_pFontMgr = IFX_FontMgr::Create(FX_GetDefFontEnumerator()); 725 m_pFontMgr = IFX_FontMgr::Create(FX_GetDefFontEnumerator());
736 #else 726 #else
737 m_pFontSource = FX_CreateDefaultFontSourceEnum(); 727 m_pFontSource = FX_CreateDefaultFontSourceEnum();
738 m_pFontMgr = IFX_FontMgr::Create(m_pFontSource); 728 m_pFontMgr = IFX_FontMgr::Create(m_pFontSource);
739 #endif 729 #endif
740 } 730 }
741 m_pFont = IFX_Font::LoadFont(wsFontFamily.GetPtr(), dwFontStyles, dwCodePage, 731 m_pFont = IFX_Font::LoadFont(wsFontFamily.GetPtr(), dwFontStyles, dwCodePage,
742 m_pFontMgr); 732 m_pFontMgr);
743 return m_pFont != NULL; 733 return m_pFont != NULL;
744 } 734 }
735
736 CFWL_FontManager* CFWL_FontManager::s_FontManager = nullptr;
737 CFWL_FontManager* CFWL_FontManager::GetInstance() {
738 if (!s_FontManager)
739 s_FontManager = new CFWL_FontManager;
740 return s_FontManager;
741 }
742 void CFWL_FontManager::DestroyInstance() {
743 delete s_FontManager;
744 s_FontManager = nullptr;
745 }
745 CFWL_FontManager::CFWL_FontManager() {} 746 CFWL_FontManager::CFWL_FontManager() {}
746 CFWL_FontManager::~CFWL_FontManager() { 747 CFWL_FontManager::~CFWL_FontManager() {}
747 for (int32_t i = 0; i < m_arrFonts.GetSize(); i++) {
748 delete static_cast<CFWL_FontData*>(m_arrFonts[i]);
749 }
750 m_arrFonts.RemoveAll();
751 }
752 IFX_Font* CFWL_FontManager::FindFont(const CFX_WideStringC& wsFontFamily, 748 IFX_Font* CFWL_FontManager::FindFont(const CFX_WideStringC& wsFontFamily,
753 FX_DWORD dwFontStyles, 749 FX_DWORD dwFontStyles,
754 FX_WORD wCodePage) { 750 FX_WORD wCodePage) {
755 for (int32_t i = 0; i < m_arrFonts.GetSize(); i++) { 751 for (const auto& pData : m_FontsArray) {
756 CFWL_FontData* data = static_cast<CFWL_FontData*>(m_arrFonts[i]); 752 if (pData->Equal(wsFontFamily, dwFontStyles, wCodePage))
757 if (data->Equal(wsFontFamily, dwFontStyles, wCodePage)) { 753 return pData->GetFont();
758 return data->GetFont();
759 }
760 } 754 }
761 CFWL_FontData* fontData = new CFWL_FontData; 755 std::unique_ptr<CFWL_FontData> pFontData(new CFWL_FontData);
762 if (!fontData->LoadFont(wsFontFamily, dwFontStyles, wCodePage)) { 756 if (!pFontData->LoadFont(wsFontFamily, dwFontStyles, wCodePage))
763 delete fontData; 757 return nullptr;
764 return NULL; 758 m_FontsArray.push_back(std::move(pFontData));
765 } 759 return m_FontsArray.back()->GetFont();
766 m_arrFonts.Add(fontData);
767 return fontData->GetFont();
768 } 760 }
769 FX_BOOL FWLTHEME_Init() { 761 FX_BOOL FWLTHEME_Init() {
770 return TRUE; 762 return TRUE;
771 } 763 }
772 void FWLTHEME_Release() { 764 void FWLTHEME_Release() {
773 CFWL_ArrowData::DestroyInstance(); 765 CFWL_ArrowData::DestroyInstance();
774 FWL_ReleaseFontManager(); 766 CFWL_FontManager::DestroyInstance();
775 } 767 }
776 FX_DWORD FWL_GetThemeLayout(FX_DWORD dwThemeID) { 768 FX_DWORD FWL_GetThemeLayout(FX_DWORD dwThemeID) {
777 return 0xffff0000 & dwThemeID; 769 return 0xffff0000 & dwThemeID;
778 } 770 }
779 FX_DWORD FWL_GetThemeColor(FX_DWORD dwThemeID) { 771 FX_DWORD FWL_GetThemeColor(FX_DWORD dwThemeID) {
780 return 0x0000ffff & dwThemeID; 772 return 0x0000ffff & dwThemeID;
781 } 773 }
782 FX_DWORD FWL_MakeThemeID(FX_DWORD dwLayout, FX_DWORD dwColor) { 774 FX_DWORD FWL_MakeThemeID(FX_DWORD dwLayout, FX_DWORD dwColor) {
783 return (dwLayout << 16) | (0x0000FFFF & dwColor); 775 return (dwLayout << 16) | (0x0000FFFF & dwColor);
784 } 776 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 m_pColorData->clrEnd[0] = ArgbEncode(255, 175, 204, 251); 829 m_pColorData->clrEnd[0] = ArgbEncode(255, 175, 204, 251);
838 m_pColorData->clrEnd[1] = ArgbEncode(255, 185, 218, 251); 830 m_pColorData->clrEnd[1] = ArgbEncode(255, 185, 218, 251);
839 m_pColorData->clrEnd[2] = ArgbEncode(255, 210, 222, 235); 831 m_pColorData->clrEnd[2] = ArgbEncode(255, 210, 222, 235);
840 m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); 832 m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236);
841 m_pColorData->clrSign[0] = ArgbEncode(255, 77, 97, 133); 833 m_pColorData->clrSign[0] = ArgbEncode(255, 77, 97, 133);
842 m_pColorData->clrSign[1] = ArgbEncode(255, 77, 97, 133); 834 m_pColorData->clrSign[1] = ArgbEncode(255, 77, 97, 133);
843 m_pColorData->clrSign[2] = ArgbEncode(255, 77, 97, 133); 835 m_pColorData->clrSign[2] = ArgbEncode(255, 77, 97, 133);
844 m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); 836 m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128);
845 } 837 }
846 } 838 }
OLDNEW
« no previous file with comments | « xfa/src/fwl/src/lightwidget/theme.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698