X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0a0be6d5a807d9295065cf9b40cd0dd5946c82be..2d1d813e2dc392d2480a2dc9cdf61ce6330db72d:/contrib/utils/wxrc/wxrc.cpp diff --git a/contrib/utils/wxrc/wxrc.cpp b/contrib/utils/wxrc/wxrc.cpp index 7b74deabc6..ea2c0ffe9c 100644 --- a/contrib/utils/wxrc/wxrc.cpp +++ b/contrib/utils/wxrc/wxrc.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // Name: wxrc.cpp // Purpose: XML resource compiler -// Author: Vaclav Slavik +// Author: Vaclav Slavik, Eduardo Marques // Created: 2000/03/05 // RCS-ID: $Id$ // Copyright: (c) 2000 Vaclav Slavik @@ -20,10 +20,10 @@ #pragma hdrstop #endif -// for all others, include the necessary headers (this file is usually all you -// need because it includes almost all "standard" wxWindows headers +// for all others, include the necessary headers #ifndef WX_PRECOMP - #include "wx/wx.h" + #include "wx/app.h" + #include "wx/log.h" #endif #include "wx/cmdline.h" @@ -33,16 +33,112 @@ #include "wx/wfstream.h" +class XRCWidgetData +{ +public: + XRCWidgetData(const wxString& vname,const wxString& vclass) + : m_class(vclass), m_name(vname) {} + const wxString& GetName() const { return m_name; } + const wxString& GetClass() const { return m_class; } +private: + wxString m_class; + wxString m_name; +}; +#include "wx/arrimpl.cpp" +WX_DECLARE_OBJARRAY(XRCWidgetData,ArrayOfXRCWidgetData); +WX_DEFINE_OBJARRAY(ArrayOfXRCWidgetData); + +class XRCWndClassData +{ +private: + wxString m_className; + wxString m_parentClassName; + ArrayOfXRCWidgetData m_wdata; + + void BrowseXmlNode(wxXmlNode* node) + { + wxString classValue; + wxString nameValue; + wxXmlNode* children; + while (node) + { + if (node->GetName() == _T("object") + && node->GetPropVal(_T("class"),&classValue) + && node->GetPropVal(_T("name"),&nameValue)) + { + m_wdata.Add(XRCWidgetData(nameValue,classValue)); + } + children = node->GetChildren(); + if (children) + BrowseXmlNode(children); + node = node->GetNext(); + } + } + +public: + XRCWndClassData(const wxString& className,const wxString& parentClassName, const wxXmlNode* node) : + m_className(className) , m_parentClassName(parentClassName) { + + BrowseXmlNode(node->GetChildren()); + + } + + const ArrayOfXRCWidgetData& GetWidgetData(){ + return m_wdata; + } + void GenerateHeaderCode(wxFFile& file){ + + file.Write(_T("class ") + m_className + _T(" : public ") + m_parentClassName + + _T(" {\nprotected:\n")); + size_t i; + for(i=0;iLoadObject(this,NULL,\"") + + m_className + + _T("\",\"") + + m_parentClassName + + _T("\");\n")); + for(i=0;iGetChildren(); + wxString classValue,nameValue; + while(node){ + if(node->GetName() == _T("object") + && node->GetPropVal(_T("class"),&classValue) + && node->GetPropVal(_T("name"),&nameValue)){ + + aXRCWndClassData.Add( + XRCWndClassData(nameValue,classValue,node) + ); + } + node = node -> GetNext(); + } + } wxString internalName = GetInternalFileName(parFiles[i], flist); doc.Save(parOutputPath + wxFILE_SEP_PATH + internalName); @@ -362,7 +486,6 @@ void XmlResApp::MakePackageZIP(const wxArrayString& flist) - static wxString FileToCppArray(wxString filename, int num) { wxString output; @@ -467,6 +590,28 @@ _T("\n")); } +void XmlResApp::GenCPPHeader() +{ + wxString fileSpec = (parOutput.BeforeLast('.')).AfterLast('/'); + wxString heaFileName = fileSpec + _T(".h"); + + wxFFile file(heaFileName, wxT("wt")); + file.Write( +_T("//\n") +_T("// This file was automatically generated by wxrc, do not edit by hand.\n") +_T("//\n\n") +_T("#ifndef __") + fileSpec + _T("_h__\n") +_T("#define __") + fileSpec + _T("_h__\n") +); + for(size_t i=0;i