+ wxString encoding(wxT("UTF-8"));
+#if !wxUSE_UNICODE && wxUSE_INTL
+ if ( (GetFlags() & wxXRC_USE_LOCALE) == 0 )
+ {
+ // In case we are not using wxLocale to translate strings, convert the
+ // strings GUI's charset. This must not be done when wxXRC_USE_LOCALE
+ // is on, because it could break wxGetTranslation lookup.
+ encoding = wxLocale::GetSystemEncodingName();
+ }
+#endif
+
+ wxScopedPtr<wxXmlDocument> doc(new wxXmlDocument);
+ if (!doc->Load(*stream, encoding))
+ {
+ wxLogError(_("Cannot load resources from file '%s'."), filename);
+ return NULL;
+ }
+
+ wxXmlNode * const root = doc->GetRoot();
+ if (root->GetName() != wxT("resource"))
+ {
+ ReportError
+ (
+ root,
+ "invalid XRC resource, doesn't have root node <resource>"
+ );
+ return NULL;
+ }
+
+ long version;
+ int v1, v2, v3, v4;
+ wxString verstr = root->GetAttribute(wxT("version"), wxT("0.0.0.0"));
+ if (wxSscanf(verstr, wxT("%i.%i.%i.%i"), &v1, &v2, &v3, &v4) == 4)
+ version = v1*256*256*256+v2*256*256+v3*256+v4;
+ else
+ version = 0;
+ if (m_version == -1)
+ m_version = version;
+ if (m_version != version)
+ {
+ wxLogWarning("Resource files must have same version number.");
+ }
+
+ ProcessPlatformProperty(root);
+ PreprocessForIdRanges(root);
+ wxIdRangeManager::Get()->FinaliseRanges(root);
+
+ return doc.release();