1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/html/helpctrl.h
3 // Purpose: wxHtmlHelpController
4 // Notes: Based on htmlhelp.cpp, implementing a monolithic
5 // HTML Help controller class, by Vaclav Slavik
6 // Author: Harm van der Heijden and Vaclav Slavik
7 // Copyright: (c) Harm van der Heijden and Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_HELPCTRL_H_
12 #define _WX_HELPCTRL_H_
18 #include "wx/helpbase.h"
19 #include "wx/html/helpfrm.h"
21 #define wxID_HTML_HELPFRAME (wxID_HIGHEST + 1)
23 // This style indicates that the window is
24 // embedded in the application and must not be
25 // destroyed by the help controller.
26 #define wxHF_EMBEDDED 0x00008000
28 // Create a dialog for the help window.
29 #define wxHF_DIALOG 0x00010000
31 // Create a frame for the help window.
32 #define wxHF_FRAME 0x00020000
34 // Make the dialog modal when displaying help.
35 #define wxHF_MODAL 0x00040000
37 class WXDLLIMPEXP_FWD_HTML wxHtmlHelpDialog
;
38 class WXDLLIMPEXP_FWD_HTML wxHtmlHelpWindow
;
39 class WXDLLIMPEXP_FWD_HTML wxHtmlHelpFrame
;
40 class WXDLLIMPEXP_FWD_HTML wxHtmlHelpDialog
;
42 class WXDLLIMPEXP_HTML wxHtmlHelpController
: public wxHelpControllerBase
// wxEvtHandler
44 DECLARE_DYNAMIC_CLASS(wxHtmlHelpController
)
47 wxHtmlHelpController(int style
= wxHF_DEFAULT_STYLE
, wxWindow
* parentWindow
= NULL
);
48 wxHtmlHelpController(wxWindow
* parentWindow
, int style
= wxHF_DEFAULT_STYLE
);
50 virtual ~wxHtmlHelpController();
52 void SetShouldPreventAppExit(bool enable
);
54 void SetTitleFormat(const wxString
& format
);
55 void SetTempDir(const wxString
& path
) { m_helpData
.SetTempDir(path
); }
56 bool AddBook(const wxString
& book_url
, bool show_wait_msg
= false);
57 bool AddBook(const wxFileName
& book_file
, bool show_wait_msg
= false);
59 bool Display(const wxString
& x
);
61 bool DisplayContents();
63 bool KeywordSearch(const wxString
& keyword
,
64 wxHelpSearchMode mode
= wxHELP_SEARCH_ALL
);
66 wxHtmlHelpWindow
* GetHelpWindow() { return m_helpWindow
; }
67 void SetHelpWindow(wxHtmlHelpWindow
* helpWindow
);
69 wxHtmlHelpFrame
* GetFrame() { return m_helpFrame
; }
70 wxHtmlHelpDialog
* GetDialog() { return m_helpDialog
; }
73 void UseConfig(wxConfigBase
*config
, const wxString
& rootpath
= wxEmptyString
);
75 // Assigns config object to the Ctrl. This config is then
76 // used in subsequent calls to Read/WriteCustomization of both help
77 // Ctrl and it's wxHtmlWindow
78 virtual void ReadCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
79 virtual void WriteCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
80 #endif // wxUSE_CONFIG
82 //// Backward compatibility with wxHelpController API
84 virtual bool Initialize(const wxString
& file
, int WXUNUSED(server
) ) { return Initialize(file
); }
85 virtual bool Initialize(const wxString
& file
);
86 virtual void SetViewer(const wxString
& WXUNUSED(viewer
), long WXUNUSED(flags
) = 0) {}
87 virtual bool LoadFile(const wxString
& file
= wxT(""));
88 virtual bool DisplaySection(int sectionNo
);
89 virtual bool DisplaySection(const wxString
& section
) { return Display(section
); }
90 virtual bool DisplayBlock(long blockNo
) { return DisplaySection(blockNo
); }
91 virtual bool DisplayTextPopup(const wxString
& text
, const wxPoint
& pos
);
93 virtual void SetFrameParameters(const wxString
& titleFormat
,
95 const wxPoint
& pos
= wxDefaultPosition
,
96 bool newFrameEachTime
= false);
97 /// Obtains the latest settings used by the help frame and the help
99 virtual wxFrame
*GetFrameParameters(wxSize
*size
= NULL
,
101 bool *newFrameEachTime
= NULL
);
103 // Get direct access to help data:
104 wxHtmlHelpData
*GetHelpData() { return &m_helpData
; }
106 virtual bool Quit() ;
107 virtual void OnQuit() {}
109 void OnCloseFrame(wxCloseEvent
& evt
);
111 // Make the help controller's frame 'modal' if
113 void MakeModalIfNeeded();
115 // Find the top-most parent window
116 wxWindow
* FindTopLevelWindow();
119 void Init(int style
);
121 virtual wxWindow
* CreateHelpWindow();
122 virtual wxHtmlHelpFrame
* CreateHelpFrame(wxHtmlHelpData
*data
);
123 virtual wxHtmlHelpDialog
* CreateHelpDialog(wxHtmlHelpData
*data
);
124 virtual void DestroyHelpWindow();
126 wxHtmlHelpData m_helpData
;
127 wxHtmlHelpWindow
* m_helpWindow
;
129 wxConfigBase
* m_Config
;
130 wxString m_ConfigRoot
;
131 #endif // wxUSE_CONFIG
132 wxString m_titleFormat
;
134 wxHtmlHelpFrame
* m_helpFrame
;
135 wxHtmlHelpDialog
* m_helpDialog
;
137 bool m_shouldPreventAppExit
;
139 wxDECLARE_NO_COPY_CLASS(wxHtmlHelpController
);
144 * A convenience class particularly for use on wxMac,
145 * where you can only show modal dialogs from a modal
150 * wxHtmlModalHelp help(parent, filename, topic);
152 * If topic is empty, the help contents is displayed.
155 class WXDLLIMPEXP_HTML wxHtmlModalHelp
158 wxHtmlModalHelp(wxWindow
* parent
, const wxString
& helpFile
, const wxString
& topic
= wxEmptyString
,
159 int style
= wxHF_DEFAULT_STYLE
| wxHF_DIALOG
| wxHF_MODAL
);
162 #endif // wxUSE_WXHTML_HELP
164 #endif // _WX_HELPCTRL_H_