Fixed compiling problem with wxWidgets 2.8.12

This commit is contained in:
Zane U. Ji 2012-08-18 23:41:27 +08:00
parent 7bad0039c5
commit 807a96c1a0
18 changed files with 189 additions and 117 deletions

View File

@ -26,8 +26,9 @@
<option id="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level.693304093" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> <option id="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level.693304093" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.334981297" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> <option id="gnu.cpp.compiler.option.include.paths.334981297" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="${BOOSTINC}"/> <listOptionValue builtIn="false" value="${BOOSTINC}"/>
<listOptionValue builtIn="false" value="${WXWIDGETS}\include"/> <listOptionValue builtIn="false" value="${WXWIDGETS}/include"/>
<listOptionValue builtIn="false" value="${WXWIDGETS}\lib\gcc_lib\mswud"/> <listOptionValue builtIn="false" value="${WXWIDGETS}/contrib/include"/>
<listOptionValue builtIn="false" value="${WXWIDGETS}/lib/gcc_lib/mswud"/>
</option> </option>
<option id="gnu.cpp.compiler.option.other.other.1952331323" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0" valueType="string"/> <option id="gnu.cpp.compiler.option.other.other.1952331323" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0" valueType="string"/>
<option id="gnu.cpp.compiler.option.preprocessor.def.1236209686" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols"> <option id="gnu.cpp.compiler.option.preprocessor.def.1236209686" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
@ -51,24 +52,22 @@
<listOptionValue builtIn="false" value="pcre"/> <listOptionValue builtIn="false" value="pcre"/>
<listOptionValue builtIn="false" value="xerces-c"/> <listOptionValue builtIn="false" value="xerces-c"/>
<listOptionValue builtIn="false" value="aspell"/> <listOptionValue builtIn="false" value="aspell"/>
<listOptionValue builtIn="false" value="wxmsw29ud_richtext"/> <listOptionValue builtIn="false" value="wxmsw28ud_richtext"/>
<listOptionValue builtIn="false" value="wxmsw29ud_html"/> <listOptionValue builtIn="false" value="wxmsw28ud_html"/>
<listOptionValue builtIn="false" value="wxmsw29ud_stc"/> <listOptionValue builtIn="false" value="wxmsw28ud_stc"/>
<listOptionValue builtIn="false" value="wxmsw29ud_aui"/> <listOptionValue builtIn="false" value="wxmsw28ud_aui"/>
<listOptionValue builtIn="false" value="wxmsw29ud_adv"/> <listOptionValue builtIn="false" value="wxmsw28ud_adv"/>
<listOptionValue builtIn="false" value="wxmsw29ud_stc"/> <listOptionValue builtIn="false" value="wxmsw28ud_stc"/>
<listOptionValue builtIn="false" value="wxmsw29ud_core"/> <listOptionValue builtIn="false" value="wxmsw28ud_core"/>
<listOptionValue builtIn="false" value="wxmsw29ud_richtext"/> <listOptionValue builtIn="false" value="wxmsw28ud_richtext"/>
<listOptionValue builtIn="false" value="wxbase29ud_xml"/> <listOptionValue builtIn="false" value="wxbase28ud_xml"/>
<listOptionValue builtIn="false" value="wxbase29ud_net"/> <listOptionValue builtIn="false" value="wxbase28ud_net"/>
<listOptionValue builtIn="false" value="wxbase29ud"/> <listOptionValue builtIn="false" value="wxbase28ud"/>
<listOptionValue builtIn="false" value="wxtiffd"/> <listOptionValue builtIn="false" value="wxtiffd"/>
<listOptionValue builtIn="false" value="wxjpegd"/> <listOptionValue builtIn="false" value="wxjpegd"/>
<listOptionValue builtIn="false" value="wxpngd"/> <listOptionValue builtIn="false" value="wxpngd"/>
<listOptionValue builtIn="false" value="wxzlibd"/> <listOptionValue builtIn="false" value="wxzlibd"/>
<listOptionValue builtIn="false" value="wxregexud"/> <listOptionValue builtIn="false" value="wxregexud"/>
<listOptionValue builtIn="false" value="wxscintillad"/>
<listOptionValue builtIn="false" value="wxregexud"/>
<listOptionValue builtIn="false" value="kernel32"/> <listOptionValue builtIn="false" value="kernel32"/>
<listOptionValue builtIn="false" value="user32"/> <listOptionValue builtIn="false" value="user32"/>
<listOptionValue builtIn="false" value="gdi32"/> <listOptionValue builtIn="false" value="gdi32"/>
@ -87,7 +86,7 @@
<listOptionValue builtIn="false" value="pthread"/> <listOptionValue builtIn="false" value="pthread"/>
</option> </option>
<option id="gnu.cpp.link.option.paths.1556491407" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> <option id="gnu.cpp.link.option.paths.1556491407" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="${WXWIDGETS}\lib\gcc_lib"/> <listOptionValue builtIn="false" value="${WXWIDGETS}/lib/gcc_lib"/>
</option> </option>
<option id="gnu.cpp.link.option.userobjs.598298270" name="Other objects" superClass="gnu.cpp.link.option.userobjs" valueType="userObjs"> <option id="gnu.cpp.link.option.userobjs.598298270" name="Other objects" superClass="gnu.cpp.link.option.userobjs" valueType="userObjs">
<listOptionValue builtIn="false" value="${ConfigName}/xmlcopyeditor_rc.o"/> <listOptionValue builtIn="false" value="${ConfigName}/xmlcopyeditor_rc.o"/>
@ -129,8 +128,9 @@
<option id="gnu.cpp.compiler.mingw.exe.release.option.debugging.level.1567946828" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/> <option id="gnu.cpp.compiler.mingw.exe.release.option.debugging.level.1567946828" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.1851942004" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> <option id="gnu.cpp.compiler.option.include.paths.1851942004" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="${BOOSTINC}"/> <listOptionValue builtIn="false" value="${BOOSTINC}"/>
<listOptionValue builtIn="false" value="${WXWIDGETS}\include"/> <listOptionValue builtIn="false" value="${WXWIDGETS}/include"/>
<listOptionValue builtIn="false" value="${WXWIDGETS}\lib\gcc_lib\mswu"/> <listOptionValue builtIn="false" value="${WXWIDGETS}/contrib/include"/>
<listOptionValue builtIn="false" value="${WXWIDGETS}/lib/gcc_lib/mswu"/>
</option> </option>
<option id="gnu.cpp.compiler.option.other.other.1853611325" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0" valueType="string"/> <option id="gnu.cpp.compiler.option.other.other.1853611325" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0" valueType="string"/>
<option id="gnu.cpp.compiler.option.preprocessor.def.1550164037" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols"> <option id="gnu.cpp.compiler.option.preprocessor.def.1550164037" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
@ -153,24 +153,22 @@
<listOptionValue builtIn="false" value="pcre"/> <listOptionValue builtIn="false" value="pcre"/>
<listOptionValue builtIn="false" value="xerces-c"/> <listOptionValue builtIn="false" value="xerces-c"/>
<listOptionValue builtIn="false" value="aspell"/> <listOptionValue builtIn="false" value="aspell"/>
<listOptionValue builtIn="false" value="wxmsw29u_richtext"/> <listOptionValue builtIn="false" value="wxmsw28u_richtext"/>
<listOptionValue builtIn="false" value="wxmsw29u_html"/> <listOptionValue builtIn="false" value="wxmsw28u_html"/>
<listOptionValue builtIn="false" value="wxmsw29u_stc"/> <listOptionValue builtIn="false" value="wxmsw28u_stc"/>
<listOptionValue builtIn="false" value="wxmsw29u_aui"/> <listOptionValue builtIn="false" value="wxmsw28u_aui"/>
<listOptionValue builtIn="false" value="wxmsw29u_adv"/> <listOptionValue builtIn="false" value="wxmsw28u_adv"/>
<listOptionValue builtIn="false" value="wxmsw29u_stc"/> <listOptionValue builtIn="false" value="wxmsw28u_stc"/>
<listOptionValue builtIn="false" value="wxmsw29u_core"/> <listOptionValue builtIn="false" value="wxmsw28u_core"/>
<listOptionValue builtIn="false" value="wxmsw29u_richtext"/> <listOptionValue builtIn="false" value="wxmsw28u_richtext"/>
<listOptionValue builtIn="false" value="wxbase29u_xml"/> <listOptionValue builtIn="false" value="wxbase28u_xml"/>
<listOptionValue builtIn="false" value="wxbase29u_net"/> <listOptionValue builtIn="false" value="wxbase28u_net"/>
<listOptionValue builtIn="false" value="wxbase29u"/> <listOptionValue builtIn="false" value="wxbase28u"/>
<listOptionValue builtIn="false" value="wxtiff"/> <listOptionValue builtIn="false" value="wxtiff"/>
<listOptionValue builtIn="false" value="wxjpeg"/> <listOptionValue builtIn="false" value="wxjpeg"/>
<listOptionValue builtIn="false" value="wxpng"/> <listOptionValue builtIn="false" value="wxpng"/>
<listOptionValue builtIn="false" value="wxzlib"/> <listOptionValue builtIn="false" value="wxzlib"/>
<listOptionValue builtIn="false" value="wxregexu"/> <listOptionValue builtIn="false" value="wxregexu"/>
<listOptionValue builtIn="false" value="wxscintilla"/>
<listOptionValue builtIn="false" value="wxregexu"/>
<listOptionValue builtIn="false" value="kernel32"/> <listOptionValue builtIn="false" value="kernel32"/>
<listOptionValue builtIn="false" value="user32"/> <listOptionValue builtIn="false" value="user32"/>
<listOptionValue builtIn="false" value="gdi32"/> <listOptionValue builtIn="false" value="gdi32"/>
@ -189,7 +187,7 @@
<listOptionValue builtIn="false" value="pthread"/> <listOptionValue builtIn="false" value="pthread"/>
</option> </option>
<option id="gnu.cpp.link.option.paths.161756907" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"> <option id="gnu.cpp.link.option.paths.161756907" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="${WXWIDGETS}\lib\gcc_lib"/> <listOptionValue builtIn="false" value="${WXWIDGETS}/lib/gcc_lib"/>
</option> </option>
<option id="gnu.cpp.link.option.userobjs.30870315" name="Other objects" superClass="gnu.cpp.link.option.userobjs" valueType="userObjs"> <option id="gnu.cpp.link.option.userobjs.30870315" name="Other objects" superClass="gnu.cpp.link.option.userobjs" valueType="userObjs">
<listOptionValue builtIn="false" value="${ConfigName}/xmlcopyeditor_rc.o"/> <listOptionValue builtIn="false" value="${ConfigName}/xmlcopyeditor_rc.o"/>

