diff --git a/common/basicframe.cpp b/common/basicframe.cpp index f97a71cb5b..258d6ba008 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -395,18 +395,27 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event ) */ if( event.GetId() == wxID_INDEX ) { - // Search for "getting_started_in_kicad.pdf" or "Getting_Started_in_KiCad.pdf" - wxString helpFile = SearchHelpFileFullPath( search, wxT( "getting_started_in_kicad.pdf" ) ); + // List of possible names for Getting Started in KiCad + const wxChar* names[2] = { + wxT( "getting_started_in_kicad" ), + wxT( "Getting_Started_in_KiCad" ) + }; - if( !helpFile ) - helpFile = SearchHelpFileFullPath( search, wxT( "Getting_Started_in_KiCad.pdf" ) ); + wxString helpFile; + // Search for "getting_started_in_kicad.html" or "getting_started_in_kicad.pdf" + // or "Getting_Started_in_KiCad.html" or "Getting_Started_in_KiCad.pdf" + for( unsigned ii = 0; ii < DIM( names ); ii++ ) + { + helpFile = SearchHelpFileFullPath( search, names[ii] ); + + if( !helpFile.IsEmpty() ) + break; + } if( !helpFile ) { wxString msg = wxString::Format( _( - "Help file '%s' could not be found." ), - wxT( "getting_started_in_kicad.pdf" ) - ); + "Html or pdf help file \n'%s'\n or\n'%s' could not be found." ), names[0], names[1] ); wxMessageBox( msg ); } else @@ -418,24 +427,6 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event ) } wxString base_name = help_name(); - -#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML - - wxHtmlHelpController* hc = Pgm().GetHtmlHelpController(); - - wxString helpFile = SearchHelpFileFullPath( search, ); - - if( !!helpFile ) - { - hc->UseConfig( Pgm().CommonSettings() ); - hc->SetTitleFormat( wxT( "KiCad Help" ) ); - hc->AddBook( helpFile ); - } - - hc->DisplayContents(); - hc->Display( helpFile ); - -#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF wxString helpFile = SearchHelpFileFullPath( search, base_name ); if( !helpFile ) @@ -450,10 +441,6 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event ) { GetAssociatedDocument( this, helpFile ); } - -#else -# error Help files format not defined -#endif } diff --git a/common/bin_mod.cpp b/common/bin_mod.cpp index fec950e415..afce71336d 100644 --- a/common/bin_mod.cpp +++ b/common/bin_mod.cpp @@ -21,13 +21,11 @@ void BIN_MOD::Init() // Prepare On Line Help. Use only lower case for help file names, in order to // avoid problems with upper/lower case file names under windows and unix. -#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML - m_help_file = wxString::FromUTF8( m_name ) + wxT( ".html" ); -#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF - m_help_file = wxString::FromUTF8( m_name ) + wxT( ".pdf" ); -#else - #error Help files format not defined -#endif + // Help files are now using html format. + // Old help files used pdf format. + // so when searching a help file, the .html file will be searched, + // and if not found, the .pdf file will be searched. + m_help_file = wxString::FromUTF8( m_name ); // no ext given. can be .html or .pdf } diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp index cbdfade849..e521e3ce7d 100644 --- a/common/pgm_base.cpp +++ b/common/pgm_base.cpp @@ -263,7 +263,6 @@ PGM_BASE::PGM_BASE() { m_pgm_checker = NULL; m_file_checker = NULL; - m_html_ctrl = NULL; m_locale = NULL; m_common_settings = NULL; @@ -296,16 +295,6 @@ void PGM_BASE::destroy() delete m_locale; m_locale = 0; - - /* - // Close the help frame - if( m_html_ctrl && m_html_ctrl->GetFrame() ) // returns NULL if no help frame active - m_html_ctrl->GetFrame()->Close( true ); - } - */ - - delete m_html_ctrl; - m_html_ctrl = 0; } void PGM_BASE::ReleaseFile() @@ -431,40 +420,6 @@ bool PGM_BASE::initPgm() } -void PGM_BASE::initHtmlHelpController() -{ -#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML - - if( !m_html_ctrl ) - m_html_ctrl = new wxHtmlHelpController( - wxHF_TOOLBAR | wxHF_CONTENTS | - wxHF_PRINT | wxHF_OPEN_FILES - // | wxHF_SEARCH - ); - - wxASSERT( m_html_ctrl ); // may not leave here as NULL - -#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF - m_html_ctrl = NULL; - -#else - #error Help files format not defined -#endif -} - - -wxHtmlHelpController* PGM_BASE::HtmlHelpController() -{ - if( !m_html_ctrl ) - initHtmlHelpController(); - - // there should not be calls to this unless ONLINE_HELP_FILES_FORMAT_IS_HTML is defined - wxASSERT( m_html_ctrl ); - - return m_html_ctrl; -} - - bool PGM_BASE::setExecutablePath() { diff --git a/common/searchhelpfilefullpath.cpp b/common/searchhelpfilefullpath.cpp index 3ce17dfbd2..b551ce0bde 100644 --- a/common/searchhelpfilefullpath.cpp +++ b/common/searchhelpfilefullpath.cpp @@ -89,10 +89,20 @@ wxString SearchHelpFileFullPath( const SEARCH_STACK& aSStack, const wxString& aB printf( "%s: m_help_file:'%s'\n", __func__, TO_UTF8( aBaseName ) ); #endif - wxString fn = FindFileInSearchPaths( ss, aBaseName, &altsubdirs ); + // Help files can be html (.html ext) or pdf (.pdf ext) files. + // Therefore, .html file is searched and if not found, + // .pdf file is searched in the same paths + + wxString fn = FindFileInSearchPaths( ss, aBaseName + wxT(".html"), &altsubdirs ); if( !fn ) - fn = FindFileInSearchPaths( ss, aBaseName, &subdirs ); + fn = FindFileInSearchPaths( ss, aBaseName + wxT(".pdf"), &altsubdirs ); + + if( !fn ) + fn = FindFileInSearchPaths( ss, aBaseName + wxT(".html"), &subdirs ); + + if( !fn ) + fn = FindFileInSearchPaths( ss, aBaseName + wxT(".pdf"), &subdirs ); // Step 2 : if not found Try to find help file in help/ if( !fn ) @@ -104,10 +114,10 @@ wxString SearchHelpFileFullPath( const SEARCH_STACK& aSStack, const wxString& aB subdirs.Add( i18n->GetName().BeforeLast( '_' ) ); altsubdirs.Add( i18n->GetName().BeforeLast( '_' ) ); - fn = FindFileInSearchPaths( ss, aBaseName, &altsubdirs ); + fn = FindFileInSearchPaths( ss, aBaseName + wxT(".html"), &altsubdirs ); if( !fn ) - fn = FindFileInSearchPaths( ss, aBaseName, &subdirs ); + fn = FindFileInSearchPaths( ss, aBaseName + wxT(".pdf"), &subdirs ); } // Step 3 : if not found Try to find help file in help/en @@ -121,7 +131,13 @@ wxString SearchHelpFileFullPath( const SEARCH_STACK& aSStack, const wxString& aB fn = FindFileInSearchPaths( ss, aBaseName, &altsubdirs ); if( !fn ) - fn = FindFileInSearchPaths( ss, aBaseName, &subdirs ); + fn = FindFileInSearchPaths( ss, aBaseName + wxT(".pdf"), &altsubdirs ); + + if( !fn ) + fn = FindFileInSearchPaths( ss, aBaseName + wxT(".html"), &subdirs ); + + if( !fn ) + fn = FindFileInSearchPaths( ss, aBaseName + wxT(".pdf"), &subdirs ); } return fn; diff --git a/include/common.h b/include/common.h index fcf7c94177..87fc92209a 100644 --- a/include/common.h +++ b/include/common.h @@ -590,7 +590,10 @@ void SystemDirsAppend( SEARCH_STACK* aSearchStack ); * Function SearchHelpFileFullPath * returns the help file's full path. *

- * Return the KiCad help file with path. + * Return the KiCad help file with path and extension. + * Help files can be html (.html ext) or pdf (.pdf ext) files. + * A .html file is searched and if not found, + * .pdf file is searched in the same path. * If the help file for the current locale is not found, an attempt to find * the English version of the help file is made. * Help file is searched in directories in this order: @@ -600,7 +603,7 @@ void SystemDirsAppend( SEARCH_STACK* aSearchStack ); *

* @param aSearchStack contains some possible base dirs that may be above the * the one actually holding @a aBaseName. These are starting points for nested searches. - * @param aBaseName is the name of the help file to search for. + * @param aBaseName is the name of the help file to search for,

without extension

. * @return wxEmptyString is returned if aBaseName is not found, else the full path & filename. */ wxString SearchHelpFileFullPath( const SEARCH_STACK& aSearchStack, const wxString& aBaseName ); diff --git a/include/online_help.h b/include/online_help.h index 94ac63171b..e8ec66f043 100644 --- a/include/online_help.h +++ b/include/online_help.h @@ -8,10 +8,6 @@ /* * KiCad uses HTML or PDF file format in the online help (help command) - * Comment one of these 2 lines */ -#define ONLINE_HELP_FILES_FORMAT_IS_PDF -//#define ONLINE_HELP_FILES_FORMAT_IS_HTML - #endif /* #ifndef ONLINE_HELP_H */ diff --git a/include/pgm_base.h b/include/pgm_base.h index e2fc807652..cd78dc113d 100644 --- a/include/pgm_base.h +++ b/include/pgm_base.h @@ -38,7 +38,6 @@ class wxConfigBase; class wxSingleInstanceChecker; -class wxHtmlHelpController; class wxApp; class wxMenu; @@ -86,8 +85,6 @@ public: //--------------------------------------------------------- - VTBL_ENTRY wxHtmlHelpController* HtmlHelpController(); - VTBL_ENTRY wxConfigBase* CommonSettings() const { return m_common_settings; } VTBL_ENTRY void SetEditorName( const wxString& aFileName ); @@ -215,8 +212,6 @@ protected: */ bool initPgm(); - void initHtmlHelpController(); - /** * Function loadCommonSettings * loads the program (process) settings subset which are stored in .kicad_common @@ -269,8 +264,6 @@ protected: wxString m_editor_name; wxSize m_help_size; - wxHtmlHelpController* m_html_ctrl; - wxApp* m_wx_app; // The PGM_* classes can have difficulties at termination if they