Always store wxBitmap objects in wxGenericImageList

There doesn't seem to be any point in storing pointers to wxBitmap or
wxIcon and storing the objects directly allows to avoid an extra heap
allocation and all the code dealing with freeing memory when replacing
or removing images from the list, making things much simpler.

Also use wxVector<> for storage instead of the obsolete and ugly
wxObjectList.

There shouldn't be any user-visible changes.
This commit is contained in:
Vadim Zeitlin
2018-10-30 23:35:10 +01:00
parent 3b5441f59e
commit 83a7b49954
2 changed files with 42 additions and 107 deletions

View File

@@ -10,10 +10,11 @@
#ifndef _WX_IMAGLISTG_H_
#define _WX_IMAGLISTG_H_
#include "wx/bitmap.h"
#include "wx/gdicmn.h"
#include "wx/vector.h"
class WXDLLIMPEXP_FWD_CORE wxDC;
class WXDLLIMPEXP_FWD_CORE wxBitmap;
class WXDLLIMPEXP_FWD_CORE wxIcon;
class WXDLLIMPEXP_FWD_CORE wxColour;
@@ -35,8 +36,9 @@ public:
int Add( const wxBitmap& bitmap, const wxColour& maskColour );
wxBitmap GetBitmap(int index) const;
wxIcon GetIcon(int index) const;
bool Replace( int index, const wxBitmap &bitmap );
bool Replace( int index, const wxBitmap &bitmap, const wxBitmap& mask );
bool Replace( int index,
const wxBitmap& bitmap,
const wxBitmap& mask = wxNullBitmap );
bool Remove( int index );
bool RemoveAll();
@@ -55,7 +57,7 @@ public:
private:
const wxBitmap *DoGetPtr(int index) const;
wxObjectList m_images;
wxVector<wxBitmap> m_images;
// Size of a single bitmap in the list.
wxSize m_size;