#include "wx/bitmap.h"
#include "wx/image.h"
#include "wx/fontmap.h"
+#include "wx/artprov.h"
#include "wx/xrc/xml.h"
#include "wx/xrc/xmlres.h"
}
else
{
- node->RemoveChild(c);
wxXmlNode *c2 = c->GetNext();
+ node->RemoveChild(c);
delete c;
c = c2;
}
}
+
int wxXmlResourceHandler::GetID()
{
wxString sid = GetName();
}
+
wxString wxXmlResourceHandler::GetName()
{
return m_node->GetPropVal(wxT("name"), wxT("-1"));
-wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param, wxSize size)
+wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param,
+ const wxArtClient& defaultArtClient,
+ wxSize size)
{
+ /* If the bitmap is specified as stock item, query wxArtProvider for it: */
+ wxXmlNode *bmpNode = GetParamNode(param);
+ if ( bmpNode )
+ {
+ wxString sid = bmpNode->GetPropVal(wxT("stock_id"), wxEmptyString);
+ if ( !sid.empty() )
+ {
+ wxString scl = bmpNode->GetPropVal(wxT("stock_client"), defaultArtClient);
+ wxBitmap stockArt =
+ wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(sid),
+ wxART_MAKE_CLIENT_ID_FROM_STR(scl),
+ size);
+ if ( stockArt.Ok() )
+ return stockArt;
+ }
+ }
+
+ /* ...or load the bitmap from file: */
wxString name = GetParamValue(param);
- if (name.IsEmpty()) return wxNullBitmap;
+ if (name.IsEmpty()) return wxNullBitmap;
#if wxUSE_FILESYSTEM
wxFSFile *fsfile = GetCurFileSystem().OpenFile(name);
if (fsfile == NULL)
#else
wxImage img(GetParamValue(wxT("bitmap")));
#endif
+
if (!img.Ok())
{
wxLogError(_("XRC resource: Cannot create bitmap from '%s'."), param.c_str());
}
if (!(size == wxDefaultSize)) img.Rescale(size.x, size.y);
return wxBitmap(img);
+
}
-wxIcon wxXmlResourceHandler::GetIcon(const wxString& param, wxSize size)
+wxIcon wxXmlResourceHandler::GetIcon(const wxString& param,
+ const wxArtClient& defaultArtClient,
+ wxSize size)
{
#if wxCHECK_VERSION(2,3,0) || defined(__WXMSW__)
wxIcon icon;
- icon.CopyFromBitmap(GetBitmap(param, size));
+ icon.CopyFromBitmap(GetBitmap(param, defaultArtClient, size));
#else
wxIcon *iconpt;
wxBitmap bmppt = GetBitmap(param, size);