+ 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;
+ }
+
+ return icon;
+}
+
+void wxIconBundle::AddIcon(const wxIcon& icon)
+{
+ wxCHECK_RET( icon.IsOk(), _T("invalid icon") );
+
+ AllocExclusive();
+
+ wxIconArray& iconArray = M_ICONBUNDLEDATA->m_icons;
+
+ // replace existing icon with the same size if we already have it
+ const size_t count = iconArray.size();
+ for ( size_t i = 0; i < count; ++i )
+ {
+ wxIcon& tmp = iconArray[i];
+ if ( tmp.Ok() &&
+ tmp.GetWidth() == icon.GetWidth() &&
+ tmp.GetHeight() == icon.GetHeight() )