1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/html/helpwnd.h
3 // Purpose: wxHtmlHelpWindow
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_HELPWND_H_
13 #define _WX_HELPWND_H_
19 #include "wx/helpbase.h"
20 #include "wx/html/helpdata.h"
21 #include "wx/window.h"
23 #include "wx/config.h"
24 #include "wx/splitter.h"
25 #include "wx/notebook.h"
26 #include "wx/listbox.h"
27 #include "wx/choice.h"
28 #include "wx/combobox.h"
29 #include "wx/checkbox.h"
30 #include "wx/stattext.h"
32 #include "wx/html/htmlwin.h"
33 #include "wx/html/htmprint.h"
35 class WXDLLIMPEXP_FWD_CORE wxButton
;
36 class WXDLLIMPEXP_FWD_CORE wxTextCtrl
;
37 class WXDLLIMPEXP_FWD_CORE wxTreeEvent
;
38 class WXDLLIMPEXP_FWD_CORE wxTreeCtrl
;
40 // style flags for the Help Frame
41 #define wxHF_TOOLBAR 0x0001
42 #define wxHF_CONTENTS 0x0002
43 #define wxHF_INDEX 0x0004
44 #define wxHF_SEARCH 0x0008
45 #define wxHF_BOOKMARKS 0x0010
46 #define wxHF_OPEN_FILES 0x0020
47 #define wxHF_PRINT 0x0040
48 #define wxHF_FLAT_TOOLBAR 0x0080
49 #define wxHF_MERGE_BOOKS 0x0100
50 #define wxHF_ICONS_BOOK 0x0200
51 #define wxHF_ICONS_BOOK_CHAPTER 0x0400
52 #define wxHF_ICONS_FOLDER 0x0000 // this is 0 since it is default
53 #define wxHF_DEFAULT_STYLE (wxHF_TOOLBAR | wxHF_CONTENTS | \
54 wxHF_INDEX | wxHF_SEARCH | \
55 wxHF_BOOKMARKS | wxHF_PRINT)
57 #define wxHF_OPENFILES wxHF_OPEN_FILES
58 #define wxHF_FLATTOOLBAR wxHF_FLAT_TOOLBAR
59 #define wxHF_DEFAULTSTYLE wxHF_DEFAULT_STYLE
61 struct wxHtmlHelpFrameCfg
68 struct wxHtmlHelpMergedIndexItem
;
69 class wxHtmlHelpMergedIndex
;
71 class WXDLLIMPEXP_FWD_CORE wxHelpControllerBase
;
72 class WXDLLIMPEXP_FWD_HTML wxHtmlHelpController
;
78 class WXDLLIMPEXP_HTML wxHtmlHelpWindow
: public wxWindow
80 DECLARE_DYNAMIC_CLASS(wxHtmlHelpWindow
)
83 wxHtmlHelpWindow(wxHtmlHelpData
* data
= NULL
) { Init(data
); }
84 wxHtmlHelpWindow(wxWindow
* parent
, wxWindowID wxWindowID
,
85 const wxPoint
& pos
= wxDefaultPosition
,
86 const wxSize
& size
= wxDefaultSize
,
87 int style
= wxTAB_TRAVERSAL
|wxNO_BORDER
,
88 int helpStyle
= wxHF_DEFAULT_STYLE
,
89 wxHtmlHelpData
* data
= NULL
);
90 bool Create(wxWindow
* parent
, wxWindowID id
,
91 const wxPoint
& pos
= wxDefaultPosition
,
92 const wxSize
& size
= wxDefaultSize
,
93 int style
= wxTAB_TRAVERSAL
|wxNO_BORDER
,
94 int helpStyle
= wxHF_DEFAULT_STYLE
);
95 virtual ~wxHtmlHelpWindow();
97 wxHtmlHelpData
* GetData() { return m_Data
; }
98 wxHtmlHelpController
* GetController() const { return m_helpController
; }
99 void SetController(wxHtmlHelpController
* controller
);
101 // Displays page x. If not found it will offect the user a choice of
103 // Looking for the page runs in these steps:
104 // 1. try to locate file named x (if x is for example "doc/howto.htm")
105 // 2. try to open starting page of book x
106 // 3. try to find x in contents (if x is for example "How To ...")
107 // 4. try to find x in index (if x is for example "How To ...")
108 bool Display(const wxString
& x
);
110 // Alternative version that works with numeric ID.
111 // (uses extension to MS format, <param name="ID" value=id>, see docs)
112 bool Display(const int id
);
114 // Displays help window and focuses contents.
115 bool DisplayContents();
117 // Displays help window and focuses index.
120 // Searches for keyword. Returns true and display page if found, return
122 // Syntax of keyword is Altavista-like:
123 // * words are separated by spaces
124 // (but "\"hello world\"" is only one world "hello world")
125 // * word may be pretended by + or -
126 // (+ : page must contain the word ; - : page can't contain the word)
127 // * if there is no + or - before the word, + is default
128 bool KeywordSearch(const wxString
& keyword
,
129 wxHelpSearchMode mode
= wxHELP_SEARCH_ALL
);
132 void UseConfig(wxConfigBase
*config
, const wxString
& rootpath
= wxEmptyString
)
135 m_ConfigRoot
= rootpath
;
136 ReadCustomization(config
, rootpath
);
139 // Saves custom settings into cfg config. it will use the path 'path'
140 // if given, otherwise it will save info into currently selected path.
141 // saved values : things set by SetFonts, SetBorders.
142 void ReadCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
143 void WriteCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
144 #endif // wxUSE_CONFIG
146 // call this to let wxHtmlHelpWindow know page changed
147 void NotifyPageChanged();
149 // Refreshes Contents and Index tabs
152 // Gets the HTML window
153 wxHtmlWindow
* GetHtmlWindow() const { return m_HtmlWin
; }
155 // Gets the splitter window
156 wxSplitterWindow
* GetSplitterWindow() const { return m_Splitter
; }
159 wxToolBar
* GetToolBar() const { return m_toolBar
; }
161 // Gets the configuration data
162 wxHtmlHelpFrameCfg
& GetCfgData() { return m_Cfg
; }
164 // Gets the tree control
165 wxTreeCtrl
*GetTreeCtrl() const { return m_ContentsBox
; }
168 void Init(wxHtmlHelpData
* data
= NULL
);
170 // Adds items to m_Contents tree control
171 void CreateContents();
173 // Adds items to m_IndexList
176 // Add books to search choice panel
179 // Updates "merged index" structure that combines indexes of all books
180 // into better searchable structure
181 void UpdateMergedIndex();
183 // Add custom buttons to toolbar
184 virtual void AddToolbarButtons(wxToolBar
*toolBar
, int style
);
186 // Displays options dialog (fonts etc.)
187 virtual void OptionsDialog();
189 void OnToolbar(wxCommandEvent
& event
);
190 void OnContentsSel(wxTreeEvent
& event
);
191 void OnIndexSel(wxCommandEvent
& event
);
192 void OnIndexFind(wxCommandEvent
& event
);
193 void OnIndexAll(wxCommandEvent
& event
);
194 void OnSearchSel(wxCommandEvent
& event
);
195 void OnSearch(wxCommandEvent
& event
);
196 void OnBookmarksSel(wxCommandEvent
& event
);
197 void OnSize(wxSizeEvent
& event
);
207 wxHtmlHelpData
* m_Data
;
208 bool m_DataCreated
; // m_Data created by frame, or supplied?
209 wxString m_TitleFormat
; // title of the help frame
210 // below are various pointers to GUI components
211 wxHtmlWindow
*m_HtmlWin
;
212 wxSplitterWindow
*m_Splitter
;
214 wxNotebook
*m_NavigNotebook
;
215 wxTreeCtrl
*m_ContentsBox
;
216 wxTextCtrl
*m_IndexText
;
217 wxButton
*m_IndexButton
;
218 wxButton
*m_IndexButtonAll
;
219 wxListBox
*m_IndexList
;
220 wxTextCtrl
*m_SearchText
;
221 wxButton
*m_SearchButton
;
222 wxListBox
*m_SearchList
;
223 wxChoice
*m_SearchChoice
;
224 wxStaticText
*m_IndexCountInfo
;
225 wxCheckBox
*m_SearchCaseSensitive
;
226 wxCheckBox
*m_SearchWholeWords
;
227 wxToolBar
* m_toolBar
;
229 wxComboBox
*m_Bookmarks
;
230 wxArrayString m_BookmarksNames
, m_BookmarksPages
;
232 wxHtmlHelpFrameCfg m_Cfg
;
235 wxConfigBase
*m_Config
;
236 wxString m_ConfigRoot
;
237 #endif // wxUSE_CONFIG
239 // pagenumbers of controls in notebook (usually 0,1,2)
244 // lists of available fonts (used in options dialog)
245 wxArrayString
*m_NormalFonts
, *m_FixedFonts
;
246 int m_FontSize
; // 0,1,2 = small,medium,big
247 wxString m_NormalFace
, m_FixedFace
;
249 bool m_UpdateContents
;
251 #if wxUSE_PRINTING_ARCHITECTURE
252 wxHtmlEasyPrinting
*m_Printer
;
254 wxHashTable
*m_PagesHash
;
255 wxHtmlHelpController
* m_helpController
;
262 void DisplayIndexItem(const wxHtmlHelpMergedIndexItem
*it
);
263 wxHtmlHelpMergedIndex
*m_mergedIndex
;
265 DECLARE_EVENT_TABLE()
266 wxDECLARE_NO_COPY_CLASS(wxHtmlHelpWindow
);
275 //wxID_HTML_HELPFRAME = wxID_HIGHEST + 1,
276 wxID_HTML_PANEL
= wxID_HIGHEST
+ 10,
285 wxID_HTML_BOOKMARKSLIST
,
286 wxID_HTML_BOOKMARKSADD
,
287 wxID_HTML_BOOKMARKSREMOVE
,
292 wxID_HTML_INDEXBUTTON
,
293 wxID_HTML_INDEXBUTTONALL
,
295 wxID_HTML_SEARCHPAGE
,
296 wxID_HTML_SEARCHTEXT
,
297 wxID_HTML_SEARCHLIST
,
298 wxID_HTML_SEARCHBUTTON
,
299 wxID_HTML_SEARCHCHOICE
,
303 #endif // wxUSE_WXHTML_HELP