X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a83f860948059b0273b5cc6d9e43fadad3ebfca..7a36d9c7c1a077ba7e05c248bcf19c4c9bb1356f:/utils/wxrc/wxrc.cpp?ds=sidebyside diff --git a/utils/wxrc/wxrc.cpp b/utils/wxrc/wxrc.cpp index 7f9abc5aa7..3b26f9d4c9 100644 --- a/utils/wxrc/wxrc.cpp +++ b/utils/wxrc/wxrc.cpp @@ -140,7 +140,7 @@ public: { const XRCWidgetData& w = m_wdata.Item(i); if( !CanBeUsedWithXRCCTRL(w.GetClass()) ) continue; - if( w.GetName().Length() == 0 ) continue; + if( w.GetName().empty() ) continue; file.Write( wxT(" ") + w.GetClass() + wxT("* ") + w.GetName() + wxT(";\n")); @@ -155,7 +155,7 @@ public: { const XRCWidgetData& w = m_wdata.Item(i); if( !CanBeUsedWithXRCCTRL(w.GetClass()) ) continue; - if( w.GetName().Length() == 0 ) continue; + if( w.GetName().empty() ) continue; file.Write( wxT(" ") + w.GetName() + wxT(" = XRCCTRL(*this,\"") @@ -356,7 +356,8 @@ void XmlResApp::CompileRes() { wxArrayString files = PrepareTempFiles(); - wxRemoveFile(parOutput); + if ( wxFileExists(parOutput) ) + wxRemoveFile(parOutput); if (!retCode) { @@ -586,7 +587,8 @@ static wxString FileToCppArray(wxString filename, int num) wxT("Huge file not supported") ); snum.Printf(wxT("%i"), num); - output.Printf(wxT("static size_t xml_res_size_") + snum + wxT(" = %i;\n"), lng); + output.Printf(wxT("static size_t xml_res_size_") + snum + wxT(" = %lu;\n"), + static_cast(lng)); output += wxT("static unsigned char xml_res_file_") + snum + wxT("[] = {\n"); // we cannot use string literals because MSVC is dumb wannabe compiler // with arbitrary limitation to 2048 strings :( @@ -618,7 +620,7 @@ static wxString FileToCppArray(wxString filename, int num) void XmlResApp::MakePackageCPP(const wxArrayString& flist) { wxFFile file(parOutput, wxT("wt")); - size_t i; + unsigned i; if (flagVerbose) wxPrintf(wxT("creating C++ source file ") + parOutput + wxT("...\n")); @@ -688,7 +690,7 @@ void XmlResApp::MakePackageCPP(const wxArrayString& flist) #endif // wxUSE_MIMETYPE s.Printf(" XRC_ADD_FILE(wxT(\"XRC_resource/" + flist[i] + - "\"), xml_res_file_%i, xml_res_size_%i, wxT(\"%s\"));\n", + "\"), xml_res_file_%u, xml_res_size_%u, wxT(\"%s\"));\n", i, i, mime.c_str()); file.Write(s); } @@ -706,16 +708,17 @@ void XmlResApp::MakePackageCPP(const wxArrayString& flist) void XmlResApp::GenCPPHeader() { - wxString fileSpec = ((parOutput.BeforeLast('.')).AfterLast('/')).AfterLast('\\'); - wxString heaFileName = fileSpec + wxT(".h"); + // Generate the output header in the same directory as the source file. + wxFileName headerName(parOutput); + headerName.SetExt("h"); - wxFFile file(heaFileName, wxT("wt")); + wxFFile file(headerName.GetFullPath(), wxT("wt")); file.Write( "//\n" "// This file was automatically generated by wxrc, do not edit by hand.\n" "//\n\n" -"#ifndef __" + fileSpec + "_h__\n" -"#define __" + fileSpec + "_h__\n" +"#ifndef __" + headerName.GetName() + "_h__\n" +"#define __" + headerName.GetName() + "_h__\n" ); for(size_t i=0;ifilename); + wxString s; + s.Printf("#line %d \"%s\"\n", + i->lineNo, filename.GetFullPath(wxPATH_UNIX)); - s.Printf("#line %d \"%s\"\n", i->lineNo, i->filename); fout.Write(s); fout.Write("_(\"" + i->str + "\");\n"); } @@ -891,7 +897,9 @@ static wxString ConvertText(const wxString& str) { if (*dt == wxT('_')) { - if ( *(++dt) == wxT('_') ) + if ( *(dt+1) == 0 ) + str2 << wxT('_'); + else if ( *(++dt) == wxT('_') ) str2 << wxT('_'); else str2 << wxT('&') << *dt; @@ -945,7 +953,14 @@ XmlResApp::FindStrings(const wxString& filename, wxXmlNode *node) node/*not n!*/->GetName() == wxT("tooltip") || node/*not n!*/->GetName() == wxT("htmlcode") || node/*not n!*/->GetName() == wxT("title") || - node/*not n!*/->GetName() == wxT("item") + node/*not n!*/->GetName() == wxT("item") || + node/*not n!*/->GetName() == wxT("message") || + node/*not n!*/->GetName() == wxT("note") || + node/*not n!*/->GetName() == wxT("defaultdirectory") || + node/*not n!*/->GetName() == wxT("defaultfilename") || + node/*not n!*/->GetName() == wxT("defaultfolder") || + node/*not n!*/->GetName() == wxT("filter") || + node/*not n!*/->GetName() == wxT("caption") )) // ...and known to contain translatable string {