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 {
51 wxNode
*node
= m_images
.Nth(index
);
53 return (wxBitmap
*)node
->Data();
55 return (wxBitmap
*) NULL
;
58 bool wxImageList::Replace( int index
, const wxBitmap
&bitmap
)
60 wxNode
*node
= m_images
.Nth( index
);
61 if (!node
) return FALSE
;
63 if (index
== m_images
.Number()-1)
65 m_images
.DeleteNode( node
);
66 m_images
.Append( new wxBitmap(bitmap
) );
70 wxNode
*next
= node
->Next();
71 m_images
.DeleteNode( node
);
72 m_images
.Insert( next
, new wxBitmap(bitmap
) );
78 bool wxImageList::Remove( int index
)
80 wxNode
*node
= m_images
.Nth( index
);
81 if (node
) m_images
.DeleteNode( node
);
82 return (node
!= NULL
);
85 bool wxImageList::RemoveAll()
91 bool wxImageList::GetSize( int index
, int &width
, int &height
) const
93 wxNode
*node
= m_images
.Nth( index
);
96 wxBitmap
*bm
= (wxBitmap
*)node
->Data();
97 width
= bm
->GetWidth();
98 height
= bm
->GetHeight();
109 bool wxImageList::Draw( int index
, wxDC
&dc
, int x
, int y
,
110 int flags
, bool WXUNUSED(solidBackground
) )
112 wxNode
*node
= m_images
.Nth( index
);
113 if (!node
) return FALSE
;
114 wxBitmap
*bm
= (wxBitmap
*)node
->Data();
116 wxIcon
*icon
= (wxIcon
*)bm
;
117 dc
.DrawIcon( *icon
, x
, y
, (flags
& wxIMAGELIST_DRAW_TRANSPARENT
) > 0 );