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
);
131 void UseConfig(wxConfigBase
*config
, const wxString
& rootpath
= wxEmptyString
)
134 m_ConfigRoot
= rootpath
;
135 ReadCustomization(config
, rootpath
);
138 // Saves custom settings into cfg config. it will use the path 'path'
139 // if given, otherwise it will save info into currently selected path.
140 // saved values : things set by SetFonts, SetBorders.
141 void ReadCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
142 void WriteCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
144 // call this to let wxHtmlHelpWindow know page changed
145 void NotifyPageChanged();
147 // Refreshes Contents and Index tabs
150 // Gets the HTML window
151 wxHtmlWindow
* GetHtmlWindow() const { return m_HtmlWin
; }
153 // Gets the splitter window
154 wxSplitterWindow
* GetSplitterWindow() const { return m_Splitter
; }
157 wxToolBar
* GetToolBar() const { return m_toolBar
; }
159 // Gets the configuration data
160 wxHtmlHelpFrameCfg
& GetCfgData() { return m_Cfg
; }
162 // Gets the tree control
163 wxTreeCtrl
*GetTreeCtrl() const { return m_ContentsBox
; }
166 void Init(wxHtmlHelpData
* data
= NULL
);
168 // Adds items to m_Contents tree control
169 void CreateContents();
171 // Adds items to m_IndexList
174 // Add books to search choice panel
177 // Updates "merged index" structure that combines indexes of all books
178 // into better searchable structure
179 void UpdateMergedIndex();
181 // Add custom buttons to toolbar
182 virtual void AddToolbarButtons(wxToolBar
*toolBar
, int style
);
184 // Displays options dialog (fonts etc.)
185 virtual void OptionsDialog();
187 void OnToolbar(wxCommandEvent
& event
);
188 void OnContentsSel(wxTreeEvent
& event
);
189 void OnIndexSel(wxCommandEvent
& event
);
190 void OnIndexFind(wxCommandEvent
& event
);
191 void OnIndexAll(wxCommandEvent
& event
);
192 void OnSearchSel(wxCommandEvent
& event
);
193 void OnSearch(wxCommandEvent
& event
);
194 void OnBookmarksSel(wxCommandEvent
& event
);
195 void OnSize(wxSizeEvent
& event
);
205 wxHtmlHelpData
* m_Data
;
206 bool m_DataCreated
; // m_Data created by frame, or supplied?
207 wxString m_TitleFormat
; // title of the help frame
208 // below are various pointers to GUI components
209 wxHtmlWindow
*m_HtmlWin
;
210 wxSplitterWindow
*m_Splitter
;
212 wxNotebook
*m_NavigNotebook
;
213 wxTreeCtrl
*m_ContentsBox
;
214 wxTextCtrl
*m_IndexText
;
215 wxButton
*m_IndexButton
;
216 wxButton
*m_IndexButtonAll
;
217 wxListBox
*m_IndexList
;
218 wxTextCtrl
*m_SearchText
;
219 wxButton
*m_SearchButton
;
220 wxListBox
*m_SearchList
;
221 wxChoice
*m_SearchChoice
;
222 wxStaticText
*m_IndexCountInfo
;
223 wxCheckBox
*m_SearchCaseSensitive
;
224 wxCheckBox
*m_SearchWholeWords
;
225 wxToolBar
* m_toolBar
;
227 wxComboBox
*m_Bookmarks
;
228 wxArrayString m_BookmarksNames
, m_BookmarksPages
;
230 wxHtmlHelpFrameCfg m_Cfg
;
232 wxConfigBase
*m_Config
;
233 wxString m_ConfigRoot
;
235 // pagenumbers of controls in notebook (usually 0,1,2)
240 // lists of available fonts (used in options dialog)
241 wxArrayString
*m_NormalFonts
, *m_FixedFonts
;
242 int m_FontSize
; // 0,1,2 = small,medium,big
243 wxString m_NormalFace
, m_FixedFace
;
245 bool m_UpdateContents
;
247 #if wxUSE_PRINTING_ARCHITECTURE
248 wxHtmlEasyPrinting
*m_Printer
;
250 wxHashTable
*m_PagesHash
;
251 wxHtmlHelpController
* m_helpController
;
258 void DisplayIndexItem(const wxHtmlHelpMergedIndexItem
*it
);
259 wxHtmlHelpMergedIndex
*m_mergedIndex
;
261 DECLARE_EVENT_TABLE()
262 wxDECLARE_NO_COPY_CLASS(wxHtmlHelpWindow
);
271 //wxID_HTML_HELPFRAME = wxID_HIGHEST + 1,
272 wxID_HTML_PANEL
= wxID_HIGHEST
+ 2,
281 wxID_HTML_BOOKMARKSLIST
,
282 wxID_HTML_BOOKMARKSADD
,
283 wxID_HTML_BOOKMARKSREMOVE
,
288 wxID_HTML_INDEXBUTTON
,
289 wxID_HTML_INDEXBUTTONALL
,
291 wxID_HTML_SEARCHPAGE
,
292 wxID_HTML_SEARCHTEXT
,
293 wxID_HTML_SEARCHLIST
,
294 wxID_HTML_SEARCHBUTTON
,
295 wxID_HTML_SEARCHCHOICE
,
299 #endif // wxUSE_WXHTML_HELP