View File

@ -146,7 +146,7 @@ void HouseStyle::collectRules ( string& fileName,
if ( report != "" ) if ( report != "" )
throw runtime_error ( report.c_str() ); throw runtime_error ( report.c_str() );
else else
throw runtime_error ( xrr->getLastError().c_str() ); throw runtime_error ( ( const char * ) xrr->getLastError().utf8_str() );
} }
// add current file to exclude set // add current file to exclude set

View File

@ -39,7 +39,7 @@ MyNotebook::MyNotebook (
{ {
rightClickPage = -1; rightClickPage = -1;
wxApp::GetInstance()->Connect ( wxEVT_KEY_DOWN, wxTheApp->Connect ( wxEVT_KEY_DOWN,
wxKeyEventHandler ( MyNotebook::OnKeyDown ), NULL, this ); wxKeyEventHandler ( MyNotebook::OnKeyDown ), NULL, this );
} }
@ -125,7 +125,8 @@ void MyNotebook::OnKeyDown ( wxKeyEvent &event )
AdvanceSelection ( !event.m_shiftDown ); AdvanceSelection ( !event.m_shiftDown );
XmlDoc *doc = ( XmlDoc * ) GetCurrentPage(); int cur = GetSelection();
XmlDoc *doc = ( XmlDoc * ) GetPage ( cur );
if ( doc != NULL ) if ( doc != NULL )
doc->SetFocus(); doc->SetFocus();
} }

