@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).}
@endTable
Example:
wxXmlNode * const oldnode = m_node;
m_node = imagelist_node;
- // size
+ // Get the size if we have it, otherwise we will use the size of the first
+ // list element.
wxSize size = GetSize();
- 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) )
{
{
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
- imagelist->Add(GetIcon(n));
+ imagelist->Add(icon);
}
n = n->GetNext();
}