+ }
+#endif // __WXMAC__
+
+ DoAddIcon
+ (
+ *this,
+ file, type,
+ wxString::Format(_("Failed to load image %%d from file '%s'."), file)
+ );
+}
+
+#if wxUSE_STREAMS
+void wxIconBundle::AddIcon(wxInputStream& stream, wxBitmapType type)
+{
+ DoAddIcon(*this, stream, type, _("Failed to load image %d from stream."));
+}
+#endif // wxUSE_STREAMS
+
+wxIcon wxIconBundle::GetIcon(const wxSize& size) const
+{
+ const size_t count = GetIconCount();
+
+ // optimize for the common case of icon bundles containing one icon only
+ wxIcon iconBest;
+ switch ( count )
+ {
+ case 0:
+ // nothing to do, iconBest is already invalid
+ break;
+
+ case 1:
+ iconBest = M_ICONBUNDLEDATA->m_icons[0];
+ break;
+
+ default:
+ // there is more than one icon, find the best match:
+ wxCoord sysX = wxSystemSettings::GetMetric( wxSYS_ICON_X ),
+ sysY = wxSystemSettings::GetMetric( wxSYS_ICON_Y );
+
+ const wxIconArray& iconArray = M_ICONBUNDLEDATA->m_icons;
+ for ( size_t i = 0; i < count; i++ )
+ {
+ const wxIcon& icon = iconArray[i];
+ wxCoord sx = icon.GetWidth(),
+ sy = icon.GetHeight();
+
+ // if we got an icon of exactly the requested size, we're done
+ if ( sx == size.x && sy == size.y )
+ {
+ iconBest = icon;
+ break;
+ }
+
+ // the best icon is by default (arbitrarily) the first one but
+ // if we find a system-sized icon, take it instead
+ if ((sx == sysX && sy == sysY) || !iconBest.IsOk())
+ iconBest = icon;
+ }
+ }
+
+#if defined( __WXMAC__ ) && wxOSX_USE_CARBON
+ return wxIcon(iconBest.GetHICON(), size);
+#else
+ return iconBest;
+#endif
+}
+
+wxIcon wxIconBundle::GetIconOfExactSize(const wxSize& size) const
+{
+ wxIcon icon = GetIcon(size);
+ if ( icon.Ok() &&
+ (icon.GetWidth() != size.x || icon.GetHeight() != size.y) )
+ {
+ icon = wxNullIcon;