]> git.saurik.com Git - wxWidgets.git/blame - include/wx/html/helpfrm.h
more extra semicolons removed (patch 1303724)
[wxWidgets.git] / include / wx / html / helpfrm.h
CommitLineData
8ec2b484
HH
1/////////////////////////////////////////////////////////////////////////////
2// Name: helpfrm.h
3// Purpose: wxHtmlHelpFrame
f42b1601 4// Notes: Based on htmlhelp.cpp, implementing a monolithic
8ec2b484
HH
5// HTML Help controller class, by Vaclav Slavik
6// Author: Harm van der Heijden and Vaclav Slavik
69941f05 7// RCS-ID: $Id$
8ec2b484 8// Copyright: (c) Harm van der Heijden and Vaclav Slavik
65571936 9// Licence: wxWindows licence
8ec2b484
HH
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_HELPFRM_H_
13#define _WX_HELPFRM_H_
14
8ec2b484
HH
15#include "wx/defs.h"
16
3379ed37 17#if wxUSE_WXHTML_HELP
8ec2b484 18
69b5cec2 19#include "wx/helpbase.h"
16a12a3d 20#include "wx/html/helpdata.h"
8ec2b484
HH
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"
382e6efe 28#include "wx/combobox.h"
c4971147 29#include "wx/checkbox.h"
240c2873 30#include "wx/stattext.h"
8ec2b484 31#include "wx/html/htmlwin.h"
0646614d 32#include "wx/html/htmprint.h"
2b5f62a0 33
6acba9a7
VS
34class WXDLLIMPEXP_CORE wxButton;
35class WXDLLIMPEXP_CORE wxTextCtrl;
46674ada
VZ
36class WXDLLIMPEXP_CORE wxTreeEvent;
37class WXDLLIMPEXP_CORE wxTreeCtrl;
8ec2b484 38
d5bb85a0 39
8ec2b484 40// style flags for the Help Frame
576507e2
VS
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
8ec2b484 60
d5bb85a0 61
97494971 62struct wxHtmlHelpFrameCfg
b31ba288 63{
68364659 64 int x, y, w, h;
d5bb85a0
VS
65 long sashpos;
66 bool navig_on;
97494971 67};
d5bb85a0 68
9817a085 69struct wxHtmlHelpMergedIndexItem;
08300277 70class wxHtmlHelpMergedIndex;
d5bb85a0 71
6acba9a7 72class WXDLLIMPEXP_CORE wxHelpControllerBase;
b31ba288 73
6acba9a7 74class WXDLLIMPEXP_HTML wxHtmlHelpFrame : public wxFrame
8ec2b484 75{
97494971
VS
76 DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame)
77
78public:
79 wxHtmlHelpFrame(wxHtmlHelpData* data = NULL) { Init(data); }
80 wxHtmlHelpFrame(wxWindow* parent, wxWindowID wxWindowID,
81 const wxString& title = wxEmptyString,
576507e2 82 int style = wxHF_DEFAULT_STYLE, wxHtmlHelpData* data = NULL);
97494971 83 bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxEmptyString,
576507e2 84 int style = wxHF_DEFAULT_STYLE);
97494971
VS
85 ~wxHtmlHelpFrame();
86
87 wxHtmlHelpData* GetData() { return m_Data; }
88 wxHelpControllerBase* GetController() const { return m_helpController; }
89 void SetController(wxHelpControllerBase* controller) { m_helpController = controller; }
90
91 // Sets format of title of the frame. Must contain exactly one "%s"
92 // (for title of displayed HTML page)
93 void SetTitleFormat(const wxString& format);
94
95 // Displays page x. If not found it will offect the user a choice of
96 // searching books.
97 // Looking for the page runs in these steps:
98 // 1. try to locate file named x (if x is for example "doc/howto.htm")
99 // 2. try to open starting page of book x
100 // 3. try to find x in contents (if x is for example "How To ...")
101 // 4. try to find x in index (if x is for example "How To ...")
102 bool Display(const wxString& x);
103
104 // Alternative version that works with numeric ID.
105 // (uses extension to MS format, <param name="ID" value=id>, see docs)
106 bool Display(const int id);
107
108 // Displays help window and focuses contents.
109 bool DisplayContents();
110
111 // Displays help window and focuses index.
112 bool DisplayIndex();
113
dabbc6a5
DS
114 // Searches for keyword. Returns true and display page if found, return
115 // false otherwise
97494971
VS
116 // Syntax of keyword is Altavista-like:
117 // * words are separated by spaces
118 // (but "\"hello world\"" is only one world "hello world")
119 // * word may be pretended by + or -
120 // (+ : page must contain the word ; - : page can't contain the word)
121 // * if there is no + or - before the word, + is default
69b5cec2
VS
122 bool KeywordSearch(const wxString& keyword,
123 wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
97494971
VS
124
125 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString)
126 {
127 m_Config = config;
128 m_ConfigRoot = rootpath;
129 ReadCustomization(config, rootpath);
130 }
131
132 // Saves custom settings into cfg config. it will use the path 'path'
133 // if given, otherwise it will save info into currently selected path.
134 // saved values : things set by SetFonts, SetBorders.
135 void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
136 void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
137
138 // call this to let wxHtmlHelpFrame know page changed
139 void NotifyPageChanged();
dabbc6a5 140
97494971
VS
141 // Refreshes Contents and Index tabs
142 void RefreshLists();
dabbc6a5 143
fc799548
JS
144protected:
145 void Init(wxHtmlHelpData* data = NULL);
97494971
VS
146
147 // Adds items to m_Contents tree control
148 void CreateContents();
149
150 // Adds items to m_IndexList
151 void CreateIndex();
152
153 // Add books to search choice panel
154 void CreateSearch();
155
08300277
VS
156 // Updates "merged index" structure that combines indexes of all books
157 // into better searchable structure
158 void UpdateMergedIndex();
159
97494971
VS
160 // Add custom buttons to toolbar
161 virtual void AddToolbarButtons(wxToolBar *toolBar, int style);
162
163 // Displays options dialog (fonts etc.)
164 virtual void OptionsDialog();
165
166 void OnToolbar(wxCommandEvent& event);
167 void OnContentsSel(wxTreeEvent& event);
168 void OnIndexSel(wxCommandEvent& event);
169 void OnIndexFind(wxCommandEvent& event);
170 void OnIndexAll(wxCommandEvent& event);
171 void OnSearchSel(wxCommandEvent& event);
172 void OnSearch(wxCommandEvent& event);
173 void OnBookmarksSel(wxCommandEvent& event);
174 void OnCloseWindow(wxCloseEvent& event);
d45bc436 175 void OnActivate(wxActivateEvent& event);
97494971 176
d9b21c9f 177#ifdef __WXMAC__
4aa31786 178 void OnClose(wxCommandEvent& event);
d9b21c9f
JS
179 void OnAbout(wxCommandEvent& event);
180#endif
181
97494971
VS
182 // Images:
183 enum {
184 IMG_Book = 0,
185 IMG_Folder,
07e252a5 186 IMG_Page
97494971
VS
187 };
188
189protected:
190 wxHtmlHelpData* m_Data;
191 bool m_DataCreated; // m_Data created by frame, or supplied?
192 wxString m_TitleFormat; // title of the help frame
193 // below are various pointers to GUI components
194 wxHtmlWindow *m_HtmlWin;
195 wxSplitterWindow *m_Splitter;
5229b11d
VS
196 wxPanel *m_NavigPan;
197 wxNotebook *m_NavigNotebook;
97494971
VS
198 wxTreeCtrl *m_ContentsBox;
199 wxTextCtrl *m_IndexText;
200 wxButton *m_IndexButton;
201 wxButton *m_IndexButtonAll;
202 wxListBox *m_IndexList;
203 wxTextCtrl *m_SearchText;
204 wxButton *m_SearchButton;
205 wxListBox *m_SearchList;
206 wxChoice *m_SearchChoice;
207 wxStaticText *m_IndexCountInfo;
208 wxCheckBox *m_SearchCaseSensitive;
209 wxCheckBox *m_SearchWholeWords;
210
211 wxComboBox *m_Bookmarks;
212 wxArrayString m_BookmarksNames, m_BookmarksPages;
213
214 wxHtmlHelpFrameCfg m_Cfg;
215
216 wxConfigBase *m_Config;
217 wxString m_ConfigRoot;
218
219 // pagenumbers of controls in notebook (usually 0,1,2)
220 int m_ContentsPage;
221 int m_IndexPage;
222 int m_SearchPage;
223
224 // lists of available fonts (used in options dialog)
225 wxArrayString *m_NormalFonts, *m_FixedFonts;
226 int m_FontSize; // 0,1,2 = small,medium,big
227 wxString m_NormalFace, m_FixedFace;
228
229 bool m_UpdateContents;
0646614d
VS
230
231#if wxUSE_PRINTING_ARCHITECTURE
97494971 232 wxHtmlEasyPrinting *m_Printer;
0646614d 233#endif
97494971
VS
234 wxHashTable *m_PagesHash;
235 wxHelpControllerBase* m_helpController;
3379ed37 236
576507e2 237 int m_hfStyle;
d5bb85a0 238
08300277
VS
239private:
240 void DisplayIndexItem(const wxHtmlHelpMergedIndexItem *it);
241 wxHtmlHelpMergedIndex *m_mergedIndex;
6953da00 242
97494971 243 DECLARE_EVENT_TABLE()
22f3361e 244 DECLARE_NO_COPY_CLASS(wxHtmlHelpFrame)
8ec2b484
HH
245};
246
3379ed37 247#endif // wxUSE_WXHTML_HELP
8ec2b484
HH
248
249#endif