diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:23:48 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:23:48 +0200 |
commit | ee1c8c5c25d25dfa42120125a8a45dc9831ee412 (patch) | |
tree | 67aa287157db954e0cadeee05b4aad331eb2ecf2 /lib/help_provider.h | |
parent | 5.13 (diff) | |
download | FreeFileSync-ee1c8c5c25d25dfa42120125a8a45dc9831ee412.tar.gz FreeFileSync-ee1c8c5c25d25dfa42120125a8a45dc9831ee412.tar.bz2 FreeFileSync-ee1c8c5c25d25dfa42120125a8a45dc9831ee412.zip |
5.14
Diffstat (limited to 'lib/help_provider.h')
-rw-r--r-- | lib/help_provider.h | 72 |
1 files changed, 50 insertions, 22 deletions
diff --git a/lib/help_provider.h b/lib/help_provider.h index 215b7dac..8227efb5 100644 --- a/lib/help_provider.h +++ b/lib/help_provider.h @@ -7,8 +7,14 @@ #ifndef HELPPROVIDER_H_INCLUDED #define HELPPROVIDER_H_INCLUDED -#include <wx/help.h> +#ifdef FFS_WIN #include <zen/zstring.h> +#include <wx/msw/helpchm.h> + +#elif defined FFS_LINUX || defined FFS_MAC +#include <wx/html/helpctrl.h> +#endif + #include "ffs_paths.h" namespace zen @@ -25,45 +31,67 @@ void displayHelpEntry(const wxString& section, wxWindow* parent); +//######################## implementation ######################## +namespace impl +{ +//finish wxWidgets' job +#ifdef FFS_WIN +class FfsHelpController +{ +public: + FfsHelpController() + { + chmHlp.Initialize(utfCvrtTo<wxString>(zen::getResourceDir()) + L"FreeFileSync.chm"); + } + void openSection(const wxString& section, wxWindow* parent) + { + if (section.empty()) + chmHlp.DisplayContents(); + else + chmHlp.DisplaySection(replaceCpy(section, L'/', utfCvrtTo<wxString>(FILE_NAME_SEPARATOR))); + } +private: + wxCHMHelpController chmHlp; +}; +#elif defined FFS_LINUX || defined FFS_MAC +class FfsHelpController +{ +public: + void openSection(const wxString& section, wxWindow* parent) + { + wxHtmlModalHelp dlg(parent, utfCvrtTo<wxString>(zen::getResourceDir()) + L"Help/FreeFileSync.hhp", section, + wxHF_DEFAULT_STYLE | wxHF_DIALOG | wxHF_MODAL | wxHF_MERGE_BOOKS); + (void)dlg; + //-> solves modal help craziness on OSX! + //-> Suse Linux: avoids program hang on exit if user closed help parent dialog before the help dialog itself was closed (why is this even possible???) + // avoids ESC key not being recognized by help dialog (but by parent dialog instead) + } +}; +#endif -//######################## implementation ######################## inline -wxHelpController& getHelpCtrl() +FfsHelpController& getHelpCtrl() { - static wxHelpController controller; //external linkage, despite inline definition! - static bool initialized = false; - if (!initialized) - { - initialized = true; - controller.Initialize(utfCvrtTo<wxString>(zen::getResourceDir()) + -#ifdef FFS_WIN - L"FreeFileSync.chm"); -#elif defined FFS_LINUX || defined FFS_MAC - L"Help/FreeFileSync.hhp"); -#endif - } - return controller; + static FfsHelpController ctrl; //external linkage, despite inline definition! + return ctrl; +} } inline void displayHelpEntry(const wxString& section, wxWindow* parent) { - getHelpCtrl().SetParentWindow(parent); //this nicely solves modal issues on OSX with help file going to the background - getHelpCtrl().DisplaySection(replaceCpy(section, L'/', utfCvrtTo<wxString>(FILE_NAME_SEPARATOR))); - getHelpCtrl().SetParentWindow(nullptr); + impl::getHelpCtrl().openSection(section, parent); } inline void displayHelpEntry(wxWindow* parent) { - getHelpCtrl().SetParentWindow(parent); - getHelpCtrl().DisplayContents(); - getHelpCtrl().SetParentWindow(nullptr); + impl::getHelpCtrl().openSection(wxString(), parent); } } |