]>
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 | { |
219f895a RR |
24 | m_width = width; |
25 | m_height = height; | |
c801d85f | 26 | Create(); |
e1e955e1 | 27 | } |
c801d85f | 28 | |
0423b685 | 29 | wxImageList::~wxImageList() |
c801d85f | 30 | { |
e1e955e1 | 31 | } |
c801d85f | 32 | |
0423b685 | 33 | int wxImageList::GetImageCount() const |
c801d85f KB |
34 | { |
35 | return m_images.Number(); | |
e1e955e1 | 36 | } |
c801d85f | 37 | |
0423b685 | 38 | bool wxImageList::Create() |
c801d85f KB |
39 | { |
40 | m_images.DeleteContents( TRUE ); | |
41 | return TRUE; | |
e1e955e1 | 42 | } |
c801d85f KB |
43 | |
44 | int wxImageList::Add( const wxBitmap &bitmap ) | |
45 | { | |
46 | m_images.Append( new wxBitmap(bitmap) ); | |
47 | return m_images.Number(); | |
e1e955e1 | 48 | } |
c801d85f | 49 | |
d069d02e | 50 | const wxBitmap *wxImageList::GetBitmap(int index) const { |
8b21b87f DP |
51 | wxNode *node = m_images.Nth(index); |
52 | if (node != NULL) | |
53 | return (wxBitmap*)node->Data(); | |
54 | ||
c67daf87 | 55 | return (wxBitmap *) NULL; |
40413a5b DP |
56 | } |
57 | ||
0423b685 | 58 | bool wxImageList::Replace( int index, const wxBitmap &bitmap ) |
c801d85f KB |
59 | { |
60 | wxNode *node = m_images.Nth( index ); | |
61 | if (!node) return FALSE; | |
62 | ||
63 | if (index == m_images.Number()-1) | |
64 | { | |
65 | m_images.DeleteNode( node ); | |
66 | m_images.Append( new wxBitmap(bitmap) ); | |
67 | } | |
68 | else | |
69 | { | |
70 | wxNode *next = node->Next(); | |
71 | m_images.DeleteNode( node ); | |
72 | m_images.Insert( next, new wxBitmap(bitmap) ); | |
e1e955e1 | 73 | } |
c801d85f KB |
74 | |
75 | return TRUE; | |
e1e955e1 | 76 | } |
c801d85f | 77 | |
0423b685 | 78 | bool wxImageList::Remove( int index ) |
c801d85f KB |
79 | { |
80 | wxNode *node = m_images.Nth( index ); | |
81 | if (node) m_images.DeleteNode( node ); | |
82 | return (node != NULL); | |
e1e955e1 | 83 | } |
c801d85f | 84 | |
0423b685 | 85 | bool wxImageList::RemoveAll() |
c801d85f KB |
86 | { |
87 | m_images.Clear(); | |
88 | return TRUE; | |
e1e955e1 | 89 | } |
c801d85f | 90 | |
0423b685 | 91 | bool wxImageList::GetSize( int index, int &width, int &height ) const |
c801d85f KB |
92 | { |
93 | wxNode *node = m_images.Nth( index ); | |
94 | if (node) | |
95 | { | |
96 | wxBitmap *bm = (wxBitmap*)node->Data(); | |
97 | width = bm->GetWidth(); | |
98 | height = bm->GetHeight(); | |
99 | return TRUE; | |
100 | } | |
101 | else | |
102 | { | |
103 | width = 0; | |
104 | height = 0; | |
105 | return FALSE; | |
e1e955e1 | 106 | } |
e1e955e1 | 107 | } |
c801d85f | 108 | |
219f895a RR |
109 | bool wxImageList::Draw( int index, wxDC &dc, int x, int y, |
110 | int flags, bool WXUNUSED(solidBackground) ) | |
c801d85f KB |
111 | { |
112 | wxNode *node = m_images.Nth( index ); | |
113 | if (!node) return FALSE; | |
114 | wxBitmap *bm = (wxBitmap*)node->Data(); | |
219f895a | 115 | |
c801d85f | 116 | wxIcon *icon = (wxIcon*)bm; |
219f895a RR |
117 | dc.DrawIcon( *icon, x, y, (flags & wxIMAGELIST_DRAW_TRANSPARENT) > 0 ); |
118 | ||
c801d85f | 119 | return TRUE; |
e1e955e1 | 120 | } |
c801d85f KB |
121 | |
122 |