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
7 // Copyright: (c) Harm van der Heijden and Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_HELPWND_H_
12 #define _WX_HELPWND_H_
18 #include "wx/helpbase.h"
19 #include "wx/html/helpdata.h"
20 #include "wx/window.h"
22 #include "wx/config.h"
23 #include "wx/splitter.h"
24 #include "wx/notebook.h"
25 #include "wx/listbox.h"
26 #include "wx/choice.h"
27 #include "wx/combobox.h"
28 #include "wx/checkbox.h"
29 #include "wx/stattext.h"
31 #include "wx/html/htmlwin.h"
32 #include "wx/html/htmprint.h"
34 class WXDLLIMPEXP_FWD_CORE wxButton
;
35 class WXDLLIMPEXP_FWD_CORE wxTextCtrl
;
36 class WXDLLIMPEXP_FWD_CORE wxTreeEvent
;
37 class WXDLLIMPEXP_FWD_CORE wxTreeCtrl
;
39 // style flags for the Help Frame
40 #define wxHF_TOOLBAR 0x0001
41 #define wxHF_CONTENTS 0x0002
42 #define wxHF_INDEX 0x0004
43 #define wxHF_SEARCH 0x0008
44 #define wxHF_BOOKMARKS 0x0010
45 #define wxHF_OPEN_FILES 0x0020
46 #define wxHF_PRINT 0x0040
47 #define wxHF_FLAT_TOOLBAR 0x0080
48 #define wxHF_MERGE_BOOKS 0x0100
49 #define wxHF_ICONS_BOOK 0x0200
50 #define wxHF_ICONS_BOOK_CHAPTER 0x0400
51 #define wxHF_ICONS_FOLDER 0x0000 // this is 0 since it is default
52 #define wxHF_DEFAULT_STYLE (wxHF_TOOLBAR | wxHF_CONTENTS | \
53 wxHF_INDEX | wxHF_SEARCH | \
54 wxHF_BOOKMARKS | wxHF_PRINT)
56 #define wxHF_OPENFILES wxHF_OPEN_FILES
57 #define wxHF_FLATTOOLBAR wxHF_FLAT_TOOLBAR
58 #define wxHF_DEFAULTSTYLE wxHF_DEFAULT_STYLE
60 struct wxHtmlHelpFrameCfg
67 struct wxHtmlHelpMergedIndexItem
;
68 class wxHtmlHelpMergedIndex
;
70 class WXDLLIMPEXP_FWD_CORE wxHelpControllerBase
;
71 class WXDLLIMPEXP_FWD_HTML wxHtmlHelpController
;
77 class WXDLLIMPEXP_HTML wxHtmlHelpWindow
: public wxWindow
79 DECLARE_DYNAMIC_CLASS(wxHtmlHelpWindow
)
82 wxHtmlHelpWindow(wxHtmlHelpData
* data
= NULL
) { Init(data
); }
83 wxHtmlHelpWindow(wxWindow
* parent
, wxWindowID wxWindowID
,
84 const wxPoint
& pos
= wxDefaultPosition
,
85 const wxSize
& size
= wxDefaultSize
,
86 int style
= wxTAB_TRAVERSAL
|wxNO_BORDER
,
87 int helpStyle
= wxHF_DEFAULT_STYLE
,
88 wxHtmlHelpData
* data
= NULL
);
89 bool Create(wxWindow
* parent
, wxWindowID id
,
90 const wxPoint
& pos
= wxDefaultPosition
,
91 const wxSize
& size
= wxDefaultSize
,
92 int style
= wxTAB_TRAVERSAL
|wxNO_BORDER
,
93 int helpStyle
= wxHF_DEFAULT_STYLE
);
94 virtual ~wxHtmlHelpWindow();
96 wxHtmlHelpData
* GetData() { return m_Data
; }
97 wxHtmlHelpController
* GetController() const { return m_helpController
; }
98 void SetController(wxHtmlHelpController
* controller
);
100 // Displays page x. If not found it will offect the user a choice of
102 // Looking for the page runs in these steps:
103 // 1. try to locate file named x (if x is for example "doc/howto.htm")
104 // 2. try to open starting page of book x
105 // 3. try to find x in contents (if x is for example "How To ...")
106 // 4. try to find x in index (if x is for example "How To ...")
107 bool Display(const wxString
& x
);
109 // Alternative version that works with numeric ID.
110 // (uses extension to MS format, <param name="ID" value=id>, see docs)
111 bool Display(const int id
);
113 // Displays help window and focuses contents.
114 bool DisplayContents();
116 // Displays help window and focuses index.
119 // Searches for keyword. Returns true and display page if found, return
121 // Syntax of keyword is Altavista-like:
122 // * words are separated by spaces
123 // (but "\"hello world\"" is only one world "hello world")
124 // * word may be pretended by + or -
125 // (+ : page must contain the word ; - : page can't contain the word)
126 // * if there is no + or - before the word, + is default
127 bool KeywordSearch(const wxString
& keyword
,
128 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
);
143 #endif // wxUSE_CONFIG
145 // call this to let wxHtmlHelpWindow know page changed
146 void NotifyPageChanged();
148 // Refreshes Contents and Index tabs
151 // Gets the HTML window
152 wxHtmlWindow
* GetHtmlWindow() const { return m_HtmlWin
; }
154 // Gets the splitter window
155 wxSplitterWindow
* GetSplitterWindow() const { return m_Splitter
; }
158 wxToolBar
* GetToolBar() const { return m_toolBar
; }
160 // Gets the configuration data
161 wxHtmlHelpFrameCfg
& GetCfgData() { return m_Cfg
; }
163 // Gets the tree control
164 wxTreeCtrl
*GetTreeCtrl() const { return m_ContentsBox
; }
167 void Init(wxHtmlHelpData
* data
= NULL
);
169 // Adds items to m_Contents tree control
170 void CreateContents();
172 // Adds items to m_IndexList
175 // Add books to search choice panel
178 // Updates "merged index" structure that combines indexes of all books
179 // into better searchable structure
180 void UpdateMergedIndex();
182 // Add custom buttons to toolbar
183 virtual void AddToolbarButtons(wxToolBar
*toolBar
, int style
);
185 // Displays options dialog (fonts etc.)
186 virtual void OptionsDialog();
188 void OnToolbar(wxCommandEvent
& event
);
189 void OnContentsSel(wxTreeEvent
& event
);
190 void OnIndexSel(wxCommandEvent
& event
);
191 void OnIndexFind(wxCommandEvent
& event
);
192 void OnIndexAll(wxCommandEvent
& event
);
193 void OnSearchSel(wxCommandEvent
& event
);
194 void OnSearch(wxCommandEvent
& event
);
195 void OnBookmarksSel(wxCommandEvent
& event
);
196 void OnSize(wxSizeEvent
& event
);
206 wxHtmlHelpData
* m_Data
;
207 bool m_DataCreated
; // m_Data created by frame, or supplied?
208 wxString m_TitleFormat
; // title of the help frame
209 // below are various pointers to GUI components
210 wxHtmlWindow
*m_HtmlWin
;
211 wxSplitterWindow
*m_Splitter
;
213 wxNotebook
*m_NavigNotebook
;
214 wxTreeCtrl
*m_ContentsBox
;
215 wxTextCtrl
*m_IndexText
;
216 wxButton
*m_IndexButton
;
217 wxButton
*m_IndexButtonAll
;
218 wxListBox
*m_IndexList
;
219 wxTextCtrl
*m_SearchText
;
220 wxButton
*m_SearchButton
;
221 wxListBox
*m_SearchList
;
222 wxChoice
*m_SearchChoice
;
223 wxStaticText
*m_IndexCountInfo
;
224 wxCheckBox
*m_SearchCaseSensitive
;
225 wxCheckBox
*m_SearchWholeWords
;
226 wxToolBar
* m_toolBar
;
228 wxComboBox
*m_Bookmarks
;
229 wxArrayString m_BookmarksNames
, m_BookmarksPages
;
231 wxHtmlHelpFrameCfg m_Cfg
;
234 wxConfigBase
*m_Config
;
235 wxString m_ConfigRoot
;
236 #endif // wxUSE_CONFIG
238 // pagenumbers of controls in notebook (usually 0,1,2)
243 // lists of available fonts (used in options dialog)
244 wxArrayString
*m_NormalFonts
, *m_FixedFonts
;
245 int m_FontSize
; // 0,1,2 = small,medium,big
246 wxString m_NormalFace
, m_FixedFace
;
248 bool m_UpdateContents
;
250 #if wxUSE_PRINTING_ARCHITECTURE
251 wxHtmlEasyPrinting
*m_Printer
;
253 wxHashTable
*m_PagesHash
;
254 wxHtmlHelpController
* m_helpController
;
261 void DisplayIndexItem(const wxHtmlHelpMergedIndexItem
*it
);
262 wxHtmlHelpMergedIndex
*m_mergedIndex
;
264 DECLARE_EVENT_TABLE()
265 wxDECLARE_NO_COPY_CLASS(wxHtmlHelpWindow
);
274 //wxID_HTML_HELPFRAME = wxID_HIGHEST + 1,
275 wxID_HTML_PANEL
= wxID_HIGHEST
+ 10,
284 wxID_HTML_BOOKMARKSLIST
,
285 wxID_HTML_BOOKMARKSADD
,
286 wxID_HTML_BOOKMARKSREMOVE
,
291 wxID_HTML_INDEXBUTTON
,
292 wxID_HTML_INDEXBUTTONALL
,
294 wxID_HTML_SEARCHPAGE
,
295 wxID_HTML_SEARCHTEXT
,
296 wxID_HTML_SEARCHLIST
,
297 wxID_HTML_SEARCHBUTTON
,
298 wxID_HTML_SEARCHCHOICE
,
302 #endif // wxUSE_WXHTML_HELP