- file.Write("\
-void " + parFuncname + "()\n\
-{\n\
-\n\
- // Check for memory FS. If not present, load the handler:\n\
- {\n\
- wxMemoryFSHandler::AddFile(\"xml_resource/dummy_file\", \"dummy one\");\n\
- wxFileSystem fsys;\n\
- wxFSFile *f = fsys.OpenFile(\"xml_resource/dummy_file\");\n\
- wxMemoryFSHandler::RemoveFile(\"xml_resource/dummy_file\");\n\
- if (f) delete f;\n\
- else wxFileSystem::AddHandler(new wxMemoryFSHandler);\n\
- }\n\
-\n");
+ file.Write(_T("")
+_T("void " + parFuncname + "()\n")
+_T("{\n")
+_T("\n")
+_T(" // Check for memory FS. If not present, load the handler:\n")
+_T(" {\n")
+_T(" wxMemoryFSHandler::AddFile(\"XRC_resource/dummy_file\", \"dummy one\");\n")
+_T(" wxFileSystem fsys;\n")
+_T(" wxFSFile *f = fsys.OpenFile(\"memory:XRC_resource/dummy_file\");\n")
+_T(" wxMemoryFSHandler::RemoveFile(\"XRC_resource/dummy_file\");\n")
+_T(" if (f) delete f;\n")
+_T(" else wxFileSystem::AddHandler(new wxMemoryFSHandler);\n")
+_T(" }\n")
+_T("\n"));
+
+ for (i = 0; i < flist.Count(); i++)
+ {
+ wxString s;
+ s.Printf(_T(" wxMemoryFSHandler::AddFile(\"XRC_resource/") + flist[i] +
+ _T("\", xml_res_file_%i, xml_res_size_%i);\n"), i, i);
+ file.Write(s);
+ }
+
+ for (i = 0; i < parFiles.Count(); i++)
+ {
+ file.Write(_T(" wxXmlResource::Get()->Load(\"memory:XRC_resource/") +
+ GetInternalFileName(parFiles[i], flist) + _T("\");\n"));
+ }
+
+ file.Write(_T("}\n"));
+
+
+}
+
+static wxString FileToPythonArray(wxString filename, int num)
+{
+ wxString output;
+ wxString tmp;
+ wxString snum;
+ wxFFile file(filename, "rb");
+ size_t lng = file.Length();
+
+ snum.Printf(_T("%i"), num);
+ output = _T(" xml_res_file_") + snum + _T(" = \"\"\"\\\n");
+
+ unsigned char *buffer = new unsigned char[lng];
+ file.Read(buffer, lng);
+
+ for (size_t i = 0, linelng = 0; i < lng; i++)
+ {
+ unsigned char c = buffer[i];
+ if (c == '\n')
+ {
+ tmp = (wxChar)c;
+ linelng = 0;
+ }
+ else if (c < 32 || c > 127)
+ tmp.Printf(_T("\\x%02x"), c);
+ else if (c == '\\')
+ tmp = _T("\\\\");
+ else
+ tmp = (wxChar)c;
+ if (linelng > 70)
+ {
+ linelng = 0;
+ output << _T("\\\n");
+ }
+ output << tmp;
+ linelng += tmp.Length();
+ }
+
+ delete[] buffer;
+
+ output += _T("\"\"\"\n\n");
+
+ return output;
+}
+
+
+void XmlResApp::MakePackagePython(const wxArrayString& flist)
+{
+ wxFFile file(parOutput, "wt");
+ size_t i;
+
+ if (flagVerbose)
+ wxPrintf(_T("creating Python source file ") + parOutput + _T("...\n"));
+
+ file.Write(
+ _T("#\n")
+ _T("# This file was automatically generated by wxrc, do not edit by hand.\n")
+ _T("#\n\n")
+ _T("from wxPython.wx import *\n")
+ _T("from wxPython.xrc import *\n\n")
+ );
+
+
+ file.Write(_T("def ") + parFuncname + _T("():\n"));
+
+ for (i = 0; i < flist.Count(); i++)
+ file.Write(FileToPythonArray(flist[i], i));