]>
git.saurik.com Git - wxWidgets.git/blob - src/generic/imaglist.cpp
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(void)
28 wxImageList::~wxImageList(void)
32 int wxImageList::GetImageCount(void) const
34 return m_images
.Number();
37 bool wxImageList::Create(void)
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( const 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( const int index
)
71 wxNode
*node
= m_images
.Nth( index
);
72 if (node
) m_images
.DeleteNode( node
);
73 return (node
!= NULL
);
76 bool wxImageList::RemoveAll(void)
82 bool wxImageList::GetSize( const 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( const int index
, wxDC
&dc
,
101 const int x
, const int y
,
102 const int WXUNUSED(flags
), const 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
);