]>
Commit | Line | Data |
---|---|---|
8ec2b484 HH |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: helpfrm.cpp | |
3 | // Purpose: wxHtmlHelpFrame | |
d5bb85a0 | 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 HH |
8 | // Copyright: (c) Harm van der Heijden and Vaclav Slavik |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
69941f05 | 13 | #pragma implementation |
8ec2b484 HH |
14 | #endif |
15 | ||
c32bfc10 VS |
16 | // For compilers that support precompilation, includes "wx.h" |
17 | ||
8ec2b484 HH |
18 | #include "wx/wxprec.h" |
19 | ||
20 | #ifdef __BORLANDC__ | |
21 | #pragma hdrstop | |
22 | #endif | |
23 | ||
24 | #include "wx/defs.h" | |
25 | ||
f6bcfd97 | 26 | #if wxUSE_HTML && wxUSE_STREAMS |
8ec2b484 | 27 | #ifndef WXPRECOMP |
3096bd2f | 28 | #include "wx/wx.h" |
8ec2b484 HH |
29 | #endif |
30 | ||
31 | #include "wx/html/helpfrm.h" | |
b4414c1f | 32 | #include "wx/html/helpctrl.h" |
8ec2b484 HH |
33 | #include "wx/notebook.h" |
34 | #include "wx/imaglist.h" | |
35 | #include "wx/treectrl.h" | |
36 | #include "wx/tokenzr.h" | |
37 | #include "wx/wfstream.h" | |
38 | #include "wx/html/htmlwin.h" | |
39 | #include "wx/busyinfo.h" | |
40 | #include "wx/progdlg.h" | |
2bd5bbc9 | 41 | #include "wx/toolbar.h" |
83efdf33 | 42 | #include "wx/fontenum.h" |
0646614d VS |
43 | #include "wx/stream.h" |
44 | #include "wx/filedlg.h" | |
8ec2b484 HH |
45 | |
46 | // Bitmaps: | |
47 | ||
48 | #ifndef __WXMSW__ | |
83efdf33 VS |
49 | #include "bitmaps/wpanel.xpm" |
50 | #include "bitmaps/wback.xpm" | |
51 | #include "bitmaps/wforward.xpm" | |
52 | #include "bitmaps/wbook.xpm" | |
53 | #include "bitmaps/woptions.xpm" | |
54 | #include "bitmaps/wfolder.xpm" | |
55 | #include "bitmaps/wpage.xpm" | |
56 | #include "bitmaps/whelp.xpm" | |
57 | #include "bitmaps/whlproot.xpm" | |
382e6efe VS |
58 | #include "bitmaps/wbkadd.xpm" |
59 | #include "bitmaps/wbkdel.xpm" | |
0646614d VS |
60 | #include "bitmaps/wup.xpm" |
61 | #include "bitmaps/wupnode.xpm" | |
62 | #include "bitmaps/wdown.xpm" | |
63 | #include "bitmaps/wopen.xpm" | |
64 | #include "bitmaps/wprint.xpm" | |
8ec2b484 HH |
65 | #endif |
66 | ||
8ec2b484 | 67 | |
f0b6a33f VS |
68 | // what is considered "small index"? |
69 | #define INDEX_IS_SMALL 100 | |
70 | ||
71 | ||
8ec2b484 | 72 | //-------------------------------------------------------------------------- |
382e6efe | 73 | // wxHtmlHelpTreeItemData (private) |
8ec2b484 HH |
74 | //-------------------------------------------------------------------------- |
75 | ||
76 | class wxHtmlHelpTreeItemData : public wxTreeItemData | |
77 | { | |
0646614d VS |
78 | public: |
79 | wxHtmlHelpTreeItemData(int id) : wxTreeItemData() | |
80 | { m_Id = id;} | |
81 | ||
82 | int m_Id; | |
83 | }; | |
8ec2b484 | 84 | |
0646614d VS |
85 | |
86 | //-------------------------------------------------------------------------- | |
87 | // wxHtmlHelpHashData (private) | |
88 | //-------------------------------------------------------------------------- | |
89 | ||
90 | class wxHtmlHelpHashData : public wxObject | |
91 | { | |
8ec2b484 | 92 | public: |
0646614d VS |
93 | wxHtmlHelpHashData(int index, wxTreeItemId id) : wxObject() |
94 | { m_Index = index; m_Id = id;} | |
f5ba273e | 95 | ~wxHtmlHelpHashData() {} |
f6bcfd97 | 96 | |
0646614d VS |
97 | int m_Index; |
98 | wxTreeItemId m_Id; | |
8ec2b484 HH |
99 | }; |
100 | ||
382e6efe | 101 | |
0646614d VS |
102 | //-------------------------------------------------------------------------- |
103 | // wxHtmlHelpHtmlWindow (private) | |
104 | //-------------------------------------------------------------------------- | |
105 | ||
106 | class wxHtmlHelpHtmlWindow : public wxHtmlWindow | |
107 | { | |
108 | public: | |
109 | wxHtmlHelpHtmlWindow(wxHtmlHelpFrame *fr, wxWindow *parent) : wxHtmlWindow(parent), m_Frame(fr) {} | |
110 | ||
111 | virtual void OnLinkClicked(const wxHtmlLinkInfo& link) | |
112 | { | |
113 | wxHtmlWindow::OnLinkClicked(link); | |
114 | m_Frame -> NotifyPageChanged(); | |
115 | } | |
116 | ||
f6bcfd97 | 117 | private: |
0646614d VS |
118 | wxHtmlHelpFrame *m_Frame; |
119 | }; | |
120 | ||
382e6efe VS |
121 | |
122 | ||
8ec2b484 HH |
123 | //--------------------------------------------------------------------------- |
124 | // wxHtmlHelpFrame | |
125 | //--------------------------------------------------------------------------- | |
126 | ||
127 | IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpFrame, wxFrame) | |
128 | ||
129 | wxHtmlHelpFrame::wxHtmlHelpFrame(wxWindow* parent, wxWindowID id, const wxString& title, | |
d5bb85a0 | 130 | int style, wxHtmlHelpData* data) |
8ec2b484 HH |
131 | { |
132 | Init(data); | |
133 | Create(parent, id, title, style); | |
134 | } | |
d5bb85a0 | 135 | |
8ec2b484 HH |
136 | void wxHtmlHelpFrame::Init(wxHtmlHelpData* data) |
137 | { | |
138 | if (data) { | |
d5bb85a0 VS |
139 | m_Data = data; |
140 | m_DataCreated = FALSE; | |
141 | } else { | |
142 | m_Data = new wxHtmlHelpData(); | |
143 | m_DataCreated = TRUE; | |
8ec2b484 HH |
144 | } |
145 | ||
8ec2b484 | 146 | m_ContentsBox = NULL; |
f0b6a33f VS |
147 | m_IndexList = NULL; |
148 | m_IndexButton = NULL; | |
149 | m_IndexButtonAll = NULL; | |
150 | m_IndexText = NULL; | |
8ec2b484 HH |
151 | m_SearchList = NULL; |
152 | m_SearchButton = NULL; | |
153 | m_SearchText = NULL; | |
154 | m_SearchChoice = NULL; | |
240c2873 | 155 | m_IndexCountInfo = NULL; |
8ec2b484 HH |
156 | m_Splitter = NULL; |
157 | m_NavigPan = NULL; | |
158 | m_HtmlWin = NULL; | |
382e6efe | 159 | m_Bookmarks = NULL; |
c4971147 VS |
160 | m_SearchCaseSensitive = NULL; |
161 | m_SearchWholeWords = NULL; | |
162 | ||
8ec2b484 HH |
163 | m_Config = NULL; |
164 | m_ConfigRoot = wxEmptyString; | |
165 | ||
166 | m_Cfg.x = m_Cfg.y = 0; | |
d5bb85a0 VS |
167 | m_Cfg.w = 700; |
168 | m_Cfg.h = 480; | |
8ec2b484 HH |
169 | m_Cfg.sashpos = 240; |
170 | m_Cfg.navig_on = TRUE; | |
83efdf33 VS |
171 | |
172 | m_NormalFonts = m_FixedFonts = NULL; | |
83efdf33 | 173 | m_NormalFace = m_FixedFace = wxEmptyString; |
0646614d | 174 | m_FontSize = 1; |
f6bcfd97 | 175 | |
0646614d VS |
176 | #if wxUSE_PRINTING_ARCHITECTURE |
177 | m_Printer = NULL; | |
178 | #endif | |
179 | ||
180 | m_PagesHash = NULL; | |
181 | m_UpdateContents = TRUE; | |
b4414c1f | 182 | m_helpController = (wxHelpControllerBase*) NULL; |
8ec2b484 HH |
183 | } |
184 | ||
d5bb85a0 VS |
185 | // Create: builds the GUI components. |
186 | // with the style flag it's possible to toggle the toolbar, contents, index and search | |
187 | // controls. | |
188 | // m_HtmlWin will *always* be created, but it's important to realize that | |
f0b6a33f | 189 | // m_ContentsBox, m_IndexList, m_SearchList, m_SearchButton, m_SearchText and |
d5bb85a0 VS |
190 | // m_SearchButton may be NULL. |
191 | // moreover, if no contents, index or searchpage is needed, m_Splitter and | |
192 | // m_NavigPan will be NULL too (with m_HtmlWin directly connected to the frame) | |
193 | ||
8ec2b484 | 194 | bool wxHtmlHelpFrame::Create(wxWindow* parent, wxWindowID id, const wxString& title, |
d5bb85a0 | 195 | int style) |
8ec2b484 | 196 | { |
8fd2b35c VS |
197 | wxImageList *ContentsImageList = new wxImageList(16, 16); |
198 | ContentsImageList->Add(wxICON(wbook)); | |
199 | ContentsImageList->Add(wxICON(wfolder)); | |
200 | ContentsImageList->Add(wxICON(wpage)); | |
201 | ContentsImageList->Add(wxICON(whlproot)); | |
202 | ||
8ec2b484 HH |
203 | // Do the config in two steps. We read the HtmlWindow customization after we |
204 | // create the window. | |
d5bb85a0 VS |
205 | if (m_Config) |
206 | ReadCustomization(m_Config, m_ConfigRoot); | |
8ec2b484 | 207 | |
8eb2940f | 208 | wxFrame::Create(parent, id, _("Help"), wxPoint(m_Cfg.x, m_Cfg.y), wxSize(m_Cfg.w, m_Cfg.h), wxDEFAULT_FRAME_STYLE, "wxHtmlHelp"); |
8ec2b484 | 209 | |
5c172c17 VS |
210 | GetPosition(&m_Cfg.x, &m_Cfg.y); |
211 | ||
83efdf33 | 212 | SetIcon(wxICON(whelp)); |
9ffdee80 | 213 | |
8ec2b484 HH |
214 | int notebook_page = 0; |
215 | ||
216 | CreateStatusBar(); | |
217 | ||
218 | // toolbar? | |
f6bcfd97 BP |
219 | if (style & (wxHF_TOOLBAR | wxHF_FLATTOOLBAR)) { |
220 | wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | | |
221 | wxTB_DOCKABLE | | |
222 | (style & wxHF_FLATTOOLBAR ? wxTB_FLAT : 0)); | |
00655497 | 223 | toolBar->SetMargins( 2, 2 ); |
b854b7b8 | 224 | AddToolbarButtons(toolBar, style); |
83efdf33 | 225 | toolBar -> Realize(); |
8ec2b484 | 226 | } |
d5bb85a0 | 227 | |
8ec2b484 | 228 | if (style & (wxHF_CONTENTS | wxHF_INDEX | wxHF_SEARCH)) { |
d5bb85a0 VS |
229 | // traditional help controller; splitter window with html page on the |
230 | // right and a notebook containing various pages on the left | |
231 | m_Splitter = new wxSplitterWindow(this); | |
232 | ||
0646614d | 233 | m_HtmlWin = new wxHtmlHelpHtmlWindow(this, m_Splitter); |
d5bb85a0 VS |
234 | m_NavigPan = new wxNotebook(m_Splitter, wxID_HTML_NOTEBOOK, |
235 | wxDefaultPosition, wxDefaultSize); | |
236 | } else { // only html window, no notebook with index,contents etc | |
237 | m_HtmlWin = new wxHtmlWindow(this); | |
8ec2b484 HH |
238 | } |
239 | ||
240 | m_HtmlWin -> SetRelatedFrame(this, m_TitleFormat); | |
241 | m_HtmlWin -> SetRelatedStatusBar(0); | |
d5bb85a0 VS |
242 | if (m_Config) |
243 | m_HtmlWin -> ReadCustomization(m_Config, m_ConfigRoot); | |
8ec2b484 HH |
244 | |
245 | // contents tree panel? | |
246 | if (style & wxHF_CONTENTS) { | |
ae80f837 VS |
247 | wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_INDEXPAGE); |
248 | ||
249 | if (style & wxHF_BOOKMARKS) { | |
250 | wxLayoutConstraints *b1 = new wxLayoutConstraints; | |
251 | wxBitmapButton *bmpbt = new wxBitmapButton(dummy, wxID_HTML_BOOKMARKSREMOVE, wxBITMAP(wbkdel), wxDefaultPosition, wxSize(20,20)); | |
252 | ||
253 | b1 -> top.SameAs (dummy, wxTop, 10); | |
254 | b1 -> right.SameAs (dummy, wxRight, 10); | |
255 | b1 -> height.AsIs(); | |
256 | b1 -> width.AsIs(); | |
257 | bmpbt -> SetConstraints(b1); | |
258 | ||
259 | wxLayoutConstraints *b2 = new wxLayoutConstraints; | |
260 | wxBitmapButton *bmpbt2 = new wxBitmapButton(dummy, wxID_HTML_BOOKMARKSADD, wxBITMAP(wbkadd), wxDefaultPosition, wxSize(20,20)); | |
261 | ||
262 | b2 -> top.SameAs (dummy, wxTop, 10); | |
263 | b2 -> right.LeftOf (bmpbt, 2); | |
264 | b2 -> height.AsIs(); | |
265 | b2 -> width.AsIs(); | |
266 | bmpbt2 -> SetConstraints(b2); | |
267 | ||
268 | #if wxUSE_TOOLTIPS | |
269 | bmpbt -> SetToolTip(_("Remove current page from bookmarks")); | |
270 | bmpbt2 -> SetToolTip(_("Add current page to bookmarks")); | |
271 | #endif //wxUSE_TOOLTIPS | |
272 | ||
273 | wxLayoutConstraints *b3 = new wxLayoutConstraints; | |
274 | m_Bookmarks = new wxComboBox(dummy, wxID_HTML_BOOKMARKSLIST, wxEmptyString, | |
275 | wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY | wxCB_SORT); | |
276 | m_Bookmarks -> Append(_("(bookmarks)")); | |
277 | for (unsigned i = 0; i < m_BookmarksNames.GetCount(); i++) | |
278 | m_Bookmarks -> Append(m_BookmarksNames[i]); | |
279 | m_Bookmarks -> SetSelection(0); | |
280 | ||
281 | b3 -> centreY.SameAs (bmpbt2, wxCentreY); | |
282 | b3 -> left.SameAs (dummy, wxLeft, 10); | |
283 | b3 -> right.LeftOf (bmpbt2, 5); | |
284 | b3 -> height.AsIs(); | |
285 | m_Bookmarks -> SetConstraints(b3); | |
286 | ||
287 | ||
288 | wxLayoutConstraints *b4 = new wxLayoutConstraints; | |
289 | m_ContentsBox = new wxTreeCtrl(dummy, wxID_HTML_TREECTRL, | |
290 | wxDefaultPosition, wxDefaultSize, | |
291 | wxTR_HAS_BUTTONS | wxSUNKEN_BORDER); | |
8fd2b35c | 292 | m_ContentsBox -> AssignImageList(ContentsImageList); |
ae80f837 VS |
293 | |
294 | b4 -> top.Below (m_Bookmarks, 10); | |
295 | b4 -> left.SameAs (dummy, wxLeft, 0); | |
296 | b4 -> right.SameAs (dummy, wxRight, 0); | |
297 | b4 -> bottom.SameAs (dummy, wxBottom, 0); | |
298 | m_ContentsBox -> SetConstraints(b4); | |
299 | ||
300 | dummy -> SetAutoLayout(TRUE); | |
301 | dummy -> Layout(); | |
302 | ||
303 | m_NavigPan -> AddPage(dummy, _("Contents")); | |
304 | } | |
305 | ||
306 | else | |
307 | { | |
308 | m_ContentsBox = new wxTreeCtrl(m_NavigPan, wxID_HTML_TREECTRL, | |
309 | wxDefaultPosition, wxDefaultSize, | |
310 | wxTR_HAS_BUTTONS | wxSUNKEN_BORDER); | |
8fd2b35c | 311 | m_ContentsBox -> AssignImageList(ContentsImageList); |
ae80f837 VS |
312 | m_NavigPan -> AddPage(m_ContentsBox, _("Contents")); |
313 | } | |
314 | ||
d5bb85a0 | 315 | m_ContentsPage = notebook_page++; |
8ec2b484 HH |
316 | } |
317 | ||
318 | // index listbox panel? | |
319 | if (style & wxHF_INDEX) { | |
d5bb85a0 | 320 | wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_INDEXPAGE); |
f0b6a33f | 321 | |
d5bb85a0 | 322 | wxLayoutConstraints *b1 = new wxLayoutConstraints; |
f0b6a33f VS |
323 | m_IndexText = new wxTextCtrl(dummy, wxID_HTML_INDEXTEXT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); |
324 | b1 -> top.SameAs (dummy, wxTop, 10); | |
325 | b1 -> left.SameAs (dummy, wxLeft, 10); | |
326 | b1 -> right.SameAs (dummy, wxRight, 10); | |
327 | b1 -> height.AsIs(); | |
328 | m_IndexText -> SetConstraints(b1); | |
329 | ||
330 | wxLayoutConstraints *b4 = new wxLayoutConstraints; | |
331 | m_IndexButtonAll = new wxButton(dummy, wxID_HTML_INDEXBUTTONALL, _("Show all")); | |
7618e374 | 332 | |
f0b6a33f VS |
333 | b4 -> top.Below (m_IndexText, 10); |
334 | b4 -> right.SameAs (dummy, wxRight, 10); | |
335 | b4 -> width.AsIs(); | |
336 | b4 -> height.AsIs(); | |
337 | m_IndexButtonAll -> SetConstraints(b4); | |
338 | ||
339 | wxLayoutConstraints *b2 = new wxLayoutConstraints; | |
340 | m_IndexButton = new wxButton(dummy, wxID_HTML_INDEXBUTTON, _("Find")); | |
f0b6a33f VS |
341 | b2 -> top.Below (m_IndexText, 10); |
342 | b2 -> right.LeftOf (m_IndexButtonAll, 10); | |
343 | b2 -> width.AsIs(); | |
344 | b2 -> height.AsIs(); | |
345 | m_IndexButton -> SetConstraints(b2); | |
346 | ||
240c2873 VS |
347 | wxLayoutConstraints *b5 = new wxLayoutConstraints; |
348 | m_IndexCountInfo = new wxStaticText(dummy, wxID_HTML_COUNTINFO, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT | wxST_NO_AUTORESIZE); | |
349 | ||
350 | b5 -> top.Below (m_IndexButton, 5); | |
351 | b5 -> right.SameAs (dummy, wxRight, 10); | |
352 | b5 -> left.SameAs (dummy, wxLeft, 10); | |
353 | b5 -> height.AsIs(); | |
354 | m_IndexCountInfo -> SetConstraints(b5); | |
355 | ||
f0b6a33f | 356 | wxLayoutConstraints *b3 = new wxLayoutConstraints; |
721ab905 | 357 | m_IndexList = new wxListBox(dummy, wxID_HTML_INDEXLIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE); |
240c2873 | 358 | b3 -> top.Below (m_IndexCountInfo, 5); |
f0b6a33f VS |
359 | b3 -> left.SameAs (dummy, wxLeft, 0); |
360 | b3 -> right.SameAs (dummy, wxRight, 0); | |
361 | b3 -> bottom.SameAs (dummy, wxBottom, 0); | |
362 | m_IndexList -> SetConstraints(b3); | |
363 | ||
7618e374 VS |
364 | #if wxUSE_TOOLTIPS |
365 | m_IndexButtonAll -> SetToolTip(_("Show all items in index")); | |
240c2873 | 366 | m_IndexButton -> SetToolTip(_("Display all index items that contain given substring. Search is case insensitive.")); |
7618e374 VS |
367 | #endif //wxUSE_TOOLTIPS |
368 | ||
d5bb85a0 | 369 | dummy -> SetAutoLayout(TRUE); |
f0b6a33f VS |
370 | dummy -> Layout(); |
371 | ||
d5bb85a0 VS |
372 | m_NavigPan -> AddPage(dummy, _("Index")); |
373 | m_IndexPage = notebook_page++; | |
8ec2b484 HH |
374 | } |
375 | ||
376 | // search list panel? | |
377 | if (style & wxHF_SEARCH) { | |
d5bb85a0 VS |
378 | wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_SEARCHPAGE); |
379 | ||
380 | wxLayoutConstraints *b1 = new wxLayoutConstraints; | |
f0b6a33f | 381 | m_SearchText = new wxTextCtrl(dummy, wxID_HTML_SEARCHTEXT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); |
d5bb85a0 VS |
382 | b1 -> top.SameAs (dummy, wxTop, 10); |
383 | b1 -> left.SameAs (dummy, wxLeft, 10); | |
384 | b1 -> right.SameAs (dummy, wxRight, 10); | |
385 | b1 -> height.AsIs(); | |
386 | m_SearchText -> SetConstraints(b1); | |
387 | ||
d5bb85a0 VS |
388 | wxLayoutConstraints *b4 = new wxLayoutConstraints; |
389 | m_SearchChoice = new wxChoice(dummy, wxID_HTML_SEARCHCHOICE, wxDefaultPosition, | |
390 | wxDefaultSize); | |
391 | b4 -> top.Below (m_SearchText, 10); | |
ae80f837 | 392 | b4 -> left.SameAs (dummy, wxLeft, 10); |
d5bb85a0 VS |
393 | b4 -> right.SameAs (dummy, wxRight, 10); |
394 | b4 -> height.AsIs(); | |
395 | m_SearchChoice -> SetConstraints(b4); | |
396 | ||
c4971147 VS |
397 | wxLayoutConstraints *b5 = new wxLayoutConstraints; |
398 | m_SearchCaseSensitive = new wxCheckBox(dummy, -1, _("Case sensitive")); | |
ae80f837 | 399 | b5 -> top.Below (m_SearchChoice, 10); |
c4971147 | 400 | b5 -> left.SameAs (dummy, wxLeft, 10); |
ae80f837 | 401 | b5 -> width.AsIs(); |
c4971147 VS |
402 | b5 -> height.AsIs (); |
403 | m_SearchCaseSensitive -> SetConstraints(b5); | |
404 | ||
405 | wxLayoutConstraints *b6 = new wxLayoutConstraints; | |
406 | m_SearchWholeWords = new wxCheckBox(dummy, -1, _("Whole words only")); | |
407 | b6 -> top.Below (m_SearchCaseSensitive, 0); | |
408 | b6 -> left.SameAs (dummy, wxLeft, 10); | |
ae80f837 | 409 | b6 -> width.AsIs(); |
c4971147 VS |
410 | b6 -> height.AsIs (); |
411 | m_SearchWholeWords -> SetConstraints(b6); | |
412 | ||
ae80f837 VS |
413 | wxLayoutConstraints *b2 = new wxLayoutConstraints; |
414 | m_SearchButton = new wxButton(dummy, wxID_HTML_SEARCHBUTTON, _("Search")); | |
415 | #if wxUSE_TOOLTIPS | |
416 | m_SearchButton -> SetToolTip(_("Search contents of help book(s) for all occurences of the text you typed above")); | |
417 | #endif //wxUSE_TOOLTIPS | |
418 | b2 -> top.Below (m_SearchWholeWords, 0); | |
419 | b2 -> right.SameAs (dummy, wxRight, 10); | |
420 | b2 -> width.AsIs(); | |
421 | b2 -> height.AsIs(); | |
422 | m_SearchButton -> SetConstraints(b2); | |
423 | ||
954269e6 | 424 | wxLayoutConstraints *b3 = new wxLayoutConstraints; |
721ab905 | 425 | m_SearchList = new wxListBox(dummy, wxID_HTML_SEARCHLIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE); |
ae80f837 | 426 | b3 -> top.Below (m_SearchButton, 10); |
954269e6 VS |
427 | b3 -> left.SameAs (dummy, wxLeft, 0); |
428 | b3 -> right.SameAs (dummy, wxRight, 0); | |
429 | b3 -> bottom.SameAs (dummy, wxBottom, 0); | |
430 | m_SearchList -> SetConstraints(b3); | |
431 | ||
d5bb85a0 VS |
432 | dummy -> SetAutoLayout(TRUE); |
433 | dummy -> Layout(); | |
434 | m_NavigPan -> AddPage(dummy, _("Search")); | |
435 | m_SearchPage = notebook_page++; | |
8ec2b484 | 436 | } |
c32bfc10 | 437 | m_HtmlWin -> Show(TRUE); |
f6bcfd97 | 438 | |
b5a7b000 | 439 | RefreshLists(); |
8ec2b484 HH |
440 | |
441 | // showtime | |
442 | if (m_NavigPan && m_Splitter) { | |
d5bb85a0 | 443 | m_Splitter -> SetMinimumPaneSize(20); |
f38374d0 DW |
444 | if (m_Cfg.navig_on) |
445 | m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); | |
446 | else { | |
447 | m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); | |
448 | m_Splitter -> Unsplit(); | |
449 | } | |
c32bfc10 VS |
450 | if (m_Cfg.navig_on) { |
451 | m_NavigPan -> Show(TRUE); | |
d5bb85a0 | 452 | m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); |
c32bfc10 | 453 | } |
68364659 | 454 | else { |
c32bfc10 VS |
455 | m_NavigPan -> Show(FALSE); |
456 | m_Splitter -> Initialize(m_HtmlWin); | |
68364659 | 457 | } |
8ec2b484 | 458 | } |
8ec2b484 HH |
459 | return TRUE; |
460 | } | |
461 | ||
462 | wxHtmlHelpFrame::~wxHtmlHelpFrame() | |
463 | { | |
b4414c1f | 464 | // PopEventHandler(); // wxhtmlhelpcontroller (not any more!) |
8ec2b484 | 465 | if (m_DataCreated) |
d5bb85a0 | 466 | delete m_Data; |
83efdf33 VS |
467 | if (m_NormalFonts) delete m_NormalFonts; |
468 | if (m_FixedFonts) delete m_FixedFonts; | |
70aedad6 | 469 | if (m_PagesHash) delete m_PagesHash; |
8ec2b484 HH |
470 | } |
471 | ||
b854b7b8 VS |
472 | |
473 | void wxHtmlHelpFrame::AddToolbarButtons(wxToolBar *toolBar, int style) | |
474 | { | |
f6bcfd97 BP |
475 | wxBitmap wpanelBitmap = wxBITMAP(wpanel); |
476 | wxBitmap wbackBitmap = wxBITMAP(wback); | |
477 | wxBitmap wforwardBitmap = wxBITMAP(wforward); | |
478 | wxBitmap wupnodeBitmap = wxBITMAP(wupnode); | |
479 | wxBitmap wupBitmap = wxBITMAP(wup); | |
480 | wxBitmap wdownBitmap = wxBITMAP(wdown); | |
481 | wxBitmap wopenBitmap = wxBITMAP(wopen); | |
482 | wxBitmap wprintBitmap = wxBITMAP(wprint); | |
483 | wxBitmap woptionsBitmap = wxBITMAP(woptions); | |
484 | ||
485 | wxASSERT_MSG( (wpanelBitmap.Ok() && wbackBitmap.Ok() && | |
486 | wforwardBitmap.Ok() && wupnodeBitmap.Ok() && | |
487 | wupBitmap.Ok() && wdownBitmap.Ok() && | |
488 | wopenBitmap.Ok() && wprintBitmap.Ok() && | |
489 | woptionsBitmap.Ok()), | |
490 | wxT("One or more HTML help frame toolbar bitmap could not be loaded.")) ; | |
491 | ||
492 | ||
493 | toolBar -> AddTool(wxID_HTML_PANEL, wpanelBitmap, wxNullBitmap, | |
b854b7b8 VS |
494 | FALSE, -1, -1, (wxObject *) NULL, |
495 | _("Show/hide navigation panel")); | |
0646614d | 496 | |
b854b7b8 | 497 | toolBar -> AddSeparator(); |
f6bcfd97 | 498 | toolBar -> AddTool(wxID_HTML_BACK, wbackBitmap, wxNullBitmap, |
b854b7b8 | 499 | FALSE, -1, -1, (wxObject *) NULL, |
0646614d | 500 | _("Go back")); |
f6bcfd97 | 501 | toolBar -> AddTool(wxID_HTML_FORWARD, wforwardBitmap, wxNullBitmap, |
b854b7b8 | 502 | FALSE, -1, -1, (wxObject *) NULL, |
0646614d | 503 | _("Go forward")); |
b854b7b8 VS |
504 | toolBar -> AddSeparator(); |
505 | ||
f6bcfd97 | 506 | toolBar -> AddTool(wxID_HTML_UPNODE, wupnodeBitmap, wxNullBitmap, |
0646614d VS |
507 | FALSE, -1, -1, (wxObject *) NULL, |
508 | _("Go one level up in document hierarchy")); | |
f6bcfd97 | 509 | toolBar -> AddTool(wxID_HTML_UP, wupBitmap, wxNullBitmap, |
0646614d VS |
510 | FALSE, -1, -1, (wxObject *) NULL, |
511 | _("Previous page")); | |
f6bcfd97 | 512 | toolBar -> AddTool(wxID_HTML_DOWN, wdownBitmap, wxNullBitmap, |
0646614d VS |
513 | FALSE, -1, -1, (wxObject *) NULL, |
514 | _("Next page")); | |
515 | ||
516 | if ((style & wxHF_PRINT) || (style & wxHF_OPENFILES)) | |
517 | toolBar -> AddSeparator(); | |
f6bcfd97 | 518 | |
0646614d | 519 | if (style & wxHF_OPENFILES) |
f6bcfd97 | 520 | toolBar -> AddTool(wxID_HTML_OPENFILE, wopenBitmap, wxNullBitmap, |
0646614d VS |
521 | FALSE, -1, -1, (wxObject *) NULL, |
522 | _("Open HTML document")); | |
523 | ||
524 | #if wxUSE_PRINTING_ARCHITECTURE | |
525 | if (style & wxHF_PRINT) | |
f6bcfd97 | 526 | toolBar -> AddTool(wxID_HTML_PRINT, wprintBitmap, wxNullBitmap, |
0646614d VS |
527 | FALSE, -1, -1, (wxObject *) NULL, |
528 | _("Print this page")); | |
529 | #endif | |
530 | ||
b854b7b8 | 531 | toolBar -> AddSeparator(); |
f6bcfd97 | 532 | toolBar -> AddTool(wxID_HTML_OPTIONS, woptionsBitmap, wxNullBitmap, |
b854b7b8 VS |
533 | FALSE, -1, -1, (wxObject *) NULL, |
534 | _("Display options dialog")); | |
535 | } | |
536 | ||
537 | ||
721ab905 VS |
538 | void wxHtmlHelpFrame::SetTitleFormat(const wxString& format) |
539 | { | |
540 | if (m_HtmlWin) | |
541 | m_HtmlWin->SetRelatedFrame(this, format); | |
542 | m_TitleFormat = format; | |
543 | } | |
544 | ||
b854b7b8 | 545 | |
8ec2b484 HH |
546 | bool wxHtmlHelpFrame::Display(const wxString& x) |
547 | { | |
548 | wxString url = m_Data->FindPageByName(x); | |
549 | if (! url.IsEmpty()) { | |
d5bb85a0 | 550 | m_HtmlWin->LoadPage(url); |
0646614d | 551 | NotifyPageChanged(); |
d5bb85a0 | 552 | return TRUE; |
8ec2b484 HH |
553 | } |
554 | return FALSE; | |
555 | } | |
556 | ||
557 | bool wxHtmlHelpFrame::Display(const int id) | |
558 | { | |
559 | wxString url = m_Data->FindPageById(id); | |
560 | if (! url.IsEmpty()) { | |
d5bb85a0 | 561 | m_HtmlWin->LoadPage(url); |
0646614d | 562 | NotifyPageChanged(); |
d5bb85a0 | 563 | return TRUE; |
8ec2b484 HH |
564 | } |
565 | return FALSE; | |
566 | } | |
567 | ||
568 | ||
569 | ||
570 | bool wxHtmlHelpFrame::DisplayContents() | |
571 | { | |
572 | if (! m_ContentsBox) | |
d5bb85a0 | 573 | return FALSE; |
8ec2b484 | 574 | if (!m_Splitter -> IsSplit()) { |
d5bb85a0 VS |
575 | m_NavigPan -> Show(TRUE); |
576 | m_HtmlWin -> Show(TRUE); | |
577 | m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); | |
c32bfc10 | 578 | m_Cfg.navig_on = TRUE; |
8ec2b484 HH |
579 | } |
580 | m_NavigPan -> SetSelection(0); | |
581 | return TRUE; | |
582 | } | |
583 | ||
584 | ||
585 | ||
586 | bool wxHtmlHelpFrame::DisplayIndex() | |
587 | { | |
f0b6a33f | 588 | if (! m_IndexList) |
d5bb85a0 | 589 | return FALSE; |
8ec2b484 | 590 | if (!m_Splitter -> IsSplit()) { |
d5bb85a0 VS |
591 | m_NavigPan -> Show(TRUE); |
592 | m_HtmlWin -> Show(TRUE); | |
593 | m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); | |
8ec2b484 HH |
594 | } |
595 | m_NavigPan -> SetSelection(1); | |
596 | return TRUE; | |
597 | } | |
598 | ||
b854b7b8 VS |
599 | |
600 | ||
8ec2b484 HH |
601 | bool wxHtmlHelpFrame::KeywordSearch(const wxString& keyword) |
602 | { | |
603 | if (! (m_SearchList && m_SearchButton && m_SearchText && m_SearchChoice)) | |
d5bb85a0 | 604 | return FALSE; |
8ec2b484 | 605 | |
c4971147 | 606 | int foundcnt = 0, curi; |
8ec2b484 HH |
607 | wxString foundstr; |
608 | wxString book = wxEmptyString; | |
609 | ||
610 | if (!m_Splitter -> IsSplit()) { | |
d5bb85a0 VS |
611 | m_NavigPan -> Show(TRUE); |
612 | m_HtmlWin -> Show(TRUE); | |
613 | m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); | |
8ec2b484 HH |
614 | } |
615 | m_NavigPan -> SetSelection(m_SearchPage); | |
616 | m_SearchList -> Clear(); | |
617 | m_SearchText -> SetValue(keyword); | |
618 | m_SearchButton -> Enable(FALSE); | |
619 | ||
620 | if (m_SearchChoice->GetSelection() != 0) | |
d5bb85a0 | 621 | book = m_SearchChoice->GetStringSelection(); |
8ec2b484 | 622 | |
f6bcfd97 BP |
623 | wxHtmlSearchStatus status(m_Data, keyword, |
624 | m_SearchCaseSensitive -> GetValue(), m_SearchWholeWords -> GetValue(), | |
c4971147 | 625 | book); |
8ec2b484 | 626 | |
d5bb85a0 VS |
627 | wxProgressDialog progress(_("Searching..."), _("No matching page found yet"), |
628 | status.GetMaxIndex(), this, | |
b4414c1f | 629 | wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_AUTO_HIDE); |
8ec2b484 HH |
630 | |
631 | while (status.IsActive()) { | |
c4971147 | 632 | curi = status.GetCurIndex(); |
b5a7b000 | 633 | if (curi % 32 == 0 && progress.Update(curi) == FALSE) |
d5bb85a0 VS |
634 | break; |
635 | if (status.Search()) { | |
636 | foundstr.Printf(_("Found %i matches"), ++foundcnt); | |
637 | progress.Update(status.GetCurIndex(), foundstr); | |
638 | m_SearchList -> Append(status.GetName(), status.GetContentsItem()); | |
639 | } | |
8ec2b484 HH |
640 | } |
641 | ||
642 | m_SearchButton -> Enable(TRUE); | |
643 | m_SearchText -> SetSelection(0, keyword.Length()); | |
644 | m_SearchText -> SetFocus(); | |
645 | if (foundcnt) { | |
646 | wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_SearchList -> GetClientData(0); | |
f6bcfd97 | 647 | if (it) |
0646614d VS |
648 | { |
649 | m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page); | |
650 | NotifyPageChanged(); | |
651 | } | |
8ec2b484 HH |
652 | } |
653 | return (foundcnt > 0); | |
654 | } | |
655 | ||
656 | #define MAX_ROOTS 64 | |
657 | ||
b5a7b000 | 658 | void wxHtmlHelpFrame::CreateContents() |
8ec2b484 HH |
659 | { |
660 | if (! m_ContentsBox) | |
d5bb85a0 | 661 | return ; |
8ec2b484 | 662 | |
8ec2b484 | 663 | m_ContentsBox->Clear(); |
f6bcfd97 | 664 | |
0646614d VS |
665 | if (m_PagesHash) delete m_PagesHash; |
666 | m_PagesHash = new wxHashTable(wxKEY_STRING, 2 * m_Data -> GetContentsCnt()); | |
667 | m_PagesHash -> DeleteContents(TRUE); | |
8ec2b484 HH |
668 | |
669 | int cnt = m_Data->GetContentsCnt(); | |
8ec2b484 HH |
670 | int i; |
671 | ||
83efdf33 | 672 | wxHtmlContentsItem *it; |
d5bb85a0 | 673 | |
8ec2b484 HH |
674 | wxTreeItemId roots[MAX_ROOTS]; |
675 | bool imaged[MAX_ROOTS]; | |
676 | ||
677 | m_ContentsBox -> DeleteAllItems(); | |
678 | roots[0] = m_ContentsBox -> AddRoot(_("(Help)")); | |
5c172c17 VS |
679 | m_ContentsBox -> SetItemImage(roots[0], IMG_RootFolder); |
680 | m_ContentsBox -> SetItemSelectedImage(roots[0], IMG_RootFolder); | |
8ec2b484 HH |
681 | imaged[0] = TRUE; |
682 | ||
83efdf33 | 683 | for (it = m_Data->GetContents(), i = 0; i < cnt; i++, it++) { |
382e6efe | 684 | roots[it -> m_Level + 1] = m_ContentsBox -> AppendItem( |
d5bb85a0 | 685 | roots[it -> m_Level], it -> m_Name, IMG_Page, -1, |
0646614d | 686 | new wxHtmlHelpTreeItemData(i)); |
f6bcfd97 | 687 | m_PagesHash -> Put(it -> m_Book -> GetBasePath() + it -> m_Page, |
0646614d | 688 | new wxHtmlHelpHashData(i, roots[it -> m_Level + 1])); |
8ec2b484 HH |
689 | |
690 | if (it -> m_Level == 0) { | |
691 | m_ContentsBox -> SetItemBold(roots[1], TRUE); | |
692 | m_ContentsBox -> SetItemImage(roots[1], IMG_Book); | |
693 | m_ContentsBox -> SetItemSelectedImage(roots[1], IMG_Book); | |
694 | imaged[1] = TRUE; | |
d5bb85a0 | 695 | } else imaged[it -> m_Level + 1] = FALSE; |
8ec2b484 HH |
696 | |
697 | if (!imaged[it -> m_Level]) { | |
698 | m_ContentsBox -> SetItemImage(roots[it -> m_Level], IMG_Folder); | |
699 | m_ContentsBox -> SetItemSelectedImage(roots[it -> m_Level], IMG_Folder); | |
700 | imaged[it -> m_Level] = TRUE; | |
701 | } | |
702 | } | |
8ec2b484 HH |
703 | m_ContentsBox -> Expand(roots[0]); |
704 | } | |
705 | ||
706 | ||
b5a7b000 | 707 | void wxHtmlHelpFrame::CreateIndex() |
8ec2b484 | 708 | { |
f0b6a33f | 709 | if (! m_IndexList) |
d5bb85a0 | 710 | return ; |
8ec2b484 | 711 | |
f0b6a33f | 712 | m_IndexList->Clear(); |
8ec2b484 HH |
713 | |
714 | int cnt = m_Data->GetIndexCnt(); | |
f6bcfd97 | 715 | |
240c2873 VS |
716 | wxString cnttext; |
717 | if (cnt > INDEX_IS_SMALL) cnttext.Printf(_("%i of %i"), 0, cnt); | |
718 | else cnttext.Printf(_("%i of %i"), cnt, cnt); | |
719 | m_IndexCountInfo -> SetLabel(cnttext); | |
f0b6a33f | 720 | if (cnt > INDEX_IS_SMALL) return; |
f6bcfd97 | 721 | |
8ec2b484 HH |
722 | wxHtmlContentsItem* index = m_Data->GetIndex(); |
723 | ||
f6bcfd97 | 724 | for (int i = 0; i < cnt; i++) |
f0b6a33f | 725 | m_IndexList -> Append(index[i].m_Name, (char*)(index + i)); |
8ec2b484 HH |
726 | } |
727 | ||
728 | void wxHtmlHelpFrame::CreateSearch() | |
729 | { | |
730 | if (! (m_SearchList && m_SearchChoice)) | |
d5bb85a0 | 731 | return ; |
8ec2b484 HH |
732 | m_SearchList -> Clear(); |
733 | m_SearchChoice -> Clear(); | |
ae80f837 | 734 | m_SearchChoice -> Append(_("Search in all books")); |
8ec2b484 HH |
735 | const wxHtmlBookRecArray& bookrec = m_Data->GetBookRecArray(); |
736 | int i, cnt = bookrec.GetCount(); | |
d5bb85a0 VS |
737 | for (i = 0; i < cnt; i++) |
738 | m_SearchChoice->Append(bookrec[i].GetTitle()); | |
8ec2b484 HH |
739 | m_SearchChoice->SetSelection(0); |
740 | } | |
741 | ||
742 | ||
b5a7b000 | 743 | void wxHtmlHelpFrame::RefreshLists() |
8ec2b484 | 744 | { |
b5a7b000 VS |
745 | CreateContents(); |
746 | CreateIndex(); | |
8ec2b484 HH |
747 | CreateSearch(); |
748 | } | |
749 | ||
750 | void wxHtmlHelpFrame::ReadCustomization(wxConfigBase *cfg, const wxString& path) | |
751 | { | |
752 | wxString oldpath; | |
753 | wxString tmp; | |
754 | ||
755 | if (path != wxEmptyString) { | |
756 | oldpath = cfg -> GetPath(); | |
3e5296e7 | 757 | cfg -> SetPath(_T("/") + path); |
8ec2b484 HH |
758 | } |
759 | ||
0646614d VS |
760 | m_Cfg.navig_on = cfg -> Read(wxT("hcNavigPanel"), m_Cfg.navig_on) != 0; |
761 | m_Cfg.sashpos = cfg -> Read(wxT("hcSashPos"), m_Cfg.sashpos); | |
762 | m_Cfg.x = cfg -> Read(wxT("hcX"), m_Cfg.x); | |
763 | m_Cfg.y = cfg -> Read(wxT("hcY"), m_Cfg.y); | |
764 | m_Cfg.w = cfg -> Read(wxT("hcW"), m_Cfg.w); | |
765 | m_Cfg.h = cfg -> Read(wxT("hcH"), m_Cfg.h); | |
8ec2b484 | 766 | |
0646614d VS |
767 | m_FixedFace = cfg -> Read(wxT("hcFixedFace"), m_FixedFace); |
768 | m_NormalFace = cfg -> Read(wxT("hcNormalFace"), m_NormalFace); | |
769 | m_FontSize = cfg -> Read(wxT("hcFontSize"), m_FontSize); | |
83efdf33 | 770 | |
382e6efe VS |
771 | { |
772 | int i; | |
773 | int cnt; | |
774 | wxString val, s; | |
f6bcfd97 | 775 | |
0646614d | 776 | cnt = cfg -> Read(wxT("hcBookmarksCnt"), 0L); |
382e6efe VS |
777 | if (cnt != 0) { |
778 | m_BookmarksNames.Clear(); | |
779 | m_BookmarksPages.Clear(); | |
780 | if (m_Bookmarks) { | |
781 | m_Bookmarks -> Clear(); | |
ae80f837 | 782 | m_Bookmarks -> Append(_("(bookmarks)")); |
382e6efe | 783 | } |
f6bcfd97 | 784 | |
382e6efe | 785 | for (i = 0; i < cnt; i++) { |
0413cec5 | 786 | val.Printf(wxT("hcBookmark_%i"), i); |
382e6efe VS |
787 | s = cfg -> Read(val); |
788 | m_BookmarksNames.Add(s); | |
789 | if (m_Bookmarks) m_Bookmarks -> Append(s); | |
0413cec5 | 790 | val.Printf(wxT("hcBookmark_%i_url"), i); |
382e6efe VS |
791 | s = cfg -> Read(val); |
792 | m_BookmarksPages.Add(s); | |
793 | } | |
794 | } | |
795 | } | |
796 | ||
8ec2b484 | 797 | if (m_HtmlWin) |
3e5296e7 | 798 | m_HtmlWin->ReadCustomization(cfg); |
8ec2b484 HH |
799 | |
800 | if (path != wxEmptyString) | |
801 | cfg -> SetPath(oldpath); | |
802 | } | |
803 | ||
804 | void wxHtmlHelpFrame::WriteCustomization(wxConfigBase *cfg, const wxString& path) | |
805 | { | |
806 | wxString oldpath; | |
807 | wxString tmp; | |
8ec2b484 HH |
808 | |
809 | if (path != wxEmptyString) { | |
810 | oldpath = cfg -> GetPath(); | |
3e5296e7 | 811 | cfg -> SetPath(_T("/") + path); |
8ec2b484 HH |
812 | } |
813 | ||
0646614d VS |
814 | cfg -> Write(wxT("hcNavigPanel"), m_Cfg.navig_on); |
815 | cfg -> Write(wxT("hcSashPos"), (long)m_Cfg.sashpos); | |
816 | cfg -> Write(wxT("hcX"), (long)m_Cfg.x); | |
817 | cfg -> Write(wxT("hcY"), (long)m_Cfg.y); | |
818 | cfg -> Write(wxT("hcW"), (long)m_Cfg.w); | |
819 | cfg -> Write(wxT("hcH"), (long)m_Cfg.h); | |
820 | cfg -> Write(wxT("hcFixedFace"), m_FixedFace); | |
821 | cfg -> Write(wxT("hcNormalFace"), m_NormalFace); | |
822 | cfg -> Write(wxT("hcFontSize"), (long)m_FontSize); | |
f6bcfd97 | 823 | |
382e6efe VS |
824 | if (m_Bookmarks) { |
825 | int i; | |
826 | int cnt = m_BookmarksNames.GetCount(); | |
827 | wxString val; | |
f6bcfd97 | 828 | |
0646614d | 829 | cfg -> Write(wxT("hcBookmarksCnt"), (long)cnt); |
382e6efe | 830 | for (i = 0; i < cnt; i++) { |
0413cec5 | 831 | val.Printf(wxT("hcBookmark_%i"), i); |
382e6efe | 832 | cfg -> Write(val, m_BookmarksNames[i]); |
0413cec5 | 833 | val.Printf(wxT("hcBookmark_%i_url"), i); |
382e6efe VS |
834 | cfg -> Write(val, m_BookmarksPages[i]); |
835 | } | |
836 | } | |
8ec2b484 HH |
837 | |
838 | if (m_HtmlWin) | |
3e5296e7 | 839 | m_HtmlWin->WriteCustomization(cfg); |
8ec2b484 HH |
840 | |
841 | if (path != wxEmptyString) | |
842 | cfg -> SetPath(oldpath); | |
843 | } | |
844 | ||
845 | ||
83efdf33 VS |
846 | |
847 | ||
848 | ||
8eb2940f | 849 | static void SetFontsToHtmlWin(wxHtmlWindow *win, wxString scalf, wxString fixf, int size) |
83efdf33 | 850 | { |
f6bcfd97 | 851 | static int f_sizes[5][7] = |
83efdf33 | 852 | { |
0646614d | 853 | { 6, 7, 9, 12, 14, 16, 19}, |
f151e8b5 | 854 | { 8, 9, 12, 14, 16, 19, 22}, |
83efdf33 | 855 | {10, 12, 14, 16, 19, 24, 32}, |
0646614d VS |
856 | {14, 16, 18, 24, 32, 38, 45}, |
857 | {16, 20, 24, 32, 38, 45, 50} | |
83efdf33 | 858 | }; |
f151e8b5 | 859 | |
8eb2940f | 860 | win -> SetFonts(scalf, fixf, f_sizes[size]); |
83efdf33 VS |
861 | } |
862 | ||
863 | ||
864 | class wxHtmlHelpFrameOptionsDialog : public wxDialog | |
865 | { | |
866 | public: | |
f151e8b5 | 867 | wxComboBox *NormalFont, *FixedFont; |
83efdf33 VS |
868 | wxRadioBox *RadioBox; |
869 | wxHtmlWindow *TestWin; | |
870 | ||
871 | wxHtmlHelpFrameOptionsDialog(wxWindow *parent) : wxDialog(parent, -1, wxString(_("Help Browser Options"))) | |
872 | { | |
0646614d | 873 | wxString choices[5] = {_("very small"), _("small"), _("medium"), _("large"), _("very large")}; |
8eb2940f | 874 | wxBoxSizer *topsizer, *sizer, *sizer2; |
83efdf33 VS |
875 | |
876 | topsizer = new wxBoxSizer(wxVERTICAL); | |
877 | ||
878 | sizer = new wxBoxSizer(wxHORIZONTAL); | |
879 | ||
6f67eafe | 880 | sizer2 = new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Normal font:")), wxVERTICAL); |
f6bcfd97 BP |
881 | sizer2 -> Add(NormalFont = new wxComboBox(this, -1, wxEmptyString, wxDefaultPosition, |
882 | wxSize(200, 200), | |
382e6efe | 883 | 0, NULL, wxCB_DROPDOWN | wxCB_READONLY), |
83efdf33 VS |
884 | 1, wxEXPAND | wxLEFT | wxRIGHT, 10); |
885 | ||
6f67eafe | 886 | sizer -> Add(sizer2, 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10); |
83efdf33 | 887 | |
6f67eafe | 888 | sizer2 = new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Fixed font:")), wxVERTICAL); |
f6bcfd97 BP |
889 | sizer2 -> Add(FixedFont = new wxComboBox(this, -1, wxEmptyString, wxDefaultPosition, |
890 | wxSize(200, 200), | |
891 | 0, NULL, wxCB_DROPDOWN | wxCB_READONLY), | |
83efdf33 VS |
892 | 1, wxEXPAND | wxLEFT | wxRIGHT, 10); |
893 | ||
6f67eafe | 894 | sizer -> Add(sizer2, 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10); |
83efdf33 VS |
895 | |
896 | topsizer -> Add(sizer); | |
897 | ||
f6bcfd97 BP |
898 | topsizer -> Add(RadioBox = new wxRadioBox(this, -1, _("Font size:"), |
899 | wxDefaultPosition, wxDefaultSize, 5, choices, 5), | |
6f67eafe | 900 | 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10); |
f6bcfd97 BP |
901 | |
902 | topsizer -> Add(new wxStaticText(this, -1, _("Preview:")), | |
83efdf33 | 903 | 0, wxLEFT | wxTOP, 10); |
f6bcfd97 | 904 | topsizer -> Add(TestWin = new wxHtmlWindow(this, -1, wxDefaultPosition, wxSize(-1, 150)), |
6f67eafe | 905 | 1, wxEXPAND | wxLEFT|wxTOP|wxRIGHT, 10); |
83efdf33 VS |
906 | |
907 | sizer = new wxBoxSizer(wxHORIZONTAL); | |
908 | sizer -> Add(new wxButton(this, wxID_OK, _("OK")), 0, wxALL, 10); | |
909 | sizer -> Add(new wxButton(this, wxID_CANCEL, _("Cancel")), 0, wxALL, 10); | |
910 | topsizer -> Add(sizer, 0, wxALIGN_RIGHT); | |
911 | ||
912 | SetAutoLayout(TRUE); | |
913 | SetSizer(topsizer); | |
914 | topsizer -> Fit(this); | |
915 | Centre(wxBOTH); | |
916 | } | |
f6bcfd97 | 917 | |
83efdf33 VS |
918 | |
919 | void UpdateTestWin() | |
920 | { | |
921 | wxBusyCursor bcur; | |
f6bcfd97 | 922 | SetFontsToHtmlWin(TestWin, |
8eb2940f VS |
923 | NormalFont -> GetStringSelection(), |
924 | FixedFont -> GetStringSelection(), | |
83efdf33 | 925 | RadioBox -> GetSelection()); |
f6bcfd97 BP |
926 | TestWin -> SetPage(_( |
927 | "<html><body>\ | |
928 | Normal face<br>(and <u>underlined</u>. <i>Italic face.</i> \ | |
929 | <b>Bold face.</b> <b><i>Bold italic face.</i></b><br>\ | |
930 | <font size=-2>font size -2</font><br>\ | |
931 | <font size=-1>font size -1</font><br>\ | |
932 | <font size=+0>font size +0</font><br>\ | |
933 | <font size=+1>font size +1</font><br>\ | |
934 | <font size=+2>font size +2</font><br>\ | |
935 | <font size=+3>font size +3</font><br>\ | |
936 | <font size=+4>font size +4</font><br>\ | |
937 | \ | |
938 | <p><tt>Fixed size face.<br> <b>bold</b> <i>italic</i> \ | |
939 | <b><i>bold italic <u>underlined</u></i></b><br>\ | |
940 | <font size=-2>font size -2</font><br>\ | |
941 | <font size=-1>font size -1</font><br>\ | |
942 | <font size=+0>font size +0</font><br>\ | |
943 | <font size=+1>font size +1</font><br>\ | |
944 | <font size=+2>font size +2</font><br>\ | |
945 | <font size=+3>font size +3</font><br>\ | |
946 | <font size=+4>font size +4</font></tt>\ | |
947 | </body></html>" | |
948 | )); | |
83efdf33 VS |
949 | } |
950 | ||
658fb8e6 | 951 | void OnUpdate(wxCommandEvent& event) |
83efdf33 VS |
952 | { |
953 | UpdateTestWin(); | |
954 | } | |
955 | ||
956 | DECLARE_EVENT_TABLE() | |
957 | }; | |
958 | ||
959 | BEGIN_EVENT_TABLE(wxHtmlHelpFrameOptionsDialog, wxDialog) | |
f151e8b5 | 960 | EVT_COMBOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate) |
83efdf33 | 961 | EVT_RADIOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate) |
83efdf33 VS |
962 | END_EVENT_TABLE() |
963 | ||
964 | ||
965 | void wxHtmlHelpFrame::OptionsDialog() | |
966 | { | |
967 | wxHtmlHelpFrameOptionsDialog dlg(this); | |
968 | unsigned i; | |
f6bcfd97 | 969 | |
83efdf33 VS |
970 | if (m_NormalFonts == NULL) { |
971 | wxFontEnumerator enu; | |
972 | enu.EnumerateFacenames(); | |
973 | m_NormalFonts = new wxArrayString; | |
974 | *m_NormalFonts = *enu.GetFacenames(); | |
975 | m_NormalFonts -> Sort(); | |
976 | } | |
977 | if (m_FixedFonts == NULL) { | |
978 | wxFontEnumerator enu; | |
979 | enu.EnumerateFacenames(wxFONTENCODING_SYSTEM, TRUE); | |
980 | m_FixedFonts = new wxArrayString; | |
981 | *m_FixedFonts = *enu.GetFacenames(); | |
982 | m_FixedFonts -> Sort(); | |
983 | } | |
f6bcfd97 | 984 | |
83efdf33 VS |
985 | for (i = 0; i < m_NormalFonts -> GetCount(); i++) |
986 | dlg.NormalFont -> Append((*m_NormalFonts)[i]); | |
987 | for (i = 0; i < m_FixedFonts -> GetCount(); i++) | |
988 | dlg.FixedFont -> Append((*m_FixedFonts)[i]); | |
989 | if (!m_NormalFace.IsEmpty()) dlg.NormalFont -> SetStringSelection(m_NormalFace); | |
990 | else dlg.NormalFont -> SetSelection(0); | |
991 | if (!m_FixedFace.IsEmpty()) dlg.FixedFont -> SetStringSelection(m_FixedFace); | |
992 | else dlg.FixedFont -> SetSelection(0); | |
993 | dlg.RadioBox -> SetSelection(m_FontSize); | |
83efdf33 | 994 | dlg.UpdateTestWin(); |
f6bcfd97 | 995 | |
83efdf33 VS |
996 | if (dlg.ShowModal() == wxID_OK) { |
997 | m_NormalFace = dlg.NormalFont -> GetStringSelection(); | |
998 | m_FixedFace = dlg.FixedFont -> GetStringSelection(); | |
999 | m_FontSize = dlg.RadioBox -> GetSelection(); | |
8eb2940f | 1000 | SetFontsToHtmlWin(m_HtmlWin, m_NormalFace, m_FixedFace, m_FontSize); |
83efdf33 VS |
1001 | } |
1002 | } | |
1003 | ||
1004 | ||
1005 | ||
0646614d VS |
1006 | void wxHtmlHelpFrame::NotifyPageChanged() |
1007 | { | |
1008 | if (m_UpdateContents && m_PagesHash) | |
1009 | { | |
1010 | wxString an = m_HtmlWin -> GetOpenedAnchor(); | |
1011 | wxHtmlHelpHashData *ha; | |
1012 | if (an.IsEmpty()) | |
1013 | ha = (wxHtmlHelpHashData*) m_PagesHash -> Get(m_HtmlWin -> GetOpenedPage()); | |
1014 | else | |
1015 | ha = (wxHtmlHelpHashData*) m_PagesHash -> Get(m_HtmlWin -> GetOpenedPage() + wxT("#") + an); | |
1016 | if (ha) | |
1017 | { | |
1018 | bool olduc = m_UpdateContents; | |
1019 | m_UpdateContents = FALSE; | |
1020 | m_ContentsBox -> SelectItem(ha -> m_Id); | |
1021 | m_ContentsBox -> EnsureVisible(ha -> m_Id); | |
1022 | m_UpdateContents = olduc; | |
1023 | } | |
1024 | } | |
1025 | } | |
1026 | ||
83efdf33 VS |
1027 | |
1028 | ||
8ec2b484 HH |
1029 | /* |
1030 | EVENT HANDLING : | |
1031 | */ | |
1032 | ||
1033 | ||
1034 | void wxHtmlHelpFrame::OnToolbar(wxCommandEvent& event) | |
1035 | { | |
1036 | switch (event.GetId()) { | |
382e6efe | 1037 | |
8ec2b484 HH |
1038 | case wxID_HTML_BACK : |
1039 | m_HtmlWin -> HistoryBack(); | |
0646614d | 1040 | NotifyPageChanged(); |
8ec2b484 | 1041 | break; |
382e6efe | 1042 | |
8ec2b484 HH |
1043 | case wxID_HTML_FORWARD : |
1044 | m_HtmlWin -> HistoryForward(); | |
0646614d VS |
1045 | NotifyPageChanged(); |
1046 | break; | |
f6bcfd97 BP |
1047 | |
1048 | case wxID_HTML_UP : | |
1049 | if (m_PagesHash) | |
0646614d VS |
1050 | { |
1051 | wxString an = m_HtmlWin -> GetOpenedAnchor(); | |
1052 | wxHtmlHelpHashData *ha; | |
1053 | if (an.IsEmpty()) | |
1054 | ha = (wxHtmlHelpHashData*) m_PagesHash -> Get(m_HtmlWin -> GetOpenedPage()); | |
1055 | else | |
1056 | ha = (wxHtmlHelpHashData*) m_PagesHash -> Get(m_HtmlWin -> GetOpenedPage() + wxT("#") + an); | |
1057 | if (ha && ha -> m_Index > 0) | |
1058 | { | |
1059 | wxHtmlContentsItem *it = m_Data -> GetContents() + (ha -> m_Index - 1); | |
1060 | m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page); | |
1061 | NotifyPageChanged(); | |
1062 | } | |
1063 | } | |
1064 | break; | |
1065 | ||
f6bcfd97 BP |
1066 | case wxID_HTML_UPNODE : |
1067 | if (m_PagesHash) | |
0646614d VS |
1068 | { |
1069 | wxString an = m_HtmlWin -> GetOpenedAnchor(); | |
1070 | wxHtmlHelpHashData *ha; | |
1071 | if (an.IsEmpty()) | |
1072 | ha = (wxHtmlHelpHashData*) m_PagesHash -> Get(m_HtmlWin -> GetOpenedPage()); | |
1073 | else | |
1074 | ha = (wxHtmlHelpHashData*) m_PagesHash -> Get(m_HtmlWin -> GetOpenedPage() + wxT("#") + an); | |
1075 | if (ha && ha -> m_Index > 0) | |
1076 | { | |
1077 | int level = m_Data -> GetContents()[ha -> m_Index].m_Level - 1; | |
1078 | wxHtmlContentsItem *it; | |
1079 | int ind = ha -> m_Index - 1; | |
f6bcfd97 | 1080 | |
0646614d VS |
1081 | it = m_Data -> GetContents() + ind; |
1082 | while (ind >= 0 && it -> m_Level != level) ind--, it--; | |
1083 | if (ind >= 0) | |
1084 | { | |
1085 | m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page); | |
1086 | NotifyPageChanged(); | |
1087 | } | |
1088 | } | |
1089 | } | |
1090 | break; | |
1091 | ||
f6bcfd97 BP |
1092 | case wxID_HTML_DOWN : |
1093 | if (m_PagesHash) | |
0646614d VS |
1094 | { |
1095 | wxString an = m_HtmlWin -> GetOpenedAnchor(); | |
721ab905 | 1096 | wxString adr; |
0646614d | 1097 | wxHtmlHelpHashData *ha; |
f6bcfd97 | 1098 | |
721ab905 VS |
1099 | if (an.IsEmpty()) adr = m_HtmlWin -> GetOpenedPage(); |
1100 | else adr = m_HtmlWin -> GetOpenedPage() + wxT("#") + an; | |
1101 | ||
1102 | ha = (wxHtmlHelpHashData*) m_PagesHash -> Get(adr); | |
0646614d VS |
1103 | |
1104 | if (ha && ha -> m_Index < m_Data -> GetContentsCnt() - 1) | |
1105 | { | |
1106 | wxHtmlContentsItem *it = m_Data -> GetContents() + (ha -> m_Index + 1); | |
f6bcfd97 | 1107 | |
721ab905 | 1108 | while (it -> m_Book -> GetBasePath() + it -> m_Page == adr) it++; |
0646614d VS |
1109 | m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page); |
1110 | NotifyPageChanged(); | |
1111 | } | |
1112 | } | |
8ec2b484 | 1113 | break; |
382e6efe | 1114 | |
8ec2b484 | 1115 | case wxID_HTML_PANEL : |
0646614d VS |
1116 | { |
1117 | if (! (m_Splitter && m_NavigPan)) | |
1118 | return ; | |
1119 | if (m_Splitter -> IsSplit()) { | |
1120 | m_Cfg.sashpos = m_Splitter -> GetSashPosition(); | |
1121 | m_Splitter -> Unsplit(m_NavigPan); | |
1122 | m_Cfg.navig_on = FALSE; | |
1123 | } else { | |
1124 | m_NavigPan -> Show(TRUE); | |
1125 | m_HtmlWin -> Show(TRUE); | |
1126 | m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); | |
1127 | m_Cfg.navig_on = TRUE; | |
1128 | } | |
8ec2b484 HH |
1129 | } |
1130 | break; | |
382e6efe | 1131 | |
83efdf33 VS |
1132 | case wxID_HTML_OPTIONS : |
1133 | OptionsDialog(); | |
1134 | break; | |
f6bcfd97 BP |
1135 | |
1136 | case wxID_HTML_BOOKMARKSADD : | |
382e6efe VS |
1137 | { |
1138 | wxString item; | |
1139 | wxString url; | |
f6bcfd97 | 1140 | |
382e6efe VS |
1141 | item = m_HtmlWin -> GetOpenedPageTitle(); |
1142 | url = m_HtmlWin -> GetOpenedPage(); | |
1143 | if (item == wxEmptyString) item = url.AfterLast(wxT('/')); | |
1144 | if (m_BookmarksPages.Index(url) == wxNOT_FOUND) { | |
1145 | m_Bookmarks -> Append(item); | |
1146 | m_BookmarksNames.Add(item); | |
1147 | m_BookmarksPages.Add(url); | |
1148 | } | |
1149 | } | |
1150 | break; | |
f6bcfd97 BP |
1151 | |
1152 | case wxID_HTML_BOOKMARKSREMOVE : | |
382e6efe VS |
1153 | { |
1154 | wxString item; | |
1155 | int pos; | |
f6bcfd97 | 1156 | |
382e6efe VS |
1157 | item = m_Bookmarks -> GetStringSelection(); |
1158 | pos = m_BookmarksNames.Index(item); | |
1159 | if (pos != wxNOT_FOUND) { | |
1160 | m_BookmarksNames.Remove(pos); | |
1161 | m_BookmarksPages.Remove(pos); | |
1162 | m_Bookmarks -> Delete(m_Bookmarks -> GetSelection()); | |
1163 | } | |
1164 | } | |
1165 | break; | |
0646614d VS |
1166 | |
1167 | #if wxUSE_PRINTING_ARCHITECTURE | |
1168 | case wxID_HTML_PRINT : | |
1169 | { | |
f6bcfd97 | 1170 | if (m_Printer == NULL) |
0646614d | 1171 | m_Printer = new wxHtmlEasyPrinting(_("Help Printing"), this); |
f5ba273e VS |
1172 | if (!m_HtmlWin -> GetOpenedPage()) |
1173 | wxLogWarning(_("Cannot print empty page.")); | |
1174 | else | |
1175 | m_Printer -> PrintFile(m_HtmlWin -> GetOpenedPage()); | |
0646614d VS |
1176 | } |
1177 | break; | |
1178 | #endif | |
1179 | ||
1180 | case wxID_HTML_OPENFILE : | |
1181 | { | |
f6bcfd97 BP |
1182 | wxString s = wxFileSelector(_("Open HTML document"), |
1183 | wxEmptyString, | |
1184 | wxEmptyString, | |
1185 | wxEmptyString, | |
1186 | _( | |
1187 | "HTML files (*.htm)|*.htm|HTML files (*.html)|*.html|\ | |
1188 | Help books (*.htb)|*.htb|Help books (*.zip)|*.zip|\ | |
1189 | HTML Help Project (*.hhp)|*.hhp|\ | |
1190 | All files (*.*)|*" | |
1191 | ), | |
1192 | wxOPEN | wxFILE_MUST_EXIST, | |
1193 | this); | |
0646614d VS |
1194 | if (!s.IsEmpty()) |
1195 | { | |
1196 | wxString ext = s.Right(4).Lower(); | |
1197 | if (ext == _T(".zip") || ext == _T(".htb") || ext == _T(".hhp")) | |
1198 | { | |
1199 | wxBusyCursor bcur; | |
1200 | m_Data -> AddBook(s); | |
1201 | RefreshLists(); | |
1202 | } | |
1203 | else | |
1204 | m_HtmlWin -> LoadPage(s); | |
1205 | } | |
1206 | } | |
1207 | break; | |
8ec2b484 HH |
1208 | } |
1209 | } | |
1210 | ||
1211 | ||
1212 | ||
1213 | void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent& event) | |
1214 | { | |
1215 | wxHtmlHelpTreeItemData *pg; | |
0646614d | 1216 | wxHtmlContentsItem *it; |
8ec2b484 HH |
1217 | |
1218 | pg = (wxHtmlHelpTreeItemData*) m_ContentsBox -> GetItemData(event.GetItem()); | |
f6bcfd97 BP |
1219 | |
1220 | if (pg && m_UpdateContents) | |
0646614d VS |
1221 | { |
1222 | it = m_Data -> GetContents() + (pg -> m_Id); | |
1223 | m_UpdateContents = FALSE; | |
1224 | m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page); | |
1225 | m_UpdateContents = TRUE; | |
1226 | } | |
8ec2b484 HH |
1227 | } |
1228 | ||
1229 | ||
1230 | ||
a4c97004 | 1231 | void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent& WXUNUSED(event)) |
8ec2b484 | 1232 | { |
f0b6a33f | 1233 | wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_IndexList -> GetClientData(m_IndexList -> GetSelection()); |
c32bfc10 | 1234 | m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page); |
0646614d | 1235 | NotifyPageChanged(); |
8ec2b484 HH |
1236 | } |
1237 | ||
1238 | ||
f0b6a33f VS |
1239 | void wxHtmlHelpFrame::OnIndexFind(wxCommandEvent& event) |
1240 | { | |
1241 | wxString sr = m_IndexText -> GetLineText(0); | |
240c2873 | 1242 | sr.MakeLower(); |
f6bcfd97 | 1243 | if (sr == wxEmptyString) |
f0b6a33f VS |
1244 | OnIndexAll(event); |
1245 | ||
1246 | else { | |
1247 | wxBusyCursor bcur; | |
1248 | const wxChar *cstr = sr.c_str(); | |
240c2873 | 1249 | wxChar mybuff[512], *ptr; |
f0b6a33f | 1250 | bool first = TRUE; |
f6bcfd97 | 1251 | |
f0b6a33f VS |
1252 | m_IndexList->Clear(); |
1253 | int cnt = m_Data->GetIndexCnt(); | |
1254 | wxHtmlContentsItem* index = m_Data->GetIndex(); | |
1255 | ||
240c2873 | 1256 | int displ = 0; |
f0b6a33f | 1257 | for (int i = 0; i < cnt; i++) |
240c2873 VS |
1258 | { |
1259 | wxStrncpy(mybuff, index[i].m_Name, 512); | |
f6bcfd97 BP |
1260 | mybuff[511] = _T('\0'); |
1261 | for (ptr = mybuff; *ptr != 0; ptr++) | |
1262 | if (*ptr >= _T('A') && *ptr <= _T('Z')) | |
1263 | *ptr -= (wxChar)(_T('A') - _T('a')); | |
240c2873 | 1264 | if (wxStrstr(mybuff, cstr) != NULL) { |
f0b6a33f | 1265 | m_IndexList -> Append(index[i].m_Name, (char*)(index + i)); |
240c2873 | 1266 | displ++; |
f0b6a33f VS |
1267 | if (first) { |
1268 | m_HtmlWin -> LoadPage(index[i].m_Book -> GetBasePath() + index[i].m_Page); | |
0646614d | 1269 | NotifyPageChanged(); |
f0b6a33f VS |
1270 | first = FALSE; |
1271 | } | |
1272 | } | |
240c2873 VS |
1273 | } |
1274 | ||
1275 | wxString cnttext; | |
1276 | cnttext.Printf(_("%i of %i"), displ, cnt); | |
1277 | m_IndexCountInfo -> SetLabel(cnttext); | |
f0b6a33f VS |
1278 | |
1279 | m_IndexText -> SetSelection(0, sr.Length()); | |
1280 | m_IndexText -> SetFocus(); | |
1281 | } | |
1282 | } | |
1283 | ||
1284 | void wxHtmlHelpFrame::OnIndexAll(wxCommandEvent& WXUNUSED(event)) | |
1285 | { | |
1286 | wxBusyCursor bcur; | |
f6bcfd97 | 1287 | |
f0b6a33f VS |
1288 | m_IndexList->Clear(); |
1289 | int cnt = m_Data->GetIndexCnt(); | |
1290 | bool first = TRUE; | |
1291 | wxHtmlContentsItem* index = m_Data->GetIndex(); | |
1292 | ||
1293 | for (int i = 0; i < cnt; i++) { | |
1294 | m_IndexList -> Append(index[i].m_Name, (char*)(index + i)); | |
1295 | if (first) { | |
1296 | m_HtmlWin -> LoadPage(index[i].m_Book -> GetBasePath() + index[i].m_Page); | |
0646614d | 1297 | NotifyPageChanged(); |
f0b6a33f VS |
1298 | first = FALSE; |
1299 | } | |
1300 | } | |
240c2873 VS |
1301 | |
1302 | wxString cnttext; | |
1303 | cnttext.Printf(_("%i of %i"), cnt, cnt); | |
1304 | m_IndexCountInfo -> SetLabel(cnttext); | |
f0b6a33f VS |
1305 | } |
1306 | ||
8ec2b484 | 1307 | |
a4c97004 | 1308 | void wxHtmlHelpFrame::OnSearchSel(wxCommandEvent& WXUNUSED(event)) |
8ec2b484 HH |
1309 | { |
1310 | wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_SearchList -> GetClientData(m_SearchList -> GetSelection()); | |
f6bcfd97 | 1311 | if (it) |
0646614d VS |
1312 | { |
1313 | m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page); | |
1314 | NotifyPageChanged(); | |
1315 | } | |
8ec2b484 HH |
1316 | } |
1317 | ||
a4c97004 | 1318 | void wxHtmlHelpFrame::OnSearch(wxCommandEvent& WXUNUSED(event)) |
8ec2b484 HH |
1319 | { |
1320 | wxString sr = m_SearchText -> GetLineText(0); | |
1321 | ||
1322 | if (sr != wxEmptyString) KeywordSearch(sr); | |
1323 | } | |
1324 | ||
382e6efe VS |
1325 | void wxHtmlHelpFrame::OnBookmarksSel(wxCommandEvent& WXUNUSED(event)) |
1326 | { | |
1327 | wxString sr = m_Bookmarks -> GetStringSelection(); | |
1328 | ||
ae80f837 | 1329 | if (sr != wxEmptyString && sr != _("(bookmarks)")) |
0646614d VS |
1330 | { |
1331 | m_HtmlWin -> LoadPage(m_BookmarksPages[m_BookmarksNames.Index(sr)]); | |
1332 | NotifyPageChanged(); | |
1333 | } | |
382e6efe VS |
1334 | } |
1335 | ||
8ec2b484 HH |
1336 | void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent& evt) |
1337 | { | |
68364659 VS |
1338 | GetSize(&m_Cfg.w, &m_Cfg.h); |
1339 | GetPosition(&m_Cfg.x, &m_Cfg.y); | |
5c172c17 | 1340 | |
68364659 VS |
1341 | if (m_Splitter && m_Cfg.navig_on) m_Cfg.sashpos = m_Splitter -> GetSashPosition(); |
1342 | ||
d5bb85a0 VS |
1343 | if (m_Config) |
1344 | WriteCustomization(m_Config, m_ConfigRoot); | |
68364659 | 1345 | |
b4414c1f JS |
1346 | if (m_helpController && m_helpController->IsKindOf(CLASSINFO(wxHtmlHelpController))) |
1347 | { | |
1348 | ((wxHtmlHelpController*) m_helpController)->OnCloseFrame(evt); | |
1349 | } | |
1350 | ||
8ec2b484 HH |
1351 | evt.Skip(); |
1352 | } | |
1353 | ||
1354 | BEGIN_EVENT_TABLE(wxHtmlHelpFrame, wxFrame) | |
ae80f837 VS |
1355 | EVT_TOOL_RANGE(wxID_HTML_PANEL, wxID_HTML_OPTIONS, wxHtmlHelpFrame::OnToolbar) |
1356 | EVT_BUTTON(wxID_HTML_BOOKMARKSREMOVE, wxHtmlHelpFrame::OnToolbar) | |
1357 | EVT_BUTTON(wxID_HTML_BOOKMARKSADD, wxHtmlHelpFrame::OnToolbar) | |
8ec2b484 HH |
1358 | EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL, wxHtmlHelpFrame::OnContentsSel) |
1359 | EVT_LISTBOX(wxID_HTML_INDEXLIST, wxHtmlHelpFrame::OnIndexSel) | |
1360 | EVT_LISTBOX(wxID_HTML_SEARCHLIST, wxHtmlHelpFrame::OnSearchSel) | |
1361 | EVT_BUTTON(wxID_HTML_SEARCHBUTTON, wxHtmlHelpFrame::OnSearch) | |
1362 | EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT, wxHtmlHelpFrame::OnSearch) | |
f0b6a33f VS |
1363 | EVT_BUTTON(wxID_HTML_INDEXBUTTON, wxHtmlHelpFrame::OnIndexFind) |
1364 | EVT_TEXT_ENTER(wxID_HTML_INDEXTEXT, wxHtmlHelpFrame::OnIndexFind) | |
1365 | EVT_BUTTON(wxID_HTML_INDEXBUTTONALL, wxHtmlHelpFrame::OnIndexAll) | |
382e6efe | 1366 | EVT_COMBOBOX(wxID_HTML_BOOKMARKSLIST, wxHtmlHelpFrame::OnBookmarksSel) |
f6bcfd97 | 1367 | EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow) |
8ec2b484 HH |
1368 | END_EVENT_TABLE() |
1369 | ||
1370 | #endif |