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.
This commit is contained in:
Vadim Zeitlin
2018-10-30 23:15:49 +01:00
parent 61e4534bd2
commit 3b5441f59e
6 changed files with 28 additions and 32 deletions

View File

@@ -47,11 +47,14 @@ public:
#if WXWIN_COMPATIBILITY_3_0 #if WXWIN_COMPATIBILITY_3_0
wxDEPRECATED_MSG("Don't use this overload: it's not portable and does nothing") wxDEPRECATED_MSG("Don't use this overload: it's not portable and does nothing")
bool Create() { return true; } bool Create() { return true; }
wxDEPRECATED_MSG("Use GetBitmap() instead")
const wxBitmap *GetBitmapPtr(int index) const { return DoGetPtr(index); }
#endif // WXWIN_COMPATIBILITY_3_0 #endif // WXWIN_COMPATIBILITY_3_0
// Internal use only
const wxBitmap *GetBitmapPtr(int index) const;
private: private:
const wxBitmap *DoGetPtr(int index) const;
wxObjectList m_images; wxObjectList m_images;
// Size of a single bitmap in the list. // Size of a single bitmap in the list.

View File

@@ -112,7 +112,7 @@ int wxGenericImageList::Add( const wxBitmap& bitmap, const wxColour& maskColour
return Add(wxBitmap(img)); 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 ); wxObjectList::compatibility_iterator node = m_images.Item( index );
@@ -124,7 +124,7 @@ const wxBitmap *wxGenericImageList::GetBitmapPtr( int index ) const
// Get the bitmap // Get the bitmap
wxBitmap wxGenericImageList::GetBitmap(int index) const wxBitmap wxGenericImageList::GetBitmap(int index) const
{ {
const wxBitmap* bmp = GetBitmapPtr(index); const wxBitmap* bmp = DoGetPtr(index);
if (!bmp) if (!bmp)
return wxNullBitmap; return wxNullBitmap;
@@ -137,7 +137,7 @@ wxBitmap wxGenericImageList::GetBitmap(int index) const
// Get the icon // Get the icon
wxIcon wxGenericImageList::GetIcon(int index) const wxIcon wxGenericImageList::GetIcon(int index) const
{ {
const wxBitmap* bmp = GetBitmapPtr(index); const wxBitmap* bmp = DoGetPtr(index);
if (!bmp) if (!bmp)
return wxNullIcon; return wxNullIcon;

View File

@@ -284,17 +284,15 @@ bool wxNotebook::SetPageImage( size_t page, int image )
if (image >= 0) if (image >= 0)
{ {
wxCHECK_MSG(HasImageList(), false, "invalid notebook imagelist"); wxCHECK_MSG(HasImageList(), false, "invalid notebook imagelist");
const wxBitmap* bitmap = GetImageList()->GetBitmapPtr(image); const wxBitmap bitmap = GetImageList()->GetBitmap(image);
if (bitmap == NULL)
return false;
if (pageData->m_image) if (pageData->m_image)
{ {
gtk_image_set_from_pixbuf( gtk_image_set_from_pixbuf(
GTK_IMAGE(pageData->m_image), bitmap->GetPixbuf()); GTK_IMAGE(pageData->m_image), bitmap.GetPixbuf());
} }
else 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_widget_show(pageData->m_image);
gtk_box_pack_start(GTK_BOX(pageData->m_box), gtk_box_pack_start(GTK_BOX(pageData->m_box),
pageData->m_image, false, false, m_padding); pageData->m_image, false, false, m_padding);
@@ -443,8 +441,8 @@ bool wxNotebook::InsertPage( size_t position,
{ {
if (HasImageList()) if (HasImageList())
{ {
const wxBitmap* bitmap = GetImageList()->GetBitmapPtr(imageId); const wxBitmap bitmap = GetImageList()->GetBitmap(imageId);
pageData->m_image = gtk_image_new_from_pixbuf(bitmap->GetPixbuf()); pageData->m_image = gtk_image_new_from_pixbuf(bitmap.GetPixbuf());
gtk_box_pack_start(GTK_BOX(pageData->m_box), gtk_box_pack_start(GTK_BOX(pageData->m_box),
pageData->m_image, false, false, m_padding); pageData->m_image, false, false, m_padding);
} }

View File

@@ -512,12 +512,12 @@ bool wxNotebook::SetPageImage( size_t page, int image )
wxASSERT( HasImageList() ); /* Just in case */ wxASSERT( HasImageList() ); /* Just in case */
/* Construct the new pixmap */ /* Construct the new pixmap */
const wxBitmap *bmp = GetImageList()->GetBitmapPtr(image); const wxBitmap bmp = GetImageList()->GetBitmap(image);
GdkPixmap *pixmap = bmp->GetPixmap(); GdkPixmap *pixmap = bmp.GetPixmap();
GdkBitmap *mask = NULL; GdkBitmap *mask = NULL;
if ( bmp->GetMask() ) if ( bmp.GetMask() )
{ {
mask = bmp->GetMask()->GetBitmap(); mask = bmp.GetMask()->GetBitmap();
} }
if (pixmapwid == NULL) if (pixmapwid == NULL)
@@ -679,12 +679,12 @@ bool wxNotebook::InsertPage( size_t position,
{ {
wxASSERT( HasImageList() ); wxASSERT( HasImageList() );
const wxBitmap *bmp = GetImageList()->GetBitmapPtr(imageId); const wxBitmap bmp = GetImageList()->GetBitmap(imageId);
GdkPixmap *pixmap = bmp->GetPixmap(); GdkPixmap *pixmap = bmp.GetPixmap();
GdkBitmap *mask = NULL; GdkBitmap *mask = NULL;
if ( bmp->GetMask() ) if ( bmp.GetMask() )
{ {
mask = bmp->GetMask()->GetBitmap(); mask = bmp.GetMask()->GetBitmap();
} }
GtkWidget *pixmapwid = gtk_pixmap_new (pixmap, mask ); GtkWidget *pixmapwid = gtk_pixmap_new (pixmap, mask );

View File

@@ -329,12 +329,9 @@ bool wxListCtrl::SetItem(wxListItem& info)
{ {
wxImageList *imglst = GetImageList(InReportView() ? wxIMAGE_LIST_SMALL : wxIMAGE_LIST_NORMAL); wxImageList *imglst = GetImageList(InReportView() ? wxIMAGE_LIST_SMALL : wxIMAGE_LIST_NORMAL);
wxCHECK_MSG(imglst, false, "invalid listctrl imagelist"); wxCHECK_MSG(imglst, false, "invalid listctrl imagelist");
const wxBitmap* bitmap = imglst->GetBitmapPtr(info.m_image); const wxBitmap bitmap = imglst->GetBitmap(info.m_image);
if (bitmap != NULL) // set the new image:
{ qitem->setIcon( info.GetColumn(), QIcon( *bitmap.GetHandle() ));
// set the new image:
qitem->setIcon( info.GetColumn(), QIcon( *bitmap->GetHandle() ));
}
} }
else else
{ {

View File

@@ -112,11 +112,9 @@ bool wxNotebook::SetPageImage(size_t n, int imageId)
if (imageId >= 0) if (imageId >= 0)
{ {
wxCHECK_MSG(HasImageList(), false, "invalid notebook imagelist"); wxCHECK_MSG(HasImageList(), false, "invalid notebook imagelist");
const wxBitmap* bitmap = GetImageList()->GetBitmapPtr(imageId); const wxBitmap bitmap = GetImageList()->GetBitmap(imageId);
if (bitmap == NULL)
return false;
// set the new image: // set the new image:
m_qtTabWidget->setTabIcon( n, QIcon( *bitmap->GetHandle() )); m_qtTabWidget->setTabIcon( n, QIcon( *bitmap.GetHandle() ));
} }
else else
{ {
@@ -137,8 +135,8 @@ bool wxNotebook::InsertPage(size_t n, wxWindow *page, const wxString& text,
{ {
if (HasImageList()) if (HasImageList())
{ {
const wxBitmap* bitmap = GetImageList()->GetBitmapPtr(imageId); const wxBitmap bitmap = GetImageList()->GetBitmap(imageId);
m_qtTabWidget->insertTab( n, page->GetHandle(), QIcon( *bitmap->GetHandle() ), wxQtConvertString( text )); m_qtTabWidget->insertTab( n, page->GetHandle(), QIcon( *bitmap.GetHandle() ), wxQtConvertString( text ));
} }
else else
{ {