summaryrefslogtreecommitdiff
path: root/lib/help_provider.h
blob: 8ddc34c7fb296dd77f3cb546d2eb921f8ae7df37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// **************************************************************************
// * This file is part of the FreeFileSync project. It is distributed under *
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html       *
// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved        *
// **************************************************************************

#ifndef HELPPROVIDER_H_INCLUDED
#define HELPPROVIDER_H_INCLUDED

#ifdef ZEN_WIN
#include <zen/zstring.h>
#include <wx/msw/helpchm.h>

#elif defined ZEN_LINUX || defined ZEN_MAC
#include <wx/html/helpctrl.h>
#endif

#include "ffs_paths.h"

namespace zen
{
//use '/' as path separator!
void displayHelpEntry(wxWindow* parent);
void displayHelpEntry(const wxString& section, wxWindow* parent);









//######################## implementation ########################
namespace impl
{
//finish wxWidgets' job
#ifdef ZEN_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 ZEN_LINUX || defined ZEN_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


inline
FfsHelpController& getHelpCtrl()
{
    static FfsHelpController ctrl; //external linkage, despite inline definition!
    return ctrl;
}
}


inline
void displayHelpEntry(const wxString& section, wxWindow* parent)
{
    impl::getHelpCtrl().openSection(section, parent);
}


inline
void displayHelpEntry(wxWindow* parent)
{
    impl::getHelpCtrl().openSection(wxString(), parent);
}
}

#endif //HELPPROVIDER_H_INCLUDED
bgstack15