From 3b5441f59e6ab3c28679f45a39fb3a37f0b06514 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 30 Oct 2018 23:15:49 +0100 Subject: [PATCH] Deprecate wxGenericImageList::GetBitmapPtr() This function was in effect deprecated since 2.5.5 (!) and it's not finally time to do it formally and to stop using it in wxWidgets own code. --- include/wx/generic/imaglist.h | 7 +++++-- src/generic/imaglist.cpp | 6 +++--- src/gtk/notebook.cpp | 12 +++++------- src/gtk1/notebook.cpp | 16 ++++++++-------- src/qt/listctrl.cpp | 9 +++------ src/qt/notebook.cpp | 10 ++++------ 6 files changed, 28 insertions(+), 32 deletions(-) diff --git a/include/wx/generic/imaglist.h b/include/wx/generic/imaglist.h index 227f0c7114..a98973487e 100644 --- a/include/wx/generic/imaglist.h +++ b/include/wx/generic/imaglist.h @@ -47,11 +47,14 @@ public: #if WXWIN_COMPATIBILITY_3_0 wxDEPRECATED_MSG("Don't use this overload: it's not portable and does nothing") bool Create() { return true; } + + wxDEPRECATED_MSG("Use GetBitmap() instead") + const wxBitmap *GetBitmapPtr(int index) const { return DoGetPtr(index); } #endif // WXWIN_COMPATIBILITY_3_0 - // Internal use only - const wxBitmap *GetBitmapPtr(int index) const; private: + const wxBitmap *DoGetPtr(int index) const; + wxObjectList m_images; // Size of a single bitmap in the list. diff --git a/src/generic/imaglist.cpp b/src/generic/imaglist.cpp index 5613be69f0..502d5fdcbf 100644 --- a/src/generic/imaglist.cpp +++ b/src/generic/imaglist.cpp @@ -112,7 +112,7 @@ int wxGenericImageList::Add( const wxBitmap& bitmap, const wxColour& maskColour return Add(wxBitmap(img)); } -const wxBitmap *wxGenericImageList::GetBitmapPtr( int index ) const +const wxBitmap *wxGenericImageList::DoGetPtr( int index ) const { wxObjectList::compatibility_iterator node = m_images.Item( index ); @@ -124,7 +124,7 @@ const wxBitmap *wxGenericImageList::GetBitmapPtr( int index ) const // Get the bitmap wxBitmap wxGenericImageList::GetBitmap(int index) const { - const wxBitmap* bmp = GetBitmapPtr(index); + const wxBitmap* bmp = DoGetPtr(index); if (!bmp) return wxNullBitmap; @@ -137,7 +137,7 @@ wxBitmap wxGenericImageList::GetBitmap(int index) const // Get the icon wxIcon wxGenericImageList::GetIcon(int index) const { - const wxBitmap* bmp = GetBitmapPtr(index); + const wxBitmap* bmp = DoGetPtr(index); if (!bmp) return wxNullIcon; diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 93878cceb6..31978cb2b0 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -284,17 +284,15 @@ bool wxNotebook::SetPageImage( size_t page, int image ) if (image >= 0) { wxCHECK_MSG(HasImageList(), false, "invalid notebook imagelist"); - const wxBitmap* bitmap = GetImageList()->GetBitmapPtr(image); - if (bitmap == NULL) - return false; + const wxBitmap bitmap = GetImageList()->GetBitmap(image); if (pageData->m_image) { gtk_image_set_from_pixbuf( - GTK_IMAGE(pageData->m_image), bitmap->GetPixbuf()); + GTK_IMAGE(pageData->m_image), bitmap.GetPixbuf()); } else { - pageData->m_image = gtk_image_new_from_pixbuf(bitmap->GetPixbuf()); + pageData->m_image = gtk_image_new_from_pixbuf(bitmap.GetPixbuf()); gtk_widget_show(pageData->m_image); gtk_box_pack_start(GTK_BOX(pageData->m_box), pageData->m_image, false, false, m_padding); @@ -443,8 +441,8 @@ bool wxNotebook::InsertPage( size_t position, { if (HasImageList()) { - const wxBitmap* bitmap = GetImageList()->GetBitmapPtr(imageId); - pageData->m_image = gtk_image_new_from_pixbuf(bitmap->GetPixbuf()); + const wxBitmap bitmap = GetImageList()->GetBitmap(imageId); + pageData->m_image = gtk_image_new_from_pixbuf(bitmap.GetPixbuf()); gtk_box_pack_start(GTK_BOX(pageData->m_box), pageData->m_image, false, false, m_padding); } diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index 6dc0752862..cb17186a51 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -512,12 +512,12 @@ bool wxNotebook::SetPageImage( size_t page, int image ) wxASSERT( HasImageList() ); /* Just in case */ /* Construct the new pixmap */ - const wxBitmap *bmp = GetImageList()->GetBitmapPtr(image); - GdkPixmap *pixmap = bmp->GetPixmap(); + const wxBitmap bmp = GetImageList()->GetBitmap(image); + GdkPixmap *pixmap = bmp.GetPixmap(); GdkBitmap *mask = NULL; - if ( bmp->GetMask() ) + if ( bmp.GetMask() ) { - mask = bmp->GetMask()->GetBitmap(); + mask = bmp.GetMask()->GetBitmap(); } if (pixmapwid == NULL) @@ -679,12 +679,12 @@ bool wxNotebook::InsertPage( size_t position, { wxASSERT( HasImageList() ); - const wxBitmap *bmp = GetImageList()->GetBitmapPtr(imageId); - GdkPixmap *pixmap = bmp->GetPixmap(); + const wxBitmap bmp = GetImageList()->GetBitmap(imageId); + GdkPixmap *pixmap = bmp.GetPixmap(); GdkBitmap *mask = NULL; - if ( bmp->GetMask() ) + if ( bmp.GetMask() ) { - mask = bmp->GetMask()->GetBitmap(); + mask = bmp.GetMask()->GetBitmap(); } GtkWidget *pixmapwid = gtk_pixmap_new (pixmap, mask ); diff --git a/src/qt/listctrl.cpp b/src/qt/listctrl.cpp index 7ddd3b8d79..8a087ef07d 100644 --- a/src/qt/listctrl.cpp +++ b/src/qt/listctrl.cpp @@ -329,12 +329,9 @@ bool wxListCtrl::SetItem(wxListItem& info) { wxImageList *imglst = GetImageList(InReportView() ? wxIMAGE_LIST_SMALL : wxIMAGE_LIST_NORMAL); wxCHECK_MSG(imglst, false, "invalid listctrl imagelist"); - const wxBitmap* bitmap = imglst->GetBitmapPtr(info.m_image); - if (bitmap != NULL) - { - // set the new image: - qitem->setIcon( info.GetColumn(), QIcon( *bitmap->GetHandle() )); - } + const wxBitmap bitmap = imglst->GetBitmap(info.m_image); + // set the new image: + qitem->setIcon( info.GetColumn(), QIcon( *bitmap.GetHandle() )); } else { diff --git a/src/qt/notebook.cpp b/src/qt/notebook.cpp index 8fd294f1f5..3730c67782 100644 --- a/src/qt/notebook.cpp +++ b/src/qt/notebook.cpp @@ -112,11 +112,9 @@ bool wxNotebook::SetPageImage(size_t n, int imageId) if (imageId >= 0) { wxCHECK_MSG(HasImageList(), false, "invalid notebook imagelist"); - const wxBitmap* bitmap = GetImageList()->GetBitmapPtr(imageId); - if (bitmap == NULL) - return false; + const wxBitmap bitmap = GetImageList()->GetBitmap(imageId); // set the new image: - m_qtTabWidget->setTabIcon( n, QIcon( *bitmap->GetHandle() )); + m_qtTabWidget->setTabIcon( n, QIcon( *bitmap.GetHandle() )); } else { @@ -137,8 +135,8 @@ bool wxNotebook::InsertPage(size_t n, wxWindow *page, const wxString& text, { if (HasImageList()) { - const wxBitmap* bitmap = GetImageList()->GetBitmapPtr(imageId); - m_qtTabWidget->insertTab( n, page->GetHandle(), QIcon( *bitmap->GetHandle() ), wxQtConvertString( text )); + const wxBitmap bitmap = GetImageList()->GetBitmap(imageId); + m_qtTabWidget->insertTab( n, page->GetHandle(), QIcon( *bitmap.GetHandle() ), wxQtConvertString( text )); } else {