From 56ac9416fbdba16aa92ded7b5f505dd865f525ac Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Thu, 30 Sep 2021 23:52:51 -0700 Subject: [PATCH] Compatibility fix for wxWidgets 3.1.5 wxBitmapCombo Box, which requires all bitmaps in a combo box to be the same size. --- clientgui/sg_ProjectPanel.cpp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/clientgui/sg_ProjectPanel.cpp b/clientgui/sg_ProjectPanel.cpp index f7cd48076c..1e5f3ca5cf 100644 --- a/clientgui/sg_ProjectPanel.cpp +++ b/clientgui/sg_ProjectPanel.cpp @@ -551,30 +551,28 @@ wxBitmap* CSimpleProjectPanel::GetProjectSpecificBitmap(char* project_url) { wxBitmap* projectBM; wxString strIconPath = wxString(defaultIcnPath,wxConvUTF8); if (wxFile::Exists(strIconPath)) { + // wxBitmapComboBox requires all its bitmaps to be the same size + // Our "project icon" bitmaps should all be 40 X 40 + wxImage img = wxImage(strIconPath, wxBITMAP_TYPE_ANY); + if (img.IsOk()) { #ifdef __WXMSW__ if ((GetXDPIScaling() > 1.05) || (GetYDPIScaling() > 1.05)) { - wxImage img = wxImage(strIconPath, wxBITMAP_TYPE_ANY); - if (img.IsOk()) { - img.Rescale((int) (img.GetWidth()*GetXDPIScaling()), - (int) (img.GetHeight()*GetYDPIScaling()), - wxIMAGE_QUALITY_BILINEAR - ); - projectBM = new wxBitmap(img); - if (projectBM->IsOk()) { - return projectBM; - } + img.Rescale((int) (40*GetXDPIScaling()), + (int) (40*GetYDPIScaling()), + wxIMAGE_QUALITY_BILINEAR + ); + } +#else + if ((img.GetHeight() != 40) || (img.GetWidth() == 40)) { + img.Rescale(40, 40, wxIMAGE_QUALITY_BILINEAR); } - } else #endif - { - projectBM = new wxBitmap(); - if ( projectBM->LoadFile(strIconPath, wxBITMAP_TYPE_ANY) ) { + projectBM = new wxBitmap(img); + if (projectBM->IsOk()) { return projectBM; } - } + } } } return pSkinSimple->GetProjectImage()->GetBitmap(); } - -