From 9d86ba11e2a64197b34dcfa81200e66be2ffa913 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 7 Nov 2021 23:40:47 +0100 Subject: [PATCH] Add support for wxBitmapBundle to wxGTK wxNotebook Just use wxWithImages::GetBitmapBundle() directly with wxGtkImage without passing by wxImageList -- this suffices to have working high DPI support for notebook page icons. --- src/gtk/notebook.cpp | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 61f7564f7e..f6659b334f 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -283,9 +283,10 @@ bool wxNotebook::SetPageImage( size_t page, int image ) wxCHECK_MSG(page < GetPageCount(), false, "invalid notebook index"); wxGtkNotebookPage* pageData = GetNotebookPage(page); - if (image >= 0) + + const wxBitmapBundle bundle = GetBitmapBundle(image); + if ( bundle.IsOk() ) { - wxCHECK_MSG(HasImageList(), false, "invalid notebook imagelist"); if (pageData->m_image == NULL) { pageData->m_image = wxGtkImage::New(); @@ -293,7 +294,7 @@ bool wxNotebook::SetPageImage( size_t page, int image ) gtk_box_pack_start(GTK_BOX(pageData->m_box), pageData->m_image, false, false, m_padding); } - WX_GTK_IMAGE(pageData->m_image)->Set(GetImageList()->GetBitmap(image)); + WX_GTK_IMAGE(pageData->m_image)->Set(bundle); } else if (pageData->m_image) { @@ -481,21 +482,13 @@ bool wxNotebook::InsertPage( size_t position, gtk_container_set_border_width(GTK_CONTAINER(pageData->m_box), 2); #endif - pageData->m_image = NULL; - if (imageId != -1) + const wxBitmapBundle bundle = GetBitmapBundle(imageId); + if ( bundle.IsOk() ) { - if (HasImageList()) - { - const wxBitmap bitmap = GetImageList()->GetBitmap(imageId); - pageData->m_image = wxGtkImage::New(); - WX_GTK_IMAGE(pageData->m_image)->Set(bitmap); - gtk_box_pack_start(GTK_BOX(pageData->m_box), - pageData->m_image, false, false, m_padding); - } - else - { - wxFAIL_MSG("invalid notebook imagelist"); - } + pageData->m_image = wxGtkImage::New(); + WX_GTK_IMAGE(pageData->m_image)->Set(bundle); + gtk_box_pack_start(GTK_BOX(pageData->m_box), + pageData->m_image, false, false, m_padding); } /* set the label text */