+#ifdef __WXMAC__
+ // Deal with standard icons
+ if ( type == wxBITMAP_TYPE_ICON_RESOURCE )
+ {
+ wxIcon tmp(file, type);
+ if (tmp.IsOk())
+ {
+ AddIcon(tmp);
+ return;
+ }
+ }
+#endif // __WXMAC__
+
+#if wxUSE_FFILE
+ wxFFileInputStream stream(file);
+#elif wxUSE_FILE
+ wxFileInputStream stream(file);
+#endif
+ DoAddIcon
+ (
+ *this,
+ stream, type,
+ wxString::Format(_("Failed to load image %%d from file '%s'."), file)
+ );
+}
+
+#endif // wxUSE_FFILE || wxUSE_FILE
+
+void wxIconBundle::AddIcon(wxInputStream& stream, wxBitmapType type)
+{
+ 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;