]> git.saurik.com Git - wxWidgets.git/commitdiff
Blindly added wxImageList::replace( int, bitmap, mask )
authorRobert Roebling <robert@roebling.de>
Sun, 30 Apr 2006 10:38:32 +0000 (10:38 +0000)
committerRobert Roebling <robert@roebling.de>
Sun, 30 Apr 2006 10:38:32 +0000 (10:38 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38961 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/generic/imaglist.h
src/generic/imaglist.cpp

index 2d6c45b244694299371a7aea9c37e453959f69f3..b04487f70e882a45a8dddbd3291d232f0054feb6 100644 (file)
@@ -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();
 
index 9ec73fa68e0a9785ac1dc27822523b4be44630a0..5f342b70c4dae45be4cd54c3068ff005957a1cb5 100644 (file)
@@ -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 );