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 WXUNUSED(mask
), int WXUNUSED(initialCount
) )
30 wxImageList::~wxImageList()
34 int wxImageList::GetImageCount() const
36 return m_images
.Number();
39 bool wxImageList::Create()
41 m_images
.DeleteContents( TRUE
);
45 int wxImageList::Add( const wxBitmap
&bitmap
)
47 m_images
.Append( new wxBitmap(bitmap
) );
48 return m_images
.Number();
51 bool wxImageList::Replace( int index
, const wxBitmap
&bitmap
)
53 wxNode
*node
= m_images
.Nth( index
);
54 if (!node
) return FALSE
;
56 if (index
== m_images
.Number()-1)
58 m_images
.DeleteNode( node
);
59 m_images
.Append( new wxBitmap(bitmap
) );
63 wxNode
*next
= node
->Next();
64 m_images
.DeleteNode( node
);
65 m_images
.Insert( next
, new wxBitmap(bitmap
) );
71 bool wxImageList::Remove( int index
)
73 wxNode
*node
= m_images
.Nth( index
);
74 if (node
) m_images
.DeleteNode( node
);
75 return (node
!= NULL
);
78 bool wxImageList::RemoveAll()
84 bool wxImageList::GetSize( int index
, int &width
, int &height
) const
91 return (m_images
.Nth( index
) != NULL
);
95 wxNode
*node
= m_images
.Nth( index
);
98 wxBitmap
*bm
= (wxBitmap
*)node
->Data();
99 width
= bm
->GetWidth();
100 height
= bm
->GetHeight();
113 bool wxImageList::Draw( int index
, wxDC
&dc
, int x
, int y
,
114 int flags
, bool WXUNUSED(solidBackground
) )
116 wxNode
*node
= m_images
.Nth( index
);
117 if (!node
) return FALSE
;
118 wxBitmap
*bm
= (wxBitmap
*)node
->Data();
122 // As X doesn't have a standard size for icons, we resize here.
123 // Otherwise we'd simply have to forbid different bitmap sizes.
125 if ((m_width
!= bm
->GetWidth()) ||
126 (m_height
!= bm
->GetHeight()))
128 bm
->Resize( m_width
, m_height
);
133 wxIcon
*icon
= (wxIcon
*)bm
;
134 dc
.DrawIcon( *icon
, x
, y
, (flags
& wxIMAGELIST_DRAW_TRANSPARENT
) > 0 );