]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
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 | ||
0423b685 | 23 | wxImageList::wxImageList(int width, int height, bool mask, int initialCount) |
c801d85f KB |
24 | { |
25 | Create(); | |
26 | }; | |
27 | ||
0423b685 | 28 | wxImageList::~wxImageList() |
c801d85f KB |
29 | { |
30 | }; | |
31 | ||
0423b685 | 32 | int wxImageList::GetImageCount() const |
c801d85f KB |
33 | { |
34 | return m_images.Number(); | |
35 | }; | |
36 | ||
0423b685 | 37 | bool wxImageList::Create() |
c801d85f KB |
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 | ||
0423b685 | 49 | bool wxImageList::Replace( int index, const wxBitmap &bitmap ) |
c801d85f KB |
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 | ||
0423b685 | 69 | bool wxImageList::Remove( int index ) |
c801d85f KB |
70 | { |
71 | wxNode *node = m_images.Nth( index ); | |
72 | if (node) m_images.DeleteNode( node ); | |
73 | return (node != NULL); | |
74 | }; | |
75 | ||
0423b685 | 76 | bool wxImageList::RemoveAll() |
c801d85f KB |
77 | { |
78 | m_images.Clear(); | |
79 | return TRUE; | |
80 | }; | |
81 | ||
0423b685 | 82 | bool wxImageList::GetSize( int index, int &width, int &height ) const |
c801d85f KB |
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 | ||
0423b685 VZ |
100 | bool wxImageList::Draw( int index, wxDC &dc, |
101 | int x, int y, | |
debe6624 | 102 | int WXUNUSED(flags), bool WXUNUSED(solidBackground) ) |
c801d85f KB |
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 |