]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/wxrc/wxrc.cpp
Fixed drawing of the lines data, also ensure that only tuples are
[wxWidgets.git] / utils / wxrc / wxrc.cpp
index c2aeec7a7edaa021fa3be095dd9f9960273094ee..79362762e17317088ab595fa905964dfc7d6a97f 100644 (file)
     #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"
-#include "wx/xrc/xml.h"
+#include "wx/xml/xml.h"
 #include "wx/ffile.h"
 #include "wx/filename.h"
 #include "wx/wfstream.h"
 
 
-
-
-
-/*
-#if wxUSE_GUI
-#error "You must compile the resource compiler with wxBase!"
-#endif
-*/
-
-class XmlResApp : public wxApp
+class XmlResApp : public wxAppConsole
 {
 public:
+    // don't use builtin cmd line parsing:
+    virtual bool OnInit() { return true; } 
 
-#if wxUSE_GUI
-    bool OnInit();
-#else
     virtual int OnRun();
-#endif
     
 private:
     
@@ -75,13 +64,9 @@ private:
     int retCode;
 };
 
-IMPLEMENT_APP(XmlResApp)
+IMPLEMENT_APP_CONSOLE(XmlResApp)
 
-#if wxUSE_GUI
-bool XmlResApp::OnInit()
-#else
 int XmlResApp::OnRun()
-#endif
 {
     static const wxCmdLineEntryDesc cmdLineDesc[] =
     {
@@ -109,7 +94,10 @@ int XmlResApp::OnRun()
     {
         case -1:
             return 0;
+            #if 0
+            // break is unreachable because of return earlier
             break;
+            #endif
 
         case 0:
             retCode = 0;
@@ -118,21 +106,20 @@ int XmlResApp::OnRun()
                 OutputGettext();
             else
                 CompileRes();
-#if wxUSE_GUI
-            return FALSE;
-#else
             return retCode;
-#endif
+            #if 0
+            // break is unreachable because of return earlier
             break;
+            #endif
 
+        #if 0
+        // default return moved outside of switch to avoid warning about lack of return in function
         default:
-#if wxUSE_GUI
-            return FALSE;
-#else
             return 1;
-#endif
             break;
+        #endif
     }
+    return 1;
 }
 
 
@@ -169,7 +156,18 @@ void XmlResApp::ParseParams(const wxCmdLineParser& cmdline)
         parFuncname = _T("InitXmlResource");
 
     for (size_t i = 0; i < cmdline.GetParamCount(); i++)
+    {
+#ifdef __WINDOWS__
+        wxString fn=wxFindFirstFile(cmdline.GetParam(i), wxFILE);
+        while (!fn.IsEmpty())
+        {
+            parFiles.Add(fn);
+            fn=wxFindNextFile();
+        }
+#else
         parFiles.Add(cmdline.GetParam(i));
+#endif
+    }
 }
 
 
@@ -370,7 +368,7 @@ static wxString FileToCppArray(wxString filename, int num)
     wxString output;
     wxString tmp;
     wxString snum;
-    wxFFile file(filename, "rb");
+    wxFFile file(filename, wxT("rb"));
     size_t lng = file.Length();
     
     snum.Printf(_T("%i"), num);
@@ -405,7 +403,7 @@ static wxString FileToCppArray(wxString filename, int num)
 
 void XmlResApp::MakePackageCPP(const wxArrayString& flist)
 {
-    wxFFile file(parOutput, "wt");
+    wxFFile file(parOutput, wxT("wt"));
     size_t i;
 
     if (flagVerbose) 
@@ -436,15 +434,15 @@ _T("\n"));
               FileToCppArray(parOutputPath + wxFILE_SEP_PATH + flist[i], i));
     
     file.Write(_T("")
-_T("void " + parFuncname + "()\n")
+_T("void ") + parFuncname + wxT("()\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("        wxMemoryFSHandler::AddFile(wxT(\"XRC_resource/dummy_file\"), wxT(\"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("        wxFSFile *f = fsys.OpenFile(wxT(\"memory:XRC_resource/dummy_file\"));\n")
+_T("        wxMemoryFSHandler::RemoveFile(wxT(\"XRC_resource/dummy_file\"));\n")
 _T("        if (f) delete f;\n")
 _T("        else wxFileSystem::AddHandler(new wxMemoryFSHandler);\n")
 _T("    }\n")
@@ -453,15 +451,15 @@ _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);
+        s.Printf(_T("    wxMemoryFSHandler::AddFile(wxT(\"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("    wxXmlResource::Get()->Load(wxT(\"memory:XRC_resource/") +
+                   GetInternalFileName(parFiles[i], flist) + _T("\"));\n"));
     }
     
     file.Write(_T("}\n"));
@@ -474,7 +472,7 @@ static wxString FileToPythonArray(wxString filename, int num)
     wxString output;
     wxString tmp;
     wxString snum;
-    wxFFile file(filename, "rb");
+    wxFFile file(filename, wxT("rb"));
     size_t lng = file.Length();
     
     snum.Printf(_T("%i"), num);
@@ -516,7 +514,7 @@ static wxString FileToPythonArray(wxString filename, int num)
 
 void XmlResApp::MakePackagePython(const wxArrayString& flist)
 {
-    wxFFile file(parOutput, "wt");
+    wxFFile file(parOutput, wxT("wt"));
     size_t i;
 
     if (flagVerbose) 
@@ -553,7 +551,7 @@ void XmlResApp::OutputGettext()
     
     wxFFile fout;
     if (!parOutput) fout.Attach(stdout);
-    else fout.Open(parOutput, "wt");
+    else fout.Open(parOutput, wxT("wt"));
     
     for (size_t i = 0; i < str.GetCount(); i++)
         fout.Write(_T("_(\"") + str[i] + _T("\");\n"));