]> git.saurik.com Git - wxWidgets.git/blob - src/generic/imaglist.cpp
*** empty log message ***
[wxWidgets.git] / src / generic / imaglist.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: imaglist.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Created: 01/02/97
6 // Id:
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifdef __GNUG__
12 #pragma implementation "imaglist.h"
13 #endif
14
15 #include "wx/imaglist.h"
16
17 //-----------------------------------------------------------------------------
18 // wxImageList
19 //-----------------------------------------------------------------------------
20
21 IMPLEMENT_DYNAMIC_CLASS(wxImageList, wxObject)
22
23 wxImageList::wxImageList(void)
24 {
25 Create();
26 };
27
28 wxImageList::~wxImageList(void)
29 {
30 };
31
32 int wxImageList::GetImageCount(void) const
33 {
34 return m_images.Number();
35 };
36
37 bool wxImageList::Create(void)
38 {
39 m_images.DeleteContents( TRUE );
40 return TRUE;
41 };
42
43 int wxImageList::Add( const wxBitmap &bitmap )
44 {
45 m_images.Append( new wxBitmap(bitmap) );
46 return m_images.Number();
47 };
48
49 bool wxImageList::Replace( const int index, const wxBitmap &bitmap )
50 {
51 wxNode *node = m_images.Nth( index );
52 if (!node) return FALSE;
53
54 if (index == m_images.Number()-1)
55 {
56 m_images.DeleteNode( node );
57 m_images.Append( new wxBitmap(bitmap) );
58 }
59 else
60 {
61 wxNode *next = node->Next();
62 m_images.DeleteNode( node );
63 m_images.Insert( next, new wxBitmap(bitmap) );
64 };
65
66 return TRUE;
67 };
68
69 bool wxImageList::Remove( const int index )
70 {
71 wxNode *node = m_images.Nth( index );
72 if (node) m_images.DeleteNode( node );
73 return (node != NULL);
74 };
75
76 bool wxImageList::RemoveAll(void)
77 {
78 m_images.Clear();
79 return TRUE;
80 };
81
82 bool wxImageList::GetSize( const int index, int &width, int &height ) const
83 {
84 wxNode *node = m_images.Nth( index );
85 if (node)
86 {
87 wxBitmap *bm = (wxBitmap*)node->Data();
88 width = bm->GetWidth();
89 height = bm->GetHeight();
90 return TRUE;
91 }
92 else
93 {
94 width = 0;
95 height = 0;
96 return FALSE;
97 };
98 };
99
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) )
103 {
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 );
109 return TRUE;
110 };
111
112