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
8 // Copyright: (c) Harm van der Heijden and Vaclav Slavik
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_HELPCTRL_H_
13 #define _WX_HELPCTRL_H_
19 #include "wx/helpbase.h"
20 #include "wx/html/helpfrm.h"
22 #define wxID_HTML_HELPFRAME (wxID_HIGHEST + 1)
24 // This style indicates that the window is
25 // embedded in the application and must not be
26 // destroyed by the help controller.
27 #define wxHF_EMBEDDED 0x00008000
29 // Create a dialog for the help window.
30 #define wxHF_DIALOG 0x00010000
32 // Create a frame for the help window.
33 #define wxHF_FRAME 0x00020000
35 // Make the dialog modal when displaying help.
36 #define wxHF_MODAL 0x00040000
38 class WXDLLIMPEXP_FWD_HTML wxHtmlHelpDialog
;
39 class WXDLLIMPEXP_FWD_HTML wxHtmlHelpWindow
;
40 class WXDLLIMPEXP_FWD_HTML wxHtmlHelpFrame
;
41 class WXDLLIMPEXP_FWD_HTML wxHtmlHelpDialog
;
43 class WXDLLIMPEXP_HTML wxHtmlHelpController
: public wxHelpControllerBase
// wxEvtHandler
45 DECLARE_DYNAMIC_CLASS(wxHtmlHelpController
)
48 wxHtmlHelpController(int style
= wxHF_DEFAULT_STYLE
, wxWindow
* parentWindow
= NULL
);
49 virtual ~wxHtmlHelpController();
51 void SetShouldPreventAppExit(bool enable
);
53 void SetTitleFormat(const wxString
& format
);
54 void SetTempDir(const wxString
& path
) { m_helpData
.SetTempDir(path
); }
55 bool AddBook(const wxString
& book_url
, bool show_wait_msg
= false);
56 bool AddBook(const wxFileName
& book_file
, bool show_wait_msg
= false);
58 bool Display(const wxString
& x
);
60 bool DisplayContents();
62 bool KeywordSearch(const wxString
& keyword
,
63 wxHelpSearchMode mode
= wxHELP_SEARCH_ALL
);
65 wxHtmlHelpWindow
* GetHelpWindow() { return m_helpWindow
; }
66 void SetHelpWindow(wxHtmlHelpWindow
* helpWindow
);
68 wxHtmlHelpFrame
* GetFrame() { return m_helpFrame
; }
69 wxHtmlHelpDialog
* GetDialog() { return m_helpDialog
; }
72 void UseConfig(wxConfigBase
*config
, const wxString
& rootpath
= wxEmptyString
);
74 // Assigns config object to the Ctrl. This config is then
75 // used in subsequent calls to Read/WriteCustomization of both help
76 // Ctrl and it's wxHtmlWindow
77 virtual void ReadCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
78 virtual void WriteCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
79 #endif // wxUSE_CONFIG
81 //// Backward compatibility with wxHelpController API
83 virtual bool Initialize(const wxString
& file
, int WXUNUSED(server
) ) { return Initialize(file
); }
84 virtual bool Initialize(const wxString
& file
);
85 virtual void SetViewer(const wxString
& WXUNUSED(viewer
), long WXUNUSED(flags
) = 0) {}
86 virtual bool LoadFile(const wxString
& file
= wxT(""));
87 virtual bool DisplaySection(int sectionNo
);
88 virtual bool DisplaySection(const wxString
& section
) { return Display(section
); }
89 virtual bool DisplayBlock(long blockNo
) { return DisplaySection(blockNo
); }
90 virtual bool DisplayTextPopup(const wxString
& text
, const wxPoint
& pos
);
92 virtual void SetFrameParameters(const wxString
& title
,
94 const wxPoint
& pos
= wxDefaultPosition
,
95 bool newFrameEachTime
= false);
96 /// Obtains the latest settings used by the help frame and the help
98 virtual wxFrame
*GetFrameParameters(wxSize
*size
= NULL
,
100 bool *newFrameEachTime
= NULL
);
102 // Get direct access to help data:
103 wxHtmlHelpData
*GetHelpData() { return &m_helpData
; }
105 virtual bool Quit() ;
106 virtual void OnQuit() {}
108 void OnCloseFrame(wxCloseEvent
& evt
);
110 // Make the help controller's frame 'modal' if
112 void MakeModalIfNeeded();
114 // Find the top-most parent window
115 wxWindow
* FindTopLevelWindow();
118 virtual wxWindow
* CreateHelpWindow();
119 virtual wxHtmlHelpFrame
* CreateHelpFrame(wxHtmlHelpData
*data
);
120 virtual wxHtmlHelpDialog
* CreateHelpDialog(wxHtmlHelpData
*data
);
121 virtual void DestroyHelpWindow();
123 wxHtmlHelpData m_helpData
;
124 wxHtmlHelpWindow
* m_helpWindow
;
126 wxConfigBase
* m_Config
;
127 wxString m_ConfigRoot
;
128 #endif // wxUSE_CONFIG
129 wxString m_titleFormat
;
131 wxHtmlHelpFrame
* m_helpFrame
;
132 wxHtmlHelpDialog
* m_helpDialog
;
134 bool m_shouldPreventAppExit
;
136 wxDECLARE_NO_COPY_CLASS(wxHtmlHelpController
);
141 * A convenience class particularly for use on wxMac,
142 * where you can only show modal dialogs from a modal
147 * wxHtmlModalHelp help(parent, filename, topic);
149 * If topic is empty, the help contents is displayed.
152 class WXDLLIMPEXP_HTML wxHtmlModalHelp
155 wxHtmlModalHelp(wxWindow
* parent
, const wxString
& helpFile
, const wxString
& topic
= wxEmptyString
,
156 int style
= wxHF_DEFAULT_STYLE
| wxHF_DIALOG
| wxHF_MODAL
);
159 #endif // wxUSE_WXHTML_HELP
161 #endif // _WX_HELPCTRL_H_