- size_t i, max = m_icons.GetCount();
- wxCoord sysX = wxSystemSettings::GetMetric( wxSYS_ICON_X ),
- sysY = wxSystemSettings::GetMetric( wxSYS_ICON_Y );
+ DoAddIcon(*this, stream, type, _("Failed to load image %d from stream."));
+}
+
+#endif // wxUSE_STREAMS && wxUSE_IMAGE
+
+wxIcon wxIconBundle::GetIcon(const wxSize& size, int flags) const
+{
+ wxASSERT( size == wxDefaultSize || (size.x >= 0 && size.y > 0) );
+
+ // We need the standard system icon size when using FALLBACK_SYSTEM.
+ wxCoord sysX = 0,
+ sysY = 0;
+ if ( flags & FALLBACK_SYSTEM )
+ {
+ sysX = wxSystemSettings::GetMetric(wxSYS_ICON_X);
+ sysY = wxSystemSettings::GetMetric(wxSYS_ICON_Y);
+ }
+
+ // If size == wxDefaultSize, we use system default icon size by convention.
+ wxCoord sizeX = size.x;
+ wxCoord sizeY = size.y;
+ if ( size == wxDefaultSize )
+ {
+ wxASSERT_MSG( flags == FALLBACK_SYSTEM,
+ wxS("Must have valid size if not using FALLBACK_SYSTEM") );
+
+ sizeX = sysX;
+ sizeY = sysY;
+ }
+
+ // Iterate over all icons searching for the exact match or the closest icon
+ // for FALLBACK_NEAREST_LARGER.
+ wxIcon iconBest;
+ int bestDiff = 0;
+ bool bestIsLarger = false;
+ bool bestIsSystem = false;