Let the image list deduce its size from the first bitmap in it. This is better
than the old behaviour of using the standard icon size as it allows to omit
the size from the image lists provided they contain the bitmaps of the same
size.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65884
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
@row3col{mask, @ref overview_xrcformat_type_bool,
If masks should be created for all images (default: true).}
@row3col{size, @ref overview_xrcformat_type_size,
@row3col{mask, @ref overview_xrcformat_type_bool,
If masks should be created for all images (default: true).}
@row3col{size, @ref overview_xrcformat_type_size,
- The size of the images in the list (default: system default icon size)).}
+ The size of the images in the list (default: the size of the first bitmap).}
wxXmlNode * const oldnode = m_node;
m_node = imagelist_node;
wxXmlNode * const oldnode = m_node;
m_node = imagelist_node;
+ // Get the size if we have it, otherwise we will use the size of the first
+ // list element.
- size.SetDefaults(wxSize(wxSystemSettings::GetMetric(wxSYS_ICON_X),
- wxSystemSettings::GetMetric(wxSYS_ICON_Y)));
-
- // mask: true by default
- bool mask = HasParam(wxT("mask")) ? GetBool(wxT("mask"), true) : true;
- // now we have everything we need to create the image list
- wxImageList *imagelist = new wxImageList(size.x, size.y, mask);
-
- // add images
+ // Start adding images, we'll create the image list when adding the first
+ // one.
+ wxImageList * imagelist = NULL;
wxString parambitmap = wxT("bitmap");
if ( HasParam(parambitmap) )
{
wxString parambitmap = wxT("bitmap");
if ( HasParam(parambitmap) )
{
{
if (n->GetType() == wxXML_ELEMENT_NODE && n->GetName() == parambitmap)
{
{
if (n->GetType() == wxXML_ELEMENT_NODE && n->GetName() == parambitmap)
{
+ wxIcon icon = GetIcon(n);
+ if ( !imagelist )
+ {
+ // We need the real image list size to create it.
+ if ( size == wxDefaultSize )
+ size = icon.GetSize();
+
+ // We use the mask by default.
+ bool mask = !HasParam(wxS("mask")) || GetBool(wxS("mask"));
+
+ imagelist = new wxImageList(size.x, size.y, mask);
+ }
+
// add icon instead of bitmap to keep the bitmap mask
// add icon instead of bitmap to keep the bitmap mask
- imagelist->Add(GetIcon(n));