- wxNode *node = m_images.Nth( index );
- if (!node) return FALSE;
-
- if (index == m_images.Number()-1)
- {
- m_images.DeleteNode( node );
- m_images.Append( new wxBitmap(bitmap) );
- }
- else
- {
- wxNode *next = node->Next();
- m_images.DeleteNode( node );
- m_images.Insert( next, new wxBitmap(bitmap) );
- };
+ wxNode *node = m_images.Nth( index );
+
+ wxCHECK_MSG( node, (wxBitmap *) NULL, _T("wrong index in image list") );
+
+ return (wxBitmap*)node->Data();
+}
+
+bool wxImageList::Replace( int index, const wxBitmap &bitmap )
+{
+ wxNode *node = m_images.Nth( index );
+
+ wxCHECK_MSG( node, FALSE, _T("wrong index in image list") );
+
+ wxBitmap* newBitmap = NULL;
+ if (bitmap.IsKindOf(CLASSINFO(wxIcon)))
+ newBitmap = new wxIcon( (const wxIcon&) bitmap );
+ else
+ newBitmap = new wxBitmap(bitmap) ;
+
+ if (index == m_images.Number()-1)
+ {
+ m_images.DeleteNode( node );
+ m_images.Append( newBitmap );
+ }
+ else
+ {
+ wxNode *next = node->Next();
+ m_images.DeleteNode( node );
+ m_images.Insert( next, newBitmap );
+ }