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: Dk4WxFrame.cpt
12 */
13 
14 #ifndef DK4WXFRAME_H_INCLUDED
15 /** Avoid multiple inclusions. */
16 #define DK4WXFRAME_H_INCLUDED 1
17 
18 
19 /**	@file	Dk4WxFrame.h	Base class for top level frames.
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 #ifdef __BORLANDC__
43 #pragma hdrstop
44 #endif
45 #ifndef WX_PRECOMP
46 #ifndef WX_WX_H_INCLUDED
47 #include <wx/wx.h>
48 #define	WX_WX_H_INCLUDED 1
49 #endif
50 #endif
51 
52 #ifndef DK4WXAPPLICATIONHELPER_H_INCLUDED
53 #if DK4_BUILDING_DKTOOLS4
54 #include <libdk4wx/Dk4WxApplicationHelper.h>
55 #else
56 #include <dktools-4/Dk4WxApplicationHelper.h>
57 #endif
58 #endif
59 
60 #ifndef	DK4WXHELPCONTROLLER_H_INCLUDED
61 #if DK4_BUILDING_DKTOOLS4
62 #include <libdk4wx/Dk4WxHelpController.h>
63 #else
64 #include <dktools-4/Dk4WxHelpController.h>
65 #endif
66 #endif
67 
68 
69 
70 /**	Frame (top level window).
71 */
72 class Dk4WxFrame : public wxFrame
73 {
74   protected:
75 
76     /**	Application helper.
77     */
78     Dk4WxApplicationHelper	*pAppHelp;
79 
80     /**	Help controller for online help.
81     */
82     Dk4WxHelpController		*pHelp;
83 
84     /**	Application name.
85     */
86     wxString			 sAppName;
87 
88 
89     /**	Synchronize access to iInstances.
90     */
91     static wxCriticalSection	 csInstances;
92 
93     /**	Number of instances.
94     */
95     static int			 iInstances;
96 
97   public:
98 
99     /**	Constructor.
100 	@param	appName		Application name.
101 	@param	appHelper	Application helper.
102 	@param	helpController	Help controller.
103 	@param	wxid		Window ID.
104     */
105     Dk4WxFrame(
106       const wxString	&	 appName,
107       Dk4WxApplicationHelper	*appHelper,
108       Dk4WxHelpController	*helpController,
109       int			 wxid
110     );
111 
112     /**	Restore previously saved window position.
113     */
114     void
115     RestorePosition(void);
116 
117     /**	Handler for close event.
118 	@param	event	Event to process.
119     */
120     void
121     OnClose(wxCloseEvent & event);
122 
123     /**	Decide whether we can close the frame.
124 	@param	isFinal	Flag: Final frame.
125 	@return	True to close the frame, false to keep it.
126     */
127     virtual
128     bool
129     CanClose(bool isFinal);
130 
131 
132     /**	Open help system.
133     */
134     void
135     DisplayContents(void);
136 
137     /**	Open help section specified by name.
138 	@param	name	Section name.
139     */
140     void
141     DisplaySection(wxString const & name);
142 
143     /**	Open a help section specified by number.
144 	@param	number	Section number (context ID).
145     */
146     void
147     DisplaySection(int number);
148 
149     /**	Find data file and launch default application
150     	or web browser on it.
151 	@param	fn		File name to search for and use.
152 	@param	bIsHelp		Flag: File is a help file.
153 	@param	bVerbose	Flag: Show diagnostics on errors.
154 	@return	Success indicator.
155     */
156     bool
157     FindFileAndLaunch(
158     	dkChar const	*fn,
159 	bool		 bIsHelp	= false,
160 	bool		 bVerbose	= false
161     );
162 
163   protected:
164 
165     /**	Save current window position.
166     */
167     void
168     SavePosition(void);
169 
170 };
171 
172 
173 
174 
175 #endif
176