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