1 /*
2 Copyright (C) 2015-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: Dk4WxHelpController.cpt
12 */
13 
14 #ifndef DK4WXHELPCONTROLLER_H_INCLUDED
15 /** Avoid multiple inclusions. */
16 #define DK4WXHELPCONTROLLER_H_INCLUDED 1
17 
18 
19 /**	@file	Dk4WxHelpController.h	Help controller class.
20 */
21 
22 #ifndef DK4CONF_H_INCLUDED
23 #if DK4_BUILDING_DKTOOLS4
24 #include "dk4conf.h"
25 #else
26 #include <dktools-4/dk4conf.h>
27 #endif
28 #endif
29 
30 #ifndef DK4TYPES_H_INCLUDED
31 #if DK4_BUILDING_DKTOOLS4
32 #include <libdk4base/dk4types.h>
33 #else
34 #include <dktools-4/dk4types.h>
35 #endif
36 #endif
37 
38 #ifndef WX_WXPREC_H_INCLUDED
39 #include <wx/wxprec.h>
40 #define	WX_WXPREC_H_INCLUDED 1
41 #endif
42 
43 #ifdef __BORLANDC__
44 #pragma hdrstop
45 #endif
46 #ifndef WX_PRECOMP
47 #ifndef WX_WX_H_INCLUDED
48 #include <wx/wx.h>
49 #define	WX_WX_H_INCLUDED 1
50 #endif
51 #endif
52 #ifndef WX_CONFIG_H_INCLUDED
53 #include <wx/config.h>
54 #define	WX_CONFIG_H_INCLUDED 1
55 #endif
56 #ifndef WX_FILENAME_H_INCLUDED
57 #include <wx/filename.h>
58 #define	WX_FILENAME_H_INCLUDED 1
59 #endif
60 #ifndef WX_HELP_H_INCLUDED
61 #include <wx/help.h>
62 #define	WX_HELP_H_INCLUDED 1
63 #endif
64 #ifndef WX_FS_ZIP_H_INCLUDED
65 #include <wx/fs_zip.h>
66 #define	WX_FS_ZIP_H_INCLUDED 1
67 #endif
68 #ifndef WX_THREAD_H_INCLUDED
69 #include <wx/thread.h>
70 #define	WX_THREAD_H_INCLUDED 1
71 #endif
72 
73 #ifndef DK4WXAPPLICATIONHELPER_H_INCLUDED
74 #if DK4_BUILDING_DKTOOLS4
75 #include <libdk4wx/Dk4WxApplicationHelper.h>
76 #else
77 #include <dktools-4/Dk4WxApplicationHelper.h>
78 #endif
79 #endif
80 
81 
82 /**	Help controller dealing with both CHM and HTB files.
83 */
84 class Dk4WxHelpController
85 {
86   protected:
87 
88     /**	Synchronized access.
89     */
90     wxCriticalSection		 csProtect;
91 
92 #ifdef __WXMSW__
93     /**	Help controller for CHM files used on Windows.
94     */
95     wxCHMHelpController		 oHelpController;
96 #else
97     /**	Help controller for HTB files used on non-Windows systems.
98     */
99     wxHtmlHelpController	 oHelpController;
100 #endif
101 
102     /**	Application helper, used for for search.
103     */
104     Dk4WxApplicationHelper	*pAppHelp;
105 
106     /**	Short file name of help file.
107     */
108     dkChar			*pdksShortFileName;
109 
110     /**	Flag: Contents was already loaded.
111     */
112     bool			 bLoaded;
113 
114     /**	Flag: Help file was found.
115     */
116     bool			 bFileFound;
117 
118   protected:
119 
120     /**	Attempt to load the help file.
121     */
122     void
123     AttemptToLoadFile(void);
124 
125     /**	Show error message.
126     */
127     void
128     ShowErrorMessage(size_t i_title = 0, size_t i_text = 1);
129 
130   public:
131 
132     /**	Default constructor.
133 	Just set the pointers to NULL.
134     */
135     Dk4WxHelpController();
136 
137     /**	Destructor.
138     */
139     ~Dk4WxHelpController();
140 
141     /**	Initialize the controller (keep pointers).
142 	@param	ahptr	Application helper for file search.
143 	@param	chmName	CHM help file name for windows.
144 	@param	htbName	HTB help file name for other systems.
145 	@return	True on success, false on error.
146     */
147     bool
148     Initialize(
149       Dk4WxApplicationHelper	*ahptr,
150       const dkChar		*chmName,
151       const dkChar		*htbName
152     );
153 
154     /**	Clean up.
155     */
156     void
157     Cleanup(void);
158 
159     /**	Open help system.
160     */
161     void
162     DisplayContents(void);
163 
164     /**	Open help section specified by name.
165 	@param	name	Section name.
166     */
167     void
168     DisplaySection(wxString const & name);
169 
170     /**	Open a help section specified by number.
171 	@param	number	Section number (context ID).
172     */
173     void
174     DisplaySection(int number);
175 
176 };
177 
178 
179 #endif
180