#include "wx/settings.h"
#include "wx/bitmap.h"
#include "wx/image.h"
+ #include "wx/module.h"
#endif
#ifndef __WXWINCE__
#include "wx/filename.h"
#include "wx/tokenzr.h"
#include "wx/fontenum.h"
-#include "wx/module.h"
#include "wx/fontmap.h"
#include "wx/artprov.h"
return old;
}
-wxXmlResource::wxXmlResource(int flags)
+wxXmlResource::wxXmlResource(int flags, const wxString& domain)
{
m_flags = flags;
m_version = -1;
+ m_domain = NULL;
+ if (! domain.empty() )
+ SetDomain(domain);
}
-wxXmlResource::wxXmlResource(const wxString& filemask, int flags)
+wxXmlResource::wxXmlResource(const wxString& filemask, int flags, const wxString& domain)
{
m_flags = flags;
m_version = -1;
+ m_domain = NULL;
+ if (! domain.empty() )
+ SetDomain(domain);
Load(filemask);
}
wxXmlResource::~wxXmlResource()
{
+ if (m_domain)
+ free(m_domain);
ClearHandlers();
}
+void wxXmlResource::SetDomain(const wxChar* domain)
+{
+ if (m_domain)
+ free(m_domain);
+ m_domain = NULL;
+ if (domain && wxStrlen(domain))
+ m_domain = wxStrdup(domain);
+}
+
/* static */
wxString wxXmlResource::ConvertFileNameToURL(const wxString& filename)
void wxXmlResource::AddHandler(wxXmlResourceHandler *handler)
{
- m_handlers.Add(handler);
+ m_handlers.Append(handler);
handler->SetParentResource(this);
}
void wxXmlResource::InsertHandler(wxXmlResourceHandler *handler)
{
- m_handlers.Insert(handler, 0);
+ m_handlers.Insert(handler);
handler->SetParentResource(this);
}
void wxXmlResource::ClearHandlers()
{
- WX_CLEAR_ARRAY(m_handlers);
+ WX_CLEAR_LIST(wxList, m_handlers);
}
return CreateResFromNode(©, parent, instance);
}
+ wxXmlResourceHandler *handler;
+
if (handlerToUse)
{
if (handlerToUse->CanHandle(node))
+ {
return handlerToUse->CreateResource(node, parent, instance);
+ }
}
else if (node->GetName() == wxT("object"))
{
- for ( wxXmlResourceHandlers::iterator i = m_handlers.begin();
- i != m_handlers.end(); ++i )
+ wxList::compatibility_iterator ND = m_handlers.GetFirst();
+ while (ND)
{
- wxXmlResourceHandler *handler = *i;
+ handler = (wxXmlResourceHandler*)ND->GetData();
if (handler->CanHandle(node))
+ {
return handler->CreateResource(node, parent, instance);
+ }
+ ND = ND->GetNext();
}
}
if (translate && parNode &&
parNode->GetPropVal(wxT("translate"), wxEmptyString) != wxT("0"))
{
- return wxGetTranslation(str2);
+ return wxGetTranslation(str2, m_resource->GetDomain());
}
else
{
wxString name = GetParamValue(param);
if (name.empty()) return wxNullBitmap;
#if wxUSE_FILESYSTEM
- wxFSFile *fsfile = GetCurFileSystem().OpenFile(name);
+ wxFSFile *fsfile = GetCurFileSystem().OpenFile(name, wxFS_READ | wxFS_SEEKABLE);
if (fsfile == NULL)
{
wxLogError(_("XRC resource: Cannot create bitmap from '%s'."),
return wxBitmap(img);
}
+#if wxUSE_ANIMATIONCTRL
+wxAnimation wxXmlResourceHandler::GetAnimation(const wxString& param)
+{
+ wxAnimation ani;
+
+ /* load the animation from file: */
+ wxString name = GetParamValue(param);
+ if (name.empty()) return wxNullAnimation;
+#if wxUSE_FILESYSTEM
+ wxFSFile *fsfile = GetCurFileSystem().OpenFile(name, wxFS_READ | wxFS_SEEKABLE);
+ if (fsfile == NULL)
+ {
+ wxLogError(_("XRC resource: Cannot create animation from '%s'."),
+ name.c_str());
+ return wxNullAnimation;
+ }
+ ani.Load(*(fsfile->GetStream()));
+ delete fsfile;
+#else
+ ani.LoadFile(name);
+#endif
+
+ if (!ani.IsOk())
+ {
+ wxLogError(_("XRC resource: Cannot create animation from '%s'."),
+ name.c_str());
+ return wxNullAnimation;
+ }
+
+ return ani;
+}
+#endif // wxUSE_ANIMATIONCTRL
+
wxIcon wxXmlResourceHandler::GetIcon(const wxString& param,
stdID(wxID_HELP);
stdID(wxID_PRINT);
stdID(wxID_PRINT_SETUP);
+ stdID(wxID_PAGE_SETUP);
stdID(wxID_PREVIEW);
stdID(wxID_ABOUT);
stdID(wxID_HELP_CONTENTS);