X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/69108ccb4e8de4279ffa0fdd4e23ea3666f84e92..914955aaa034862c3b9b827463cde26455d06c79:/src/generic/helpext.cpp diff --git a/src/generic/helpext.cpp b/src/generic/helpext.cpp index d8649e494f..840ae94fa0 100644 --- a/src/generic/helpext.cpp +++ b/src/generic/helpext.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: helpext.cpp -// Purpose: an external help controller for wxWindows +// Purpose: an external help controller for wxWidgets // Author: Karsten Ballueder // Modified by: // Created: 04/01/98 @@ -9,7 +9,7 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) # pragma implementation "wxexthlp.h" #endif @@ -19,7 +19,7 @@ #pragma hdrstop #endif -#if wxUSE_HELP +#if wxUSE_HELP && !defined(__WXWINCE__) && (!defined(__WXMAC__) || defined(__WXMAC_OSX__)) #ifndef WX_PRECOMP #include "wx/setup.h" @@ -27,6 +27,9 @@ #include "wx/utils.h" #include "wx/list.h" #include "wx/intl.h" + #include "wx/msgdlg.h" + #include "wx/choicdlg.h" + #include "wx/log.h" #endif #include "wx/helpbase.h" @@ -42,6 +45,7 @@ #ifdef __WXMSW__ #include +#include "wx/msw/winundef.h" #endif // ---------------------------------------------------------------------------- @@ -119,9 +123,8 @@ wxExtHelpController::DisplayHelp(const wxString &relativeURL) wxLogSysError(_("Cannot open URL '%s'"), relativeURL.c_str()); return false; } - else - return true; + return true; #elif defined(__WXPM__) wxString url; @@ -135,7 +138,7 @@ wxExtHelpController::DisplayHelp(const wxString &relativeURL) // return false; // } // else - return TRUE; + return true; #elif defined(__DOS__) @@ -171,7 +174,7 @@ wxExtHelpController::DisplayHelp(const wxString &relativeURL) << WXEXTHELP_SEPARATOR << relativeURL << wxT(")"); success = wxExecute(command); if(success != 0 ) // returns PID on success - return TRUE; + return true; } } #endif @@ -196,11 +199,11 @@ void wxExtHelpController::DeleteList() { if(m_MapList) { - wxNode *node = m_MapList->GetFirst(); + wxList::compatibility_iterator node = m_MapList->GetFirst(); while (node) { delete (wxExtHelpMapEntry *)node->GetData(); - delete node; + m_MapList->Erase(node); node = m_MapList->GetFirst(); } delete m_MapList; @@ -229,7 +232,7 @@ bool wxExtHelpController::LoadFile(const wxString& ifile) wxBusyCursor b; // display a busy cursor - if(! ifile.IsEmpty()) + if(! ifile.empty()) { file = ifile; if(! wxIsAbsolutePath(file)) @@ -252,11 +255,11 @@ bool wxExtHelpController::LoadFile(const wxString& ifile) // set to be "de", then look in "/usr/local/myapp/help/de/" // first and fall back to "/usr/local/myapp/help" if that // doesn't exist. - if(wxGetLocale() && !wxGetLocale()->GetName().IsEmpty()) + if(wxGetLocale() && !wxGetLocale()->GetName().empty()) { wxString newfile; newfile << WXEXTHELP_SEPARATOR << wxGetLocale()->GetName(); - if(wxDirExists(newfile)) + if(wxPathExists(newfile)) file = newfile; else { @@ -264,14 +267,14 @@ bool wxExtHelpController::LoadFile(const wxString& ifile) const wxChar *cptr = wxGetLocale()->GetName().c_str(); while(*cptr && *cptr != wxT('_')) newfile << *(cptr++); - if(wxDirExists(newfile)) + if(wxPathExists(newfile)) file = newfile; } } #endif - if(! wxDirExists(file)) - return FALSE; + if(! wxPathExists(file)) + return false; mapFile << file << WXEXTHELP_SEPARATOR << WXEXTHELP_MAPFILE; } @@ -279,7 +282,7 @@ bool wxExtHelpController::LoadFile(const wxString& ifile) mapFile = m_MapFile; if(! wxFileExists(mapFile)) - return FALSE; + return false; DeleteList(); m_MapList = new wxList; @@ -287,7 +290,7 @@ bool wxExtHelpController::LoadFile(const wxString& ifile) FILE *input = wxFopen(mapFile,wxT("rt")); if(! input) - return FALSE; + return false; do { if(fgets(buffer,WXEXTHELP_BUFLEN,input) && *buffer != WXEXTHELP_COMMENTCHAR) @@ -299,13 +302,13 @@ bool wxExtHelpController::LoadFile(const wxString& ifile) break; // error for(i=0; isdigit(buffer[i])||isspace(buffer[i])||buffer[i]=='-'; i++) ; // find begin of URL - url = wxT(""); + url = wxEmptyString; while(buffer[i] && ! isspace(buffer[i]) && buffer[i] != WXEXTHELP_COMMENTCHAR) url << (wxChar) buffer[i++]; while(buffer[i] && buffer[i] != WXEXTHELP_COMMENTCHAR) i++; - doc = wxT(""); + doc = wxEmptyString; if(buffer[i]) doc = wxString::FromAscii( (buffer + i + 1) ); // skip the comment character m_MapList->Append(new wxExtHelpMapEntry(id,url,doc)); @@ -315,7 +318,7 @@ bool wxExtHelpController::LoadFile(const wxString& ifile) fclose(input); m_MapFile = file; // now it's valid - return TRUE; + return true; } @@ -323,10 +326,10 @@ bool wxExtHelpController::DisplayContents() { if(! m_NumOfEntries) - return FALSE; + return false; wxString contents; - wxNode *node = m_MapList->GetFirst(); + wxList::compatibility_iterator node = m_MapList->GetFirst(); wxExtHelpMapEntry *entry; while(node) { @@ -339,7 +342,7 @@ wxExtHelpController::DisplayContents() node = node->GetNext(); } - bool rc = FALSE; + bool rc = false; wxString file; file << m_MapFile << WXEXTHELP_SEPARATOR << contents; if(file.Contains(wxT('#'))) @@ -348,17 +351,17 @@ wxExtHelpController::DisplayContents() rc = DisplaySection(CONTENTS_ID); // if not found, open homemade toc: - return rc ? TRUE : KeywordSearch(wxT("")); + return rc ? true : KeywordSearch(wxEmptyString); } bool wxExtHelpController::DisplaySection(int sectionNo) { if(! m_NumOfEntries) - return FALSE; + return false; wxBusyCursor b; // display a busy cursor - wxNode *node = m_MapList->GetFirst(); + wxList::compatibility_iterator node = m_MapList->GetFirst(); wxExtHelpMapEntry *entry; while(node) { @@ -367,7 +370,7 @@ wxExtHelpController::DisplaySection(int sectionNo) return DisplayHelp(entry->url); node = node->GetNext(); } - return FALSE; + return false; } bool wxExtHelpController::DisplaySection(const wxString& section) @@ -387,10 +390,11 @@ wxExtHelpController::DisplayBlock(long blockNo) } bool -wxExtHelpController::KeywordSearch(const wxString& k) +wxExtHelpController::KeywordSearch(const wxString& k, + wxHelpSearchMode WXUNUSED(mode)) { if(! m_NumOfEntries) - return FALSE; + return false; wxString *choices = new wxString[m_NumOfEntries]; wxString *urls = new wxString[m_NumOfEntries]; @@ -398,8 +402,8 @@ wxExtHelpController::KeywordSearch(const wxString& k) int idx = 0, j; bool rc; - bool showAll = k.IsEmpty(); - wxNode *node = m_MapList->GetFirst(); + bool showAll = k.empty(); + wxList::compatibility_iterator node = m_MapList->GetFirst(); wxExtHelpMapEntry *entry; { @@ -409,14 +413,14 @@ wxExtHelpController::KeywordSearch(const wxString& k) { entry = (wxExtHelpMapEntry *)node->GetData(); compB = entry->doc; compB.LowerCase(); - if((showAll || compB.Contains(k)) && ! compB.IsEmpty()) + if((showAll || compB.Contains(k)) && ! compB.empty()) { urls[idx] = entry->url; // doesn't work: // choices[idx] = (**i).doc.Contains((**i).doc.Before(WXEXTHELP_COMMENTCHAR)); - //if(choices[idx].IsEmpty()) // didn't contain the ';' + //if(choices[idx].empty()) // didn't contain the ';' // choices[idx] = (**i).doc; - choices[idx] = wxT(""); + choices[idx] = wxEmptyString; for(j=0;entry->doc.c_str()[j] && entry->doc.c_str()[j] != WXEXTHELP_COMMENTCHAR; j++) choices[idx] << entry->doc.c_str()[j]; @@ -431,7 +435,7 @@ wxExtHelpController::KeywordSearch(const wxString& k) else if(idx == 0) { wxMessageBox(_("No entries found.")); - rc = FALSE; + rc = false; } else { @@ -441,7 +445,7 @@ wxExtHelpController::KeywordSearch(const wxString& k) if(idx != -1) rc = DisplayHelp(urls[idx]); else - rc = FALSE; + rc = false; } delete[] urls; delete[] choices; @@ -452,7 +456,7 @@ wxExtHelpController::KeywordSearch(const wxString& k) bool wxExtHelpController::Quit() { - return TRUE; + return true; } void wxExtHelpController::OnQuit()