]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/generic/imaglist.cpp
missing functions implemented in wxMSW tree ctrl (custom sorting,
[wxWidgets.git] / src / generic / imaglist.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: imaglist.cpp
3// Purpose:
4// Author: Robert Roebling
5// Id: $id$
6// Copyright: (c) 1998 Robert Roebling
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
20IMPLEMENT_DYNAMIC_CLASS(wxImageList, wxObject)
21
22wxImageList::wxImageList( int width, int height, bool WXUNUSED(mask), int WXUNUSED(initialCount) )
23{
24 m_width = width;
25 m_height = height;
26 Create();
27}
28
29wxImageList::~wxImageList()
30{
31}
32
33int wxImageList::GetImageCount() const
34{
35 return m_images.Number();
36}
37
38bool wxImageList::Create()
39{
40 m_images.DeleteContents( TRUE );
41 return TRUE;
42}
43
44int wxImageList::Add( const wxBitmap &bitmap )
45{
46 m_images.Append( new wxBitmap(bitmap) );
47 return m_images.Number();
48}
49
50const 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
56 return (wxBitmap*)node->Data();
57}
58
59bool wxImageList::Replace( int index, const wxBitmap &bitmap )
60{
61 wxNode *node = m_images.Nth( index );
62
63 wxCHECK_MSG( node, FALSE, "wrong index in image list" );
64
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 }
76
77 return TRUE;
78}
79
80bool wxImageList::Remove( int index )
81{
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;
89}
90
91bool wxImageList::RemoveAll()
92{
93 m_images.Clear();
94
95 return TRUE;
96}
97
98bool wxImageList::GetSize( int index, int &width, int &height ) const
99{
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
107 wxBitmap *bm = (wxBitmap*)node->Data();
108 width = bm->GetWidth();
109 height = bm->GetHeight();
110
111 return TRUE;
112}
113
114bool wxImageList::Draw( int index, wxDC &dc, int x, int y,
115 int flags, bool WXUNUSED(solidBackground) )
116{
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();
122
123 dc.DrawBitmap( *bm, x, y, (flags & wxIMAGELIST_DRAW_TRANSPARENT) > 0 );
124
125 return TRUE;
126}
127
128