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