2000-07-25 18:47:21 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wxrc.cpp
|
|
|
|
// Purpose: XML resource compiler
|
2004-02-05 21:58:29 +00:00
|
|
|
// Author: Vaclav Slavik, Eduardo Marques <edrdo@netcabo.pt>
|
2000-07-25 18:47:21 +00:00
|
|
|
// Created: 2000/03/05
|
|
|
|
// Copyright: (c) 2000 Vaclav Slavik
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
2003-09-19 15:44:28 +00:00
|
|
|
// for all others, include the necessary headers
|
2000-07-25 18:47:21 +00:00
|
|
|
#ifndef WX_PRECOMP
|
2003-09-19 15:44:28 +00:00
|
|
|
#include "wx/app.h"
|
|
|
|
#include "wx/log.h"
|
2007-04-27 21:03:46 +00:00
|
|
|
#include "wx/wxcrtvararg.h"
|
2000-07-25 18:47:21 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/cmdline.h"
|
2003-07-20 22:15:32 +00:00
|
|
|
#include "wx/xml/xml.h"
|
2000-07-25 18:47:21 +00:00
|
|
|
#include "wx/ffile.h"
|
2002-12-25 15:23:44 +00:00
|
|
|
#include "wx/filename.h"
|
2000-08-11 19:07:43 +00:00
|
|
|
#include "wx/wfstream.h"
|
2005-01-21 12:40:19 +00:00
|
|
|
#include "wx/utils.h"
|
2006-05-06 22:53:06 +00:00
|
|
|
#include "wx/hashset.h"
|
2007-06-18 18:43:34 +00:00
|
|
|
#include "wx/mimetype.h"
|
2007-09-30 11:11:51 +00:00
|
|
|
#include "wx/vector.h"
|
2000-08-11 19:07:43 +00:00
|
|
|
|
2012-08-06 11:06:45 +00:00
|
|
|
WX_DECLARE_HASH_SET(wxString, wxStringHash, wxStringEqual, StringSet);
|
2000-08-11 19:07:43 +00:00
|
|
|
|
2004-02-05 21:58:29 +00:00
|
|
|
class XRCWidgetData
|
|
|
|
{
|
|
|
|
public:
|
2004-06-11 13:14:23 +00:00
|
|
|
XRCWidgetData(const wxString& vname,const wxString& vclass)
|
2004-02-05 21:58:29 +00:00
|
|
|
: 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;
|
|
|
|
};
|
2005-01-13 19:57:24 +00:00
|
|
|
|
2004-02-05 21:58:29 +00:00
|
|
|
#include "wx/arrimpl.cpp"
|
|
|
|
WX_DECLARE_OBJARRAY(XRCWidgetData,ArrayOfXRCWidgetData);
|
2005-09-25 19:59:19 +00:00
|
|
|
WX_DEFINE_OBJARRAY(ArrayOfXRCWidgetData)
|
2004-02-05 21:58:29 +00:00
|
|
|
|
|
|
|
class XRCWndClassData
|
|
|
|
{
|
2004-06-11 13:14:23 +00:00
|
|
|
private:
|
2004-02-05 21:58:29 +00:00
|
|
|
wxString m_className;
|
|
|
|
wxString m_parentClassName;
|
2006-05-06 22:53:06 +00:00
|
|
|
StringSet m_ancestorClassNames;
|
2004-02-05 21:58:29 +00:00
|
|
|
ArrayOfXRCWidgetData m_wdata;
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2004-02-05 21:58:29 +00:00
|
|
|
void BrowseXmlNode(wxXmlNode* node)
|
|
|
|
{
|
|
|
|
wxString classValue;
|
|
|
|
wxString nameValue;
|
2004-06-11 13:14:23 +00:00
|
|
|
wxXmlNode* children;
|
2004-02-05 21:58:29 +00:00
|
|
|
while (node)
|
|
|
|
{
|
2009-07-23 20:30:22 +00:00
|
|
|
if (node->GetName() == wxT("object")
|
|
|
|
&& node->GetAttribute(wxT("class"),&classValue)
|
|
|
|
&& node->GetAttribute(wxT("name"),&nameValue))
|
2004-02-05 21:58:29 +00:00
|
|
|
{
|
|
|
|
m_wdata.Add(XRCWidgetData(nameValue,classValue));
|
|
|
|
}
|
|
|
|
children = node->GetChildren();
|
|
|
|
if (children)
|
2004-06-11 13:14:23 +00:00
|
|
|
BrowseXmlNode(children);
|
2004-02-05 21:58:29 +00:00
|
|
|
node = node->GetNext();
|
|
|
|
}
|
|
|
|
}
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2004-02-05 21:58:29 +00:00
|
|
|
public:
|
2006-05-06 22:53:06 +00:00
|
|
|
XRCWndClassData(const wxString& className,
|
|
|
|
const wxString& parentClassName,
|
|
|
|
const wxXmlNode* node) :
|
2005-01-13 19:57:24 +00:00
|
|
|
m_className(className) , m_parentClassName(parentClassName)
|
|
|
|
{
|
2009-07-23 20:30:22 +00:00
|
|
|
if ( className == wxT("wxMenu") )
|
2006-05-06 22:53:06 +00:00
|
|
|
{
|
2009-07-23 20:30:22 +00:00
|
|
|
m_ancestorClassNames.insert(wxT("wxMenu"));
|
|
|
|
m_ancestorClassNames.insert(wxT("wxMenuBar"));
|
2006-05-06 22:53:06 +00:00
|
|
|
}
|
2009-07-23 20:30:22 +00:00
|
|
|
else if ( className == wxT("wxMDIChildFrame") )
|
2006-05-06 22:53:06 +00:00
|
|
|
{
|
2009-07-23 20:30:22 +00:00
|
|
|
m_ancestorClassNames.insert(wxT("wxMDIParentFrame"));
|
2006-05-06 22:53:06 +00:00
|
|
|
}
|
2009-07-23 20:30:22 +00:00
|
|
|
else if( className == wxT("wxMenuBar") ||
|
|
|
|
className == wxT("wxStatusBar") ||
|
|
|
|
className == wxT("wxToolBar") )
|
2006-05-06 22:53:06 +00:00
|
|
|
{
|
2009-07-23 20:30:22 +00:00
|
|
|
m_ancestorClassNames.insert(wxT("wxFrame"));
|
2006-05-06 22:53:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-23 20:30:22 +00:00
|
|
|
m_ancestorClassNames.insert(wxT("wxWindow"));
|
2006-05-06 22:53:06 +00:00
|
|
|
}
|
|
|
|
|
2004-03-18 17:23:31 +00:00
|
|
|
BrowseXmlNode(node->GetChildren());
|
|
|
|
}
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2005-01-13 19:57:24 +00:00
|
|
|
const ArrayOfXRCWidgetData& GetWidgetData()
|
|
|
|
{
|
2004-03-18 17:23:31 +00:00
|
|
|
return m_wdata;
|
|
|
|
}
|
2004-08-23 12:55:16 +00:00
|
|
|
|
2007-03-17 16:48:11 +00:00
|
|
|
bool CanBeUsedWithXRCCTRL(const wxString& name)
|
2004-08-23 12:55:16 +00:00
|
|
|
{
|
2009-07-23 20:30:22 +00:00
|
|
|
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")) )
|
2004-08-23 12:55:16 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2005-01-13 19:57:24 +00:00
|
|
|
|
2004-08-23 12:55:16 +00:00
|
|
|
void GenerateHeaderCode(wxFFile& file)
|
|
|
|
{
|
2004-03-18 17:23:31 +00:00
|
|
|
|
2009-07-23 20:30:22 +00:00
|
|
|
file.Write(wxT("class ") + m_className + wxT(" : public ") + m_parentClassName
|
|
|
|
+ wxT(" {\nprotected:\n"));
|
2004-03-18 17:23:31 +00:00
|
|
|
size_t i;
|
2007-04-11 00:23:19 +00:00
|
|
|
for(i=0;i<m_wdata.GetCount();++i)
|
2004-08-23 12:55:16 +00:00
|
|
|
{
|
2004-03-18 17:23:31 +00:00
|
|
|
const XRCWidgetData& w = m_wdata.Item(i);
|
2007-03-17 16:48:11 +00:00
|
|
|
if( !CanBeUsedWithXRCCTRL(w.GetClass()) ) continue;
|
2011-01-22 14:38:36 +00:00
|
|
|
if( w.GetName().empty() ) continue;
|
2004-03-18 17:23:31 +00:00
|
|
|
file.Write(
|
2009-07-23 20:30:22 +00:00
|
|
|
wxT(" ") + w.GetClass() + wxT("* ") + w.GetName()
|
|
|
|
+ wxT(";\n"));
|
2004-03-18 17:23:31 +00:00
|
|
|
}
|
2009-07-23 20:30:22 +00:00
|
|
|
file.Write(wxT("\nprivate:\n void InitWidgetsFromXRC(wxWindow *parent){\n")
|
|
|
|
wxT(" wxXmlResource::Get()->LoadObject(this,parent,wxT(\"")
|
2004-06-11 13:14:23 +00:00
|
|
|
+ m_className
|
2009-07-23 20:30:22 +00:00
|
|
|
+ wxT("\"), wxT(\"")
|
2004-06-11 13:14:23 +00:00
|
|
|
+ m_parentClassName
|
2009-07-23 20:30:22 +00:00
|
|
|
+ wxT("\"));\n"));
|
2007-04-11 00:23:19 +00:00
|
|
|
for(i=0;i<m_wdata.GetCount();++i)
|
2004-08-23 12:55:16 +00:00
|
|
|
{
|
2004-03-18 17:23:31 +00:00
|
|
|
const XRCWidgetData& w = m_wdata.Item(i);
|
2007-03-17 16:48:11 +00:00
|
|
|
if( !CanBeUsedWithXRCCTRL(w.GetClass()) ) continue;
|
2011-01-22 14:38:36 +00:00
|
|
|
if( w.GetName().empty() ) continue;
|
2009-07-23 20:30:22 +00:00
|
|
|
file.Write( wxT(" ")
|
2004-06-11 13:14:23 +00:00
|
|
|
+ w.GetName()
|
2009-07-23 20:30:22 +00:00
|
|
|
+ wxT(" = XRCCTRL(*this,\"")
|
2004-06-11 13:14:23 +00:00
|
|
|
+ w.GetName()
|
2009-07-23 20:30:22 +00:00
|
|
|
+ wxT("\",")
|
2004-03-18 17:23:31 +00:00
|
|
|
+ w.GetClass()
|
2009-07-23 20:30:22 +00:00
|
|
|
+ wxT(");\n"));
|
2004-03-18 17:23:31 +00:00
|
|
|
}
|
2009-07-23 20:30:22 +00:00
|
|
|
file.Write(wxT(" }\n"));
|
2005-01-13 19:57:24 +00:00
|
|
|
|
2009-07-23 20:30:22 +00:00
|
|
|
file.Write( wxT("public:\n"));
|
2006-05-06 22:53:06 +00:00
|
|
|
|
|
|
|
if ( m_ancestorClassNames.size() == 1 )
|
|
|
|
{
|
|
|
|
file.Write
|
|
|
|
(
|
|
|
|
m_className +
|
2009-07-23 20:30:22 +00:00
|
|
|
wxT("(") +
|
2006-05-06 22:53:06 +00:00
|
|
|
*m_ancestorClassNames.begin() +
|
2009-07-23 20:30:22 +00:00
|
|
|
wxT(" *parent=NULL){\n") +
|
|
|
|
wxT(" InitWidgetsFromXRC((wxWindow *)parent);\n")
|
|
|
|
wxT(" }\n")
|
|
|
|
wxT("};\n")
|
2006-05-06 22:53:06 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-23 20:30:22 +00:00
|
|
|
file.Write(m_className + wxT("(){\n") +
|
|
|
|
wxT(" InitWidgetsFromXRC(NULL);\n")
|
|
|
|
wxT(" }\n")
|
|
|
|
wxT("};\n"));
|
2006-05-06 22:53:06 +00:00
|
|
|
|
|
|
|
for ( StringSet::const_iterator it = m_ancestorClassNames.begin();
|
|
|
|
it != m_ancestorClassNames.end();
|
|
|
|
++it )
|
|
|
|
{
|
2009-07-23 20:30:22 +00:00
|
|
|
file.Write(m_className + wxT("(") + *it + wxT(" *parent){\n") +
|
|
|
|
wxT(" InitWidgetsFromXRC((wxWindow *)parent);\n")
|
|
|
|
wxT(" }\n")
|
|
|
|
wxT("};\n"));
|
2006-05-06 22:53:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-02-05 21:58:29 +00:00
|
|
|
};
|
|
|
|
WX_DECLARE_OBJARRAY(XRCWndClassData,ArrayOfXRCWndClassData);
|
2005-09-25 19:59:19 +00:00
|
|
|
WX_DEFINE_OBJARRAY(ArrayOfXRCWndClassData)
|
2004-02-05 21:58:29 +00:00
|
|
|
|
2007-09-30 11:11:51 +00:00
|
|
|
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;
|
|
|
|
|
2004-02-05 21:58:29 +00:00
|
|
|
|
2003-07-20 22:15:32 +00:00
|
|
|
class XmlResApp : public wxAppConsole
|
2000-07-25 18:47:21 +00:00
|
|
|
{
|
|
|
|
public:
|
2003-08-09 20:09:02 +00:00
|
|
|
// don't use builtin cmd line parsing:
|
2014-03-20 13:26:28 +00:00
|
|
|
virtual bool OnInit() wxOVERRIDE { return true; }
|
|
|
|
virtual int OnRun() wxOVERRIDE;
|
2004-06-11 13:14:23 +00:00
|
|
|
|
|
|
|
private:
|
2000-07-25 18:47:21 +00:00
|
|
|
void ParseParams(const wxCmdLineParser& cmdline);
|
|
|
|
void CompileRes();
|
|
|
|
wxArrayString PrepareTempFiles();
|
2000-08-11 19:07:43 +00:00
|
|
|
void FindFilesInXML(wxXmlNode *node, wxArrayString& flist, const wxString& inputPath);
|
|
|
|
|
2002-06-22 23:33:12 +00:00
|
|
|
wxString GetInternalFileName(const wxString& name, const wxArrayString& flist);
|
2000-07-25 18:47:21 +00:00
|
|
|
void DeleteTempFiles(const wxArrayString& flist);
|
|
|
|
void MakePackageZIP(const wxArrayString& flist);
|
|
|
|
void MakePackageCPP(const wxArrayString& flist);
|
2002-08-14 11:02:39 +00:00
|
|
|
void MakePackagePython(const wxArrayString& flist);
|
2000-11-24 17:20:20 +00:00
|
|
|
|
|
|
|
void OutputGettext();
|
2007-09-30 11:11:51 +00:00
|
|
|
ExtractedStrings FindStrings();
|
|
|
|
ExtractedStrings FindStrings(const wxString& filename, wxXmlNode *node);
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2013-10-11 15:31:39 +00:00
|
|
|
bool Validate();
|
|
|
|
|
|
|
|
bool flagVerbose, flagCPP, flagPython, flagGettext, flagValidate, flagValidateOnly;
|
|
|
|
wxString parOutput, parFuncname, parOutputPath, parSchemaFile;
|
2000-07-25 18:47:21 +00:00
|
|
|
wxArrayString parFiles;
|
|
|
|
int retCode;
|
2004-02-05 21:58:29 +00:00
|
|
|
|
|
|
|
ArrayOfXRCWndClassData aXRCWndClassData;
|
2004-03-18 17:23:31 +00:00
|
|
|
bool flagH;
|
|
|
|
void GenCPPHeader();
|
2000-07-25 18:47:21 +00:00
|
|
|
};
|
|
|
|
|
2015-04-23 11:49:01 +00:00
|
|
|
wxIMPLEMENT_APP_CONSOLE(XmlResApp);
|
2000-07-25 18:47:21 +00:00
|
|
|
|
|
|
|
int XmlResApp::OnRun()
|
|
|
|
{
|
|
|
|
static const wxCmdLineEntryDesc cmdLineDesc[] =
|
|
|
|
{
|
2007-09-17 14:37:12 +00:00
|
|
|
{ wxCMD_LINE_SWITCH, "h", "help", "show help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
|
|
|
|
{ wxCMD_LINE_SWITCH, "v", "verbose", "be verbose" },
|
|
|
|
{ wxCMD_LINE_SWITCH, "e", "extra-cpp-code", "output C++ header file with XRC derived classes" },
|
|
|
|
{ wxCMD_LINE_SWITCH, "c", "cpp-code", "output C++ source rather than .rsc file" },
|
|
|
|
{ wxCMD_LINE_SWITCH, "p", "python-code", "output wxPython source rather than .rsc file" },
|
|
|
|
{ wxCMD_LINE_SWITCH, "g", "gettext", "output list of translatable strings (to stdout or file if -o used)" },
|
|
|
|
{ wxCMD_LINE_OPTION, "n", "function", "C++/Python function name (with -c or -p) [InitXmlResource]" },
|
|
|
|
{ wxCMD_LINE_OPTION, "o", "output", "output file [resource.xrs/cpp]" },
|
2013-10-11 15:31:39 +00:00
|
|
|
{ wxCMD_LINE_SWITCH, "", "validate", "check XRC correctness (in addition to other processing)" },
|
|
|
|
{ wxCMD_LINE_SWITCH, "", "validate-only", "check XRC correctness and do nothing else" },
|
|
|
|
{ wxCMD_LINE_OPTION, "", "xrc-schema", "RELAX NG schema file to validate against (optional)" },
|
2002-07-02 22:06:00 +00:00
|
|
|
#if 0 // not yet implemented
|
2007-09-17 14:37:12 +00:00
|
|
|
{ wxCMD_LINE_OPTION, "l", "list-of-handlers", "output list of necessary handlers to this file" },
|
2002-07-02 22:06:00 +00:00
|
|
|
#endif
|
2007-09-17 14:37:12 +00:00
|
|
|
{ wxCMD_LINE_PARAM, NULL, NULL, "input file(s)",
|
2004-06-11 13:14:23 +00:00
|
|
|
wxCMD_LINE_VAL_STRING,
|
2002-07-02 22:06:00 +00:00
|
|
|
wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_OPTION_MANDATORY },
|
2000-07-25 18:47:21 +00:00
|
|
|
|
2009-01-07 01:47:47 +00:00
|
|
|
wxCMD_LINE_DESC_END
|
2000-07-25 18:47:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
wxCmdLineParser parser(cmdLineDesc, argc, argv);
|
|
|
|
|
|
|
|
switch (parser.Parse())
|
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
retCode = 0;
|
|
|
|
ParseParams(parser);
|
2013-10-11 15:31:39 +00:00
|
|
|
|
|
|
|
if (flagValidate)
|
|
|
|
{
|
|
|
|
if ( !Validate() )
|
|
|
|
return 2;
|
|
|
|
if ( flagValidateOnly )
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-11-24 17:20:20 +00:00
|
|
|
if (flagGettext)
|
|
|
|
OutputGettext();
|
|
|
|
else
|
|
|
|
CompileRes();
|
2000-07-25 18:47:21 +00:00
|
|
|
return retCode;
|
|
|
|
}
|
2003-09-11 09:30:59 +00:00
|
|
|
return 1;
|
2000-07-25 18:47:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void XmlResApp::ParseParams(const wxCmdLineParser& cmdline)
|
|
|
|
{
|
2007-09-17 14:37:12 +00:00
|
|
|
flagGettext = cmdline.Found("g");
|
|
|
|
flagVerbose = cmdline.Found("v");
|
|
|
|
flagCPP = cmdline.Found("c");
|
|
|
|
flagPython = cmdline.Found("p");
|
|
|
|
flagH = flagCPP && cmdline.Found("e");
|
2013-10-11 15:31:39 +00:00
|
|
|
flagValidateOnly = cmdline.Found("validate-only");
|
|
|
|
flagValidate = flagValidateOnly || cmdline.Found("validate");
|
2004-02-05 21:58:29 +00:00
|
|
|
|
2013-10-11 15:31:39 +00:00
|
|
|
cmdline.Found("xrc-schema", &parSchemaFile);
|
2000-07-25 18:47:21 +00:00
|
|
|
|
2007-09-17 14:37:12 +00:00
|
|
|
if (!cmdline.Found("o", &parOutput))
|
2000-11-24 17:20:20 +00:00
|
|
|
{
|
|
|
|
if (flagGettext)
|
|
|
|
parOutput = wxEmptyString;
|
|
|
|
else
|
2002-08-14 11:02:39 +00:00
|
|
|
{
|
|
|
|
if (flagCPP)
|
2009-07-23 20:30:22 +00:00
|
|
|
parOutput = wxT("resource.cpp");
|
2002-08-14 11:02:39 +00:00
|
|
|
else if (flagPython)
|
2009-07-23 20:30:22 +00:00
|
|
|
parOutput = wxT("resource.py");
|
2002-08-14 11:02:39 +00:00
|
|
|
else
|
2009-07-23 20:30:22 +00:00
|
|
|
parOutput = wxT("resource.xrs");
|
2002-08-14 11:02:39 +00:00
|
|
|
}
|
2000-11-24 17:20:20 +00:00
|
|
|
}
|
2004-02-05 21:58:29 +00:00
|
|
|
if (!parOutput.empty())
|
|
|
|
{
|
|
|
|
wxFileName fn(parOutput);
|
|
|
|
fn.Normalize();
|
|
|
|
parOutput = fn.GetFullPath();
|
|
|
|
parOutputPath = wxPathOnly(parOutput);
|
|
|
|
}
|
2009-07-23 20:30:22 +00:00
|
|
|
if (!parOutputPath) parOutputPath = wxT(".");
|
2000-07-25 18:47:21 +00:00
|
|
|
|
2007-09-17 14:37:12 +00:00
|
|
|
if (!cmdline.Found("n", &parFuncname))
|
2009-07-23 20:30:22 +00:00
|
|
|
parFuncname = wxT("InitXmlResource");
|
2000-07-25 18:47:21 +00:00
|
|
|
|
|
|
|
for (size_t i = 0; i < cmdline.GetParamCount(); i++)
|
2003-07-21 22:23:09 +00:00
|
|
|
{
|
|
|
|
#ifdef __WINDOWS__
|
|
|
|
wxString fn=wxFindFirstFile(cmdline.GetParam(i), wxFILE);
|
2005-01-13 19:57:24 +00:00
|
|
|
while (!fn.empty())
|
2003-07-21 22:23:09 +00:00
|
|
|
{
|
|
|
|
parFiles.Add(fn);
|
|
|
|
fn=wxFindNextFile();
|
|
|
|
}
|
|
|
|
#else
|
2000-07-25 18:47:21 +00:00
|
|
|
parFiles.Add(cmdline.GetParam(i));
|
2003-07-21 22:23:09 +00:00
|
|
|
#endif
|
|
|
|
}
|
2000-07-25 18:47:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void XmlResApp::CompileRes()
|
|
|
|
{
|
|
|
|
wxArrayString files = PrepareTempFiles();
|
|
|
|
|
2013-04-04 16:15:13 +00:00
|
|
|
if ( wxFileExists(parOutput) )
|
|
|
|
wxRemoveFile(parOutput);
|
2000-07-25 18:47:21 +00:00
|
|
|
|
|
|
|
if (!retCode)
|
2004-06-11 13:14:23 +00:00
|
|
|
{
|
2004-02-05 21:58:29 +00:00
|
|
|
if (flagCPP){
|
2000-07-25 18:47:21 +00:00
|
|
|
MakePackageCPP(files);
|
2004-02-05 21:58:29 +00:00
|
|
|
if (flagH)
|
|
|
|
GenCPPHeader();
|
|
|
|
}
|
2002-08-14 11:02:39 +00:00
|
|
|
else if (flagPython)
|
|
|
|
MakePackagePython(files);
|
2000-07-25 18:47:21 +00:00
|
|
|
else
|
|
|
|
MakePackageZIP(files);
|
|
|
|
}
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2000-07-25 18:47:21 +00:00
|
|
|
DeleteTempFiles(files);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-22 23:33:12 +00:00
|
|
|
wxString XmlResApp::GetInternalFileName(const wxString& name, const wxArrayString& flist)
|
|
|
|
{
|
|
|
|
wxString name2 = name;
|
2009-07-23 20:30:22 +00:00
|
|
|
name2.Replace(wxT(":"), wxT("_"));
|
|
|
|
name2.Replace(wxT("/"), wxT("_"));
|
|
|
|
name2.Replace(wxT("\\"), wxT("_"));
|
|
|
|
name2.Replace(wxT("*"), wxT("_"));
|
|
|
|
name2.Replace(wxT("?"), wxT("_"));
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2009-07-23 20:30:22 +00:00
|
|
|
wxString s = wxFileNameFromPath(parOutput) + wxT("$") + name2;
|
2002-06-22 23:33:12 +00:00
|
|
|
|
|
|
|
if (wxFileExists(s) && flist.Index(s) == wxNOT_FOUND)
|
2004-06-11 13:14:23 +00:00
|
|
|
{
|
2002-06-22 23:33:12 +00:00
|
|
|
for (int i = 0;; i++)
|
|
|
|
{
|
2009-07-23 20:30:22 +00:00
|
|
|
s.Printf(wxFileNameFromPath(parOutput) + wxT("$%03i-") + name2, i);
|
2002-06-22 23:33:12 +00:00
|
|
|
if (!wxFileExists(s) || flist.Index(s) != wxNOT_FOUND)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
2000-07-25 18:47:21 +00:00
|
|
|
|
|
|
|
wxArrayString XmlResApp::PrepareTempFiles()
|
|
|
|
{
|
|
|
|
wxArrayString flist;
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2007-04-11 00:23:19 +00:00
|
|
|
for (size_t i = 0; i < parFiles.GetCount(); i++)
|
2000-07-25 18:47:21 +00:00
|
|
|
{
|
2004-06-11 13:14:23 +00:00
|
|
|
if (flagVerbose)
|
2009-07-23 20:30:22 +00:00
|
|
|
wxPrintf(wxT("processing ") + parFiles[i] + wxT("...\n"));
|
2000-07-25 18:47:21 +00:00
|
|
|
|
|
|
|
wxXmlDocument doc;
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2000-07-25 18:47:21 +00:00
|
|
|
if (!doc.Load(parFiles[i]))
|
|
|
|
{
|
2009-07-23 20:30:22 +00:00
|
|
|
wxLogError(wxT("Error parsing file ") + parFiles[i]);
|
2000-07-25 18:47:21 +00:00
|
|
|
retCode = 1;
|
|
|
|
continue;
|
|
|
|
}
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2000-08-11 19:07:43 +00:00
|
|
|
wxString name, ext, path;
|
2009-01-07 01:47:47 +00:00
|
|
|
wxFileName::SplitPath(parFiles[i], &path, &name, &ext);
|
2000-08-11 19:07:43 +00:00
|
|
|
|
|
|
|
FindFilesInXML(doc.GetRoot(), flist, path);
|
2004-02-05 21:58:29 +00:00
|
|
|
if (flagH)
|
|
|
|
{
|
|
|
|
wxXmlNode* node = (doc.GetRoot())->GetChildren();
|
2004-03-18 17:23:31 +00:00
|
|
|
wxString classValue,nameValue;
|
|
|
|
while(node){
|
2009-07-23 20:30:22 +00:00
|
|
|
if(node->GetName() == wxT("object")
|
|
|
|
&& node->GetAttribute(wxT("class"),&classValue)
|
|
|
|
&& node->GetAttribute(wxT("name"),&nameValue)){
|
2004-02-05 21:58:29 +00:00
|
|
|
|
|
|
|
aXRCWndClassData.Add(
|
2004-03-18 17:23:31 +00:00
|
|
|
XRCWndClassData(nameValue,classValue,node)
|
2004-02-05 21:58:29 +00:00
|
|
|
);
|
|
|
|
}
|
2004-03-18 17:23:31 +00:00
|
|
|
node = node -> GetNext();
|
2004-02-05 21:58:29 +00:00
|
|
|
}
|
|
|
|
}
|
2002-06-22 23:33:12 +00:00
|
|
|
wxString internalName = GetInternalFileName(parFiles[i], flist);
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2002-12-25 15:23:44 +00:00
|
|
|
doc.Save(parOutputPath + wxFILE_SEP_PATH + internalName);
|
2002-06-22 23:33:12 +00:00
|
|
|
flist.Add(internalName);
|
2000-07-25 18:47:21 +00:00
|
|
|
}
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2000-07-25 18:47:21 +00:00
|
|
|
return flist;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-25 15:23:44 +00:00
|
|
|
// Does 'node' contain filename information at all?
|
|
|
|
static bool NodeContainsFilename(wxXmlNode *node)
|
|
|
|
{
|
2006-03-21 15:12:37 +00:00
|
|
|
const wxString name = node->GetName();
|
|
|
|
|
|
|
|
// Any bitmaps (bitmap2 is used for disabled toolbar buttons):
|
2009-07-23 20:30:22 +00:00
|
|
|
if ( name == wxT("bitmap") || name == wxT("bitmap2") )
|
2004-06-11 13:14:23 +00:00
|
|
|
return true;
|
2005-01-13 19:57:24 +00:00
|
|
|
|
2009-07-23 20:30:22 +00:00
|
|
|
if ( name == wxT("icon") )
|
2004-10-31 11:42:27 +00:00
|
|
|
return true;
|
2002-12-25 15:23:44 +00:00
|
|
|
|
|
|
|
// wxBitmapButton:
|
|
|
|
wxXmlNode *parent = node->GetParent();
|
2004-06-11 13:14:23 +00:00
|
|
|
if (parent != NULL &&
|
2009-07-23 20:30:22 +00:00
|
|
|
parent->GetAttribute(wxT("class"), wxT("")) == wxT("wxBitmapButton") &&
|
|
|
|
(name == wxT("focus") ||
|
|
|
|
name == wxT("disabled") ||
|
|
|
|
name == wxT("hover") ||
|
|
|
|
name == wxT("selected")))
|
2004-06-11 13:14:23 +00:00
|
|
|
return true;
|
|
|
|
|
2002-12-25 15:23:44 +00:00
|
|
|
// wxBitmap or wxIcon toplevel resources:
|
2009-07-23 20:30:22 +00:00
|
|
|
if ( name == wxT("object") )
|
2002-12-25 15:23:44 +00:00
|
|
|
{
|
2009-07-23 20:30:22 +00:00
|
|
|
wxString klass = node->GetAttribute(wxT("class"), wxEmptyString);
|
|
|
|
if (klass == wxT("wxBitmap") ||
|
|
|
|
klass == wxT("wxIcon") ||
|
|
|
|
klass == wxT("data") )
|
2004-06-11 13:14:23 +00:00
|
|
|
return true;
|
2002-12-25 15:23:44 +00:00
|
|
|
}
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2014-08-04 18:58:15 +00:00
|
|
|
// wxAnimationCtrl animations:
|
|
|
|
if ( name == wxS("animation") )
|
|
|
|
return true;
|
|
|
|
|
2007-06-25 12:16:20 +00:00
|
|
|
// URLs in wxHtmlWindow:
|
2009-07-23 20:30:22 +00:00
|
|
|
if ( name == wxT("url") &&
|
2007-06-25 12:16:20 +00:00
|
|
|
parent != NULL &&
|
2009-07-23 20:30:22 +00:00
|
|
|
parent->GetAttribute(wxT("class"), wxT("")) == wxT("wxHtmlWindow") )
|
2007-06-25 12:16:20 +00:00
|
|
|
{
|
|
|
|
// FIXME: this is wrong for e.g. http:// URLs
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-06-11 13:14:23 +00:00
|
|
|
return false;
|
2002-12-25 15:23:44 +00:00
|
|
|
}
|
2000-07-25 18:47:21 +00:00
|
|
|
|
2000-08-11 19:07:43 +00:00
|
|
|
// find all files mentioned in structure, e.g. <bitmap>filename</bitmap>
|
|
|
|
void XmlResApp::FindFilesInXML(wxXmlNode *node, wxArrayString& flist, const wxString& inputPath)
|
|
|
|
{
|
2002-12-04 14:11:26 +00:00
|
|
|
// Is 'node' XML node element?
|
|
|
|
if (node == NULL) return;
|
|
|
|
if (node->GetType() != wxXML_ELEMENT_NODE) return;
|
|
|
|
|
2002-12-25 15:23:44 +00:00
|
|
|
bool containsFilename = NodeContainsFilename(node);
|
2002-12-04 14:11:26 +00:00
|
|
|
|
|
|
|
wxXmlNode *n = node->GetChildren();
|
2000-08-11 19:07:43 +00:00
|
|
|
while (n)
|
|
|
|
{
|
2002-12-04 14:11:26 +00:00
|
|
|
if (containsFilename &&
|
2004-06-11 13:14:23 +00:00
|
|
|
(n->GetType() == wxXML_TEXT_NODE ||
|
2002-12-04 14:11:26 +00:00
|
|
|
n->GetType() == wxXML_CDATA_SECTION_NODE))
|
2000-08-11 19:07:43 +00:00
|
|
|
{
|
|
|
|
wxString fullname;
|
2002-12-04 14:11:26 +00:00
|
|
|
if (wxIsAbsolutePath(n->GetContent()) || inputPath.empty())
|
|
|
|
fullname = n->GetContent();
|
|
|
|
else
|
2002-12-25 15:23:44 +00:00
|
|
|
fullname = inputPath + wxFILE_SEP_PATH + n->GetContent();
|
2002-06-22 23:33:12 +00:00
|
|
|
|
2004-06-11 13:14:23 +00:00
|
|
|
if (flagVerbose)
|
2009-07-23 20:30:22 +00:00
|
|
|
wxPrintf(wxT("adding ") + fullname + wxT("...\n"));
|
2002-12-04 14:11:26 +00:00
|
|
|
|
2002-06-22 23:33:12 +00:00
|
|
|
wxString filename = GetInternalFileName(n->GetContent(), flist);
|
2000-08-11 19:07:43 +00:00
|
|
|
n->SetContent(filename);
|
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
if (flist.Index(filename) == wxNOT_FOUND)
|
|
|
|
flist.Add(filename);
|
2000-08-11 19:07:43 +00:00
|
|
|
|
|
|
|
wxFileInputStream sin(fullname);
|
2002-12-25 15:23:44 +00:00
|
|
|
wxFileOutputStream sout(parOutputPath + wxFILE_SEP_PATH + filename);
|
2000-08-11 19:07:43 +00:00
|
|
|
sin.Read(sout); // copy the stream
|
|
|
|
}
|
2002-12-04 14:11:26 +00:00
|
|
|
|
2000-08-11 19:07:43 +00:00
|
|
|
// subnodes:
|
|
|
|
if (n->GetType() == wxXML_ELEMENT_NODE)
|
|
|
|
FindFilesInXML(n, flist, inputPath);
|
2002-12-04 14:11:26 +00:00
|
|
|
|
2000-08-11 19:07:43 +00:00
|
|
|
n = n->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-07-25 18:47:21 +00:00
|
|
|
void XmlResApp::DeleteTempFiles(const wxArrayString& flist)
|
|
|
|
{
|
2007-04-11 00:23:19 +00:00
|
|
|
for (size_t i = 0; i < flist.GetCount(); i++)
|
2002-12-25 15:23:44 +00:00
|
|
|
wxRemoveFile(parOutputPath + wxFILE_SEP_PATH + flist[i]);
|
2000-07-25 18:47:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void XmlResApp::MakePackageZIP(const wxArrayString& flist)
|
|
|
|
{
|
|
|
|
wxString files;
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2007-04-11 00:23:19 +00:00
|
|
|
for (size_t i = 0; i < flist.GetCount(); i++)
|
2009-07-23 20:30:22 +00:00
|
|
|
files += flist[i] + wxT(" ");
|
2000-07-25 18:47:21 +00:00
|
|
|
files.RemoveLast();
|
2004-06-11 13:14:23 +00:00
|
|
|
|
|
|
|
if (flagVerbose)
|
2009-07-23 20:30:22 +00:00
|
|
|
wxPrintf(wxT("compressing ") + parOutput + wxT("...\n"));
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2002-12-25 15:23:44 +00:00
|
|
|
wxString cwd = wxGetCwd();
|
|
|
|
wxSetWorkingDirectory(parOutputPath);
|
2009-07-23 20:30:22 +00:00
|
|
|
int execres = wxExecute(wxT("zip -9 -j ") +
|
|
|
|
wxString(flagVerbose ? wxT("\"") : wxT("-q \"")) +
|
2013-10-11 15:31:36 +00:00
|
|
|
parOutput + wxT("\" ") + files,
|
|
|
|
wxEXEC_BLOCK);
|
2002-12-25 15:23:44 +00:00
|
|
|
wxSetWorkingDirectory(cwd);
|
|
|
|
if (execres == -1)
|
2000-07-25 18:47:21 +00:00
|
|
|
{
|
2009-07-23 20:30:22 +00:00
|
|
|
wxLogError(wxT("Unable to execute zip program. Make sure it is in the path."));
|
|
|
|
wxLogError(wxT("You can download it at http://www.cdrom.com/pub/infozip/"));
|
2000-07-25 18:47:21 +00:00
|
|
|
retCode = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static wxString FileToCppArray(wxString filename, int num)
|
|
|
|
{
|
|
|
|
wxString output;
|
|
|
|
wxString tmp;
|
2000-08-11 19:07:43 +00:00
|
|
|
wxString snum;
|
2003-03-16 20:27:15 +00:00
|
|
|
wxFFile file(filename, wxT("rb"));
|
2005-01-13 19:57:24 +00:00
|
|
|
wxFileOffset offset = file.Length();
|
|
|
|
wxASSERT_MSG( offset >= 0 , wxT("Invalid file length") );
|
2005-09-25 19:59:19 +00:00
|
|
|
|
|
|
|
const size_t lng = wx_truncate_cast(size_t, offset);
|
2008-11-02 02:43:11 +00:00
|
|
|
wxASSERT_MSG( static_cast<wxFileOffset>(lng) == offset,
|
2008-01-21 13:53:37 +00:00
|
|
|
wxT("Huge file not supported") );
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2009-07-23 20:30:22 +00:00
|
|
|
snum.Printf(wxT("%i"), num);
|
2010-07-23 23:32:30 +00:00
|
|
|
output.Printf(wxT("static size_t xml_res_size_") + snum + wxT(" = %lu;\n"),
|
|
|
|
static_cast<unsigned long>(lng));
|
2009-07-23 20:30:22 +00:00
|
|
|
output += wxT("static unsigned char xml_res_file_") + snum + wxT("[] = {\n");
|
2000-10-07 21:56:37 +00:00
|
|
|
// we cannot use string literals because MSVC is dumb wannabe compiler
|
|
|
|
// with arbitrary limitation to 2048 strings :(
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2000-07-25 18:47:21 +00:00
|
|
|
unsigned char *buffer = new unsigned char[lng];
|
|
|
|
file.Read(buffer, lng);
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2000-08-11 19:07:43 +00:00
|
|
|
for (size_t i = 0, linelng = 0; i < lng; i++)
|
2000-07-25 18:47:21 +00:00
|
|
|
{
|
2009-07-23 20:30:22 +00:00
|
|
|
tmp.Printf(wxT("%i"), buffer[i]);
|
|
|
|
if (i != 0) output << wxT(',');
|
2000-10-07 21:56:37 +00:00
|
|
|
if (linelng > 70)
|
2000-08-11 19:07:43 +00:00
|
|
|
{
|
|
|
|
linelng = 0;
|
2009-07-23 20:30:22 +00:00
|
|
|
output << wxT("\n");
|
2000-08-11 19:07:43 +00:00
|
|
|
}
|
2000-10-07 21:56:37 +00:00
|
|
|
output << tmp;
|
|
|
|
linelng += tmp.Length()+1;
|
2000-07-25 18:47:21 +00:00
|
|
|
}
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2000-07-25 18:47:21 +00:00
|
|
|
delete[] buffer;
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2009-07-23 20:30:22 +00:00
|
|
|
output += wxT("};\n\n");
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2000-07-25 18:47:21 +00:00
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void XmlResApp::MakePackageCPP(const wxArrayString& flist)
|
|
|
|
{
|
2003-03-16 20:27:15 +00:00
|
|
|
wxFFile file(parOutput, wxT("wt"));
|
2010-07-03 14:24:27 +00:00
|
|
|
unsigned i;
|
2000-07-25 18:47:21 +00:00
|
|
|
|
2004-06-11 13:14:23 +00:00
|
|
|
if (flagVerbose)
|
2009-07-23 20:30:22 +00:00
|
|
|
wxPrintf(wxT("creating C++ source file ") + parOutput + wxT("...\n"));
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2007-06-18 20:22:08 +00:00
|
|
|
file.Write(""
|
|
|
|
"//\n"
|
|
|
|
"// This file was automatically generated by wxrc, do not edit by hand.\n"
|
|
|
|
"//\n\n"
|
|
|
|
"#include <wx/wxprec.h>\n"
|
|
|
|
"\n"
|
|
|
|
"#ifdef __BORLANDC__\n"
|
|
|
|
" #pragma hdrstop\n"
|
|
|
|
"#endif\n"
|
|
|
|
"\n"
|
|
|
|
""
|
|
|
|
"#include <wx/filesys.h>\n"
|
|
|
|
"#include <wx/fs_mem.h>\n"
|
|
|
|
"#include <wx/xrc/xmlres.h>\n"
|
|
|
|
"#include <wx/xrc/xh_all.h>\n"
|
|
|
|
"\n"
|
|
|
|
"#if wxCHECK_VERSION(2,8,5) && wxABI_VERSION >= 20805\n"
|
|
|
|
" #define XRC_ADD_FILE(name, data, size, mime) \\\n"
|
|
|
|
" wxMemoryFSHandler::AddFileWithMimeType(name, data, size, mime)\n"
|
|
|
|
"#else\n"
|
|
|
|
" #define XRC_ADD_FILE(name, data, size, mime) \\\n"
|
|
|
|
" wxMemoryFSHandler::AddFile(name, data, size)\n"
|
|
|
|
"#endif\n"
|
|
|
|
"\n");
|
2000-07-25 18:47:21 +00:00
|
|
|
|
2007-04-11 00:23:19 +00:00
|
|
|
for (i = 0; i < flist.GetCount(); i++)
|
2002-12-25 15:23:44 +00:00
|
|
|
file.Write(
|
|
|
|
FileToCppArray(parOutputPath + wxFILE_SEP_PATH + flist[i], i));
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2007-06-18 20:22:08 +00:00
|
|
|
file.Write(""
|
2007-06-18 20:30:20 +00:00
|
|
|
"void " + parFuncname + "()\n"
|
2007-06-18 20:22:08 +00:00
|
|
|
"{\n"
|
|
|
|
"\n"
|
|
|
|
" // Check for memory FS. If not present, load the handler:\n"
|
|
|
|
" {\n"
|
|
|
|
" wxMemoryFSHandler::AddFile(wxT(\"XRC_resource/dummy_file\"), wxT(\"dummy one\"));\n"
|
|
|
|
" wxFileSystem fsys;\n"
|
|
|
|
" wxFSFile *f = fsys.OpenFile(wxT(\"memory:XRC_resource/dummy_file\"));\n"
|
|
|
|
" wxMemoryFSHandler::RemoveFile(wxT(\"XRC_resource/dummy_file\"));\n"
|
|
|
|
" if (f) delete f;\n"
|
|
|
|
" else wxFileSystem::AddHandler(new wxMemoryFSHandler);\n"
|
|
|
|
" }\n"
|
|
|
|
"\n");
|
2000-07-25 18:47:21 +00:00
|
|
|
|
2007-04-11 00:23:19 +00:00
|
|
|
for (i = 0; i < flist.GetCount(); i++)
|
2000-07-25 18:47:21 +00:00
|
|
|
{
|
|
|
|
wxString s;
|
2007-06-18 18:43:34 +00:00
|
|
|
|
|
|
|
wxString mime;
|
|
|
|
wxString ext = wxFileName(flist[i]).GetExt();
|
2009-07-23 20:30:22 +00:00
|
|
|
if ( ext.Lower() == wxT("xrc") )
|
|
|
|
mime = wxT("text/xml");
|
2007-10-02 11:25:29 +00:00
|
|
|
#if wxUSE_MIMETYPE
|
2007-06-18 18:43:34 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);
|
|
|
|
if ( ft )
|
2007-10-02 11:25:29 +00:00
|
|
|
{
|
2007-06-18 18:43:34 +00:00
|
|
|
ft->GetMimeType(&mime);
|
2007-10-02 11:25:29 +00:00
|
|
|
delete ft;
|
|
|
|
}
|
2007-06-18 18:43:34 +00:00
|
|
|
}
|
2007-10-02 11:25:29 +00:00
|
|
|
#endif // wxUSE_MIMETYPE
|
2007-06-18 18:43:34 +00:00
|
|
|
|
2007-06-18 20:22:08 +00:00
|
|
|
s.Printf(" XRC_ADD_FILE(wxT(\"XRC_resource/" + flist[i] +
|
2010-07-03 14:24:27 +00:00
|
|
|
"\"), xml_res_file_%u, xml_res_size_%u, wxT(\"%s\"));\n",
|
2007-06-18 18:43:34 +00:00
|
|
|
i, i, mime.c_str());
|
2000-07-25 18:47:21 +00:00
|
|
|
file.Write(s);
|
|
|
|
}
|
2000-08-11 19:07:43 +00:00
|
|
|
|
2007-04-11 00:23:19 +00:00
|
|
|
for (i = 0; i < parFiles.GetCount(); i++)
|
2000-08-11 19:07:43 +00:00
|
|
|
{
|
2007-06-18 20:22:08 +00:00
|
|
|
file.Write(" wxXmlResource::Get()->Load(wxT(\"memory:XRC_resource/" +
|
|
|
|
GetInternalFileName(parFiles[i], flist) + "\"));\n");
|
2000-08-11 19:07:43 +00:00
|
|
|
}
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2007-06-18 20:22:08 +00:00
|
|
|
file.Write("}\n");
|
2000-07-25 18:47:21 +00:00
|
|
|
|
2000-08-11 19:07:43 +00:00
|
|
|
|
2000-07-25 18:47:21 +00:00
|
|
|
}
|
2000-11-24 17:20:20 +00:00
|
|
|
|
2004-02-05 21:58:29 +00:00
|
|
|
void XmlResApp::GenCPPHeader()
|
|
|
|
{
|
2010-10-24 14:34:22 +00:00
|
|
|
// Generate the output header in the same directory as the source file.
|
|
|
|
wxFileName headerName(parOutput);
|
|
|
|
headerName.SetExt("h");
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2010-10-24 14:34:22 +00:00
|
|
|
wxFFile file(headerName.GetFullPath(), wxT("wt"));
|
2004-02-05 21:58:29 +00:00
|
|
|
file.Write(
|
2007-06-18 20:22:08 +00:00
|
|
|
"//\n"
|
|
|
|
"// This file was automatically generated by wxrc, do not edit by hand.\n"
|
|
|
|
"//\n\n"
|
2010-10-24 14:34:22 +00:00
|
|
|
"#ifndef __" + headerName.GetName() + "_h__\n"
|
|
|
|
"#define __" + headerName.GetName() + "_h__\n"
|
2004-06-11 13:14:23 +00:00
|
|
|
);
|
2007-04-11 00:23:19 +00:00
|
|
|
for(size_t i=0;i<aXRCWndClassData.GetCount();++i){
|
2004-06-11 13:14:23 +00:00
|
|
|
aXRCWndClassData.Item(i).GenerateHeaderCode(file);
|
|
|
|
}
|
2004-02-05 21:58:29 +00:00
|
|
|
file.Write(
|
2007-06-18 20:22:08 +00:00
|
|
|
"\nvoid \n"
|
2004-03-18 17:23:31 +00:00
|
|
|
+ parFuncname
|
2007-06-18 20:22:08 +00:00
|
|
|
+ "();\n#endif\n");
|
2004-02-05 21:58:29 +00:00
|
|
|
}
|
|
|
|
|
2002-08-14 11:02:39 +00:00
|
|
|
static wxString FileToPythonArray(wxString filename, int num)
|
|
|
|
{
|
|
|
|
wxString output;
|
|
|
|
wxString tmp;
|
|
|
|
wxString snum;
|
2003-03-16 20:27:15 +00:00
|
|
|
wxFFile file(filename, wxT("rb"));
|
2005-01-13 19:57:24 +00:00
|
|
|
wxFileOffset offset = file.Length();
|
|
|
|
wxASSERT_MSG( offset >= 0 , wxT("Invalid file length") );
|
2005-09-25 19:59:19 +00:00
|
|
|
|
|
|
|
const size_t lng = wx_truncate_cast(size_t, offset);
|
2008-11-02 02:43:11 +00:00
|
|
|
wxASSERT_MSG( static_cast<wxFileOffset>(lng) == offset,
|
2008-01-21 13:53:37 +00:00
|
|
|
wxT("Huge file not supported") );
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2009-07-23 20:30:22 +00:00
|
|
|
snum.Printf(wxT("%i"), num);
|
2007-06-18 20:30:20 +00:00
|
|
|
output = " xml_res_file_" + snum + " = '''\\\n";
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2002-08-14 11:02:39 +00:00
|
|
|
unsigned char *buffer = new unsigned char[lng];
|
|
|
|
file.Read(buffer, lng);
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2002-08-14 11:02:39 +00:00
|
|
|
for (size_t i = 0, linelng = 0; i < lng; i++)
|
|
|
|
{
|
|
|
|
unsigned char c = buffer[i];
|
|
|
|
if (c == '\n')
|
|
|
|
{
|
|
|
|
tmp = (wxChar)c;
|
|
|
|
linelng = 0;
|
|
|
|
}
|
2004-09-29 00:20:27 +00:00
|
|
|
else if (c < 32 || c > 127 || c == '\'')
|
2009-07-23 20:30:22 +00:00
|
|
|
tmp.Printf(wxT("\\x%02x"), c);
|
2002-08-14 11:02:39 +00:00
|
|
|
else if (c == '\\')
|
2009-07-23 20:30:22 +00:00
|
|
|
tmp = wxT("\\\\");
|
2002-08-14 11:02:39 +00:00
|
|
|
else
|
|
|
|
tmp = (wxChar)c;
|
|
|
|
if (linelng > 70)
|
|
|
|
{
|
|
|
|
linelng = 0;
|
2009-07-23 20:30:22 +00:00
|
|
|
output << wxT("\\\n");
|
2002-08-14 11:02:39 +00:00
|
|
|
}
|
|
|
|
output << tmp;
|
|
|
|
linelng += tmp.Length();
|
|
|
|
}
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2002-08-14 11:02:39 +00:00
|
|
|
delete[] buffer;
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2009-07-23 20:30:22 +00:00
|
|
|
output += wxT("'''\n\n");
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2002-08-14 11:02:39 +00:00
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void XmlResApp::MakePackagePython(const wxArrayString& flist)
|
|
|
|
{
|
2003-03-16 20:27:15 +00:00
|
|
|
wxFFile file(parOutput, wxT("wt"));
|
2010-07-03 14:24:27 +00:00
|
|
|
unsigned i;
|
2002-08-14 11:02:39 +00:00
|
|
|
|
2004-06-11 13:14:23 +00:00
|
|
|
if (flagVerbose)
|
2009-07-23 20:30:22 +00:00
|
|
|
wxPrintf(wxT("creating Python source file ") + parOutput + wxT("...\n"));
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2002-08-14 11:02:39 +00:00
|
|
|
file.Write(
|
2007-06-18 20:22:08 +00:00
|
|
|
"#\n"
|
|
|
|
"# This file was automatically generated by wxrc, do not edit by hand.\n"
|
|
|
|
"#\n\n"
|
|
|
|
"import wx\n"
|
|
|
|
"import wx.xrc\n\n"
|
2002-08-14 11:02:39 +00:00
|
|
|
);
|
|
|
|
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2007-06-18 20:30:20 +00:00
|
|
|
file.Write("def " + parFuncname + "():\n");
|
2002-08-14 11:02:39 +00:00
|
|
|
|
2007-04-11 00:23:19 +00:00
|
|
|
for (i = 0; i < flist.GetCount(); i++)
|
2002-12-25 15:23:44 +00:00
|
|
|
file.Write(
|
|
|
|
FileToPythonArray(parOutputPath + wxFILE_SEP_PATH + flist[i], i));
|
2002-08-14 11:02:39 +00:00
|
|
|
|
2005-01-13 19:57:24 +00:00
|
|
|
file.Write(
|
2007-06-18 20:22:08 +00:00
|
|
|
" # check if the memory filesystem handler has been loaded yet, and load it if not\n"
|
|
|
|
" wx.MemoryFSHandler.AddFile('XRC_resource/dummy_file', 'dummy value')\n"
|
|
|
|
" fsys = wx.FileSystem()\n"
|
|
|
|
" f = fsys.OpenFile('memory:XRC_resource/dummy_file')\n"
|
|
|
|
" wx.MemoryFSHandler.RemoveFile('XRC_resource/dummy_file')\n"
|
|
|
|
" if f is not None:\n"
|
|
|
|
" f.Destroy()\n"
|
|
|
|
" else:\n"
|
|
|
|
" wx.FileSystem.AddHandler(wx.MemoryFSHandler())\n"
|
|
|
|
"\n"
|
|
|
|
" # load all the strings as memory files and load into XmlRes\n"
|
2004-09-29 00:15:21 +00:00
|
|
|
);
|
|
|
|
|
2005-01-13 19:57:24 +00:00
|
|
|
|
2007-04-11 00:23:19 +00:00
|
|
|
for (i = 0; i < flist.GetCount(); i++)
|
2002-08-14 11:02:39 +00:00
|
|
|
{
|
|
|
|
wxString s;
|
2007-06-18 20:22:08 +00:00
|
|
|
s.Printf(" wx.MemoryFSHandler.AddFile('XRC_resource/" + flist[i] +
|
2010-07-03 14:24:27 +00:00
|
|
|
"', xml_res_file_%u)\n", i);
|
2002-08-14 11:02:39 +00:00
|
|
|
file.Write(s);
|
|
|
|
}
|
2007-04-11 00:23:19 +00:00
|
|
|
for (i = 0; i < parFiles.GetCount(); i++)
|
2004-09-29 00:15:21 +00:00
|
|
|
{
|
2007-06-18 20:22:08 +00:00
|
|
|
file.Write(" wx.xrc.XmlResource.Get().Load('memory:XRC_resource/" +
|
|
|
|
GetInternalFileName(parFiles[i], flist) + "')\n");
|
2004-09-29 00:15:21 +00:00
|
|
|
}
|
|
|
|
|
2007-06-18 20:22:08 +00:00
|
|
|
file.Write("\n");
|
2002-08-14 11:02:39 +00:00
|
|
|
}
|
|
|
|
|
2000-11-24 17:20:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
void XmlResApp::OutputGettext()
|
|
|
|
{
|
2007-09-30 11:11:51 +00:00
|
|
|
ExtractedStrings str = FindStrings();
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2000-11-24 17:20:20 +00:00
|
|
|
wxFFile fout;
|
2004-02-05 21:58:29 +00:00
|
|
|
if (parOutput.empty())
|
|
|
|
fout.Attach(stdout);
|
|
|
|
else
|
|
|
|
fout.Open(parOutput, wxT("wt"));
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2007-09-30 11:11:51 +00:00
|
|
|
for (ExtractedStrings::const_iterator i = str.begin(); i != str.end(); ++i)
|
|
|
|
{
|
2010-05-30 16:53:20 +00:00
|
|
|
const wxFileName filename(i->filename);
|
|
|
|
|
2007-09-30 11:11:51 +00:00
|
|
|
wxString s;
|
2010-05-30 16:53:20 +00:00
|
|
|
s.Printf("#line %d \"%s\"\n",
|
|
|
|
i->lineNo, filename.GetFullPath(wxPATH_UNIX));
|
2007-09-30 11:11:51 +00:00
|
|
|
|
|
|
|
fout.Write(s);
|
|
|
|
fout.Write("_(\"" + i->str + "\");\n");
|
|
|
|
}
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2000-11-24 17:20:20 +00:00
|
|
|
if (!parOutput) fout.Detach();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-09-30 11:11:51 +00:00
|
|
|
ExtractedStrings XmlResApp::FindStrings()
|
2000-11-24 17:20:20 +00:00
|
|
|
{
|
2007-09-30 11:11:51 +00:00
|
|
|
ExtractedStrings arr, a2;
|
2000-11-24 17:20:20 +00:00
|
|
|
|
2007-04-11 00:23:19 +00:00
|
|
|
for (size_t i = 0; i < parFiles.GetCount(); i++)
|
2000-11-24 17:20:20 +00:00
|
|
|
{
|
2004-06-11 13:14:23 +00:00
|
|
|
if (flagVerbose)
|
2009-07-23 20:30:22 +00:00
|
|
|
wxPrintf(wxT("processing ") + parFiles[i] + wxT("...\n"));
|
2000-11-24 17:20:20 +00:00
|
|
|
|
2004-06-11 13:14:23 +00:00
|
|
|
wxXmlDocument doc;
|
2000-11-24 17:20:20 +00:00
|
|
|
if (!doc.Load(parFiles[i]))
|
|
|
|
{
|
2009-07-23 20:30:22 +00:00
|
|
|
wxLogError(wxT("Error parsing file ") + parFiles[i]);
|
2000-11-24 17:20:20 +00:00
|
|
|
retCode = 1;
|
|
|
|
continue;
|
|
|
|
}
|
2007-09-30 11:11:51 +00:00
|
|
|
a2 = FindStrings(parFiles[i], doc.GetRoot());
|
|
|
|
|
2000-11-24 17:20:20 +00:00
|
|
|
WX_APPEND_ARRAY(arr, a2);
|
|
|
|
}
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2000-11-24 17:20:20 +00:00
|
|
|
return arr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-03-09 16:35:00 +00:00
|
|
|
static wxString ConvertText(const wxString& str)
|
|
|
|
{
|
|
|
|
wxString str2;
|
|
|
|
const wxChar *dt;
|
|
|
|
|
|
|
|
for (dt = str.c_str(); *dt; dt++)
|
|
|
|
{
|
|
|
|
if (*dt == wxT('_'))
|
|
|
|
{
|
2012-01-15 17:45:14 +00:00
|
|
|
if ( *(dt+1) == 0 )
|
|
|
|
str2 << wxT('_');
|
|
|
|
else if ( *(++dt) == wxT('_') )
|
2002-03-09 16:35:00 +00:00
|
|
|
str2 << wxT('_');
|
|
|
|
else
|
|
|
|
str2 << wxT('&') << *dt;
|
|
|
|
}
|
2004-06-11 13:14:23 +00:00
|
|
|
else
|
2002-03-09 16:35:00 +00:00
|
|
|
{
|
|
|
|
switch (*dt)
|
|
|
|
{
|
|
|
|
case wxT('\n') : str2 << wxT("\\n"); break;
|
|
|
|
case wxT('\t') : str2 << wxT("\\t"); break;
|
|
|
|
case wxT('\r') : str2 << wxT("\\r"); break;
|
2002-12-04 14:11:26 +00:00
|
|
|
case wxT('\\') : if ((*(dt+1) != 'n') &&
|
|
|
|
(*(dt+1) != 't') &&
|
|
|
|
(*(dt+1) != 'r'))
|
|
|
|
str2 << wxT("\\\\");
|
|
|
|
else
|
2004-06-11 13:14:23 +00:00
|
|
|
str2 << wxT("\\");
|
2002-12-04 14:11:26 +00:00
|
|
|
break;
|
2002-08-23 18:52:31 +00:00
|
|
|
case wxT('"') : str2 << wxT("\\\""); break;
|
2002-03-09 16:35:00 +00:00
|
|
|
default : str2 << *dt; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return str2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-10 23:27:08 +00:00
|
|
|
enum ContentsKind
|
|
|
|
{
|
|
|
|
Contents_NotTrans, // Not a translatable text at all.
|
|
|
|
Contents_TransOnly, // Translatable but not escaped text.
|
|
|
|
Contents_Text // Text, i.e. both translatable and escaped.
|
|
|
|
};
|
|
|
|
|
|
|
|
// Check if the given node contains translatable text and, if it does, whether
|
|
|
|
// it's escaped (i.e. parsed using GetText()) or not.
|
|
|
|
ContentsKind
|
|
|
|
GetNodeContentsKind(wxXmlNode& node, const wxString& contents)
|
|
|
|
{
|
|
|
|
if ( node.GetName() == wxT("label") ||
|
|
|
|
(node.GetName() == wxT("value") && !contents.IsNumber()) ||
|
|
|
|
node.GetName() == wxT("help") ||
|
|
|
|
node.GetName() == wxT("hint") ||
|
|
|
|
node.GetName() == wxT("longhelp") ||
|
|
|
|
node.GetName() == wxT("tooltip") ||
|
|
|
|
node.GetName() == wxT("htmlcode") ||
|
|
|
|
node.GetName() == wxT("title") ||
|
|
|
|
node.GetName() == wxT("message") ||
|
|
|
|
node.GetName() == wxT("note") ||
|
|
|
|
node.GetName() == wxT("defaultdirectory") ||
|
|
|
|
node.GetName() == wxT("defaultfilename") ||
|
|
|
|
node.GetName() == wxT("defaultfolder") ||
|
|
|
|
node.GetName() == wxT("filter") ||
|
|
|
|
node.GetName() == wxT("caption") )
|
|
|
|
{
|
|
|
|
return Contents_Text;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This one is special: it is translated in XRC, but its contents is not
|
2018-01-11 00:14:47 +00:00
|
|
|
// escaped, except for the special case of wxRadioBox when it can be, if
|
|
|
|
// "label" attribute is supplied.
|
2018-01-10 23:27:08 +00:00
|
|
|
if ( node.GetName() == wxT("item") )
|
2018-01-11 00:14:47 +00:00
|
|
|
{
|
|
|
|
return node.GetAttribute(wxT("label"), wxT("0")) == wxT("1")
|
|
|
|
? Contents_Text
|
|
|
|
: Contents_TransOnly;
|
|
|
|
}
|
2018-01-10 23:27:08 +00:00
|
|
|
|
|
|
|
return Contents_NotTrans;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-30 11:11:51 +00:00
|
|
|
ExtractedStrings
|
|
|
|
XmlResApp::FindStrings(const wxString& filename, wxXmlNode *node)
|
2000-11-24 17:20:20 +00:00
|
|
|
{
|
2007-09-30 11:11:51 +00:00
|
|
|
ExtractedStrings arr;
|
2000-11-24 17:20:20 +00:00
|
|
|
|
|
|
|
wxXmlNode *n = node;
|
|
|
|
if (n == NULL) return arr;
|
|
|
|
n = n->GetChildren();
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2000-11-24 17:20:20 +00:00
|
|
|
while (n)
|
|
|
|
{
|
|
|
|
if ((node->GetType() == wxXML_ELEMENT_NODE) &&
|
|
|
|
// parent is an element, i.e. has subnodes...
|
2004-06-11 13:14:23 +00:00
|
|
|
(n->GetType() == wxXML_TEXT_NODE ||
|
2018-01-10 23:27:08 +00:00
|
|
|
n->GetType() == wxXML_CDATA_SECTION_NODE))
|
2000-11-24 17:20:20 +00:00
|
|
|
// ...it is textnode...
|
|
|
|
{
|
2018-01-10 23:27:08 +00:00
|
|
|
wxString s = n->GetContent();
|
|
|
|
switch ( GetNodeContentsKind(*node, s) )
|
2004-08-29 18:27:51 +00:00
|
|
|
{
|
2018-01-10 23:27:08 +00:00
|
|
|
case Contents_NotTrans:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Contents_Text:
|
|
|
|
s = ConvertText(s);
|
|
|
|
wxFALLTHROUGH;
|
|
|
|
|
|
|
|
case Contents_TransOnly:
|
|
|
|
if (!flagGettext ||
|
|
|
|
node->GetAttribute(wxT("translate"), wxT("1")) != wxT("0"))
|
|
|
|
{
|
|
|
|
arr.push_back(ExtractedString(s, filename, n->GetLineNumber()));
|
|
|
|
}
|
|
|
|
break;
|
2004-08-29 18:27:51 +00:00
|
|
|
}
|
2000-11-24 17:20:20 +00:00
|
|
|
}
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2000-11-24 17:20:20 +00:00
|
|
|
// subnodes:
|
|
|
|
if (n->GetType() == wxXML_ELEMENT_NODE)
|
|
|
|
{
|
2007-09-30 11:11:51 +00:00
|
|
|
ExtractedStrings a2 = FindStrings(filename, n);
|
2000-11-24 17:20:20 +00:00
|
|
|
WX_APPEND_ARRAY(arr, a2);
|
|
|
|
}
|
2004-06-11 13:14:23 +00:00
|
|
|
|
2000-11-24 17:20:20 +00:00
|
|
|
n = n->GetNext();
|
|
|
|
}
|
|
|
|
return arr;
|
|
|
|
}
|
2013-10-11 15:31:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool XmlResApp::Validate()
|
|
|
|
{
|
|
|
|
if ( flagVerbose )
|
|
|
|
wxPuts("validating XRC files...");
|
|
|
|
|
|
|
|
wxString schemaURI;
|
|
|
|
|
|
|
|
if ( !parSchemaFile.empty() )
|
|
|
|
{
|
|
|
|
schemaURI = parSchemaFile;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
schemaURI = "http://www.wxwidgets.org/wxxrc";
|
|
|
|
|
|
|
|
// Normally, we'd use an OASIS XML catalog to map the URI to a local copy,
|
|
|
|
// but Jing's catalog support (-C catalogFile) requires additional
|
|
|
|
// dependency, resolver.jar, that is not commonly installed alongside Jing
|
|
|
|
// by systems that package Jing. So do the (trivial) mapping manually here:
|
|
|
|
wxString wxWinRoot;
|
|
|
|
if ( wxGetEnv("WXWIN", &wxWinRoot) )
|
|
|
|
{
|
|
|
|
wxString schemaFile(wxWinRoot + "/misc/schema/xrc_schema.rnc");
|
|
|
|
if ( wxFileExists(schemaFile) )
|
|
|
|
schemaURI = schemaFile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString cmdline = wxString::Format("jing -c \"%s\"", schemaURI);
|
|
|
|
for ( size_t i = 0; i < parFiles.GetCount(); i++ )
|
|
|
|
cmdline << wxString::Format(" \"%s\"", parFiles[i]);
|
|
|
|
|
|
|
|
int res = wxExecute(cmdline, wxEXEC_BLOCK);
|
|
|
|
if (res == -1)
|
|
|
|
{
|
|
|
|
wxLogError("Running RELAX NG validator failed.");
|
|
|
|
wxLogError("Please install Jing (http://www.thaiopensource.com/relaxng/jing.html).");
|
2015-02-21 03:07:15 +00:00
|
|
|
wxLogError("See https://github.com/wxWidgets/wxWidgets/blob/master/misc/schema/README for more information.");
|
2013-10-11 15:31:39 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( flagVerbose )
|
|
|
|
{
|
|
|
|
if ( res == 0 )
|
|
|
|
wxPuts("XRC validation passed without errors.");
|
|
|
|
else
|
|
|
|
wxPuts("XRC validation failed, there are errors.");
|
|
|
|
}
|
|
|
|
|
|
|
|
return res == 0;
|
|
|
|
}
|