1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHtmlHelpFrame
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_HELPFRM_H_
13 #define _WX_HELPFRM_H_
23 #include "wx/html/helpdata.h"
24 #include "wx/window.h"
26 #include "wx/config.h"
27 #include "wx/splitter.h"
28 #include "wx/notebook.h"
29 #include "wx/listbox.h"
30 #include "wx/choice.h"
31 #include "wx/combobox.h"
32 #include "wx/checkbox.h"
33 #include "wx/stattext.h"
34 #include "wx/html/htmlwin.h"
37 // style flags for the Help Frame
38 #define wxHF_TOOLBAR 0x0001
39 #define wxHF_CONTENTS 0x0002
40 #define wxHF_INDEX 0x0004
41 #define wxHF_SEARCH 0x0008
42 #define wxHF_BOOKMARKS 0x0010
43 #define wxHF_DEFAULTSTYLE (wxHF_TOOLBAR | wxHF_CONTENTS | wxHF_INDEX | wxHF_SEARCH | wxHF_BOOKMARKS)
49 wxID_HTML_PANEL
= wxID_HIGHEST
+ 1,
53 wxID_HTML_BOOKMARKSLIST
,
54 wxID_HTML_BOOKMARKSADD
,
55 wxID_HTML_BOOKMARKSREMOVE
,
60 wxID_HTML_INDEXBUTTON
,
61 wxID_HTML_INDEXBUTTONALL
,
66 wxID_HTML_SEARCHBUTTON
,
67 wxID_HTML_SEARCHCHOICE
,
69 wxID_HTML_HELPFRAME
// the id of wxHtmlHelpController's helpframe
84 class WXDLLEXPORT wxHtmlHelpFrame
: public wxFrame
86 DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame
)
89 wxHtmlHelpFrame(wxHtmlHelpData
* data
= NULL
) { Init(data
); }
90 wxHtmlHelpFrame(wxWindow
* parent
, int wxWindowID
,
91 const wxString
& title
= wxEmptyString
,
92 int style
= wxHF_DEFAULTSTYLE
, wxHtmlHelpData
* data
= NULL
);
93 bool Create(wxWindow
* parent
, wxWindowID id
, const wxString
& title
= wxEmptyString
,
94 int style
= wxHF_DEFAULTSTYLE
);
97 wxHtmlHelpData
* GetData() { return m_Data
; }
99 void SetTitleFormat(const wxString
& format
)
102 m_HtmlWin
->SetRelatedFrame(this, format
);
103 m_TitleFormat
= format
;
105 // Sets format of title of the frame. Must contain exactly one "%s"
106 // (for title of displayed HTML page)
108 bool Display(const wxString
& x
);
109 // Displays page x. If not found it will offect the user a choice of
111 // Looking for the page runs in these steps:
112 // 1. try to locate file named x (if x is for example "doc/howto.htm")
113 // 2. try to open starting page of book x
114 // 3. try to find x in contents (if x is for example "How To ...")
115 // 4. try to find x in index (if x is for example "How To ...")
116 bool Display(const int id
);
117 // Alternative version that works with numeric ID.
118 // (uses extension to MS format, <param name="ID" value=id>, see docs)
120 bool DisplayContents();
121 // Displays help window and focuses contents.
124 // Displays help window and focuses index.
126 bool KeywordSearch(const wxString
& keyword
);
127 // Searches for keyword. Returns TRUE and display page if found, return
129 // Syntax of keyword is Altavista-like:
130 // * words are separated by spaces
131 // (but "\"hello world\"" is only one world "hello world")
132 // * word may be pretended by + or -
133 // (+ : page must contain the word ; - : page can't contain the word)
134 // * if there is no + or - before the word, + is default
136 void UseConfig(wxConfigBase
*config
, const wxString
& rootpath
= wxEmptyString
)
139 m_ConfigRoot
= rootpath
;
140 ReadCustomization(config
, rootpath
);
143 void ReadCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
144 // saves custom settings into cfg config. it will use the path 'path'
145 // if given, otherwise it will save info into currently selected path.
146 // saved values : things set by SetFonts, SetBorders.
147 void WriteCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
151 void Init(wxHtmlHelpData
* data
= NULL
);
154 // Refreshes Contents and Index tabs
156 void CreateContents();
157 // Adds items to m_Contents tree control
160 // Adds items to m_IndexList
163 // Add books to search choice panel
166 virtual void OptionsDialog();
167 // Displays options dialog (fonts etc.)
169 void OnToolbar(wxCommandEvent
& event
);
170 void OnContentsSel(wxTreeEvent
& event
);
171 void OnIndexSel(wxCommandEvent
& event
);
172 void OnIndexFind(wxCommandEvent
& event
);
173 void OnIndexAll(wxCommandEvent
& event
);
174 void OnSearchSel(wxCommandEvent
& event
);
175 void OnSearch(wxCommandEvent
& event
);
176 void OnBookmarksSel(wxCommandEvent
& event
);
177 void OnCloseWindow(wxCloseEvent
& event
);
188 wxHtmlHelpData
* m_Data
;
189 bool m_DataCreated
; // m_Data created by frame, or supplied?
190 wxString m_TitleFormat
; // title of the help frame
191 // below are various pointers to GUI components
192 wxHtmlWindow
*m_HtmlWin
;
193 wxSplitterWindow
*m_Splitter
;
194 wxNotebook
*m_NavigPan
;
195 wxTreeCtrl
*m_ContentsBox
;
196 wxImageList
*m_ContentsImageList
;
197 wxTextCtrl
*m_IndexText
;
198 wxButton
*m_IndexButton
;
199 wxButton
*m_IndexButtonAll
;
200 wxListBox
*m_IndexList
;
201 wxTextCtrl
*m_SearchText
;
202 wxButton
*m_SearchButton
;
203 wxListBox
*m_SearchList
;
204 wxChoice
*m_SearchChoice
;
205 wxStaticText
*m_IndexCountInfo
;
206 wxCheckBox
*m_SearchCaseSensitive
;
207 wxCheckBox
*m_SearchWholeWords
;
209 wxComboBox
*m_Bookmarks
;
210 wxArrayString m_BookmarksNames
, m_BookmarksPages
;
212 wxHtmlHelpFrameCfg m_Cfg
;
214 wxConfigBase
*m_Config
;
215 wxString m_ConfigRoot
;
217 // pagenumbers of controls in notebook (usually 0,1,2)
222 // lists of available fonts (used in options dialog)
223 wxArrayString
*m_NormalFonts
, *m_FixedFonts
;
224 int m_FontSize
; // 0,1,2 = small,medium,big
225 wxString m_NormalFace
, m_FixedFace
;
227 DECLARE_EVENT_TABLE()