X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1020103f16649373e73561004099dac972747c91..7ea1c917764fb2588fe1aadc75c49ba300f8cb2f:/src/generic/helpext.cpp diff --git a/src/generic/helpext.cpp b/src/generic/helpext.cpp index 1f89d737a2..1bf7d2b43d 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 +// Name: src/generic/helpext.cpp +// Purpose: an external help controller for wxWidgets // Author: Karsten Ballueder // Modified by: // Created: 04/01/98 @@ -9,20 +9,15 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -# pragma implementation "wxexthlp.h" -#endif - #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif -#if wxUSE_HELP && !defined(__WXWINCE__) +#if wxUSE_HELP && !defined(__WXWINCE__) && (!defined(__WXMAC__) || defined(__WXMAC_OSX__)) #ifndef WX_PRECOMP - #include "wx/setup.h" #include "wx/string.h" #include "wx/utils.h" #include "wx/list.h" @@ -43,8 +38,13 @@ #include #endif +#ifdef __WINDOWS__ +#include "wx/msw/mslu.h" +#endif + #ifdef __WXMSW__ #include +#include "wx/msw/winundef.h" #endif // ---------------------------------------------------------------------------- @@ -73,7 +73,8 @@ IMPLEMENT_CLASS(wxExtHelpController, wxHelpControllerBase) and a file mapping numerical Section numbers to relative URLS. */ -wxExtHelpController::wxExtHelpController() +wxExtHelpController::wxExtHelpController(wxWindow* parentWindow): + wxHelpControllerBase(parentWindow) { m_MapList = (wxList*) NULL; m_NumOfEntries = 0; @@ -122,10 +123,9 @@ wxExtHelpController::DisplayHelp(const wxString &relativeURL) wxLogSysError(_("Cannot open URL '%s'"), relativeURL.c_str()); return false; } - else - return true; -#elif defined(__WXPM__) + return true; +#elif defined(__OS2__) wxString url; url << m_MapFile << '\\' << relativeURL.BeforeFirst('#'); @@ -138,7 +138,7 @@ wxExtHelpController::DisplayHelp(const wxString &relativeURL) // return false; // } // else - return TRUE; + return true; #elif defined(__DOS__) @@ -174,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 @@ -232,14 +232,12 @@ bool wxExtHelpController::LoadFile(const wxString& ifile) wxBusyCursor b; // display a busy cursor - if(! ifile.IsEmpty()) + if(! ifile.empty()) { file = ifile; if(! wxIsAbsolutePath(file)) { - wxChar* f = wxGetWorkingDirectory(); - file = f; - delete[] f; // wxGetWorkingDirectory returns new memory + file = wxGetCwd(); #ifdef __WXMAC__ file << ifile; #else @@ -255,7 +253,7 @@ 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(); @@ -274,7 +272,7 @@ bool wxExtHelpController::LoadFile(const wxString& ifile) #endif if(! wxDirExists(file)) - return FALSE; + return false; mapFile << file << WXEXTHELP_SEPARATOR << WXEXTHELP_MAPFILE; } @@ -282,7 +280,7 @@ bool wxExtHelpController::LoadFile(const wxString& ifile) mapFile = m_MapFile; if(! wxFileExists(mapFile)) - return FALSE; + return false; DeleteList(); m_MapList = new wxList; @@ -290,7 +288,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) @@ -302,13 +300,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)); @@ -318,7 +316,7 @@ bool wxExtHelpController::LoadFile(const wxString& ifile) fclose(input); m_MapFile = file; // now it's valid - return TRUE; + return true; } @@ -326,7 +324,7 @@ bool wxExtHelpController::DisplayContents() { if(! m_NumOfEntries) - return FALSE; + return false; wxString contents; wxList::compatibility_iterator node = m_MapList->GetFirst(); @@ -342,23 +340,23 @@ wxExtHelpController::DisplayContents() node = node->GetNext(); } - bool rc = FALSE; + bool rc = false; wxString file; file << m_MapFile << WXEXTHELP_SEPARATOR << contents; if(file.Contains(wxT('#'))) file = file.BeforeLast(wxT('#')); - if(contents.Length() && wxFileExists(file)) + if(contents.length() && wxFileExists(file)) 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 wxList::compatibility_iterator node = m_MapList->GetFirst(); @@ -370,7 +368,7 @@ wxExtHelpController::DisplaySection(int sectionNo) return DisplayHelp(entry->url); node = node->GetNext(); } - return FALSE; + return false; } bool wxExtHelpController::DisplaySection(const wxString& section) @@ -390,10 +388,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]; @@ -401,7 +400,7 @@ wxExtHelpController::KeywordSearch(const wxString& k) int idx = 0, j; bool rc; - bool showAll = k.IsEmpty(); + bool showAll = k.empty(); wxList::compatibility_iterator node = m_MapList->GetFirst(); wxExtHelpMapEntry *entry; @@ -412,14 +411,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]; @@ -434,7 +433,7 @@ wxExtHelpController::KeywordSearch(const wxString& k) else if(idx == 0) { wxMessageBox(_("No entries found.")); - rc = FALSE; + rc = false; } else { @@ -444,7 +443,7 @@ wxExtHelpController::KeywordSearch(const wxString& k) if(idx != -1) rc = DisplayHelp(urls[idx]); else - rc = FALSE; + rc = false; } delete[] urls; delete[] choices; @@ -455,7 +454,7 @@ wxExtHelpController::KeywordSearch(const wxString& k) bool wxExtHelpController::Quit() { - return TRUE; + return true; } void wxExtHelpController::OnQuit() @@ -464,4 +463,3 @@ void wxExtHelpController::OnQuit() #endif // wxUSE_HELP -