Merge branch 'imaglist-destroy'
Add wxImageList::Destroy() and other minor improvements to this class. See https://github.com/wxWidgets/wxWidgets/pull/2551
This commit is contained in:
@@ -22,10 +22,11 @@ class WXDLLIMPEXP_FWD_CORE wxColour;
|
|||||||
class WXDLLIMPEXP_CORE wxGenericImageList: public wxObject
|
class WXDLLIMPEXP_CORE wxGenericImageList: public wxObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxGenericImageList() { }
|
wxGenericImageList();
|
||||||
wxGenericImageList( int width, int height, bool mask = true, int initialCount = 1 );
|
wxGenericImageList( int width, int height, bool mask = true, int initialCount = 1 );
|
||||||
virtual ~wxGenericImageList();
|
virtual ~wxGenericImageList();
|
||||||
bool Create( int width, int height, bool mask = true, int initialCount = 1 );
|
bool Create( int width, int height, bool mask = true, int initialCount = 1 );
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
virtual int GetImageCount() const;
|
virtual int GetImageCount() const;
|
||||||
virtual bool GetSize( int index, int &width, int &height ) const;
|
virtual bool GetSize( int index, int &width, int &height ) const;
|
||||||
|
@@ -32,6 +32,7 @@ public:
|
|||||||
// from icons), and the initial size of the list.
|
// from icons), and the initial size of the list.
|
||||||
wxImageList(int width, int height, bool mask = true, int initialCount = 1)
|
wxImageList(int width, int height, bool mask = true, int initialCount = 1)
|
||||||
{
|
{
|
||||||
|
m_hImageList = 0;
|
||||||
Create(width, height, mask, initialCount);
|
Create(width, height, mask, initialCount);
|
||||||
}
|
}
|
||||||
virtual ~wxImageList();
|
virtual ~wxImageList();
|
||||||
@@ -58,6 +59,9 @@ public:
|
|||||||
// initialNumber is the initial number of images to reserve.
|
// initialNumber is the initial number of images to reserve.
|
||||||
bool Create(int width, int height, bool mask = true, int initialNumber = 1);
|
bool Create(int width, int height, bool mask = true, int initialNumber = 1);
|
||||||
|
|
||||||
|
// Destroys the image list, Create() may then be called again later.
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
// Adds a bitmap, and optionally a mask bitmap.
|
// Adds a bitmap, and optionally a mask bitmap.
|
||||||
// Note that wxImageList creates *new* bitmaps, so you may delete
|
// Note that wxImageList creates *new* bitmaps, so you may delete
|
||||||
// 'bitmap' and 'mask' after calling Add.
|
// 'bitmap' and 'mask' after calling Add.
|
||||||
|
@@ -124,11 +124,29 @@ public:
|
|||||||
int Add(const wxIcon& icon);
|
int Add(const wxIcon& icon);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initializes the list. See wxImageList() for details.
|
Initializes the list.
|
||||||
|
|
||||||
|
See wxImageList() for details.
|
||||||
|
|
||||||
|
This function can be called only once after creating the object using
|
||||||
|
its default ctor or after calling Destroy().
|
||||||
*/
|
*/
|
||||||
bool Create(int width, int height, bool mask = true,
|
bool Create(int width, int height, bool mask = true,
|
||||||
int initialCount = 1);
|
int initialCount = 1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destroys the current list.
|
||||||
|
|
||||||
|
This function resets the object to its initial state and does more than
|
||||||
|
just RemoveAll() in the native wxMSW version.
|
||||||
|
|
||||||
|
After calling it, Create() may be called again to recreate the image
|
||||||
|
list, e.g. using a different size.
|
||||||
|
|
||||||
|
@since 3.1.6
|
||||||
|
*/
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Draws a specified image onto a device context.
|
Draws a specified image onto a device context.
|
||||||
|
|
||||||
|
@@ -29,14 +29,26 @@
|
|||||||
wxIMPLEMENT_DYNAMIC_CLASS(wxGenericImageList, wxObject);
|
wxIMPLEMENT_DYNAMIC_CLASS(wxGenericImageList, wxObject);
|
||||||
wxIMPLEMENT_DYNAMIC_CLASS(wxImageList, wxGenericImageList);
|
wxIMPLEMENT_DYNAMIC_CLASS(wxImageList, wxGenericImageList);
|
||||||
|
|
||||||
|
wxGenericImageList::wxGenericImageList()
|
||||||
|
{
|
||||||
|
Create(0, 0, false);
|
||||||
|
}
|
||||||
|
|
||||||
wxGenericImageList::wxGenericImageList( int width, int height, bool mask, int initialCount )
|
wxGenericImageList::wxGenericImageList( int width, int height, bool mask, int initialCount )
|
||||||
{
|
{
|
||||||
(void)Create(width, height, mask, initialCount);
|
(void)Create(width, height, mask, initialCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGenericImageList::~wxGenericImageList()
|
void wxGenericImageList::Destroy()
|
||||||
{
|
{
|
||||||
(void)RemoveAll();
|
(void)RemoveAll();
|
||||||
|
|
||||||
|
// Make it invalid.
|
||||||
|
m_size = wxSize(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxGenericImageList::~wxGenericImageList()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxGenericImageList::GetImageCount() const
|
int wxGenericImageList::GetImageCount() const
|
||||||
|
@@ -73,6 +73,8 @@ wxImageList::wxImageList()
|
|||||||
// Creates an image list
|
// Creates an image list
|
||||||
bool wxImageList::Create(int width, int height, bool mask, int initial)
|
bool wxImageList::Create(int width, int height, bool mask, int initial)
|
||||||
{
|
{
|
||||||
|
wxASSERT_MSG( m_hImageList == NULL, "Recreating existing wxImageList?" );
|
||||||
|
|
||||||
// Prevent from storing negative dimensions
|
// Prevent from storing negative dimensions
|
||||||
m_size = wxSize(wxMax(width, 0), wxMax(height, 0));
|
m_size = wxSize(wxMax(width, 0), wxMax(height, 0));
|
||||||
UINT flags = 0;
|
UINT flags = 0;
|
||||||
@@ -100,7 +102,7 @@ bool wxImageList::Create(int width, int height, bool mask, int initial)
|
|||||||
return m_hImageList != 0;
|
return m_hImageList != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxImageList::~wxImageList()
|
void wxImageList::Destroy()
|
||||||
{
|
{
|
||||||
if ( m_hImageList )
|
if ( m_hImageList )
|
||||||
{
|
{
|
||||||
@@ -109,6 +111,11 @@ wxImageList::~wxImageList()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxImageList::~wxImageList()
|
||||||
|
{
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxImageList attributes
|
// wxImageList attributes
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user