View File

@ -41,6 +41,7 @@ MyPropertySheet::MyPropertySheet (
bool expandInternalEntitiesParameter, bool expandInternalEntitiesParameter,
bool showFullPathOnFrameParameter, bool showFullPathOnFrameParameter,
int lang, int lang,
const wxArrayString &translations,
wxWindowID id, wxWindowID id,
wxString title, wxString title,
const wxPoint& position, const wxPoint& position,
@ -165,23 +166,18 @@ MyPropertySheet::MyPropertySheet (
generalPanel, generalPanel,
wxID_ANY ); wxID_ANY );
wxTranslations *t = wxTranslations::Get();
if ( t != NULL )
{
int index; int index;
const wxLanguageInfo *info; const wxLanguageInfo *info;
wxArrayString langs = t->GetAvailableTranslations ( _T ( "messages" ) ); wxArrayString::const_iterator trans = translations.begin();
for ( size_t i = 0; i < langs.Count(); i++ ) for ( ; trans != translations.end(); trans++ )
{ {
info = wxLocale::FindLanguageInfo ( langs[i] ); info = wxLocale::FindLanguageInfo ( *trans );
if ( info == NULL ) continue; if ( info == NULL ) continue;
index = languageBox->Append ( info->Description, (void*)info->Language ); index = languageBox->Append ( info->Description, (void*)info->Language );
if (lang == info->Language) if (lang == info->Language)
languageBox->SetSelection ( index ); languageBox->SetSelection ( index );
} }
}
libxmlNetAccessBox = new wxCheckBox ( libxmlNetAccessBox = new wxCheckBox (
generalPanel, wxID_ANY, _ ( "&Enable network access for DTD validation" ) ); generalPanel, wxID_ANY, _ ( "&Enable network access for DTD validation" ) );

View File

@ -47,6 +47,7 @@ class MyPropertySheet : public wxPropertySheetDialog
bool expandInternalEntities, bool expandInternalEntities,
bool showFullPathOnFrame, bool showFullPathOnFrame,
int lang, int lang,
const wxArrayString &translations,
wxWindowID id = wxID_ANY, wxWindowID id = wxID_ANY,
wxString title = _T ( "" ), wxString title = _T ( "" ),
const wxPoint& position = wxDefaultPosition, const wxPoint& position = wxDefaultPosition,

View File

@ -6,7 +6,7 @@
#include <memory> #include <memory>
wxDEFINE_EVENT(wxEVT_COMMAND_VALIDATION_COMPLETED, wxThreadEvent); DEFINE_EVENT_TYPE(wxEVT_COMMAND_VALIDATION_COMPLETED);
ValidationThread::ValidationThread ( ValidationThread::ValidationThread (
wxEvtHandler *handler, wxEvtHandler *handler,
@ -67,8 +67,8 @@ void *ValidationThread::Entry()
myMessage = validator->getLastError(); myMessage = validator->getLastError();
} }
wxEvent *event = new wxThreadEvent(wxEVT_THREAD, wxEVT_COMMAND_VALIDATION_COMPLETED); wxCommandEvent event ( wxEVT_COMMAND_VALIDATION_COMPLETED );
wxQueueEvent ( myEventHandler, event ); wxPostEvent ( myEventHandler, event );
return NULL; return NULL;
} }

View File

