+static wxString FileToPythonArray(wxString filename, int num)
+{
+ wxString output;
+ wxString tmp;
+ wxString snum;
+ wxFFile file(filename, "rb");
+ size_t lng = file.Length();
+
+ snum.Printf("%i", num);
+ output = " xml_res_file_" + snum + " = \"\"\"\\\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("\\x%02x", c);
+ else if (c == '\\')
+ tmp = "\\\\";
+ else
+ tmp = (wxChar)c;
+ if (linelng > 70)
+ {
+ linelng = 0;
+ output << "\\\n";
+ }
+ output << tmp;
+ linelng += tmp.Length();
+ }
+
+ delete[] buffer;
+
+ output += "\"\"\"\n\n";
+
+ return output;
+}
+
+
+void XmlResApp::MakePackagePython(const wxArrayString& flist)
+{
+ wxFFile file(parOutput, "wt");
+ size_t i;
+
+ if (flagVerbose)
+ wxPrintf("creating Python source file " + parOutput + "...\n");
+
+ file.Write(
+ "#\n"
+ "# This file was automatically generated by wxrc, do not edit by hand.\n"
+ "#\n\n"
+ "from wxPython.wx import *\n"
+ "from wxPython.xrc import *\n\n"
+ );
+
+
+ file.Write("def " + parFuncname + "():\n");
+
+ for (i = 0; i < flist.Count(); i++)
+ file.Write(FileToPythonArray(flist[i], i));
+
+ for (i = 0; i < flist.Count(); i++)
+ {
+ wxString s;
+ s.Printf(" wxXmlResource_Get().LoadFromString(xml_res_file_%i)\n", i);
+ file.Write(s);
+ }
+}
+