From f644bc116bbe46d6ab609a44c05835dc4d87ba02 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 30 Apr 2006 10:38:32 +0000 Subject: [PATCH] Blindly added wxImageList::replace( int, bitmap, mask ) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38961 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/imaglist.h | 1 + src/generic/imaglist.cpp | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/wx/generic/imaglist.h b/include/wx/generic/imaglist.h index 2d6c45b244..b04487f70e 100644 --- a/include/wx/generic/imaglist.h +++ b/include/wx/generic/imaglist.h @@ -68,6 +68,7 @@ public: wxBitmap GetBitmap(int index) const; wxIcon GetIcon(int index) const; bool Replace( int index, const wxBitmap &bitmap ); + bool Replace( int index, const wxBitmap &bitmap, const wxBitmap& mask ); bool Remove( int index ); bool RemoveAll(); diff --git a/src/generic/imaglist.cpp b/src/generic/imaglist.cpp index 9ec73fa68e..5f342b70c4 100644 --- a/src/generic/imaglist.cpp +++ b/src/generic/imaglist.cpp @@ -169,6 +169,42 @@ bool wxGenericImageList::Replace( int index, const wxBitmap &bitmap ) return true; } +bool wxGenericImageList::Replace( int index, const wxBitmap &bitmap, const wxBitmap &mask ) +{ + wxList::compatibility_iterator node = m_images.Item( index ); + + wxCHECK_MSG( node, false, wxT("wrong index in image list") ); + + wxBitmap* newBitmap = (bitmap.IsKindOf(CLASSINFO(wxIcon))) ? + #if defined(__VISAGECPP__) + //just can't do this in VisualAge now, with all this new Bitmap-Icon stuff + //so construct it from a bitmap object until I can figure this nonsense out. (DW) + new wxBitmap(bitmap) + #else + new wxBitmap( (const wxIcon&) bitmap ) + #endif + : new wxBitmap(bitmap) ; + + if (index == (int) m_images.GetCount() - 1) + { + delete node->GetData(); + m_images.Erase( node ); + m_images.Append( newBitmap ); + } + else + { + wxList::compatibility_iterator next = node->GetNext(); + delete node->GetData(); + m_images.Erase( node ); + m_images.Insert( next, newBitmap ); + } + + if (mask.Ok()) + newBitmap->SetMask(new wxMask(mask)); + + return true; +} + bool wxGenericImageList::Remove( int index ) { wxList::compatibility_iterator node = m_images.Item( index ); -- 2.45.2