1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "imaglist.h"
14 #include "wx/imaglist.h"
16 //-----------------------------------------------------------------------------
18 //-----------------------------------------------------------------------------
20 IMPLEMENT_DYNAMIC_CLASS(wxImageList
, wxObject
)
22 wxImageList::wxImageList( int width
, int height
, bool WXUNUSED(mask
), int WXUNUSED(initialCount
) )
29 wxImageList::~wxImageList()
33 int wxImageList::GetImageCount() const
35 return m_images
.Number();
38 bool wxImageList::Create()
40 m_images
.DeleteContents( TRUE
);
44 int wxImageList::Add( const wxBitmap
&bitmap
)
46 m_images
.Append( new wxBitmap(bitmap
) );
47 return m_images
.Number();
50 const wxBitmap
*wxImageList::GetBitmap( int index
) const
52 wxNode
*node
= m_images
.Nth( index
);
54 wxCHECK_MSG( node
, (wxBitmap
*) NULL
, "wrong index in image list" );
56 return (wxBitmap
*)node
->Data();
59 bool wxImageList::Replace( int index
, const wxBitmap
&bitmap
)
61 wxNode
*node
= m_images
.Nth( index
);
63 wxCHECK_MSG( node
, FALSE
, "wrong index in image list" );
65 if (index
== m_images
.Number()-1)
67 m_images
.DeleteNode( node
);
68 m_images
.Append( new wxBitmap(bitmap
) );
72 wxNode
*next
= node
->Next();
73 m_images
.DeleteNode( node
);
74 m_images
.Insert( next
, new wxBitmap(bitmap
) );
80 bool wxImageList::Remove( int index
)
82 wxNode
*node
= m_images
.Nth( index
);
84 wxCHECK_MSG( node
, FALSE
, "wrong index in image list" );
86 m_images
.DeleteNode( node
);
91 bool wxImageList::RemoveAll()
98 bool wxImageList::GetSize( int index
, int &width
, int &height
) const
103 wxNode
*node
= m_images
.Nth( index
);
105 wxCHECK_MSG( node
, FALSE
, "wrong index in image list" );
107 wxBitmap
*bm
= (wxBitmap
*)node
->Data();
108 width
= bm
->GetWidth();
109 height
= bm
->GetHeight();
114 bool wxImageList::Draw( int index
, wxDC
&dc
, int x
, int y
,
115 int flags
, bool WXUNUSED(solidBackground
) )
117 wxNode
*node
= m_images
.Nth( index
);
119 wxCHECK_MSG( node
, FALSE
, "wrong index in image list" );
121 wxBitmap
*bm
= (wxBitmap
*)node
->Data();
123 dc
.DrawBitmap( *bm
, x
, y
, (flags
& wxIMAGELIST_DRAW_TRANSPARENT
) > 0 );