+ BrowseXmlNode(node->GetChildren());
+ }
+
+ const ArrayOfXRCWidgetData& GetWidgetData()
+ {
+ return m_wdata;
+ }
+
+ bool CanBeUsedWithXRCCTRL(const wxString& name)
+ {
+ if (name == wxT("tool") ||
+ name == wxT("data") ||
+ name == wxT("unknown") ||
+ name == wxT("notebookpage") ||
+ name == wxT("separator") ||
+ name == wxT("sizeritem") ||
+ name == wxT("wxMenu") ||
+ name == wxT("wxMenuBar") ||
+ name == wxT("wxMenuItem") ||
+ name.EndsWith(wxT("Sizer")) )
+ {
+ return false;
+ }
+ return true;
+ }
+
+ void GenerateHeaderCode(wxFFile& file)
+ {
+
+ file.Write(wxT("class ") + m_className + wxT(" : public ") + m_parentClassName
+ + wxT(" {\nprotected:\n"));
+ size_t i;
+ for(i=0;i<m_wdata.GetCount();++i)
+ {
+ const XRCWidgetData& w = m_wdata.Item(i);
+ if( !CanBeUsedWithXRCCTRL(w.GetClass()) ) continue;
+ if( w.GetName().empty() ) continue;
+ file.Write(
+ wxT(" ") + w.GetClass() + wxT("* ") + w.GetName()
+ + wxT(";\n"));
+ }
+ file.Write(wxT("\nprivate:\n void InitWidgetsFromXRC(wxWindow *parent){\n")
+ wxT(" wxXmlResource::Get()->LoadObject(this,parent,wxT(\"")
+ + m_className
+ + wxT("\"), wxT(\"")
+ + m_parentClassName
+ + wxT("\"));\n"));
+ for(i=0;i<m_wdata.GetCount();++i)
+ {
+ const XRCWidgetData& w = m_wdata.Item(i);
+ if( !CanBeUsedWithXRCCTRL(w.GetClass()) ) continue;
+ if( w.GetName().empty() ) continue;
+ file.Write( wxT(" ")
+ + w.GetName()
+ + wxT(" = XRCCTRL(*this,\"")
+ + w.GetName()
+ + wxT("\",")
+ + w.GetClass()
+ + wxT(");\n"));
+ }
+ file.Write(wxT(" }\n"));
+
+ file.Write( wxT("public:\n"));
+
+ if ( m_ancestorClassNames.size() == 1 )
+ {
+ file.Write
+ (
+ m_className +
+ wxT("(") +
+ *m_ancestorClassNames.begin() +
+ wxT(" *parent=NULL){\n") +
+ wxT(" InitWidgetsFromXRC((wxWindow *)parent);\n")
+ wxT(" }\n")
+ wxT("};\n")
+ );
+ }
+ else
+ {
+ file.Write(m_className + wxT("(){\n") +
+ wxT(" InitWidgetsFromXRC(NULL);\n")
+ wxT(" }\n")
+ wxT("};\n"));
+
+ for ( StringSet::const_iterator it = m_ancestorClassNames.begin();
+ it != m_ancestorClassNames.end();
+ ++it )
+ {
+ file.Write(m_className + wxT("(") + *it + wxT(" *parent){\n") +
+ wxT(" InitWidgetsFromXRC((wxWindow *)parent);\n")
+ wxT(" }\n")
+ wxT("};\n"));
+ }
+ }
+ }
+};
+WX_DECLARE_OBJARRAY(XRCWndClassData,ArrayOfXRCWndClassData);
+WX_DEFINE_OBJARRAY(ArrayOfXRCWndClassData)
+
+struct ExtractedString
+{
+ ExtractedString() : lineNo(-1) {}
+ ExtractedString(const wxString& str_,
+ const wxString& filename_, int lineNo_)
+ : str(str_), filename(filename_), lineNo(lineNo_)
+ {}
+
+ wxString str;
+
+ wxString filename;
+ int lineNo;
+};
+
+typedef wxVector<ExtractedString> ExtractedStrings;
+
+
+class XmlResApp : public wxAppConsole
+{
+public:
+ // don't use builtin cmd line parsing:
+ virtual bool OnInit() { return true; }