]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: imaglist.cpp | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
01111366 RR |
5 | // Id: $id$ |
6 | // Copyright: (c) 1998 Robert Roebling | |
c801d85f KB |
7 | // Licence: wxWindows licence |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #ifdef __GNUG__ | |
11 | #pragma implementation "imaglist.h" | |
12 | #endif | |
13 | ||
14 | #include "wx/imaglist.h" | |
15 | ||
16 | //----------------------------------------------------------------------------- | |
17 | // wxImageList | |
18 | //----------------------------------------------------------------------------- | |
19 | ||
20 | IMPLEMENT_DYNAMIC_CLASS(wxImageList, wxObject) | |
21 | ||
219f895a | 22 | wxImageList::wxImageList( int width, int height, bool WXUNUSED(mask), int WXUNUSED(initialCount) ) |
c801d85f | 23 | { |
b46e8696 RR |
24 | m_width = width; |
25 | m_height = height; | |
26 | Create(); | |
e1e955e1 | 27 | } |
c801d85f | 28 | |
0423b685 | 29 | wxImageList::~wxImageList() |
c801d85f | 30 | { |
e1e955e1 | 31 | } |
c801d85f | 32 | |
0423b685 | 33 | int wxImageList::GetImageCount() const |
c801d85f | 34 | { |
b46e8696 | 35 | return m_images.Number(); |
e1e955e1 | 36 | } |
c801d85f | 37 | |
0423b685 | 38 | bool wxImageList::Create() |
c801d85f | 39 | { |
b46e8696 RR |
40 | m_images.DeleteContents( TRUE ); |
41 | return TRUE; | |
e1e955e1 | 42 | } |
c801d85f KB |
43 | |
44 | int wxImageList::Add( const wxBitmap &bitmap ) | |
45 | { | |
b46e8696 RR |
46 | m_images.Append( new wxBitmap(bitmap) ); |
47 | return m_images.Number(); | |
e1e955e1 | 48 | } |
c801d85f | 49 | |
b46e8696 RR |
50 | const wxBitmap *wxImageList::GetBitmap( int index ) const |
51 | { | |
52 | wxNode *node = m_images.Nth( index ); | |
53 | ||
54 | wxCHECK_MSG( node, (wxBitmap *) NULL, "wrong index in image list" ); | |
55 | ||
8b21b87f | 56 | return (wxBitmap*)node->Data(); |
40413a5b DP |
57 | } |
58 | ||
0423b685 | 59 | bool wxImageList::Replace( int index, const wxBitmap &bitmap ) |
c801d85f | 60 | { |
b46e8696 RR |
61 | wxNode *node = m_images.Nth( index ); |
62 | ||
63 | wxCHECK_MSG( node, FALSE, "wrong index in image list" ); | |
c801d85f | 64 | |
b46e8696 RR |
65 | if (index == m_images.Number()-1) |
66 | { | |
67 | m_images.DeleteNode( node ); | |
68 | m_images.Append( new wxBitmap(bitmap) ); | |
69 | } | |
70 | else | |
71 | { | |
72 | wxNode *next = node->Next(); | |
73 | m_images.DeleteNode( node ); | |
74 | m_images.Insert( next, new wxBitmap(bitmap) ); | |
75 | } | |
c801d85f | 76 | |
b46e8696 | 77 | return TRUE; |
e1e955e1 | 78 | } |
c801d85f | 79 | |
0423b685 | 80 | bool wxImageList::Remove( int index ) |
c801d85f | 81 | { |
b46e8696 RR |
82 | wxNode *node = m_images.Nth( index ); |
83 | ||
84 | wxCHECK_MSG( node, FALSE, "wrong index in image list" ); | |
85 | ||
86 | m_images.DeleteNode( node ); | |
87 | ||
88 | return TRUE; | |
e1e955e1 | 89 | } |
c801d85f | 90 | |
0423b685 | 91 | bool wxImageList::RemoveAll() |
c801d85f | 92 | { |
b46e8696 RR |
93 | m_images.Clear(); |
94 | ||
95 | return TRUE; | |
e1e955e1 | 96 | } |
c801d85f | 97 | |
0423b685 | 98 | bool wxImageList::GetSize( int index, int &width, int &height ) const |
c801d85f | 99 | { |
b46e8696 RR |
100 | width = 0; |
101 | height = 0; | |
102 | ||
103 | wxNode *node = m_images.Nth( index ); | |
104 | ||
105 | wxCHECK_MSG( node, FALSE, "wrong index in image list" ); | |
106 | ||
c801d85f KB |
107 | wxBitmap *bm = (wxBitmap*)node->Data(); |
108 | width = bm->GetWidth(); | |
109 | height = bm->GetHeight(); | |
b46e8696 | 110 | |
c801d85f | 111 | return TRUE; |
e1e955e1 | 112 | } |
c801d85f | 113 | |
219f895a RR |
114 | bool wxImageList::Draw( int index, wxDC &dc, int x, int y, |
115 | int flags, bool WXUNUSED(solidBackground) ) | |
c801d85f | 116 | { |
b46e8696 RR |
117 | wxNode *node = m_images.Nth( index ); |
118 | ||
119 | wxCHECK_MSG( node, FALSE, "wrong index in image list" ); | |
120 | ||
121 | wxBitmap *bm = (wxBitmap*)node->Data(); | |
219f895a | 122 | |
b46e8696 | 123 | dc.DrawBitmap( *bm, x, y, (flags & wxIMAGELIST_DRAW_TRANSPARENT) > 0 ); |
219f895a | 124 | |
b46e8696 | 125 | return TRUE; |
e1e955e1 | 126 | } |
c801d85f KB |
127 | |
128 |