1
///////////////////////////////////////////////////////////////////////////////
2
// Name: wx/withimages.h
3
// Purpose: Declaration of a simple wxWithImages class.
4
// Author: Vadim Zeitlin
6
// RCS-ID: $Id: withimages.h 68813 2011-08-21 14:52:16Z VZ $
7
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8
// Licence: wxWindows licence
9
///////////////////////////////////////////////////////////////////////////////
11
#ifndef _WX_WITHIMAGES_H_
12
#define _WX_WITHIMAGES_H_
16
#include "wx/imaglist.h"
18
// ----------------------------------------------------------------------------
19
// wxWithImages: mix-in class providing access to wxImageList.
20
// ----------------------------------------------------------------------------
22
class WXDLLIMPEXP_CORE wxWithImages
33
m_ownsImageList = false;
36
virtual ~wxWithImages()
41
// Sets the image list to use, it is *not* deleted by the control.
42
virtual void SetImageList(wxImageList* imageList)
45
m_imageList = imageList;
48
// As SetImageList() but we will delete the image list ourselves.
49
void AssignImageList(wxImageList* imageList)
51
SetImageList(imageList);
52
m_ownsImageList = true;
55
// Get pointer (may be NULL) to the associated image list.
56
wxImageList* GetImageList() const { return m_imageList; }
59
// Return true if we have a valid image list.
60
bool HasImageList() const { return m_imageList != NULL; }
62
// Return the image with the given index from the image list.
64
// If there is no image list or if index == NO_IMAGE, silently returns
66
wxIcon GetImage(int iconIndex) const
68
return m_imageList && iconIndex != NO_IMAGE
69
? m_imageList->GetIcon(iconIndex)
74
// Free the image list if necessary, i.e. if we own it.
77
if ( m_ownsImageList )
82
// We don't own it any more.
83
m_ownsImageList = false;
88
// The associated image list or NULL.
89
wxImageList* m_imageList;
91
// False by default, if true then we delete m_imageList.
94
wxDECLARE_NO_COPY_CLASS(wxWithImages);
97
#endif // _WX_WITHIMAGES_H_