summaryrefslogtreecommitdiff
path: root/support/dktools/Dk4WxHelpController.h
blob: 8a6615aaa8eed2f64f4f5af7904a1165b9b35fea (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*
	WARNING: This file was generated by dkct.
	Changes you make here will be lost if dkct is run again!
	You should modify the original source and run dkct on it.
	Original source: Dk4WxHelpController.cpt
*/

/*
Copyright (C) 2015-2017, Dirk Krause

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
  this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above opyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used
  to endorse or promote products derived from this software without specific
  prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef DK4WXHELPCONTROLLER_H_INCLUDED
/** Avoid multiple inclusions. */
#define DK4WXHELPCONTROLLER_H_INCLUDED 1


#line 9 "Dk4WxHelpController.cpt"

/**	@file	Dk4WxHelpController.h	Help controller class.
*/

#ifndef DK4CONF_H_INCLUDED
#include "dk4conf.h"
#endif

#ifndef DK4TYPES_H_INCLUDED
#include "dk4types.h"
#endif

#ifndef WX_WXPREC_H_INCLUDED
#include <wx/wxprec.h>
#define	WX_WXPREC_H_INCLUDED 1
#endif

#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#ifndef WX_WX_H_INCLUDED
#include <wx/wx.h>
#define	WX_WX_H_INCLUDED 1
#endif
#endif
#ifndef WX_CONFIG_H_INCLUDED
#include <wx/config.h>
#define	WX_CONFIG_H_INCLUDED 1
#endif
#ifndef WX_FILENAME_H_INCLUDED
#include <wx/filename.h>
#define	WX_FILENAME_H_INCLUDED 1
#endif
#ifndef WX_HELP_H_INCLUDED
#include <wx/help.h>
#define	WX_HELP_H_INCLUDED 1
#endif
#ifndef WX_FS_ZIP_H_INCLUDED
#include <wx/fs_zip.h>
#define	WX_FS_ZIP_H_INCLUDED 1
#endif
#ifndef WX_THREAD_H_INCLUDED
#include <wx/thread.h>
#define	WX_THREAD_H_INCLUDED 1
#endif

#ifndef DK4WXAPPLICATIONHELPER_H_INCLUDED
#include "Dk4WxApplicationHelper.h"
#endif


/**	Help controller dealing with both CHM and HTB files.
*/
class Dk4WxHelpController
{
  protected:

    /**	Synchronized access.
    */
    wxCriticalSection		 csProtect;

#ifdef __WXMSW__
    /**	Help controller for CHM files used on Windows.
    */
    wxCHMHelpController		 oHelpController;
#else
    /**	Help controller for HTB files used on non-Windows systems.
    */
    wxHtmlHelpController	 oHelpController;
#endif

    /**	Application helper, used for for search.
    */
    Dk4WxApplicationHelper	*pAppHelp;

    /**	Short file name of help file.
    */
    dkChar			*pdksShortFileName;

    /**	Flag: Contents was already loaded.
    */
    bool			 bLoaded;

    /**	Flag: Help file was found.
    */
    bool			 bFileFound;

  protected:

    /**	Attempt to load the help file.
    */
    void
    AttemptToLoadFile(void);

    /**	Show error message.
    */
    void
    ShowErrorMessage(size_t i_title = 0, size_t i_text = 1);

  public:

    /**	Default constructor.
	Just set the pointers to NULL.
    */
    Dk4WxHelpController();

    /**	Destructor.
    */
    ~Dk4WxHelpController();

    /**	Initialize the controller (keep pointers).
	@param	ahptr	Application helper for file search.
	@param	chmName	CHM help file name for windows.
	@param	htbName	HTB help file name for other systems.
	@return	True on success, false on error.
    */
    bool
    Initialize(
      Dk4WxApplicationHelper	*ahptr,
      const dkChar		*chmName,
      const dkChar		*htbName
    );

    /**	Clean up.
    */
    void
    Cleanup(void);

    /**	Open help system.
    */
    void
    DisplayContents(void);
    
    /**	Open help section specified by name.
	@param	name	Section name.
    */
    void
    DisplaySection(wxString const & name);

    /**	Open a help section specified by number.
	@param	number	Section number (context ID).
    */
    void
    DisplaySection(int number);

};


#endif