From 9d1972fd11a4f4a575dd893cb2844c03a1953abf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 12 Nov 2021 17:54:37 +0000 Subject: [PATCH] Use wxBitmapBundle in wxToolbook This allows using the version of the bitmap appropriate for the current DPI scaling. It also simplifies the code. --- src/generic/toolbkg.cpp | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/generic/toolbkg.cpp b/src/generic/toolbkg.cpp index 4cf5ba0739..b83d4bb14b 100644 --- a/src/generic/toolbkg.cpp +++ b/src/generic/toolbkg.cpp @@ -161,12 +161,11 @@ int wxToolbook::GetPageImage(size_t WXUNUSED(n)) const bool wxToolbook::SetPageImage(size_t n, int imageId) { - wxASSERT( GetImageList() != NULL ); - if (!GetImageList()) + wxBitmapBundle bmp = GetBitmapBundle(imageId); + if ( !bmp.IsOk() ) return false; int toolId = PageToToolId(n); - wxBitmap bmp = GetImageList()->GetBitmap(imageId); GetToolBar()->SetToolNormalBitmap(toolId, bmp); return true; @@ -271,24 +270,10 @@ bool wxToolbook::InsertPage(size_t n, m_needsRealizing = true; - wxASSERT(GetImageList() != NULL); - - if (!GetImageList()) - return false; - - // TODO: make sure all platforms can convert between icon and bitmap, - // and/or test whether the image is a bitmap or an icon. -#ifdef __WXMAC__ - wxBitmap bitmap = GetImageList()->GetBitmap(imageId); -#else - // On Windows, we can lose information by using GetBitmap, so extract icon instead - wxIcon icon = GetImageList()->GetIcon(imageId); - wxBitmap bitmap; - bitmap.CopyFromIcon(icon); -#endif + wxBitmapBundle bitmap = GetBitmapBundle(imageId); int toolId = page->GetId(); - GetToolBar()->InsertTool(n, toolId, text, bitmap, wxNullBitmap, wxITEM_RADIO); + GetToolBar()->InsertTool(n, toolId, text, bitmap, wxBitmapBundle(), wxITEM_RADIO); // fix current selection if (m_selection == wxNOT_FOUND)