]> git.saurik.com Git - wxWidgets.git/blob - include/wx/html/helpfrm.h
wxHandleFatalExceptions() added, documented
[wxWidgets.git] / include / wx / html / helpfrm.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: helpfrm.h
3 // Purpose: wxHtmlHelpFrame
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_HELPFRM_H_
13 #define _WX_HELPFRM_H_
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "wx/defs.h"
20
21 #if wxUSE_HTML
22
23 #include "wx/html/helpdata.h"
24 #include "wx/window.h"
25 #include "wx/frame.h"
26 #include "wx/config.h"
27 #include "wx/splitter.h"
28 #include "wx/notebook.h"
29 #include "wx/listbox.h"
30 #include "wx/choice.h"
31 #include "wx/combobox.h"
32 #include "wx/checkbox.h"
33 #include "wx/stattext.h"
34 #include "wx/html/htmlwin.h"
35 #include "wx/html/htmprint.h"
36
37
38 // style flags for the Help Frame
39 #define wxHF_TOOLBAR 0x0001
40 #define wxHF_CONTENTS 0x0002
41 #define wxHF_INDEX 0x0004
42 #define wxHF_SEARCH 0x0008
43 #define wxHF_BOOKMARKS 0x0010
44 #define wxHF_OPENFILES 0x0020
45 #define wxHF_PRINT 0x0040
46 #define wxHF_DEFAULTSTYLE (wxHF_TOOLBAR | wxHF_CONTENTS | wxHF_INDEX | wxHF_SEARCH | wxHF_BOOKMARKS | wxHF_PRINT)
47
48
49 // Command IDs :
50 enum
51 {
52 wxID_HTML_PANEL = wxID_HIGHEST + 1,
53 wxID_HTML_BACK,
54 wxID_HTML_FORWARD,
55 wxID_HTML_UPNODE,
56 wxID_HTML_UP,
57 wxID_HTML_DOWN,
58 wxID_HTML_PRINT,
59 wxID_HTML_OPENFILE,
60 wxID_HTML_OPTIONS,
61 wxID_HTML_BOOKMARKSLIST,
62 wxID_HTML_BOOKMARKSADD,
63 wxID_HTML_BOOKMARKSREMOVE,
64 wxID_HTML_TREECTRL,
65 wxID_HTML_INDEXPAGE,
66 wxID_HTML_INDEXLIST,
67 wxID_HTML_INDEXTEXT,
68 wxID_HTML_INDEXBUTTON,
69 wxID_HTML_INDEXBUTTONALL,
70 wxID_HTML_NOTEBOOK,
71 wxID_HTML_SEARCHPAGE,
72 wxID_HTML_SEARCHTEXT,
73 wxID_HTML_SEARCHLIST,
74 wxID_HTML_SEARCHBUTTON,
75 wxID_HTML_SEARCHCHOICE,
76 wxID_HTML_COUNTINFO,
77 wxID_HTML_HELPFRAME // the id of wxHtmlHelpController's helpframe
78 }
79 ;
80
81
82 typedef struct
83 {
84 int x, y, w, h;
85 long sashpos;
86 bool navig_on;
87 }
88 wxHtmlHelpFrameCfg;
89
90
91 class WXDLLEXPORT wxHelpControllerBase;
92
93 class WXDLLEXPORT wxHtmlHelpFrame : public wxFrame
94 {
95 DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame)
96
97 public:
98 wxHtmlHelpFrame(wxHtmlHelpData* data = NULL) { Init(data); }
99 wxHtmlHelpFrame(wxWindow* parent, wxWindowID wxWindowID,
100 const wxString& title = wxEmptyString,
101 int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
102 bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxEmptyString,
103 int style = wxHF_DEFAULTSTYLE);
104 ~wxHtmlHelpFrame();
105
106 wxHtmlHelpData* GetData() { return m_Data; }
107 wxHelpControllerBase* GetController() const { return m_helpController; }
108 void SetController(wxHelpControllerBase* controller) { m_helpController = controller; }
109
110 void SetTitleFormat(const wxString& format);
111 // Sets format of title of the frame. Must contain exactly one "%s"
112 // (for title of displayed HTML page)
113
114 bool Display(const wxString& x);
115 // Displays page x. If not found it will offect the user a choice of
116 // searching books.
117 // Looking for the page runs in these steps:
118 // 1. try to locate file named x (if x is for example "doc/howto.htm")
119 // 2. try to open starting page of book x
120 // 3. try to find x in contents (if x is for example "How To ...")
121 // 4. try to find x in index (if x is for example "How To ...")
122 bool Display(const int id);
123 // Alternative version that works with numeric ID.
124 // (uses extension to MS format, <param name="ID" value=id>, see docs)
125
126 bool DisplayContents();
127 // Displays help window and focuses contents.
128
129 bool DisplayIndex();
130 // Displays help window and focuses index.
131
132 bool KeywordSearch(const wxString& keyword);
133 // Searches for keyword. Returns TRUE and display page if found, return
134 // FALSE otherwise
135 // Syntax of keyword is Altavista-like:
136 // * words are separated by spaces
137 // (but "\"hello world\"" is only one world "hello world")
138 // * word may be pretended by + or -
139 // (+ : page must contain the word ; - : page can't contain the word)
140 // * if there is no + or - before the word, + is default
141
142 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString)
143 {
144 m_Config = config;
145 m_ConfigRoot = rootpath;
146 ReadCustomization(config, rootpath);
147 }
148
149 void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
150 // saves custom settings into cfg config. it will use the path 'path'
151 // if given, otherwise it will save info into currently selected path.
152 // saved values : things set by SetFonts, SetBorders.
153 void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
154 // ...
155
156 void NotifyPageChanged();
157 // call this to let wxHtmlHelpFrame know page changed
158
159 protected:
160 void Init(wxHtmlHelpData* data = NULL);
161
162 void RefreshLists();
163 // Refreshes Contents and Index tabs
164
165 void CreateContents();
166 // Adds items to m_Contents tree control
167
168 void CreateIndex();
169 // Adds items to m_IndexList
170
171 void CreateSearch();
172 // Add books to search choice panel
173
174 virtual void AddToolbarButtons(wxToolBar *toolBar, int style);
175 // Add custom buttons to toolbar
176
177 virtual void OptionsDialog();
178 // Displays options dialog (fonts etc.)
179
180 void OnToolbar(wxCommandEvent& event);
181 void OnContentsSel(wxTreeEvent& event);
182 void OnIndexSel(wxCommandEvent& event);
183 void OnIndexFind(wxCommandEvent& event);
184 void OnIndexAll(wxCommandEvent& event);
185 void OnSearchSel(wxCommandEvent& event);
186 void OnSearch(wxCommandEvent& event);
187 void OnBookmarksSel(wxCommandEvent& event);
188 void OnCloseWindow(wxCloseEvent& event);
189
190 // Images:
191 enum {
192 IMG_Book = 0,
193 IMG_Folder,
194 IMG_Page,
195 IMG_RootFolder
196 };
197
198 protected:
199 wxHtmlHelpData* m_Data;
200 bool m_DataCreated; // m_Data created by frame, or supplied?
201 wxString m_TitleFormat; // title of the help frame
202 // below are various pointers to GUI components
203 wxHtmlWindow *m_HtmlWin;
204 wxSplitterWindow *m_Splitter;
205 wxNotebook *m_NavigPan;
206 wxTreeCtrl *m_ContentsBox;
207 wxImageList *m_ContentsImageList;
208 wxTextCtrl *m_IndexText;
209 wxButton *m_IndexButton;
210 wxButton *m_IndexButtonAll;
211 wxListBox *m_IndexList;
212 wxTextCtrl *m_SearchText;
213 wxButton *m_SearchButton;
214 wxListBox *m_SearchList;
215 wxChoice *m_SearchChoice;
216 wxStaticText *m_IndexCountInfo;
217 wxCheckBox *m_SearchCaseSensitive;
218 wxCheckBox *m_SearchWholeWords;
219
220 wxComboBox *m_Bookmarks;
221 wxArrayString m_BookmarksNames, m_BookmarksPages;
222
223 wxHtmlHelpFrameCfg m_Cfg;
224
225 wxConfigBase *m_Config;
226 wxString m_ConfigRoot;
227
228 // pagenumbers of controls in notebook (usually 0,1,2)
229 int m_ContentsPage;
230 int m_IndexPage;
231 int m_SearchPage;
232
233 // lists of available fonts (used in options dialog)
234 wxArrayString *m_NormalFonts, *m_FixedFonts;
235 int m_FontSize; // 0,1,2 = small,medium,big
236 wxString m_NormalFace, m_FixedFace;
237
238 bool m_UpdateContents;
239
240 #if wxUSE_PRINTING_ARCHITECTURE
241 wxHtmlEasyPrinting *m_Printer;
242 #endif
243 wxHashTable *m_PagesHash;
244 wxHelpControllerBase* m_helpController;
245
246 DECLARE_EVENT_TABLE()
247 };
248
249 #endif // wxUSE_HTML
250
251 #endif