@ -6,7 +6,7 @@
#include <string> #include <string>
#include <wx/thread.h> #include <wx/thread.h>
wxDECLARE_EVENT(wxEVT_COMMAND_VALIDATION_COMPLETED, wxThreadEvent); DECLARE_EVENT_TYPE(wxEVT_COMMAND_VALIDATION_COMPLETED, wxID_ANY);
class ValidationThread : public wxThread class ValidationThread : public wxThread
{ {

View File

@ -173,8 +173,7 @@ bool WrapDaisy::run (
if ( !xsp->parse ( output.c_str() ) ) if ( !xsp->parse ( output.c_str() ) )
{ {
frame->newDocument ( output ); frame->newDocument ( output );
std::string stdError = xsp->getLastError(); error = xsp->getLastError();
error = wxString ( stdError.c_str(), wxConvUTF8, stdError.size() );
return false; return false;
} }
output = xsp->getBuffer(); output = xsp->getBuffer();
@ -200,8 +199,7 @@ bool WrapDaisy::run (
if ( !xp->parse ( output.c_str() ) ) if ( !xp->parse ( output.c_str() ) )
{ {
frame->newDocument ( output ); frame->newDocument ( output );
std::string stdError = xp->getLastError(); error = xp->getLastError();
error = wxString ( stdError.c_str(), wxConvUTF8, stdError.size() );
return false; return false;
} }
output = xp->getBuffer(); output = xp->getBuffer();
@ -289,8 +287,7 @@ bool WrapDaisy::run (
if ( !xci->parse ( output.c_str() ) ) if ( !xci->parse ( output.c_str() ) )
{ {
frame->newDocument ( output ); frame->newDocument ( output );
std::string stdError = xci->getLastError(); error = xci->getLastError();
error = wxString ( stdError.c_str(), wxConvUTF8, stdError.size() );
return false; return false;
} }
output = xci->getBuffer(); output = xci->getBuffer();
@ -301,7 +298,7 @@ bool WrapDaisy::run (
std::ofstream canonicalStream ( stdCanonicalFile.c_str() );//canonicalFile.name().c_str() ); std::ofstream canonicalStream ( stdCanonicalFile.c_str() );//canonicalFile.name().c_str() );
if ( !canonicalStream ) if ( !canonicalStream )
{ {
error = _T( "Cannot write canonical XHTML file" ); error = _ ( "Cannot write canonical XHTML file" );
return false; return false;
} }
canonicalStream << output.c_str() << std::endl; canonicalStream << output.c_str() << std::endl;
@ -316,9 +313,9 @@ bool WrapDaisy::run (
while (wxTheApp->Pending()) while (wxTheApp->Pending())
wxTheApp->Dispatch(); wxTheApp->Dispatch();
if ( !pd->Update ( 40, _T("Preparing DTBook...") ) ) if ( !pd->Update ( 40, _ ("Preparing DTBook...") ) )
{ {
error = _T ( "Cancelled" ); error = _ ( "Cancelled" );
return false; return false;
} }

View File

@ -68,17 +68,17 @@ pair<int, int> WrapExpat::getErrorPosition()
XML_GetCurrentColumnNumber ( p ) ); XML_GetCurrentColumnNumber ( p ) );
} }
string WrapExpat::getLastError() wxString WrapExpat::getLastError()
{ {
if ( !p ) if ( !p )
return "Unable to create parser instance"; return _ ( "Unable to create parser instance" );
stringstream ss; stringstream ss;
ss << "Error at line "; ss << "Error at line ";
ss << XML_GetCurrentLineNumber ( p ); ss << XML_GetCurrentLineNumber ( p );
ss << ", column " << XML_GetCurrentColumnNumber ( p ) + 1 << ":" << endl; ss << ", column " << XML_GetCurrentColumnNumber ( p ) + 1 << ":" << endl;
ss << XML_ErrorString ( XML_GetErrorCode ( p ) ); ss << XML_ErrorString ( XML_GetErrorCode ( p ) );
return ss.str(); return wxString ( ss.str().c_str(), wxConvUTF8 );
} }
string WrapExpat::xmliseTextNode ( const string &textnode ) string WrapExpat::xmliseTextNode ( const string &textnode )

View File

@ -20,6 +20,7 @@
#ifndef WRAP_EXPAT #ifndef WRAP_EXPAT
#define WRAP_EXPAT #define WRAP_EXPAT
#include <wx/wx.h>
#include <expat.h> #include <expat.h>
#include <string> #include <string>
#include <vector> #include <vector>
@ -36,7 +37,7 @@ class WrapExpat
bool parse ( const string &buffer, bool isFinal = true ); bool parse ( const string &buffer, bool isFinal = true );
bool parse ( const char *buffer, size_t size, bool isFinal = true ); bool parse ( const char *buffer, size_t size, bool isFinal = true );
pair<int, int> getErrorPosition(); pair<int, int> getErrorPosition();
string getLastError(); wxString getLastError();
bool isEncodingError(); bool isEncodingError();
static string xmliseTextNode ( const string &textnode ); static string xmliseTextNode ( const string &textnode );
static string xmliseAttribute ( const string &attribute ); static string xmliseAttribute ( const string &attribute );

View File

@ -96,7 +96,7 @@ bool WrapXerces::validate ( const std::string& fileName )
delete parser; delete parser;
lastError << _T ( "Validation stopped at line " ) lastError << _T ( "Validation stopped at line " )
<< e.getLineNumber() << _T ( ", column " ) << e.getColumnNumber() << e.getLineNumber() << _T ( ", column " ) << e.getColumnNumber()
<< ": " << toString ( e.getMessage() ); << _T ( ": " ) << toString ( e.getMessage() );
errorPosition = std::make_pair ( e.getLineNumber(), e.getColumnNumber() ); errorPosition = std::make_pair ( e.getLineNumber(), e.getColumnNumber() );
return false; return false;
} }

View File

@ -58,6 +58,8 @@
#include <wx/stockitem.h> #include <wx/stockitem.h>
#include <iconv.h> #include <iconv.h>
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
#include <wx/tokenzr.h>
#include <wx/dir.h>
#define ngettext wxGetTranslation #define ngettext wxGetTranslation
@ -301,14 +303,23 @@ MyApp::MyApp() : checker ( NULL ), server ( NULL ), connection ( NULL ),
} }
myLocale.Init ( lang, wxLOCALE_LOAD_DEFAULT ); myLocale.Init ( lang, wxLOCALE_LOAD_DEFAULT );
wxLocale::AddCatalogLookupPathPrefix ( wxT ( "." ) );
wxLocale::AddCatalogLookupPathPrefix ( wxT ( ".." ) );
wxArrayString prefixes;
#ifdef __WXGTK__
prefixes.Add ( wxT ( "/usr/share/locale" ) );
prefixes.Add ( wxT ( "/usr/local/share/locale" ) );
#endif
wxString poDir = wxStandardPaths::Get().GetDataDir() + wxString poDir = wxStandardPaths::Get().GetDataDir() +
wxFileName::GetPathSeparator() + _T ( "po" ) + wxFileName::GetPathSeparator(); wxFileName::GetPathSeparator() + _T ( "po" ) + wxFileName::GetPathSeparator();
wxLocale::AddCatalogLookupPathPrefix ( poDir ); prefixes.Add ( poDir );
wxArrayString::const_iterator itr;
for ( itr = prefixes.begin(); itr != prefixes.end(); itr++ )
wxLocale::AddCatalogLookupPathPrefix ( *itr );
if ( !myLocale.AddCatalog ( _T ( "messages" ) ) ) wxString catalog = _T ( "messages" );
getAvailableTranslations ( &prefixes, &catalog );
if ( !myLocale.AddCatalog ( catalog ) )
; ;
#ifndef __WXMSW__ #ifndef __WXMSW__
@ -328,7 +339,6 @@ MyApp::~MyApp()
bool MyApp::OnInit() bool MyApp::OnInit()
{ {
wxString name, service, hostName; wxString name, service, hostName;
name.Printf ( _T ( "xmlcopyeditor-%s" ), wxGetUserId().c_str() ); name.Printf ( _T ( "xmlcopyeditor-%s" ), wxGetUserId().c_str() );
service = IPC_SERVICE; service = IPC_SERVICE;
@ -347,14 +357,8 @@ bool MyApp::OnInit()
break; break;
else else
{ {
wxString argument, what; wxString argument;
wxChar *whatBuffer; wxChar whatBuffer[] = _T ( "Data" );
what = _T ( "Data" );
#if wxCHECK_VERSION(2,9,0)
whatBuffer = (wxChar *)what.wchar_str();
#else
whatBuffer = (wxChar *)what.c_str();
#endif
if ( this->argc > 1 ) if ( this->argc > 1 )
{ {
for ( int i = 1; i < this->argc; i++ ) for ( int i = 1; i < this->argc; i++ )
@ -403,7 +407,7 @@ bool MyApp::OnInit()
catch ( const XMLException &e ) catch ( const XMLException &e )
{ {
wxString error; wxString error;
error << _ ( "Failed to initialize Xerces-c:\n" ) error << _ ( "Failed to initialize Xerces-C:\n" )
<< WrapXerces::toString ( e.getMessage() ); << WrapXerces::toString ( e.getMessage() );
wxMessageBox ( error, _ ( "Error" ), wxOK | wxICON_ERROR ); wxMessageBox ( error, _ ( "Error" ), wxOK | wxICON_ERROR );
return false; return false;
@ -568,6 +572,66 @@ void MyApp::HandleEvent ( wxEvtHandler *handler, wxEventFunction func, wxEvent&
} }
#endif #endif
const wxArrayString &MyApp::getAvailableTranslations (
const wxArrayString *catalogLookupPathPrefixes /*= NULL*/,
const wxString *catalog /*= NULL*/ )
{
static class Translations // Most of the code was copied from wxTranslations
{
public:
Translations ( const wxArrayString *catalogLookupPathPrefixes,
const wxString *catalog )
{
if ( catalogLookupPathPrefixes == NULL )
throw std::invalid_argument ( "catalogLookupPathPrefixes" );
if ( catalog == NULL )
throw std::invalid_argument ( "catelog" );
#if wxCHECK_VERSION(2,9,0)
wxTranslations *t = wxTranslations::Get();
if ( t != NULL )
translations = t->GetAvailableTranslations ( *catalog );
#else
wxArrayString::const_iterator i = catalogLookupPathPrefixes->begin();
for ( i = catalogLookupPathPrefixes->begin();
i != catalogLookupPathPrefixes->end(); ++i )
{
if ( i->empty() )
continue;
wxDir dir;
if ( !dir.Open(*i) )
continue;
wxString lang;
for ( bool ok = dir.GetFirst ( &lang, wxEmptyString, wxDIR_DIRS ); ok;
ok = dir.GetNext (&lang) ) {
const wxString langdir = *i + wxFILE_SEP_PATH + lang;
if ( HasMsgCatalogInDir ( langdir, *catalog ) ) {
#ifdef __WXOSX__
wxString rest;
if ( lang.EndsWith(".lproj", &rest) )
lang = rest;
#endif // __WXOSX__
translations.push_back(lang);
}
}
}
#endif
}
bool HasMsgCatalogInDir ( const wxString &dir, const wxString &catelog )
{
return wxFileName ( dir, catelog, _T ( "mo" ) ).FileExists()
|| wxFileName ( dir + wxFILE_SEP_PATH + _T ( "LC_MESSAGES" ), catelog, _T ( "mo" ) ).FileExists();
}
const wxArrayString &operator()() { return translations; }
protected:
wxArrayString translations;
} translations ( catalogLookupPathPrefixes, catalog );
return translations();
}
MyFrame::MyFrame ( MyFrame::MyFrame (
const wxString& title, const wxString& title,
wxFileConfig *configParameter, wxFileConfig *configParameter,
@ -2509,6 +2573,7 @@ void MyFrame::OnOptions ( wxCommandEvent& WXUNUSED ( event ) )
#else #else
( _ ( "Preferences" ) ); ( _ ( "Preferences" ) );
#endif #endif
MyApp *app = ( MyApp * ) wxTheApp;
std::auto_ptr<MyPropertySheet> mpsd ( new MyPropertySheet ( std::auto_ptr<MyPropertySheet> mpsd ( new MyPropertySheet (
this, this,
properties, properties,
@ -2522,6 +2587,7 @@ void MyFrame::OnOptions ( wxCommandEvent& WXUNUSED ( event ) )
expandInternalEntities, expandInternalEntities,
showFullPathOnFrame, showFullPathOnFrame,
lang, lang,
app->getAvailableTranslations(),
wxID_ANY, wxID_ANY,
title ) ); title ) );
if ( mpsd->ShowModal() == wxID_OK ) if ( mpsd->ShowModal() == wxID_OK )
@ -2859,10 +2925,11 @@ void MyFrame::newDocument ( const std::string& s, const std::string& path, bool
catalogUtilityPath, catalogUtilityPath,
path, path,
auxPath ); auxPath );
mainBook->AddPage ( ( wxWindow * ) doc, documentLabel, true ); mainBook->AddPage ( ( wxWindow * ) doc, documentLabel );
Thaw(); Thaw();
mainBook->Refresh(); mainBook->Layout();
if ( properties.completion ) if ( properties.completion )
doc->updatePromptMaps(); doc->updatePromptMaps();
doc->setShortFileName ( documentLabel ); doc->setShortFileName ( documentLabel );
@ -2915,9 +2982,12 @@ void MyFrame::OnOpen ( wxCommandEvent& event )
size_t count = paths.Count(); size_t count = paths.Count();
if ( !count ) if ( !count )
return; return;
Freeze();
for ( size_t i = 0; i < count; ++i ) for ( size_t i = 0; i < count; ++i )
if ( !openFile ( paths[i], largeFile ) ) if ( !openFile ( paths[i], largeFile ) )
break; break;
Thaw();
mainBook->Layout();
} }
bool MyFrame::openFile ( wxString& fileName, bool largeFile ) bool MyFrame::openFile ( wxString& fileName, bool largeFile )
@ -3186,7 +3256,7 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
Thaw(); Thaw();
statusProgress ( wxEmptyString ); statusProgress ( wxEmptyString );
mainBook->Refresh(); mainBook->Layout();
wxFileName fn ( fileName ); wxFileName fn ( fileName );
doc->setLastModified ( fn.GetModificationTime() ); doc->setLastModified ( fn.GetModificationTime() );
@ -3247,11 +3317,9 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
if ( !optimisedParseSuccess ) if ( !optimisedParseSuccess )
{ {
std::string error = we->getLastError();
wideError = wxString ( error.c_str(), wxConvUTF8, error.size() );
posPair = we->getErrorPosition(); posPair = we->getErrorPosition();
-- ( posPair.first ); -- ( posPair.first );
messagePane ( wideError, CONST_WARNING ); messagePane ( we->getLastError(), CONST_WARNING );
int newPosition = doc->PositionFromLine ( posPair.first ); int newPosition = doc->PositionFromLine ( posPair.first );
doc->SetSelection ( newPosition, newPosition ); doc->SetSelection ( newPosition, newPosition );
@ -5267,6 +5335,7 @@ wxMenuBar *MyFrame::getMenuBar()
_ ( "Word Count" ) ); _ ( "Word Count" ) );
wordCountItem->SetBitmap ( wxNullBitmap ); wordCountItem->SetBitmap ( wxNullBitmap );
wxMenuItem *commandItem = wxMenuItem *commandItem =
new wxMenuItem ( new wxMenuItem (
NULL, NULL,
@ -5300,6 +5369,8 @@ wxMenuBar *MyFrame::getMenuBar()
new wxMenuItem ( NULL, wxID_HELP, new wxMenuItem ( NULL, wxID_HELP,
_ ( "&XML Copy Editor Help\tF1" ), _ ( "Help" ) ); _ ( "&XML Copy Editor Help\tF1" ), _ ( "Help" ) );
helpItem->SetBitmap ( helpBitmap ); helpItem->SetBitmap ( helpBitmap );
wxMenuItem *homeItem = wxMenuItem *homeItem =
new wxMenuItem ( NULL, ID_HOME, new wxMenuItem ( NULL, ID_HOME,
_ ( "&Home Page" ), _ ( "Home Page" ) ); _ ( "&Home Page" ), _ ( "Home Page" ) );
@ -5316,6 +5387,7 @@ wxMenuBar *MyFrame::getMenuBar()
_ ( "&Browse Source" ), _ ( "Browse Source" ) ); _ ( "&Browse Source" ), _ ( "Browse Source" ) );
downloadSourceItem->SetBitmap ( wxNullBitmap ); downloadSourceItem->SetBitmap ( wxNullBitmap );
helpMenu->Append ( helpItem ); helpMenu->Append ( helpItem );
helpMenu->AppendSeparator(); helpMenu->AppendSeparator();
helpMenu->Append ( homeItem ); helpMenu->Append ( homeItem );
helpMenu->Append ( feedbackItem ); helpMenu->Append ( feedbackItem );
@ -5364,7 +5436,6 @@ void MyFrame::updateFileMenu ( bool deleteExisting )
wxMenuItem *saveItem = wxMenuItem *saveItem =
new wxMenuItem ( NULL, wxID_SAVE, _ ( "&Save\tCtrl+S" ), _ ( "Save" ) ); new wxMenuItem ( NULL, wxID_SAVE, _ ( "&Save\tCtrl+S" ), _ ( "Save" ) );
saveItem->SetBitmap ( save16Bitmap ); saveItem->SetBitmap ( save16Bitmap );
wxMenuItem *saveAsItem = wxMenuItem *saveAsItem =
new wxMenuItem ( NULL, wxID_SAVEAS, _ ( "S&ave As...\tF12" ), _ ( "Save As..." ) ); new wxMenuItem ( NULL, wxID_SAVEAS, _ ( "S&ave As...\tF12" ), _ ( "Save As..." ) );
saveAsItem->SetBitmap ( wxNullBitmap ); saveAsItem->SetBitmap ( wxNullBitmap );
@ -5423,6 +5494,7 @@ void MyFrame::updateFileMenu ( bool deleteExisting )
fileMenu->Append ( exportMSWordItem ); fileMenu->Append ( exportMSWordItem );
#endif #endif
history.AddFilesToMenu ( fileMenu ); history.AddFilesToMenu ( fileMenu );
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();
fileMenu->Append ( exitItem ); fileMenu->Append ( exitItem );
} }
@ -5808,7 +5880,7 @@ void MyFrame::OnAssociate ( wxCommandEvent& event )
message.Printf ( message.Printf (
_ ( "Cannot associate %s: %s" ), _ ( "Cannot associate %s: %s" ),
type.c_str(), type.c_str(),
wellformedparser->getLastError() ); wellformedparser->getLastError().c_str() );
messagePane ( message, CONST_STOP ); messagePane ( message, CONST_STOP );
return; return;
} }
@ -5907,18 +5979,19 @@ void MyFrame::OnAssociate ( wxCommandEvent& event )
void MyFrame::openRememberedTabs() void MyFrame::openRememberedTabs()
{ {
if ( openTabsOnClose.empty() ) Freeze();
return;
wxArrayString v = wxSplit ( openTabsOnClose, _T ( '|' ) );
if ( v.empty() )
return;
wxArrayString::iterator vit; wxStringTokenizer files ( openTabsOnClose, _T ( "|" ) );
for ( vit = v.begin(); vit != v.end(); vit++ ) while ( files.HasMoreTokens() )
{ {
if ( vit->IsEmpty() || !openFile ( *vit ) ) wxString file = files.GetNextToken();
if ( file.IsEmpty() || !openFile ( file ) )
continue; //break; // Ignore errors continue; //break; // Ignore errors
} }
Thaw();
mainBook->Layout();
XmlDoc *doc; XmlDoc *doc;
if ( ( doc = getActiveDocument() ) != NULL ) if ( ( doc = getActiveDocument() ) != NULL )
doc->SetFocus(); doc->SetFocus();
@ -5948,11 +6021,8 @@ void MyFrame::OnWordCount ( wxCommandEvent& event )
wxString msg; wxString msg;
if ( !xwc->parse ( buffer.c_str() ) ) if ( !xwc->parse ( buffer.c_str() ) )
{ {
std::string error = xwc->getLastError();
wxString werror = wxString ( error.c_str(), wxConvUTF8, error.size() );
statusProgress ( wxEmptyString ); statusProgress ( wxEmptyString );
msg.Printf ( _ ( "Cannot count words: %s" ), xwc->getLastError().c_str() );
msg.Printf ( _ ( "Cannot count words: %s" ), werror.c_str() );
messagePane ( msg, CONST_STOP ); messagePane ( msg, CONST_STOP );
return; return;
} }

View File

@ -176,6 +176,9 @@ class MyApp : public wxApp
#ifndef __WXMSW__ #ifndef __WXMSW__
virtual void HandleEvent ( wxEvtHandler *handler, wxEventFunction func, wxEvent& event ) const; virtual void HandleEvent ( wxEvtHandler *handler, wxEventFunction func, wxEvent& event ) const;
#endif #endif
const wxArrayString &getAvailableTranslations (
const wxArrayString *catalogLookupPathPrefixes = NULL,
const wxString *catelog = NULL );
protected: protected:
wxLocale myLocale; wxLocale myLocale;
private: private:

View File

@ -23,7 +23,11 @@
#else #else
#define FILE_FILTER _("All files (*)|*|XML (*.xml)|*.xml|XHTML (*.html)|*.html|DTD (*.dtd)|*.dtd|XML Schema (*.xsd)|*.xsd|RELAX NG grammar (*.rng)|*.rng|XSL (*.xsl)|*.xsl") #define FILE_FILTER _("All files (*)|*|XML (*.xml)|*.xml|XHTML (*.html)|*.html|DTD (*.dtd)|*.dtd|XML Schema (*.xsd)|*.xsd|RELAX NG grammar (*.rng)|*.rng|XSL (*.xsl)|*.xsl")
#endif #endif
#if wxCHECK_VERSION(2,9,0)
#define ABOUT_COPYRIGHT _(_T("Copyright © 2005-2009 Gerald Schmidt <gnschmidt@users.sourceforge.net>")) #define ABOUT_COPYRIGHT _(_T("Copyright © 2005-2009 Gerald Schmidt <gnschmidt@users.sourceforge.net>"))
#else
#define ABOUT_COPYRIGHT _("Copyright © 2005-2009 Gerald Schmidt <gnschmidt@users.sourceforge.net>")
#endif
#define ABOUT_DESCRIPTION _("\nXML Copy Editor is free software released under the GNU\nGeneral Public License.\n\nMany thanks are due to ") #define ABOUT_DESCRIPTION _("\nXML Copy Editor is free software released under the GNU\nGeneral Public License.\n\nMany thanks are due to ")
#define ABOUT_CONTRIBUTORS _T(\ #define ABOUT_CONTRIBUTORS _T(\
"Tim van Niekerk, Matt Smigielski,\n"\ "Tim van Niekerk, Matt Smigielski,\n"\

View File

@ -40,7 +40,7 @@ BEGIN_EVENT_TABLE ( XmlCtrl, wxStyledTextCtrl )
EVT_LEFT_UP ( XmlCtrl::OnMouseLeftUp ) EVT_LEFT_UP ( XmlCtrl::OnMouseLeftUp )
EVT_RIGHT_UP ( XmlCtrl::OnMouseRightUp ) EVT_RIGHT_UP ( XmlCtrl::OnMouseRightUp )
EVT_MIDDLE_DOWN ( XmlCtrl::OnMiddleDown ) EVT_MIDDLE_DOWN ( XmlCtrl::OnMiddleDown )
EVT_THREAD(wxEVT_COMMAND_VALIDATION_COMPLETED, XmlCtrl::OnValidationCompleted) EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_VALIDATION_COMPLETED, XmlCtrl::OnValidationCompleted)
END_EVENT_TABLE() END_EVENT_TABLE()
// global protection for validation threads // global protection for validation threads
@ -94,7 +94,11 @@ XmlCtrl::XmlCtrl (
bufferLen = strlen ( DEFAULT_XML_DECLARATION_UTF8 ); bufferLen = strlen ( DEFAULT_XML_DECLARATION_UTF8 );
} }
#if wxCHECK_VERSION(2,9,0)
AddTextRaw ( buffer, bufferLen ); AddTextRaw ( buffer, bufferLen );
#else
SendMsg ( 2001, bufferLen, ( long ) ( const char * ) buffer );
#endif
SetSelection ( 0, 0 ); SetSelection ( 0, 0 );
@ -164,7 +168,7 @@ void XmlCtrl::OnIdle ( wxIdleEvent& event )
adjustNoColumnWidth(); // exits if unchanged adjustNoColumnWidth(); // exits if unchanged
} }
void XmlCtrl::OnValidationCompleted ( wxThreadEvent &event ) void XmlCtrl::OnValidationCompleted ( wxCommandEvent &event )
{ {
wxCriticalSectionLocker locker ( xmlcopyeditorCriticalSection ); wxCriticalSectionLocker locker ( xmlcopyeditorCriticalSection );
@ -472,12 +476,7 @@ void XmlCtrl::handleOpenAngleBracket ( wxKeyEvent& event )
if ( parentCloseAngleBracket < 0 ) if ( parentCloseAngleBracket < 0 )
return; return;
wxString wideParent = getLastElementName ( parentCloseAngleBracket ); wxString parent = getLastElementName ( parentCloseAngleBracket );
if ( wideParent.empty() )
return;
std::string parent = ( const char * ) wideParent.mb_str ( wxConvUTF8 );
if ( elementMap.find ( parent ) == elementMap.end() ) if ( elementMap.find ( parent ) == elementMap.end() )
return; return;

View File

@ -185,7 +185,7 @@ class XmlCtrl: public wxStyledTextCtrl
void OnMarginClick ( wxStyledTextEvent& event ); void OnMarginClick ( wxStyledTextEvent& event );
void OnChar ( wxKeyEvent& event ); void OnChar ( wxKeyEvent& event );
void OnIdle ( wxIdleEvent& event ); void OnIdle ( wxIdleEvent& event );
void OnValidationCompleted (wxThreadEvent &event); void OnValidationCompleted (wxCommandEvent &event);
void OnKeyPressed ( wxKeyEvent& event ); void OnKeyPressed ( wxKeyEvent& event );
void OnMouseLeftDown ( wxMouseEvent& event ); void OnMouseLeftDown ( wxMouseEvent& event );
void OnMouseLeftUp ( wxMouseEvent& event ); void OnMouseLeftUp ( wxMouseEvent& event );

View File

@ -261,7 +261,9 @@ void XMLCALL XmlPromptGenerator::attlistdeclhandler (
PromptGeneratorData *d; PromptGeneratorData *d;
d = ( PromptGeneratorData * ) data; d = ( PromptGeneratorData * ) data;
std::set<wxString> &attributeValues = d->attributeMap[elname][attname]; wxString element ( elname, wxConvUTF8 );
wxString attribute ( attname, wxConvUTF8 );
std::set<wxString> &attributeValues = d->attributeMap[element][attribute];
if ( *att_type == '(' ) // change to exclude _known_ identifiers? if ( *att_type == '(' ) // change to exclude _known_ identifiers?
{ {
const char *s, *word; const char *s, *word;
@ -283,7 +285,7 @@ void XMLCALL XmlPromptGenerator::attlistdeclhandler (
if ( isrequired ) if ( isrequired )
{ {
d->requiredAttributeMap[elname].insert ( wxString ( attname, wxConvUTF8 ) ); d->requiredAttributeMap[element].insert ( attribute );
} }
} }

View File

@ -145,9 +145,9 @@ void XMLCALL XmlShallowValidator::skippedentity (
{ {
if ( is_parameter_entity ) if ( is_parameter_entity )
return; return;
XmlShallowValidatorData *vd; XmlShallowValidatorData *vd = ( XmlShallowValidatorData * ) data;
vd = ( XmlShallowValidatorData * ) data; wxString entity ( entityName, wxConvUTF8 );
if ( vd->entitySet.find ( entityName ) != vd->entitySet.end() ) if ( vd->entitySet.find ( entity ) != vd->entitySet.end() )
return; return;
vd->isValid = false; vd->isValid = false;