1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "imaglist.h"
15 #include "wx/imaglist.h"
17 //-----------------------------------------------------------------------------
19 //-----------------------------------------------------------------------------
21 IMPLEMENT_DYNAMIC_CLASS(wxImageList
, wxObject
)
23 wxImageList
::wxImageList(int width
, int height
, bool mask
, int initialCount
)
28 wxImageList
::~wxImageList()
32 int wxImageList
::GetImageCount() const
34 return m_images
.Number();
37 bool wxImageList
::Create()
39 m_images
.DeleteContents( TRUE
);
43 int wxImageList
::Add( const wxBitmap
&bitmap
)
45 m_images
.Append( new wxBitmap(bitmap
) );
46 return m_images
.Number();
49 bool wxImageList
::Replace( int index
, const wxBitmap
&bitmap
)
51 wxNode
*node
= m_images
.Nth( index
);
52 if (!node
) return FALSE
;
54 if (index
== m_images
.Number()-1)
56 m_images
.DeleteNode( node
);
57 m_images
.Append( new wxBitmap(bitmap
) );
61 wxNode
*next
= node
->Next();
62 m_images
.DeleteNode( node
);
63 m_images
.Insert( next
, new wxBitmap(bitmap
) );
69 bool wxImageList
::Remove( int index
)
71 wxNode
*node
= m_images
.Nth( index
);
72 if (node
) m_images
.DeleteNode( node
);
73 return (node
!= NULL
);
76 bool wxImageList
::RemoveAll()
82 bool wxImageList
::GetSize( int index
, int &width
, int &height
) const
84 wxNode
*node
= m_images
.Nth( index
);
87 wxBitmap
*bm
= (wxBitmap
*)node
->Data();
88 width
= bm
->GetWidth();
89 height
= bm
->GetHeight();
100 bool wxImageList
::Draw( int index
, wxDC
&dc
,
102 int WXUNUSED(flags
), bool WXUNUSED(solidBackground
) )
104 wxNode
*node
= m_images
.Nth( index
);
105 if (!node
) return FALSE
;
106 wxBitmap
*bm
= (wxBitmap
*)node
->Data();
107 wxIcon
*icon
= (wxIcon
*)bm
;
108 dc
.DrawIcon( *icon
, x
, y
);