X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/155ecd4c4221d3bbc7aa93d472d11948f21d21ab..2d76b6d8c3d13ce08f0aef47f859078368f7fed7:/src/xrc/xmlres.cpp diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp index 8743a5c135..479dbbd138 100644 --- a/src/xrc/xmlres.cpp +++ b/src/xrc/xmlres.cpp @@ -28,6 +28,7 @@ #include "wx/settings.h" #include "wx/bitmap.h" #include "wx/image.h" + #include "wx/module.h" #endif #ifndef __WXWINCE__ @@ -39,7 +40,6 @@ #include "wx/filename.h" #include "wx/tokenzr.h" #include "wx/fontenum.h" -#include "wx/module.h" #include "wx/fontmap.h" #include "wx/artprov.h" @@ -65,24 +65,41 @@ wxXmlResource *wxXmlResource::ms_instance = NULL; 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) @@ -916,7 +933,7 @@ wxString wxXmlResourceHandler::GetText(const wxString& param, bool translate) if (translate && parNode && parNode->GetPropVal(wxT("translate"), wxEmptyString) != wxT("0")) { - return wxGetTranslation(str2); + return wxGetTranslation(str2, m_resource->GetDomain()); } else { @@ -1042,9 +1059,13 @@ static wxColour GetSystemColour(const wxString& name) return wxNullColour; } -wxColour wxXmlResourceHandler::GetColour(const wxString& param) +wxColour wxXmlResourceHandler::GetColour(const wxString& param, const wxColour& defaultv) { wxString v = GetParamValue(param); + + if ( v.empty() ) + return defaultv; + wxColour clr; // wxString -> wxColour conversion @@ -1095,7 +1116,7 @@ wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param, 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'."), @@ -1118,6 +1139,39 @@ wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param, 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, @@ -1603,6 +1657,7 @@ static void AddStdXRCID_Records() stdID(wxID_HELP); stdID(wxID_PRINT); stdID(wxID_PRINT_SETUP); + stdID(wxID_PAGE_SETUP); stdID(wxID_PREVIEW); stdID(wxID_ABOUT); stdID(wxID_HELP_CONTENTS);