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