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