]> git.saurik.com Git - wxWidgets.git/blob - src/html/helpfrm.cpp
more wxHtmlHelpFrame fixes (didn't store customization correctly, still needs some...
[wxWidgets.git] / src / html / helpfrm.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: helpfrm.cpp
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 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #include "wx/defs.h"
24
25 #if wxUSE_HTML
26
27 #ifndef WXPRECOMP
28 #include <wx/wx.h>
29 #endif
30
31 #include "wx/html/helpfrm.h"
32 #include "wx/notebook.h"
33 #include "wx/imaglist.h"
34 #include "wx/treectrl.h"
35 #include "wx/tokenzr.h"
36 #include "wx/wfstream.h"
37 #include "wx/html/htmlwin.h"
38 #include "wx/busyinfo.h"
39 #include "wx/progdlg.h"
40 #include "wx/toolbar.h"
41
42 // Bitmaps:
43
44 #ifndef __WXMSW__
45 #include "bitmaps/panel.xpm"
46 #include "bitmaps/back.xpm"
47 #include "bitmaps/forward.xpm"
48 #include "bitmaps/book.xpm"
49 #include "bitmaps/folder.xpm"
50 #include "bitmaps/page.xpm"
51 #endif
52
53 #include "wx/stream.h"
54
55 // number of times that the contents/index creation progress dialog
56 // is updated.
57 #define PROGRESS_STEP 40
58
59 //--------------------------------------------------------------------------
60 // wxHtmlHelpTreeItemData
61 //--------------------------------------------------------------------------
62
63 class wxHtmlHelpTreeItemData : public wxTreeItemData
64 {
65 private:
66 wxString m_Page;
67
68 public:
69 wxHtmlHelpTreeItemData(wxHtmlContentsItem *it) : wxTreeItemData()
70 {
71 m_Page = it -> m_Book -> GetBasePath() + it -> m_Page;
72 }
73 const wxString& GetPage() { return m_Page; }
74 };
75
76 //---------------------------------------------------------------------------
77 // wxHtmlHelpFrame
78 //---------------------------------------------------------------------------
79
80 IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpFrame, wxFrame)
81
82 wxHtmlHelpFrame::wxHtmlHelpFrame(wxWindow* parent, wxWindowID id, const wxString& title,
83 int style, wxHtmlHelpData* data)
84 {
85 Init(data);
86 Create(parent, id, title, style);
87 }
88
89 void wxHtmlHelpFrame::Init(wxHtmlHelpData* data)
90 {
91 if (data) {
92 m_Data = data;
93 m_DataCreated = FALSE;
94 } else {
95 m_Data = new wxHtmlHelpData();
96 m_DataCreated = TRUE;
97 }
98
99 m_ContentsImageList = new wxImageList(16, 16);
100 m_ContentsImageList -> Add(wxICON(book));
101 m_ContentsImageList -> Add(wxICON(folder));
102 m_ContentsImageList -> Add(wxICON(page));
103
104 m_ContentsBox = NULL;
105 m_IndexBox = NULL;
106 m_SearchList = NULL;
107 m_SearchButton = NULL;
108 m_SearchText = NULL;
109 m_SearchChoice = NULL;
110 m_Splitter = NULL;
111 m_NavigPan = NULL;
112 m_HtmlWin = NULL;
113 m_Config = NULL;
114 m_ConfigRoot = wxEmptyString;
115
116 m_Cfg.x = m_Cfg.y = 0;
117 m_Cfg.w = 700;
118 m_Cfg.h = 480;
119 m_Cfg.sashpos = 240;
120 m_Cfg.navig_on = TRUE;
121 }
122
123 // Create: builds the GUI components.
124 // with the style flag it's possible to toggle the toolbar, contents, index and search
125 // controls.
126 // m_HtmlWin will *always* be created, but it's important to realize that
127 // m_ContentsBox, m_IndexBox, m_SearchList, m_SearchButton, m_SearchText and
128 // m_SearchButton may be NULL.
129 // moreover, if no contents, index or searchpage is needed, m_Splitter and
130 // m_NavigPan will be NULL too (with m_HtmlWin directly connected to the frame)
131
132 bool wxHtmlHelpFrame::Create(wxWindow* parent, wxWindowID id, const wxString& title,
133 int style)
134 {
135 // Do the config in two steps. We read the HtmlWindow customization after we
136 // create the window.
137 if (m_Config)
138 ReadCustomization(m_Config, m_ConfigRoot);
139
140 wxFrame::Create(parent, id, _("Help"), wxPoint(m_Cfg.x, m_Cfg.y), wxSize(m_Cfg.w, m_Cfg.h));
141
142 int notebook_page = 0;
143
144 CreateStatusBar();
145
146 // toolbar?
147 if (style & wxHF_TOOLBAR) {
148 wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | /*wxTB_FLAT | */
149 wxTB_DOCKABLE);
150 toolBar -> SetMargins(2, 2);
151 wxBitmap* toolBarBitmaps[3];
152
153 #ifdef __WXMSW__
154 toolBarBitmaps[0] = new wxBitmap("panel");
155 toolBarBitmaps[1] = new wxBitmap("back");
156 toolBarBitmaps[2] = new wxBitmap("forward");
157 int width = 24;
158 #else
159 toolBarBitmaps[0] = new wxBitmap(panel_xpm);
160 toolBarBitmaps[1] = new wxBitmap(back_xpm);
161 toolBarBitmaps[2] = new wxBitmap(forward_xpm);
162 int width = 16;
163 #endif
164
165 int currentX = 5;
166
167 toolBar -> AddTool(wxID_HTML_PANEL, *(toolBarBitmaps[0]), wxNullBitmap,
168 FALSE, currentX, -1, (wxObject *) NULL,
169 _("Show/hide navigation panel"));
170 currentX += width + 5;
171 toolBar -> AddSeparator();
172 toolBar -> AddTool(wxID_HTML_BACK, *(toolBarBitmaps[1]), wxNullBitmap,
173 FALSE, currentX, -1, (wxObject *) NULL,
174 _("Go back to the previous HTML page"));
175 currentX += width + 5;
176 toolBar -> AddTool(wxID_HTML_FORWARD, *(toolBarBitmaps[2]), wxNullBitmap,
177 FALSE, currentX, -1, (wxObject *) NULL,
178 _("Go forward to the next HTML page"));
179 currentX += width + 5;
180
181 toolBar -> Realize();
182
183 // Can delete the bitmaps since they're reference counted
184 for (int i = 0; i < 3; i++)
185 delete toolBarBitmaps[i];
186 }
187
188 if (style & (wxHF_CONTENTS | wxHF_INDEX | wxHF_SEARCH)) {
189 // traditional help controller; splitter window with html page on the
190 // right and a notebook containing various pages on the left
191 m_Splitter = new wxSplitterWindow(this);
192
193 m_HtmlWin = new wxHtmlWindow(m_Splitter);
194 m_NavigPan = new wxNotebook(m_Splitter, wxID_HTML_NOTEBOOK,
195 wxDefaultPosition, wxDefaultSize);
196 } else { // only html window, no notebook with index,contents etc
197 m_HtmlWin = new wxHtmlWindow(this);
198 }
199
200 m_HtmlWin -> SetRelatedFrame(this, m_TitleFormat);
201 m_HtmlWin -> SetRelatedStatusBar(0);
202 if (m_Config)
203 m_HtmlWin -> ReadCustomization(m_Config, m_ConfigRoot);
204
205 // contents tree panel?
206 if (style & wxHF_CONTENTS) {
207 m_ContentsBox = new wxTreeCtrl(m_NavigPan, wxID_HTML_TREECTRL,
208 wxDefaultPosition, wxDefaultSize,
209 wxTR_HAS_BUTTONS | wxSUNKEN_BORDER);
210 m_ContentsBox -> SetImageList(m_ContentsImageList);
211 m_NavigPan -> AddPage(m_ContentsBox, _("Contents"));
212 m_ContentsPage = notebook_page++;
213 }
214
215 // index listbox panel?
216 if (style & wxHF_INDEX) {
217 wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_INDEXPAGE);
218 wxLayoutConstraints *b1 = new wxLayoutConstraints;
219 b1 -> top.SameAs (dummy, wxTop, 0);
220 b1 -> left.SameAs (dummy, wxLeft, 0);
221 b1 -> width.PercentOf (dummy, wxWidth, 100);
222 b1 -> bottom.SameAs (dummy, wxBottom, 0);
223 m_IndexBox = new wxListBox(dummy, wxID_HTML_INDEXLIST, wxDefaultPosition,
224 wxDefaultSize, 0, NULL, wxLB_SINGLE | wxLB_ALWAYS_SB);
225 m_IndexBox -> SetConstraints(b1);
226 dummy -> SetAutoLayout(TRUE);
227 m_NavigPan -> AddPage(dummy, _("Index"));
228 m_IndexPage = notebook_page++;
229 }
230
231 // search list panel?
232 if (style & wxHF_SEARCH) {
233 wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_SEARCHPAGE);
234
235 wxLayoutConstraints *b1 = new wxLayoutConstraints;
236 m_SearchText = new wxTextCtrl(dummy, wxID_HTML_SEARCHTEXT);
237 b1 -> top.SameAs (dummy, wxTop, 10);
238 b1 -> left.SameAs (dummy, wxLeft, 10);
239 b1 -> right.SameAs (dummy, wxRight, 10);
240 b1 -> height.AsIs();
241 m_SearchText -> SetConstraints(b1);
242
243 wxLayoutConstraints *b2 = new wxLayoutConstraints;
244 m_SearchButton = new wxButton(dummy, wxID_HTML_SEARCHBUTTON, _("Search"));
245 b2 -> top.Below (m_SearchText, 10);
246 b2 -> left.SameAs (dummy, wxLeft, 10);
247 b2 -> width.AsIs();
248 b2 -> height.AsIs();
249 m_SearchButton -> SetConstraints(b2);
250
251 wxLayoutConstraints *b3 = new wxLayoutConstraints;
252 m_SearchList = new wxListBox(dummy, wxID_HTML_SEARCHLIST, wxDefaultPosition, wxDefaultSize, 0);
253 b3 -> top.Below (m_SearchButton, 10);
254 b3 -> left.SameAs (dummy, wxLeft, 0);
255 b3 -> right.SameAs (dummy, wxRight, 0);
256 b3 -> bottom.SameAs (dummy, wxBottom, 0);
257 m_SearchList -> SetConstraints(b3);
258
259 wxLayoutConstraints *b4 = new wxLayoutConstraints;
260 m_SearchChoice = new wxChoice(dummy, wxID_HTML_SEARCHCHOICE, wxDefaultPosition,
261 wxDefaultSize);
262 b4 -> top.Below (m_SearchText, 10);
263 b4 -> left.SameAs (m_SearchButton, wxRight, 10);
264 b4 -> right.SameAs (dummy, wxRight, 10);
265 b4 -> height.AsIs();
266 m_SearchChoice -> SetConstraints(b4);
267
268 dummy -> SetAutoLayout(TRUE);
269 dummy -> Layout();
270 m_NavigPan -> AddPage(dummy, _("Search"));
271 m_SearchPage = notebook_page++;
272 }
273
274 //RefreshLists();
275
276 // showtime
277 if (m_NavigPan && m_Splitter) {
278 m_NavigPan -> Show(TRUE);
279 m_Splitter -> SetMinimumPaneSize(20);
280 if (m_Cfg.navig_on)
281 m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
282 else {
283 m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
284 m_Splitter -> Unsplit();
285 }
286 }
287 m_HtmlWin -> Show(TRUE);
288 return TRUE;
289 }
290
291 wxHtmlHelpFrame::~wxHtmlHelpFrame()
292 {
293 delete m_ContentsImageList;
294 if (m_DataCreated)
295 delete m_Data;
296 }
297
298 bool wxHtmlHelpFrame::Display(const wxString& x)
299 {
300 wxString url = m_Data->FindPageByName(x);
301 if (! url.IsEmpty()) {
302 m_HtmlWin->LoadPage(url);
303 return TRUE;
304 }
305 return FALSE;
306 }
307
308 bool wxHtmlHelpFrame::Display(const int id)
309 {
310 wxString url = m_Data->FindPageById(id);
311 if (! url.IsEmpty()) {
312 m_HtmlWin->LoadPage(url);
313 return TRUE;
314 }
315 return FALSE;
316 }
317
318
319
320 bool wxHtmlHelpFrame::DisplayContents()
321 {
322 if (! m_ContentsBox)
323 return FALSE;
324 if (!m_Splitter -> IsSplit()) {
325 m_NavigPan -> Show(TRUE);
326 m_HtmlWin -> Show(TRUE);
327 m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
328 }
329 m_NavigPan -> SetSelection(0);
330 return TRUE;
331 }
332
333
334
335 bool wxHtmlHelpFrame::DisplayIndex()
336 {
337 if (! m_IndexBox)
338 return FALSE;
339 if (!m_Splitter -> IsSplit()) {
340 m_NavigPan -> Show(TRUE);
341 m_HtmlWin -> Show(TRUE);
342 m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
343 }
344 m_NavigPan -> SetSelection(1);
345 return TRUE;
346 }
347
348 bool wxHtmlHelpFrame::KeywordSearch(const wxString& keyword)
349 {
350 if (! (m_SearchList && m_SearchButton && m_SearchText && m_SearchChoice))
351 return FALSE;
352
353 int foundcnt = 0;
354 wxString foundstr;
355 wxString book = wxEmptyString;
356
357 if (!m_Splitter -> IsSplit()) {
358 m_NavigPan -> Show(TRUE);
359 m_HtmlWin -> Show(TRUE);
360 m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
361 }
362 m_NavigPan -> SetSelection(m_SearchPage);
363 m_SearchList -> Clear();
364 m_SearchText -> SetValue(keyword);
365 m_SearchButton -> Enable(FALSE);
366
367 if (m_SearchChoice->GetSelection() != 0)
368 book = m_SearchChoice->GetStringSelection();
369
370 wxHtmlSearchStatus status(m_Data, keyword, book);
371
372 wxProgressDialog progress(_("Searching..."), _("No matching page found yet"),
373 status.GetMaxIndex(), this,
374 wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_AUTO_HIDE);
375
376 while (status.IsActive()) {
377 if (progress.Update(status.GetCurIndex()) == FALSE)
378 break;
379 if (status.Search()) {
380 foundstr.Printf(_("Found %i matches"), ++foundcnt);
381 progress.Update(status.GetCurIndex(), foundstr);
382 m_SearchList -> Append(status.GetName(), status.GetContentsItem());
383 }
384 wxYield();
385 }
386
387 m_SearchButton -> Enable(TRUE);
388 m_SearchText -> SetSelection(0, keyword.Length());
389 m_SearchText -> SetFocus();
390 if (foundcnt) {
391 wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_SearchList -> GetClientData(0);
392 if (it) m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page);
393 }
394 return (foundcnt > 0);
395 }
396
397 #define MAX_ROOTS 64
398
399 void wxHtmlHelpFrame::CreateContents(bool show_progress)
400 {
401 if (! m_ContentsBox)
402 return ;
403
404 wxProgressDialog *progress;
405 wxString proginfo;
406
407 m_ContentsBox->Clear();
408
409 int cnt = m_Data->GetContentsCnt();
410 int div = (cnt / PROGRESS_STEP) + 1;
411 int i;
412
413 wxHtmlContentsItem *it = m_Data->GetContents();
414
415 if (show_progress)
416 progress = new wxProgressDialog(_("Building contents tree..."), wxEmptyString,
417 cnt, this, wxPD_APP_MODAL | wxPD_CAN_ABORT |
418 wxPD_AUTO_HIDE);
419
420 wxTreeItemId roots[MAX_ROOTS];
421 bool imaged[MAX_ROOTS];
422
423 m_ContentsBox -> DeleteAllItems();
424 roots[0] = m_ContentsBox -> AddRoot(_("(Help)"));
425 imaged[0] = TRUE;
426
427 for (i = 0; i < cnt; i++, it++) {
428 if (show_progress && ((i % div) == 0)) {
429 proginfo.Printf(_("Added %d/%d items"), i, cnt);
430 if (! progress->Update(i, proginfo))
431 break;
432 wxYield();
433 }
434 roots[it -> m_Level + 1] = m_ContentsBox -> AppendItem(
435 roots[it -> m_Level], it -> m_Name, IMG_Page, -1,
436 new wxHtmlHelpTreeItemData(it));
437
438 if (it -> m_Level == 0) {
439 m_ContentsBox -> SetItemBold(roots[1], TRUE);
440 m_ContentsBox -> SetItemImage(roots[1], IMG_Book);
441 m_ContentsBox -> SetItemSelectedImage(roots[1], IMG_Book);
442 imaged[1] = TRUE;
443 } else imaged[it -> m_Level + 1] = FALSE;
444
445 if (!imaged[it -> m_Level]) {
446 m_ContentsBox -> SetItemImage(roots[it -> m_Level], IMG_Folder);
447 m_ContentsBox -> SetItemSelectedImage(roots[it -> m_Level], IMG_Folder);
448 imaged[it -> m_Level] = TRUE;
449 }
450 }
451 if (show_progress)
452 delete progress;
453 m_ContentsBox -> Expand(roots[0]);
454 }
455
456
457 void wxHtmlHelpFrame::CreateIndex(bool show_progress)
458 {
459 if (! m_IndexBox)
460 return ;
461
462 wxProgressDialog *progress;
463 wxString proginfo;
464
465 m_IndexBox->Clear();
466
467 int cnt = m_Data->GetIndexCnt();
468 int div = (cnt / PROGRESS_STEP) + 1;
469
470 wxHtmlContentsItem* index = m_Data->GetIndex();
471
472 if (show_progress)
473 progress = new wxProgressDialog(_("Building index list..."), wxEmptyString,
474 cnt, this, wxPD_APP_MODAL | wxPD_CAN_ABORT |
475 wxPD_AUTO_HIDE);
476 for (int i = 0; i < cnt; i++) {
477 if (show_progress && ((i % div) == 0)) {
478 proginfo.Printf(_("Added %d/%d items"), i, cnt);
479 if (! progress->Update(i, proginfo))
480 break;
481 wxYield();
482 }
483 m_IndexBox -> Append(index[i].m_Name, (char*)(index + i));
484 }
485
486 if (show_progress)
487 delete progress;
488 }
489
490 void wxHtmlHelpFrame::CreateSearch()
491 {
492 if (! (m_SearchList && m_SearchChoice))
493 return ;
494 m_SearchList -> Clear();
495 m_SearchChoice -> Clear();
496 m_SearchChoice -> Append(_("all books"));
497 const wxHtmlBookRecArray& bookrec = m_Data->GetBookRecArray();
498 int i, cnt = bookrec.GetCount();
499 for (i = 0; i < cnt; i++)
500 m_SearchChoice->Append(bookrec[i].GetTitle());
501 m_SearchChoice->SetSelection(0);
502 }
503
504
505 void wxHtmlHelpFrame::RefreshLists(bool show_progress)
506 {
507 CreateContents(show_progress);
508 CreateIndex(show_progress);
509 CreateSearch();
510 }
511
512 void wxHtmlHelpFrame::ReadCustomization(wxConfigBase *cfg, const wxString& path)
513 {
514 wxString oldpath;
515 wxString tmp;
516
517 if (path != wxEmptyString) {
518 oldpath = cfg -> GetPath();
519 cfg -> SetPath(path);
520 }
521
522 m_Cfg.navig_on = cfg -> Read("hcNavigPanel", m_Cfg.navig_on) != 0;
523 m_Cfg.sashpos = cfg -> Read("hcSashPos", m_Cfg.sashpos);
524 m_Cfg.x = cfg -> Read("hcX", m_Cfg.x);
525 m_Cfg.y = cfg -> Read("hcY", m_Cfg.y);
526 m_Cfg.w = cfg -> Read("hcW", m_Cfg.w);
527 m_Cfg.h = cfg -> Read("hcH", m_Cfg.h);
528
529 if (m_HtmlWin)
530 m_HtmlWin->ReadCustomization(cfg, path);
531
532 if (path != wxEmptyString)
533 cfg -> SetPath(oldpath);
534 }
535
536 void wxHtmlHelpFrame::WriteCustomization(wxConfigBase *cfg, const wxString& path)
537 {
538 wxString oldpath;
539 wxString tmp;
540
541 if (path != wxEmptyString) {
542 oldpath = cfg -> GetPath();
543 cfg -> SetPath(path);
544 }
545
546 cfg -> Write("hcNavigPanel", m_Cfg.navig_on);
547 cfg -> Write("hcSashPos", (long)m_Cfg.sashpos);
548 cfg -> Write("hcX", (long)m_Cfg.x);
549 cfg -> Write("hcY", (long)m_Cfg.y);
550 cfg -> Write("hcW", (long)m_Cfg.w);
551 cfg -> Write("hcH", (long)m_Cfg.h);
552
553 if (m_HtmlWin)
554 m_HtmlWin->WriteCustomization(cfg, path);
555
556 if (path != wxEmptyString)
557 cfg -> SetPath(oldpath);
558 }
559
560
561 /*
562 EVENT HANDLING :
563 */
564
565
566 void wxHtmlHelpFrame::OnToolbar(wxCommandEvent& event)
567 {
568 switch (event.GetId()) {
569 case wxID_HTML_BACK :
570 m_HtmlWin -> HistoryBack();
571 break;
572 case wxID_HTML_FORWARD :
573 m_HtmlWin -> HistoryForward();
574 break;
575 case wxID_HTML_PANEL :
576 if (! (m_Splitter && m_NavigPan))
577 return ;
578 if (m_Splitter -> IsSplit()) {
579 m_Cfg.sashpos = m_Splitter -> GetSashPosition();
580 m_Splitter -> Unsplit(m_NavigPan);
581 m_Cfg.navig_on = FALSE;
582 } else {
583 m_NavigPan -> Show(TRUE);
584 m_HtmlWin -> Show(TRUE);
585 m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
586 m_Cfg.navig_on = TRUE;
587 }
588 break;
589 }
590 }
591
592
593
594 void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent& event)
595 {
596 wxHtmlHelpTreeItemData *pg;
597
598 pg = (wxHtmlHelpTreeItemData*) m_ContentsBox -> GetItemData(event.GetItem());
599 if (pg) m_HtmlWin -> LoadPage(pg -> GetPage());
600 }
601
602
603
604 void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent& WXUNUSED(event))
605 {
606 wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_IndexBox -> GetClientData(m_IndexBox -> GetSelection());
607 if (it) m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page);
608 }
609
610
611
612 void wxHtmlHelpFrame::OnSearchSel(wxCommandEvent& WXUNUSED(event))
613 {
614 wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_SearchList -> GetClientData(m_SearchList -> GetSelection());
615 if (it) m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page);
616 }
617
618 void wxHtmlHelpFrame::OnSearch(wxCommandEvent& WXUNUSED(event))
619 {
620 wxString sr = m_SearchText -> GetLineText(0);
621
622 if (sr != wxEmptyString) KeywordSearch(sr);
623 }
624
625 void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent& evt)
626 {
627 GetSize(&m_Cfg.w, &m_Cfg.h);
628 GetPosition(&m_Cfg.x, &m_Cfg.y);
629 if (m_Splitter && m_Cfg.navig_on) m_Cfg.sashpos = m_Splitter -> GetSashPosition();
630
631 if (m_Config)
632 WriteCustomization(m_Config, m_ConfigRoot);
633
634 evt.Skip();
635 }
636
637 BEGIN_EVENT_TABLE(wxHtmlHelpFrame, wxFrame)
638 EVT_TOOL_RANGE(wxID_HTML_PANEL, wxID_HTML_FORWARD, wxHtmlHelpFrame::OnToolbar)
639 EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL, wxHtmlHelpFrame::OnContentsSel)
640 EVT_LISTBOX(wxID_HTML_INDEXLIST, wxHtmlHelpFrame::OnIndexSel)
641 EVT_LISTBOX(wxID_HTML_SEARCHLIST, wxHtmlHelpFrame::OnSearchSel)
642 EVT_BUTTON(wxID_HTML_SEARCHBUTTON, wxHtmlHelpFrame::OnSearch)
643 EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT, wxHtmlHelpFrame::OnSearch)
644 EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow)
645 END_EVENT_TABLE()
646
647 #endif