]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/html/helpwnd.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / html / helpwnd.h
... / ...
CommitLineData
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/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_HELPWND_H_
12#define _WX_HELPWND_H_
13
14#include "wx/defs.h"
15
16#if wxUSE_WXHTML_HELP
17
18#include "wx/helpbase.h"
19#include "wx/html/helpdata.h"
20#include "wx/window.h"
21#include "wx/frame.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"
30#include "wx/hash.h"
31#include "wx/html/htmlwin.h"
32#include "wx/html/htmprint.h"
33
34class WXDLLIMPEXP_FWD_CORE wxButton;
35class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
36class WXDLLIMPEXP_FWD_CORE wxTreeEvent;
37class WXDLLIMPEXP_FWD_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_FWD_CORE wxHelpControllerBase;
71class WXDLLIMPEXP_FWD_HTML wxHtmlHelpController;
72
73/*!
74 * Help window
75 */
76
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 virtual ~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#if wxUSE_CONFIG
131 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString)
132 {
133 m_Config = config;
134 m_ConfigRoot = rootpath;
135 ReadCustomization(config, rootpath);
136 }
137
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
144
145 // call this to let wxHtmlHelpWindow know page changed
146 void NotifyPageChanged();
147
148 // Refreshes Contents and Index tabs
149 void RefreshLists();
150
151 // Gets the HTML window
152 wxHtmlWindow* GetHtmlWindow() const { return m_HtmlWin; }
153
154 // Gets the splitter window
155 wxSplitterWindow* GetSplitterWindow() const { return m_Splitter; }
156
157 // Gets the toolbar
158 wxToolBar* GetToolBar() const { return m_toolBar; }
159
160 // Gets the configuration data
161 wxHtmlHelpFrameCfg& GetCfgData() { return m_Cfg; }
162
163 // Gets the tree control
164 wxTreeCtrl *GetTreeCtrl() const { return m_ContentsBox; }
165
166protected:
167 void Init(wxHtmlHelpData* data = NULL);
168
169 // Adds items to m_Contents tree control
170 void CreateContents();
171
172 // Adds items to m_IndexList
173 void CreateIndex();
174
175 // Add books to search choice panel
176 void CreateSearch();
177
178 // Updates "merged index" structure that combines indexes of all books
179 // into better searchable structure
180 void UpdateMergedIndex();
181
182 // Add custom buttons to toolbar
183 virtual void AddToolbarButtons(wxToolBar *toolBar, int style);
184
185 // Displays options dialog (fonts etc.)
186 virtual void OptionsDialog();
187
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);
197
198 // Images:
199 enum {
200 IMG_Book = 0,
201 IMG_Folder,
202 IMG_Page
203 };
204
205protected:
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;
212 wxPanel *m_NavigPan;
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;
227
228 wxComboBox *m_Bookmarks;
229 wxArrayString m_BookmarksNames, m_BookmarksPages;
230
231 wxHtmlHelpFrameCfg m_Cfg;
232
233#if wxUSE_CONFIG
234 wxConfigBase *m_Config;
235 wxString m_ConfigRoot;
236#endif // wxUSE_CONFIG
237
238 // pagenumbers of controls in notebook (usually 0,1,2)
239 int m_ContentsPage;
240 int m_IndexPage;
241 int m_SearchPage;
242
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;
247
248 bool m_UpdateContents;
249
250#if wxUSE_PRINTING_ARCHITECTURE
251 wxHtmlEasyPrinting *m_Printer;
252#endif
253 wxHashTable *m_PagesHash;
254 wxHtmlHelpController* m_helpController;
255
256 int m_hfStyle;
257
258private:
259 void DoIndexFind();
260 void DoIndexAll();
261 void DisplayIndexItem(const wxHtmlHelpMergedIndexItem *it);
262 wxHtmlHelpMergedIndex *m_mergedIndex;
263
264 DECLARE_EVENT_TABLE()
265 wxDECLARE_NO_COPY_CLASS(wxHtmlHelpWindow);
266};
267
268/*!
269 * Command IDs
270 */
271
272enum
273{
274 //wxID_HTML_HELPFRAME = wxID_HIGHEST + 1,
275 wxID_HTML_PANEL = wxID_HIGHEST + 10,
276 wxID_HTML_BACK,
277 wxID_HTML_FORWARD,
278 wxID_HTML_UPNODE,
279 wxID_HTML_UP,
280 wxID_HTML_DOWN,
281 wxID_HTML_PRINT,
282 wxID_HTML_OPENFILE,
283 wxID_HTML_OPTIONS,
284 wxID_HTML_BOOKMARKSLIST,
285 wxID_HTML_BOOKMARKSADD,
286 wxID_HTML_BOOKMARKSREMOVE,
287 wxID_HTML_TREECTRL,
288 wxID_HTML_INDEXPAGE,
289 wxID_HTML_INDEXLIST,
290 wxID_HTML_INDEXTEXT,
291 wxID_HTML_INDEXBUTTON,
292 wxID_HTML_INDEXBUTTONALL,
293 wxID_HTML_NOTEBOOK,
294 wxID_HTML_SEARCHPAGE,
295 wxID_HTML_SEARCHTEXT,
296 wxID_HTML_SEARCHLIST,
297 wxID_HTML_SEARCHBUTTON,
298 wxID_HTML_SEARCHCHOICE,
299 wxID_HTML_COUNTINFO
300};
301
302#endif // wxUSE_WXHTML_HELP
303
304#endif