+wxIconBundle wxXmlResourceHandler::GetIconBundle(const wxString& param,
+ const wxArtClient& defaultArtClient)
+{
+ wxString art_id, art_client;
+ if ( GetStockArtAttrs(GetParamNode(param), defaultArtClient,
+ art_id, art_client) )
+ {
+ wxIconBundle stockArt(wxArtProvider::GetIconBundle(art_id, art_client));
+ if ( stockArt.IsOk() )
+ return stockArt;
+ }
+
+ const wxString name = GetParamValue(param);
+ if ( name.empty() )
+ return wxNullIconBundle;
+
+#if wxUSE_FILESYSTEM
+ wxFSFile *fsfile = GetCurFileSystem().OpenFile(name, wxFS_READ | wxFS_SEEKABLE);
+ if ( fsfile == NULL )
+ {
+ ReportParamError
+ (
+ param,
+ wxString::Format("cannot open icon resource \"%s\"", name)
+ );
+ return wxNullIconBundle;
+ }
+
+ wxIconBundle bundle(*(fsfile->GetStream()));
+ delete fsfile;
+#else
+ wxIconBundle bundle(name);
+#endif
+
+ if ( !bundle.IsOk() )
+ {
+ ReportParamError
+ (
+ param,
+ wxString::Format("cannot create icon from \"%s\"", name)
+ );
+ return wxNullIconBundle;
+ }
+
+ return bundle;
+}
+
+
+wxImageList *wxXmlResourceHandler::GetImageList(const wxString& param)
+{
+ wxXmlNode * const imagelist_node = GetParamNode(param);
+ if ( !imagelist_node )
+ return NULL;
+
+ wxXmlNode * const oldnode = m_node;
+ m_node = imagelist_node;
+
+ // size
+ wxSize size = GetSize();
+ size.SetDefaults(wxSize(wxSystemSettings::GetMetric(wxSYS_ICON_X),
+ wxSystemSettings::GetMetric(wxSYS_ICON_Y)));
+
+ // mask: true by default
+ bool mask = HasParam(wxT("mask")) ? GetBool(wxT("mask"), true) : true;
+
+ // now we have everything we need to create the image list
+ wxImageList *imagelist = new wxImageList(size.x, size.y, mask);
+
+ // add images
+ wxString parambitmap = wxT("bitmap");
+ if ( HasParam(parambitmap) )
+ {
+ wxXmlNode *n = m_node->GetChildren();
+ while (n)
+ {
+ if (n->GetType() == wxXML_ELEMENT_NODE && n->GetName() == parambitmap)
+ {
+ // add icon instead of bitmap to keep the bitmap mask
+ imagelist->Add(GetIcon(n));
+ }
+ n = n->GetNext();
+ }
+ }
+
+ m_node = oldnode;
+ return imagelist;
+}