- if( !m_icons[i].Ok() )
- continue;
- wxCoord sx = m_icons[i].GetWidth(), sy = m_icons[i].GetHeight();
- // requested size
- if( sx == size.x && sy == size.y )
- return m_icons[i];
- // keep track if there is a system-size icon
- if( sx == sysX && sy == sysY )
- sysIcon = &m_icons[i];
+ 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.IsOk() &&
+ (icon.GetWidth() != size.x || icon.GetHeight() != size.y) )
+ {
+ icon = wxNullIcon;