1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "imaglist.h"
14 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
21 #include "wx/imaglist.h"
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
27 IMPLEMENT_DYNAMIC_CLASS(wxImageList
, wxObject
)
29 wxImageList::wxImageList( int width
, int height
, bool WXUNUSED(mask
), int WXUNUSED(initialCount
) )
36 wxImageList::~wxImageList()
40 int wxImageList::GetImageCount() const
42 return m_images
.Number();
45 bool wxImageList::Create()
47 m_images
.DeleteContents( TRUE
);
51 int wxImageList::Add( const wxBitmap
&bitmap
)
53 m_images
.Append( new wxBitmap(bitmap
) );
54 return m_images
.Number();
57 const wxBitmap
*wxImageList::GetBitmap( int index
) const
59 wxNode
*node
= m_images
.Nth( index
);
61 wxCHECK_MSG( node
, (wxBitmap
*) NULL
, "wrong index in image list" );
63 return (wxBitmap
*)node
->Data();
66 bool wxImageList::Replace( int index
, const wxBitmap
&bitmap
)
68 wxNode
*node
= m_images
.Nth( index
);
70 wxCHECK_MSG( node
, FALSE
, "wrong index in image list" );
72 if (index
== m_images
.Number()-1)
74 m_images
.DeleteNode( node
);
75 m_images
.Append( new wxBitmap(bitmap
) );
79 wxNode
*next
= node
->Next();
80 m_images
.DeleteNode( node
);
81 m_images
.Insert( next
, new wxBitmap(bitmap
) );
87 bool wxImageList::Remove( int index
)
89 wxNode
*node
= m_images
.Nth( index
);
91 wxCHECK_MSG( node
, FALSE
, "wrong index in image list" );
93 m_images
.DeleteNode( node
);
98 bool wxImageList::RemoveAll()
105 bool wxImageList::GetSize( int index
, int &width
, int &height
) const
110 wxNode
*node
= m_images
.Nth( index
);
112 wxCHECK_MSG( node
, FALSE
, "wrong index in image list" );
114 wxBitmap
*bm
= (wxBitmap
*)node
->Data();
115 width
= bm
->GetWidth();
116 height
= bm
->GetHeight();
121 bool wxImageList::Draw( int index
, wxDC
&dc
, int x
, int y
,
122 int flags
, bool WXUNUSED(solidBackground
) )
124 wxNode
*node
= m_images
.Nth( index
);
126 wxCHECK_MSG( node
, FALSE
, "wrong index in image list" );
128 wxBitmap
*bm
= (wxBitmap
*)node
->Data();
130 dc
.DrawBitmap( *bm
, x
, y
, (flags
& wxIMAGELIST_DRAW_TRANSPARENT
) > 0 );