]> git.saurik.com Git - wxWidgets.git/blob - include/wx/html/helpwnd.h
synchronize GTK2 minimum version in docs
[wxWidgets.git] / include / wx / html / helpwnd.h
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 // RCS-ID: $Id$
8 // Copyright: (c) Harm van der Heijden and Vaclav Slavik
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_HELPWND_H_
13 #define _WX_HELPWND_H_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_WXHTML_HELP
18
19 #include "wx/helpbase.h"
20 #include "wx/html/helpdata.h"
21 #include "wx/window.h"
22 #include "wx/frame.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"
31 #include "wx/hash.h"
32 #include "wx/html/htmlwin.h"
33 #include "wx/html/htmprint.h"
34
35 class WXDLLIMPEXP_FWD_CORE wxButton;
36 class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
37 class WXDLLIMPEXP_FWD_CORE wxTreeEvent;
38 class WXDLLIMPEXP_FWD_CORE wxTreeCtrl;
39
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)
56 //compatibility:
57 #define wxHF_OPENFILES wxHF_OPEN_FILES
58 #define wxHF_FLATTOOLBAR wxHF_FLAT_TOOLBAR
59 #define wxHF_DEFAULTSTYLE wxHF_DEFAULT_STYLE
60
61 struct wxHtmlHelpFrameCfg
62 {
63 int x, y, w, h;
64 long sashpos;
65 bool navig_on;
66 };
67
68 struct wxHtmlHelpMergedIndexItem;
69 class wxHtmlHelpMergedIndex;
70
71 class WXDLLIMPEXP_FWD_CORE wxHelpControllerBase;
72 class WXDLLIMPEXP_FWD_HTML wxHtmlHelpController;
73
74 /*!
75 * Help window
76 */
77
78 class WXDLLIMPEXP_HTML wxHtmlHelpWindow : public wxWindow
79 {
80 DECLARE_DYNAMIC_CLASS(wxHtmlHelpWindow)
81
82 public:
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();
96
97 wxHtmlHelpData* GetData() { return m_Data; }
98 wxHtmlHelpController* GetController() const { return m_helpController; }
99 void SetController(wxHtmlHelpController* controller);
100
101 // Displays page x. If not found it will offect the user a choice of
102 // searching books.
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);
109
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);
113
114 // Displays help window and focuses contents.
115 bool DisplayContents();
116
117 // Displays help window and focuses index.
118 bool DisplayIndex();
119
120 // Searches for keyword. Returns true and display page if found, return
121 // false otherwise
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);
130
131 #if wxUSE_CONFIG
132 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString)
133 {
134 m_Config = config;
135 m_ConfigRoot = rootpath;
136 ReadCustomization(config, rootpath);
137 }
138
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
145
146 // call this to let wxHtmlHelpWindow know page changed
147 void NotifyPageChanged();
148
149 // Refreshes Contents and Index tabs
150 void RefreshLists();
151
152 // Gets the HTML window
153 wxHtmlWindow* GetHtmlWindow() const { return m_HtmlWin; }
154
155 // Gets the splitter window
156 wxSplitterWindow* GetSplitterWindow() const { return m_Splitter; }
157
158 // Gets the toolbar
159 wxToolBar* GetToolBar() const { return m_toolBar; }
160
161 // Gets the configuration data
162 wxHtmlHelpFrameCfg& GetCfgData() { return m_Cfg; }
163
164 // Gets the tree control
165 wxTreeCtrl *GetTreeCtrl() const { return m_ContentsBox; }
166
167 protected:
168 void Init(wxHtmlHelpData* data = NULL);
169
170 // Adds items to m_Contents tree control
171 void CreateContents();
172
173 // Adds items to m_IndexList
174 void CreateIndex();
175
176 // Add books to search choice panel
177 void CreateSearch();
178
179 // Updates "merged index" structure that combines indexes of all books
180 // into better searchable structure
181 void UpdateMergedIndex();
182
183 // Add custom buttons to toolbar
184 virtual void AddToolbarButtons(wxToolBar *toolBar, int style);
185
186 // Displays options dialog (fonts etc.)
187 virtual void OptionsDialog();
188
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);
198
199 // Images:
200 enum {
201 IMG_Book = 0,
202 IMG_Folder,
203 IMG_Page
204 };
205
206 protected:
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;
213 wxPanel *m_NavigPan;
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;
228
229 wxComboBox *m_Bookmarks;
230 wxArrayString m_BookmarksNames, m_BookmarksPages;
231
232 wxHtmlHelpFrameCfg m_Cfg;
233
234 #if wxUSE_CONFIG
235 wxConfigBase *m_Config;
236 wxString m_ConfigRoot;
237 #endif // wxUSE_CONFIG
238
239 // pagenumbers of controls in notebook (usually 0,1,2)
240 int m_ContentsPage;
241 int m_IndexPage;
242 int m_SearchPage;
243
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;
248
249 bool m_UpdateContents;
250
251 #if wxUSE_PRINTING_ARCHITECTURE
252 wxHtmlEasyPrinting *m_Printer;
253 #endif
254 wxHashTable *m_PagesHash;
255 wxHtmlHelpController* m_helpController;
256
257 int m_hfStyle;
258
259 private:
260 void DoIndexFind();
261 void DoIndexAll();
262 void DisplayIndexItem(const wxHtmlHelpMergedIndexItem *it);
263 wxHtmlHelpMergedIndex *m_mergedIndex;
264
265 DECLARE_EVENT_TABLE()
266 wxDECLARE_NO_COPY_CLASS(wxHtmlHelpWindow);
267 };
268
269 /*!
270 * Command IDs
271 */
272
273 enum
274 {
275 //wxID_HTML_HELPFRAME = wxID_HIGHEST + 1,
276 wxID_HTML_PANEL = wxID_HIGHEST + 10,
277 wxID_HTML_BACK,
278 wxID_HTML_FORWARD,
279 wxID_HTML_UPNODE,
280 wxID_HTML_UP,
281 wxID_HTML_DOWN,
282 wxID_HTML_PRINT,
283 wxID_HTML_OPENFILE,
284 wxID_HTML_OPTIONS,
285 wxID_HTML_BOOKMARKSLIST,
286 wxID_HTML_BOOKMARKSADD,
287 wxID_HTML_BOOKMARKSREMOVE,
288 wxID_HTML_TREECTRL,
289 wxID_HTML_INDEXPAGE,
290 wxID_HTML_INDEXLIST,
291 wxID_HTML_INDEXTEXT,
292 wxID_HTML_INDEXBUTTON,
293 wxID_HTML_INDEXBUTTONALL,
294 wxID_HTML_NOTEBOOK,
295 wxID_HTML_SEARCHPAGE,
296 wxID_HTML_SEARCHTEXT,
297 wxID_HTML_SEARCHLIST,
298 wxID_HTML_SEARCHBUTTON,
299 wxID_HTML_SEARCHCHOICE,
300 wxID_HTML_COUNTINFO
301 };
302
303 #endif // wxUSE_WXHTML_HELP
304
305 #endif