]> git.saurik.com Git - wxWidgets.git/blame - include/wx/html/helpwnd.h
Partly reverted changes to Get(Current)Selection.
[wxWidgets.git] / include / wx / html / helpwnd.h
CommitLineData
3755cfa6 1/////////////////////////////////////////////////////////////////////////////
548b5377 2// Name: wx/html/helpwnd.h
3755cfa6
JS
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
33a8a628
JS
12#ifndef _WX_HELPWND_H_
13#define _WX_HELPWND_H_
3755cfa6
JS
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/html/htmlwin.h"
32#include "wx/html/htmprint.h"
33
34class WXDLLIMPEXP_CORE wxButton;
35class WXDLLIMPEXP_CORE wxTextCtrl;
36class WXDLLIMPEXP_CORE wxTreeEvent;
37class WXDLLIMPEXP_CORE wxTreeCtrl;
38
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)
55//compatibility:
56#define wxHF_OPENFILES wxHF_OPEN_FILES
57#define wxHF_FLATTOOLBAR wxHF_FLAT_TOOLBAR
58#define wxHF_DEFAULTSTYLE wxHF_DEFAULT_STYLE
59
60struct wxHtmlHelpFrameCfg
61{
62 int x, y, w, h;
63 long sashpos;
64 bool navig_on;
65};
66
67struct wxHtmlHelpMergedIndexItem;
68class wxHtmlHelpMergedIndex;
69
70class WXDLLIMPEXP_CORE wxHelpControllerBase;
71class WXDLLIMPEXP_HTML wxHtmlHelpController;
72
13344b25
JS
73/*!
74 * Help window
75 */
76
3755cfa6
JS
77class WXDLLIMPEXP_HTML wxHtmlHelpWindow : public wxWindow
78{
79 DECLARE_DYNAMIC_CLASS(wxHtmlHelpWindow)
80
81public:
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 ~wxHtmlHelpWindow();
95
96 wxHtmlHelpData* GetData() { return m_Data; }
97 wxHtmlHelpController* GetController() const { return m_helpController; }
98 void SetController(wxHtmlHelpController* controller);
99
100 // Displays page x. If not found it will offect the user a choice of
101 // searching books.
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);
108
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);
112
113 // Displays help window and focuses contents.
114 bool DisplayContents();
115
116 // Displays help window and focuses index.
117 bool DisplayIndex();
118
119 // Searches for keyword. Returns true and display page if found, return
120 // false otherwise
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);
129
130 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString)
131 {
132 m_Config = config;
133 m_ConfigRoot = rootpath;
134 ReadCustomization(config, rootpath);
135 }
136
137 // Saves custom settings into cfg config. it will use the path 'path'
138 // if given, otherwise it will save info into currently selected path.
139 // saved values : things set by SetFonts, SetBorders.
140 void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
141 void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
142
143 // call this to let wxHtmlHelpWindow know page changed
144 void NotifyPageChanged();
145
146 // Refreshes Contents and Index tabs
147 void RefreshLists();
148
149 // Gets the HTML window
150 wxHtmlWindow* GetHtmlWindow() const { return m_HtmlWin; }
151
152 // Gets the splitter window
153 wxSplitterWindow* GetSplitterWindow() const { return m_Splitter; }
154
155 // Gets the toolbar
156 wxToolBar* GetToolBar() const { return m_toolBar; }
157
158 // Gets the configuration data
159 wxHtmlHelpFrameCfg& GetCfgData() { return m_Cfg; }
160
161 // Gets the tree control
162 wxTreeCtrl *GetTreeCtrl() const { return m_ContentsBox; }
163
164protected:
165 void Init(wxHtmlHelpData* data = NULL);
166
167 // Adds items to m_Contents tree control
168 void CreateContents();
169
170 // Adds items to m_IndexList
171 void CreateIndex();
172
173 // Add books to search choice panel
174 void CreateSearch();
175
176 // Updates "merged index" structure that combines indexes of all books
177 // into better searchable structure
178 void UpdateMergedIndex();
179
180 // Add custom buttons to toolbar
181 virtual void AddToolbarButtons(wxToolBar *toolBar, int style);
182
183 // Displays options dialog (fonts etc.)
184 virtual void OptionsDialog();
185
186 void OnToolbar(wxCommandEvent& event);
187 void OnContentsSel(wxTreeEvent& event);
188 void OnIndexSel(wxCommandEvent& event);
189 void OnIndexFind(wxCommandEvent& event);
190 void OnIndexAll(wxCommandEvent& event);
191 void OnSearchSel(wxCommandEvent& event);
192 void OnSearch(wxCommandEvent& event);
193 void OnBookmarksSel(wxCommandEvent& event);
194 void OnSize(wxSizeEvent& event);
195
196 // Images:
197 enum {
198 IMG_Book = 0,
199 IMG_Folder,
200 IMG_Page
201 };
202
203protected:
204 wxHtmlHelpData* m_Data;
205 bool m_DataCreated; // m_Data created by frame, or supplied?
206 wxString m_TitleFormat; // title of the help frame
207 // below are various pointers to GUI components
208 wxHtmlWindow *m_HtmlWin;
209 wxSplitterWindow *m_Splitter;
210 wxPanel *m_NavigPan;
211 wxNotebook *m_NavigNotebook;
212 wxTreeCtrl *m_ContentsBox;
213 wxTextCtrl *m_IndexText;
214 wxButton *m_IndexButton;
215 wxButton *m_IndexButtonAll;
216 wxListBox *m_IndexList;
217 wxTextCtrl *m_SearchText;
218 wxButton *m_SearchButton;
219 wxListBox *m_SearchList;
220 wxChoice *m_SearchChoice;
221 wxStaticText *m_IndexCountInfo;
222 wxCheckBox *m_SearchCaseSensitive;
223 wxCheckBox *m_SearchWholeWords;
224 wxToolBar* m_toolBar;
225
226 wxComboBox *m_Bookmarks;
227 wxArrayString m_BookmarksNames, m_BookmarksPages;
228
229 wxHtmlHelpFrameCfg m_Cfg;
230
231 wxConfigBase *m_Config;
232 wxString m_ConfigRoot;
233
234 // pagenumbers of controls in notebook (usually 0,1,2)
235 int m_ContentsPage;
236 int m_IndexPage;
237 int m_SearchPage;
238
239 // lists of available fonts (used in options dialog)
240 wxArrayString *m_NormalFonts, *m_FixedFonts;
241 int m_FontSize; // 0,1,2 = small,medium,big
242 wxString m_NormalFace, m_FixedFace;
243
244 bool m_UpdateContents;
245
246#if wxUSE_PRINTING_ARCHITECTURE
247 wxHtmlEasyPrinting *m_Printer;
248#endif
249 wxHashTable *m_PagesHash;
250 wxHtmlHelpController* m_helpController;
251
252 int m_hfStyle;
253
254private:
548b5377
WS
255 void DoIndexFind();
256 void DoIndexAll();
3755cfa6
JS
257 void DisplayIndexItem(const wxHtmlHelpMergedIndexItem *it);
258 wxHtmlHelpMergedIndex *m_mergedIndex;
259
260 DECLARE_EVENT_TABLE()
261 DECLARE_NO_COPY_CLASS(wxHtmlHelpWindow)
262};
263
13344b25
JS
264/*!
265 * Command IDs
266 */
267
268enum
269{
270 //wxID_HTML_HELPFRAME = wxID_HIGHEST + 1,
271 wxID_HTML_PANEL = wxID_HIGHEST + 2,
272 wxID_HTML_BACK,
273 wxID_HTML_FORWARD,
274 wxID_HTML_UPNODE,
275 wxID_HTML_UP,
276 wxID_HTML_DOWN,
277 wxID_HTML_PRINT,
278 wxID_HTML_OPENFILE,
279 wxID_HTML_OPTIONS,
280 wxID_HTML_BOOKMARKSLIST,
281 wxID_HTML_BOOKMARKSADD,
282 wxID_HTML_BOOKMARKSREMOVE,
283 wxID_HTML_TREECTRL,
284 wxID_HTML_INDEXPAGE,
285 wxID_HTML_INDEXLIST,
286 wxID_HTML_INDEXTEXT,
287 wxID_HTML_INDEXBUTTON,
288 wxID_HTML_INDEXBUTTONALL,
289 wxID_HTML_NOTEBOOK,
290 wxID_HTML_SEARCHPAGE,
291 wxID_HTML_SEARCHTEXT,
292 wxID_HTML_SEARCHLIST,
293 wxID_HTML_SEARCHBUTTON,
294 wxID_HTML_SEARCHCHOICE,
295 wxID_HTML_COUNTINFO
296};
297
298/*!
299 * Help window event
300 */
301
3755cfa6
JS
302class WXDLLIMPEXP_HTML wxHtmlWindowEvent: public wxNotifyEvent
303{
304public:
305 wxHtmlWindowEvent(wxEventType commandType = wxEVT_NULL, int id = 0):
306 wxNotifyEvent(commandType, id)
307 {
308
309 }
310
311 void SetURL(const wxString& url) { m_url = url; }
312 const wxString& GetURL() const { return m_url; }
313
314private:
315 wxString m_url;
316
76241d0f 317 DECLARE_DYNAMIC_CLASS(wxHtmlWindowEvent)
3755cfa6
JS
318};
319
320typedef void (wxEvtHandler::*wxHtmlWindowEventFunction)(wxHtmlWindowEvent&);
321
322BEGIN_DECLARE_EVENT_TYPES()
90c4e038
VZ
323 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_HTML,
324 wxEVT_COMMAND_HTMLWINDOW_URL_CLICKED, 1000)
3755cfa6
JS
325END_DECLARE_EVENT_TYPES()
326
327#define EVT_HTMLWINDOW_URL_CLICKED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_HTMLWINDOW_URL_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxHtmlWindowEventFunction) & fn, (wxObject *) NULL ),
328
329#endif // wxUSE_WXHTML_HELP
330
331#endif