WX_DEFINE_OBJARRAY(wxXmlResourceDataRecords);
-wxXmlResource::wxXmlResource(bool use_locale)
+wxXmlResource::wxXmlResource(int flags)
{
m_handlers.DeleteContents(TRUE);
- m_useLocale = use_locale;
+ m_flags = flags;
m_version = -1;
}
-wxXmlResource::wxXmlResource(const wxString& filemask, bool use_locale)
+wxXmlResource::wxXmlResource(const wxString& filemask, int flags)
{
- m_useLocale = use_locale;
+ m_flags = flags;
m_version = -1;
m_handlers.DeleteContents(TRUE);
Load(filemask);
wxObject *myParent = m_parent, *myInstance = m_instance;
wxWindow *myParentAW = m_parentAsWindow, *myInstanceAW = m_instanceAsWindow;
+ m_instance = instance;
+ if (!m_instance && node->HasProp(wxT("subclass")) &&
+ !(m_resource->GetFlags() & wxXRC_NO_SUBCLASSING))
+ {
+ wxString subclass = node->GetPropVal(wxT("subclass"), wxEmptyString);
+ wxClassInfo* classInfo = wxClassInfo::FindClass(subclass);
+
+ if (classInfo)
+ m_instance = classInfo->CreateObject();
+
+ if (!m_instance)
+ {
+ wxLogError(_("Subclass '%s' not found for resource '%s', not subclassing!"),
+ subclass.c_str(), node->GetPropVal(wxT("name"), wxEmptyString).c_str());
+ }
+
+ m_instance = classInfo->CreateObject();
+ }
+
m_node = node;
m_class = node->GetPropVal(wxT("class"), wxEmptyString);
m_parent = parent;
- m_instance = instance;
m_parentAsWindow = wxDynamicCast(m_parent, wxWindow);
m_instanceAsWindow = wxDynamicCast(m_instance, wxWindow);
void wxXmlResourceHandler::AddWindowStyles()
{
- ADD_STYLE(wxSIMPLE_BORDER);
- ADD_STYLE(wxSUNKEN_BORDER);
- ADD_STYLE(wxDOUBLE_BORDER);
- ADD_STYLE(wxRAISED_BORDER);
- ADD_STYLE(wxSTATIC_BORDER);
- ADD_STYLE(wxNO_BORDER);
- ADD_STYLE(wxTRANSPARENT_WINDOW);
- ADD_STYLE(wxWANTS_CHARS);
- ADD_STYLE(wxNO_FULL_REPAINT_ON_RESIZE);
+ XRC_ADD_STYLE(wxSIMPLE_BORDER);
+ XRC_ADD_STYLE(wxSUNKEN_BORDER);
+ XRC_ADD_STYLE(wxDOUBLE_BORDER);
+ XRC_ADD_STYLE(wxRAISED_BORDER);
+ XRC_ADD_STYLE(wxSTATIC_BORDER);
+ XRC_ADD_STYLE(wxNO_BORDER);
+ XRC_ADD_STYLE(wxTRANSPARENT_WINDOW);
+ XRC_ADD_STYLE(wxWANTS_CHARS);
+ XRC_ADD_STYLE(wxNO_FULL_REPAINT_ON_RESIZE);
}
wxString wxXmlResourceHandler::GetText(const wxString& param)
{
- wxString str1 = GetParamValue(param);
+ wxString str1;
wxString str2;
const wxChar *dt;
wxChar amp_char;
+ if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
+ str1 = wxGetTranslation(GetParamValue(param));
+ else
+ str1 = GetParamValue(param);
+
// VS: First version of XRC resources used $ instead of & (which is illegal in XML),
// but later I realized that '_' fits this purpose much better (because
// &File means "File with F underlined").
}
else str2 << *dt;
}
-
- if (m_resource->GetUseLocale())
- return wxGetTranslation(str2);
- else
- return str2;
+
+ return str2;
}