]> git.saurik.com Git - wxWidgets.git/blame - src/html/helpfrm.cpp
compilation fix for MSW
[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
c32bfc10
VS
16// For compilers that support precompilation, includes "wx.h"
17
8ec2b484
HH
18#include "wx/wxprec.h"
19
20#ifdef __BORLANDC__
21#pragma hdrstop
22#endif
23
3379ed37 24#if wxUSE_WXHTML_HELP
07b8d7ec 25
8ec2b484 26#ifndef WXPRECOMP
07b8d7ec
VZ
27 #include "wx/intl.h"
28 #include "wx/log.h"
29
30 #include "wx/object.h"
31 #include "wx/layout.h"
32 #include "wx/sizer.h"
33
34 #include "wx/bmpbuttn.h"
35 #include "wx/statbox.h"
36 #include "wx/radiobox.h"
37#endif // WXPRECOMP
8ec2b484
HH
38
39#include "wx/html/helpfrm.h"
b4414c1f 40#include "wx/html/helpctrl.h"
8ec2b484
HH
41#include "wx/notebook.h"
42#include "wx/imaglist.h"
43#include "wx/treectrl.h"
44#include "wx/tokenzr.h"
45#include "wx/wfstream.h"
46#include "wx/html/htmlwin.h"
47#include "wx/busyinfo.h"
48#include "wx/progdlg.h"
2bd5bbc9 49#include "wx/toolbar.h"
83efdf33 50#include "wx/fontenum.h"
0646614d
VS
51#include "wx/stream.h"
52#include "wx/filedlg.h"
8ec2b484
HH
53
54// Bitmaps:
55
56#ifndef __WXMSW__
83efdf33
VS
57#include "bitmaps/wpanel.xpm"
58#include "bitmaps/wback.xpm"
59#include "bitmaps/wforward.xpm"
60#include "bitmaps/wbook.xpm"
61#include "bitmaps/woptions.xpm"
62#include "bitmaps/wfolder.xpm"
63#include "bitmaps/wpage.xpm"
64#include "bitmaps/whelp.xpm"
65#include "bitmaps/whlproot.xpm"
382e6efe
VS
66#include "bitmaps/wbkadd.xpm"
67#include "bitmaps/wbkdel.xpm"
0646614d
VS
68#include "bitmaps/wup.xpm"
69#include "bitmaps/wupnode.xpm"
70#include "bitmaps/wdown.xpm"
71#include "bitmaps/wopen.xpm"
72#include "bitmaps/wprint.xpm"
8ec2b484
HH
73#endif
74
8ec2b484 75
f0b6a33f
VS
76// what is considered "small index"?
77#define INDEX_IS_SMALL 100
78
9806a47c
JS
79/* Motif defines this as a macro */
80#ifdef Below
81#undef Below
82#endif
f0b6a33f 83
8ec2b484 84//--------------------------------------------------------------------------
382e6efe 85// wxHtmlHelpTreeItemData (private)
8ec2b484
HH
86//--------------------------------------------------------------------------
87
88class wxHtmlHelpTreeItemData : public wxTreeItemData
89{
0646614d 90 public:
da4cc40c
DW
91#if defined(__VISAGECPP__)
92// VA needs a default ctor for some reason....
93 wxHtmlHelpTreeItemData() : wxTreeItemData()
94 { m_Id = 0; }
95#endif
0646614d
VS
96 wxHtmlHelpTreeItemData(int id) : wxTreeItemData()
97 { m_Id = id;}
98
99 int m_Id;
100};
8ec2b484 101
0646614d
VS
102
103//--------------------------------------------------------------------------
104// wxHtmlHelpHashData (private)
105//--------------------------------------------------------------------------
106
107class wxHtmlHelpHashData : public wxObject
108{
8ec2b484 109 public:
0646614d
VS
110 wxHtmlHelpHashData(int index, wxTreeItemId id) : wxObject()
111 { m_Index = index; m_Id = id;}
f5ba273e 112 ~wxHtmlHelpHashData() {}
f6bcfd97 113
0646614d
VS
114 int m_Index;
115 wxTreeItemId m_Id;
8ec2b484
HH
116};
117
382e6efe 118
0646614d
VS
119//--------------------------------------------------------------------------
120// wxHtmlHelpHtmlWindow (private)
121//--------------------------------------------------------------------------
122
123class wxHtmlHelpHtmlWindow : public wxHtmlWindow
124{
125 public:
126 wxHtmlHelpHtmlWindow(wxHtmlHelpFrame *fr, wxWindow *parent) : wxHtmlWindow(parent), m_Frame(fr) {}
127
128 virtual void OnLinkClicked(const wxHtmlLinkInfo& link)
129 {
130 wxHtmlWindow::OnLinkClicked(link);
4f9297b0 131 m_Frame->NotifyPageChanged();
0646614d
VS
132 }
133
f6bcfd97 134 private:
0646614d
VS
135 wxHtmlHelpFrame *m_Frame;
136};
137
382e6efe
VS
138
139
8ec2b484
HH
140//---------------------------------------------------------------------------
141// wxHtmlHelpFrame
142//---------------------------------------------------------------------------
143
576507e2
VS
144// Command IDs :
145enum
146{
147 //wxID_HTML_HELPFRAME = wxID_HIGHEST + 1,
148 wxID_HTML_PANEL = wxID_HIGHEST + 2,
149 wxID_HTML_BACK,
150 wxID_HTML_FORWARD,
151 wxID_HTML_UPNODE,
152 wxID_HTML_UP,
153 wxID_HTML_DOWN,
154 wxID_HTML_PRINT,
155 wxID_HTML_OPENFILE,
156 wxID_HTML_OPTIONS,
157 wxID_HTML_BOOKMARKSLIST,
158 wxID_HTML_BOOKMARKSADD,
159 wxID_HTML_BOOKMARKSREMOVE,
160 wxID_HTML_TREECTRL,
161 wxID_HTML_INDEXPAGE,
162 wxID_HTML_INDEXLIST,
163 wxID_HTML_INDEXTEXT,
164 wxID_HTML_INDEXBUTTON,
165 wxID_HTML_INDEXBUTTONALL,
166 wxID_HTML_NOTEBOOK,
167 wxID_HTML_SEARCHPAGE,
168 wxID_HTML_SEARCHTEXT,
169 wxID_HTML_SEARCHLIST,
170 wxID_HTML_SEARCHBUTTON,
171 wxID_HTML_SEARCHCHOICE,
172 wxID_HTML_COUNTINFO
173};
174
175
8ec2b484
HH
176IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpFrame, wxFrame)
177
178wxHtmlHelpFrame::wxHtmlHelpFrame(wxWindow* parent, wxWindowID id, const wxString& title,
d5bb85a0 179 int style, wxHtmlHelpData* data)
8ec2b484
HH
180{
181 Init(data);
182 Create(parent, id, title, style);
183}
d5bb85a0 184
8ec2b484
HH
185void wxHtmlHelpFrame::Init(wxHtmlHelpData* data)
186{
da4cc40c 187 if (data)
4f9297b0 188 {
d5bb85a0
VS
189 m_Data = data;
190 m_DataCreated = FALSE;
da4cc40c 191 } else
4f9297b0 192 {
d5bb85a0
VS
193 m_Data = new wxHtmlHelpData();
194 m_DataCreated = TRUE;
8ec2b484
HH
195 }
196
8ec2b484 197 m_ContentsBox = NULL;
f0b6a33f
VS
198 m_IndexList = NULL;
199 m_IndexButton = NULL;
200 m_IndexButtonAll = NULL;
201 m_IndexText = NULL;
8ec2b484
HH
202 m_SearchList = NULL;
203 m_SearchButton = NULL;
204 m_SearchText = NULL;
205 m_SearchChoice = NULL;
240c2873 206 m_IndexCountInfo = NULL;
8ec2b484
HH
207 m_Splitter = NULL;
208 m_NavigPan = NULL;
209 m_HtmlWin = NULL;
382e6efe 210 m_Bookmarks = NULL;
c4971147
VS
211 m_SearchCaseSensitive = NULL;
212 m_SearchWholeWords = NULL;
213
8ec2b484
HH
214 m_Config = NULL;
215 m_ConfigRoot = wxEmptyString;
216
217 m_Cfg.x = m_Cfg.y = 0;
d5bb85a0
VS
218 m_Cfg.w = 700;
219 m_Cfg.h = 480;
8ec2b484
HH
220 m_Cfg.sashpos = 240;
221 m_Cfg.navig_on = TRUE;
83efdf33
VS
222
223 m_NormalFonts = m_FixedFonts = NULL;
83efdf33 224 m_NormalFace = m_FixedFace = wxEmptyString;
0646614d 225 m_FontSize = 1;
f6bcfd97 226
0646614d
VS
227#if wxUSE_PRINTING_ARCHITECTURE
228 m_Printer = NULL;
229#endif
230
231 m_PagesHash = NULL;
232 m_UpdateContents = TRUE;
b4414c1f 233 m_helpController = (wxHelpControllerBase*) NULL;
8ec2b484
HH
234}
235
d5bb85a0
VS
236// Create: builds the GUI components.
237// with the style flag it's possible to toggle the toolbar, contents, index and search
238// controls.
239// m_HtmlWin will *always* be created, but it's important to realize that
f0b6a33f 240// m_ContentsBox, m_IndexList, m_SearchList, m_SearchButton, m_SearchText and
d5bb85a0
VS
241// m_SearchButton may be NULL.
242// moreover, if no contents, index or searchpage is needed, m_Splitter and
243// m_NavigPan will be NULL too (with m_HtmlWin directly connected to the frame)
244
3379ed37 245bool wxHtmlHelpFrame::Create(wxWindow* parent, wxWindowID id,
576507e2 246 const wxString& WXUNUSED(title), int style)
8ec2b484 247{
576507e2
VS
248 m_hfStyle = style;
249
8fd2b35c
VS
250 wxImageList *ContentsImageList = new wxImageList(16, 16);
251 ContentsImageList->Add(wxICON(wbook));
252 ContentsImageList->Add(wxICON(wfolder));
253 ContentsImageList->Add(wxICON(wpage));
254 ContentsImageList->Add(wxICON(whlproot));
255
8ec2b484
HH
256 // Do the config in two steps. We read the HtmlWindow customization after we
257 // create the window.
d5bb85a0
VS
258 if (m_Config)
259 ReadCustomization(m_Config, m_ConfigRoot);
8ec2b484 260
8eb2940f 261 wxFrame::Create(parent, id, _("Help"), wxPoint(m_Cfg.x, m_Cfg.y), wxSize(m_Cfg.w, m_Cfg.h), wxDEFAULT_FRAME_STYLE, "wxHtmlHelp");
8ec2b484 262
5c172c17
VS
263 GetPosition(&m_Cfg.x, &m_Cfg.y);
264
83efdf33 265 SetIcon(wxICON(whelp));
9ffdee80 266
8ec2b484
HH
267 int notebook_page = 0;
268
269 CreateStatusBar();
270
271 // toolbar?
576507e2 272 if (style & (wxHF_TOOLBAR | wxHF_FLAT_TOOLBAR))
4f9297b0 273 {
f6bcfd97
BP
274 wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL |
275 wxTB_DOCKABLE |
576507e2 276 (style & wxHF_FLAT_TOOLBAR ? wxTB_FLAT : 0));
00655497 277 toolBar->SetMargins( 2, 2 );
b854b7b8 278 AddToolbarButtons(toolBar, style);
4f9297b0 279 toolBar->Realize();
8ec2b484 280 }
d5bb85a0 281
da4cc40c 282 if (style & (wxHF_CONTENTS | wxHF_INDEX | wxHF_SEARCH))
4f9297b0 283 {
d5bb85a0
VS
284 // traditional help controller; splitter window with html page on the
285 // right and a notebook containing various pages on the left
286 m_Splitter = new wxSplitterWindow(this);
287
0646614d 288 m_HtmlWin = new wxHtmlHelpHtmlWindow(this, m_Splitter);
d5bb85a0
VS
289 m_NavigPan = new wxNotebook(m_Splitter, wxID_HTML_NOTEBOOK,
290 wxDefaultPosition, wxDefaultSize);
da4cc40c
DW
291 }
292 else
4f9297b0 293 { // only html window, no notebook with index,contents etc
d5bb85a0 294 m_HtmlWin = new wxHtmlWindow(this);
8ec2b484
HH
295 }
296
4f9297b0
VS
297 m_HtmlWin->SetRelatedFrame(this, m_TitleFormat);
298 m_HtmlWin->SetRelatedStatusBar(0);
d5bb85a0 299 if (m_Config)
4f9297b0 300 m_HtmlWin->ReadCustomization(m_Config, m_ConfigRoot);
8ec2b484
HH
301
302 // contents tree panel?
da4cc40c 303 if (style & wxHF_CONTENTS)
4f9297b0 304 {
ae80f837
VS
305 wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_INDEXPAGE);
306
da4cc40c 307 if (style & wxHF_BOOKMARKS)
3379ed37 308 {
ae80f837
VS
309 wxLayoutConstraints *b1 = new wxLayoutConstraints;
310 wxBitmapButton *bmpbt = new wxBitmapButton(dummy, wxID_HTML_BOOKMARKSREMOVE, wxBITMAP(wbkdel), wxDefaultPosition, wxSize(20,20));
311
4f9297b0
VS
312 b1->top.SameAs (dummy, wxTop, 10);
313 b1->right.SameAs (dummy, wxRight, 10);
314 b1->height.AsIs();
315 b1->width.AsIs();
316 bmpbt->SetConstraints(b1);
ae80f837
VS
317
318 wxLayoutConstraints *b2 = new wxLayoutConstraints;
319 wxBitmapButton *bmpbt2 = new wxBitmapButton(dummy, wxID_HTML_BOOKMARKSADD, wxBITMAP(wbkadd), wxDefaultPosition, wxSize(20,20));
320
4f9297b0
VS
321 b2->top.SameAs (dummy, wxTop, 10);
322 b2->right.LeftOf (bmpbt, 2);
323 b2->height.AsIs();
324 b2->width.AsIs();
325 bmpbt2->SetConstraints(b2);
ae80f837
VS
326
327#if wxUSE_TOOLTIPS
4f9297b0
VS
328 bmpbt->SetToolTip(_("Remove current page from bookmarks"));
329 bmpbt2->SetToolTip(_("Add current page to bookmarks"));
ae80f837
VS
330#endif //wxUSE_TOOLTIPS
331
332 wxLayoutConstraints *b3 = new wxLayoutConstraints;
333 m_Bookmarks = new wxComboBox(dummy, wxID_HTML_BOOKMARKSLIST, wxEmptyString,
334 wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY | wxCB_SORT);
4f9297b0 335 m_Bookmarks->Append(_("(bookmarks)"));
ae80f837 336 for (unsigned i = 0; i < m_BookmarksNames.GetCount(); i++)
4f9297b0
VS
337 m_Bookmarks->Append(m_BookmarksNames[i]);
338 m_Bookmarks->SetSelection(0);
ae80f837 339
4f9297b0
VS
340 b3->centreY.SameAs (bmpbt2, wxCentreY);
341 b3->left.SameAs (dummy, wxLeft, 10);
342 b3->right.LeftOf (bmpbt2, 5);
343 b3->height.AsIs();
344 m_Bookmarks->SetConstraints(b3);
ae80f837
VS
345
346
347 wxLayoutConstraints *b4 = new wxLayoutConstraints;
348 m_ContentsBox = new wxTreeCtrl(dummy, wxID_HTML_TREECTRL,
349 wxDefaultPosition, wxDefaultSize,
350 wxTR_HAS_BUTTONS | wxSUNKEN_BORDER);
4f9297b0 351 m_ContentsBox->AssignImageList(ContentsImageList);
ae80f837 352
4f9297b0
VS
353 b4->top.Below (m_Bookmarks, 10);
354 b4->left.SameAs (dummy, wxLeft, 0);
355 b4->right.SameAs (dummy, wxRight, 0);
356 b4->bottom.SameAs (dummy, wxBottom, 0);
357 m_ContentsBox->SetConstraints(b4);
ae80f837 358
4f9297b0
VS
359 dummy->SetAutoLayout(TRUE);
360 dummy->Layout();
ae80f837 361
4f9297b0 362 m_NavigPan->AddPage(dummy, _("Contents"));
ae80f837
VS
363 }
364
365 else
366 {
367 m_ContentsBox = new wxTreeCtrl(m_NavigPan, wxID_HTML_TREECTRL,
368 wxDefaultPosition, wxDefaultSize,
369 wxTR_HAS_BUTTONS | wxSUNKEN_BORDER);
4f9297b0
VS
370 m_ContentsBox->AssignImageList(ContentsImageList);
371 m_NavigPan->AddPage(m_ContentsBox, _("Contents"));
ae80f837
VS
372 }
373
d5bb85a0 374 m_ContentsPage = notebook_page++;
8ec2b484
HH
375 }
376
377 // index listbox panel?
da4cc40c 378 if (style & wxHF_INDEX)
4f9297b0 379 {
d5bb85a0 380 wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_INDEXPAGE);
f0b6a33f 381
d5bb85a0 382 wxLayoutConstraints *b1 = new wxLayoutConstraints;
f0b6a33f 383 m_IndexText = new wxTextCtrl(dummy, wxID_HTML_INDEXTEXT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
4f9297b0
VS
384 b1->top.SameAs (dummy, wxTop, 10);
385 b1->left.SameAs (dummy, wxLeft, 10);
386 b1->right.SameAs (dummy, wxRight, 10);
387 b1->height.AsIs();
388 m_IndexText->SetConstraints(b1);
f0b6a33f
VS
389
390 wxLayoutConstraints *b4 = new wxLayoutConstraints;
391 m_IndexButtonAll = new wxButton(dummy, wxID_HTML_INDEXBUTTONALL, _("Show all"));
7618e374 392
4f9297b0
VS
393 b4->top.Below (m_IndexText, 10);
394 b4->right.SameAs (dummy, wxRight, 10);
395 b4->width.AsIs();
396 b4->height.AsIs();
397 m_IndexButtonAll->SetConstraints(b4);
f0b6a33f
VS
398
399 wxLayoutConstraints *b2 = new wxLayoutConstraints;
400 m_IndexButton = new wxButton(dummy, wxID_HTML_INDEXBUTTON, _("Find"));
4f9297b0
VS
401 b2->top.Below (m_IndexText, 10);
402 b2->right.LeftOf (m_IndexButtonAll, 10);
403 b2->width.AsIs();
404 b2->height.AsIs();
405 m_IndexButton->SetConstraints(b2);
f0b6a33f 406
240c2873
VS
407 wxLayoutConstraints *b5 = new wxLayoutConstraints;
408 m_IndexCountInfo = new wxStaticText(dummy, wxID_HTML_COUNTINFO, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
409
4f9297b0
VS
410 b5->top.Below (m_IndexButton, 5);
411 b5->right.SameAs (dummy, wxRight, 10);
412 b5->left.SameAs (dummy, wxLeft, 10);
413 b5->height.AsIs();
414 m_IndexCountInfo->SetConstraints(b5);
240c2873 415
f0b6a33f 416 wxLayoutConstraints *b3 = new wxLayoutConstraints;
721ab905 417 m_IndexList = new wxListBox(dummy, wxID_HTML_INDEXLIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE);
4f9297b0
VS
418 b3->top.Below (m_IndexCountInfo, 5);
419 b3->left.SameAs (dummy, wxLeft, 0);
420 b3->right.SameAs (dummy, wxRight, 0);
421 b3->bottom.SameAs (dummy, wxBottom, 0);
422 m_IndexList->SetConstraints(b3);
f0b6a33f 423
7618e374 424#if wxUSE_TOOLTIPS
4f9297b0
VS
425 m_IndexButtonAll->SetToolTip(_("Show all items in index"));
426 m_IndexButton->SetToolTip(_("Display all index items that contain given substring. Search is case insensitive."));
7618e374
VS
427#endif //wxUSE_TOOLTIPS
428
4f9297b0
VS
429 dummy->SetAutoLayout(TRUE);
430 dummy->Layout();
f0b6a33f 431
4f9297b0 432 m_NavigPan->AddPage(dummy, _("Index"));
d5bb85a0 433 m_IndexPage = notebook_page++;
8ec2b484
HH
434 }
435
436 // search list panel?
da4cc40c 437 if (style & wxHF_SEARCH)
4f9297b0 438 {
d5bb85a0
VS
439 wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_SEARCHPAGE);
440
441 wxLayoutConstraints *b1 = new wxLayoutConstraints;
f0b6a33f 442 m_SearchText = new wxTextCtrl(dummy, wxID_HTML_SEARCHTEXT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
4f9297b0
VS
443 b1->top.SameAs (dummy, wxTop, 10);
444 b1->left.SameAs (dummy, wxLeft, 10);
445 b1->right.SameAs (dummy, wxRight, 10);
446 b1->height.AsIs();
447 m_SearchText->SetConstraints(b1);
d5bb85a0 448
d5bb85a0
VS
449 wxLayoutConstraints *b4 = new wxLayoutConstraints;
450 m_SearchChoice = new wxChoice(dummy, wxID_HTML_SEARCHCHOICE, wxDefaultPosition,
451 wxDefaultSize);
4f9297b0
VS
452 b4->top.Below (m_SearchText, 10);
453 b4->left.SameAs (dummy, wxLeft, 10);
454 b4->right.SameAs (dummy, wxRight, 10);
455 b4->height.AsIs();
456 m_SearchChoice->SetConstraints(b4);
d5bb85a0 457
c4971147
VS
458 wxLayoutConstraints *b5 = new wxLayoutConstraints;
459 m_SearchCaseSensitive = new wxCheckBox(dummy, -1, _("Case sensitive"));
4f9297b0
VS
460 b5->top.Below (m_SearchChoice, 10);
461 b5->left.SameAs (dummy, wxLeft, 10);
462 b5->width.AsIs();
463 b5->height.AsIs ();
464 m_SearchCaseSensitive->SetConstraints(b5);
c4971147
VS
465
466 wxLayoutConstraints *b6 = new wxLayoutConstraints;
467 m_SearchWholeWords = new wxCheckBox(dummy, -1, _("Whole words only"));
4f9297b0
VS
468 b6->top.Below (m_SearchCaseSensitive, 0);
469 b6->left.SameAs (dummy, wxLeft, 10);
470 b6->width.AsIs();
471 b6->height.AsIs ();
472 m_SearchWholeWords->SetConstraints(b6);
c4971147 473
ae80f837
VS
474 wxLayoutConstraints *b2 = new wxLayoutConstraints;
475 m_SearchButton = new wxButton(dummy, wxID_HTML_SEARCHBUTTON, _("Search"));
476#if wxUSE_TOOLTIPS
4f9297b0 477 m_SearchButton->SetToolTip(_("Search contents of help book(s) for all occurences of the text you typed above"));
ae80f837 478#endif //wxUSE_TOOLTIPS
4f9297b0
VS
479 b2->top.Below (m_SearchWholeWords, 0);
480 b2->right.SameAs (dummy, wxRight, 10);
481 b2->width.AsIs();
482 b2->height.AsIs();
483 m_SearchButton->SetConstraints(b2);
ae80f837 484
954269e6 485 wxLayoutConstraints *b3 = new wxLayoutConstraints;
721ab905 486 m_SearchList = new wxListBox(dummy, wxID_HTML_SEARCHLIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE);
4f9297b0
VS
487 b3->top.Below (m_SearchButton, 10);
488 b3->left.SameAs (dummy, wxLeft, 0);
489 b3->right.SameAs (dummy, wxRight, 0);
490 b3->bottom.SameAs (dummy, wxBottom, 0);
491 m_SearchList->SetConstraints(b3);
492
493 dummy->SetAutoLayout(TRUE);
494 dummy->Layout();
495 m_NavigPan->AddPage(dummy, _("Search"));
d5bb85a0 496 m_SearchPage = notebook_page++;
8ec2b484 497 }
4f9297b0 498 m_HtmlWin->Show(TRUE);
f6bcfd97 499
b5a7b000 500 RefreshLists();
8ec2b484
HH
501
502 // showtime
da4cc40c 503 if (m_NavigPan && m_Splitter)
4f9297b0
VS
504 {
505 m_Splitter->SetMinimumPaneSize(20);
f38374d0 506 if (m_Cfg.navig_on)
4f9297b0 507 m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
da4cc40c 508 else
3379ed37 509 {
4f9297b0
VS
510 m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
511 m_Splitter->Unsplit();
f38374d0 512 }
4f9297b0 513
3379ed37
VZ
514 if (m_Cfg.navig_on)
515 {
4f9297b0
VS
516 m_NavigPan->Show(TRUE);
517 m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
c32bfc10 518 }
da4cc40c 519 else
3379ed37 520 {
4f9297b0
VS
521 m_NavigPan->Show(FALSE);
522 m_Splitter->Initialize(m_HtmlWin);
68364659 523 }
8ec2b484 524 }
8ec2b484
HH
525 return TRUE;
526}
527
528wxHtmlHelpFrame::~wxHtmlHelpFrame()
529{
b4414c1f 530 // PopEventHandler(); // wxhtmlhelpcontroller (not any more!)
8ec2b484 531 if (m_DataCreated)
d5bb85a0 532 delete m_Data;
83efdf33
VS
533 if (m_NormalFonts) delete m_NormalFonts;
534 if (m_FixedFonts) delete m_FixedFonts;
70aedad6 535 if (m_PagesHash) delete m_PagesHash;
8ec2b484
HH
536}
537
b854b7b8
VS
538
539void wxHtmlHelpFrame::AddToolbarButtons(wxToolBar *toolBar, int style)
540{
f6bcfd97
BP
541 wxBitmap wpanelBitmap = wxBITMAP(wpanel);
542 wxBitmap wbackBitmap = wxBITMAP(wback);
543 wxBitmap wforwardBitmap = wxBITMAP(wforward);
544 wxBitmap wupnodeBitmap = wxBITMAP(wupnode);
545 wxBitmap wupBitmap = wxBITMAP(wup);
546 wxBitmap wdownBitmap = wxBITMAP(wdown);
547 wxBitmap wopenBitmap = wxBITMAP(wopen);
548 wxBitmap wprintBitmap = wxBITMAP(wprint);
549 wxBitmap woptionsBitmap = wxBITMAP(woptions);
550
551 wxASSERT_MSG( (wpanelBitmap.Ok() && wbackBitmap.Ok() &&
552 wforwardBitmap.Ok() && wupnodeBitmap.Ok() &&
553 wupBitmap.Ok() && wdownBitmap.Ok() &&
554 wopenBitmap.Ok() && wprintBitmap.Ok() &&
555 woptionsBitmap.Ok()),
556 wxT("One or more HTML help frame toolbar bitmap could not be loaded.")) ;
557
558
4f9297b0 559 toolBar->AddTool(wxID_HTML_PANEL, wpanelBitmap, wxNullBitmap,
b854b7b8
VS
560 FALSE, -1, -1, (wxObject *) NULL,
561 _("Show/hide navigation panel"));
0646614d 562
4f9297b0
VS
563 toolBar->AddSeparator();
564 toolBar->AddTool(wxID_HTML_BACK, wbackBitmap, wxNullBitmap,
b854b7b8 565 FALSE, -1, -1, (wxObject *) NULL,
0646614d 566 _("Go back"));
4f9297b0 567 toolBar->AddTool(wxID_HTML_FORWARD, wforwardBitmap, wxNullBitmap,
b854b7b8 568 FALSE, -1, -1, (wxObject *) NULL,
0646614d 569 _("Go forward"));
4f9297b0 570 toolBar->AddSeparator();
b854b7b8 571
4f9297b0 572 toolBar->AddTool(wxID_HTML_UPNODE, wupnodeBitmap, wxNullBitmap,
0646614d
VS
573 FALSE, -1, -1, (wxObject *) NULL,
574 _("Go one level up in document hierarchy"));
4f9297b0 575 toolBar->AddTool(wxID_HTML_UP, wupBitmap, wxNullBitmap,
0646614d
VS
576 FALSE, -1, -1, (wxObject *) NULL,
577 _("Previous page"));
4f9297b0 578 toolBar->AddTool(wxID_HTML_DOWN, wdownBitmap, wxNullBitmap,
0646614d
VS
579 FALSE, -1, -1, (wxObject *) NULL,
580 _("Next page"));
581
576507e2 582 if ((style & wxHF_PRINT) || (style & wxHF_OPEN_FILES))
4f9297b0 583 toolBar->AddSeparator();
f6bcfd97 584
576507e2 585 if (style & wxHF_OPEN_FILES)
4f9297b0 586 toolBar->AddTool(wxID_HTML_OPENFILE, wopenBitmap, wxNullBitmap,
0646614d
VS
587 FALSE, -1, -1, (wxObject *) NULL,
588 _("Open HTML document"));
589
590#if wxUSE_PRINTING_ARCHITECTURE
591 if (style & wxHF_PRINT)
4f9297b0 592 toolBar->AddTool(wxID_HTML_PRINT, wprintBitmap, wxNullBitmap,
0646614d
VS
593 FALSE, -1, -1, (wxObject *) NULL,
594 _("Print this page"));
595#endif
596
4f9297b0
VS
597 toolBar->AddSeparator();
598 toolBar->AddTool(wxID_HTML_OPTIONS, woptionsBitmap, wxNullBitmap,
b854b7b8
VS
599 FALSE, -1, -1, (wxObject *) NULL,
600 _("Display options dialog"));
601}
602
603
721ab905
VS
604void wxHtmlHelpFrame::SetTitleFormat(const wxString& format)
605{
606 if (m_HtmlWin)
607 m_HtmlWin->SetRelatedFrame(this, format);
608 m_TitleFormat = format;
609}
610
b854b7b8 611
8ec2b484
HH
612bool wxHtmlHelpFrame::Display(const wxString& x)
613{
614 wxString url = m_Data->FindPageByName(x);
da4cc40c 615 if (!url.IsEmpty())
4f9297b0 616 {
d5bb85a0 617 m_HtmlWin->LoadPage(url);
0646614d 618 NotifyPageChanged();
d5bb85a0 619 return TRUE;
8ec2b484
HH
620 }
621 return FALSE;
622}
623
624bool wxHtmlHelpFrame::Display(const int id)
625{
626 wxString url = m_Data->FindPageById(id);
da4cc40c 627 if (!url.IsEmpty())
4f9297b0 628 {
d5bb85a0 629 m_HtmlWin->LoadPage(url);
0646614d 630 NotifyPageChanged();
d5bb85a0 631 return TRUE;
8ec2b484
HH
632 }
633 return FALSE;
634}
635
636
637
638bool wxHtmlHelpFrame::DisplayContents()
639{
640 if (! m_ContentsBox)
d5bb85a0 641 return FALSE;
da4cc40c 642 if (!m_Splitter->IsSplit())
4f9297b0
VS
643 {
644 m_NavigPan->Show(TRUE);
645 m_HtmlWin->Show(TRUE);
646 m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
c32bfc10 647 m_Cfg.navig_on = TRUE;
8ec2b484 648 }
4f9297b0 649 m_NavigPan->SetSelection(0);
71d04f7f
JS
650 if (m_Data->GetBookRecArray().GetCount() > 0)
651 {
652 wxHtmlBookRecord& book = m_Data->GetBookRecArray()[0];
653 if (!book.GetStart().IsEmpty())
468ae730 654 m_HtmlWin->LoadPage(book.GetFullPath(book.GetStart()));
71d04f7f 655 }
8ec2b484
HH
656 return TRUE;
657}
658
659
660
661bool wxHtmlHelpFrame::DisplayIndex()
662{
f0b6a33f 663 if (! m_IndexList)
d5bb85a0 664 return FALSE;
da4cc40c 665 if (!m_Splitter->IsSplit())
4f9297b0
VS
666 {
667 m_NavigPan->Show(TRUE);
668 m_HtmlWin->Show(TRUE);
669 m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
8ec2b484 670 }
4f9297b0 671 m_NavigPan->SetSelection(1);
71d04f7f
JS
672 if (m_Data->GetBookRecArray().GetCount() > 0)
673 {
674 wxHtmlBookRecord& book = m_Data->GetBookRecArray()[0];
675 if (!book.GetStart().IsEmpty())
468ae730 676 m_HtmlWin->LoadPage(book.GetFullPath(book.GetStart()));
71d04f7f 677 }
8ec2b484
HH
678 return TRUE;
679}
680
b854b7b8
VS
681
682
8ec2b484
HH
683bool wxHtmlHelpFrame::KeywordSearch(const wxString& keyword)
684{
685 if (! (m_SearchList && m_SearchButton && m_SearchText && m_SearchChoice))
d5bb85a0 686 return FALSE;
8ec2b484 687
c4971147 688 int foundcnt = 0, curi;
8ec2b484
HH
689 wxString foundstr;
690 wxString book = wxEmptyString;
691
da4cc40c 692 if (!m_Splitter->IsSplit())
4f9297b0
VS
693 {
694 m_NavigPan->Show(TRUE);
695 m_HtmlWin->Show(TRUE);
696 m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
8ec2b484 697 }
4f9297b0
VS
698 m_NavigPan->SetSelection(m_SearchPage);
699 m_SearchList->Clear();
700 m_SearchText->SetValue(keyword);
701 m_SearchButton->Enable(FALSE);
8ec2b484
HH
702
703 if (m_SearchChoice->GetSelection() != 0)
d5bb85a0 704 book = m_SearchChoice->GetStringSelection();
8ec2b484 705
f6bcfd97 706 wxHtmlSearchStatus status(m_Data, keyword,
4f9297b0 707 m_SearchCaseSensitive->GetValue(), m_SearchWholeWords->GetValue(),
c4971147 708 book);
8ec2b484 709
d5bb85a0
VS
710 wxProgressDialog progress(_("Searching..."), _("No matching page found yet"),
711 status.GetMaxIndex(), this,
b4414c1f 712 wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_AUTO_HIDE);
8ec2b484 713
da4cc40c 714 while (status.IsActive())
4f9297b0 715 {
c4971147 716 curi = status.GetCurIndex();
b5a7b000 717 if (curi % 32 == 0 && progress.Update(curi) == FALSE)
d5bb85a0 718 break;
da4cc40c 719 if (status.Search())
3379ed37 720 {
d5bb85a0
VS
721 foundstr.Printf(_("Found %i matches"), ++foundcnt);
722 progress.Update(status.GetCurIndex(), foundstr);
4f9297b0 723 m_SearchList->Append(status.GetName(), status.GetContentsItem());
d5bb85a0 724 }
8ec2b484
HH
725 }
726
4f9297b0
VS
727 m_SearchButton->Enable(TRUE);
728 m_SearchText->SetSelection(0, keyword.Length());
729 m_SearchText->SetFocus();
da4cc40c 730 if (foundcnt)
4f9297b0
VS
731 {
732 wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_SearchList->GetClientData(0);
f6bcfd97 733 if (it)
0646614d 734 {
468ae730 735 m_HtmlWin->LoadPage(it->GetFullPath());
0646614d
VS
736 NotifyPageChanged();
737 }
8ec2b484
HH
738 }
739 return (foundcnt > 0);
740}
741
b5a7b000 742void wxHtmlHelpFrame::CreateContents()
8ec2b484
HH
743{
744 if (! m_ContentsBox)
d5bb85a0 745 return ;
8ec2b484 746
8ec2b484 747 m_ContentsBox->Clear();
f6bcfd97 748
0646614d 749 if (m_PagesHash) delete m_PagesHash;
4f9297b0
VS
750 m_PagesHash = new wxHashTable(wxKEY_STRING, 2 * m_Data->GetContentsCnt());
751 m_PagesHash->DeleteContents(TRUE);
8ec2b484
HH
752
753 int cnt = m_Data->GetContentsCnt();
8ec2b484 754 int i;
576507e2 755 size_t booksCnt = m_Data->GetBookRecArray().GetCount();
8ec2b484 756
83efdf33 757 wxHtmlContentsItem *it;
d5bb85a0 758
576507e2 759 const int MAX_ROOTS = 64;
8ec2b484 760 wxTreeItemId roots[MAX_ROOTS];
576507e2
VS
761 // VS: this array holds information about whether we've set item icon at
762 // given level. This is neccessary because m_Data has flat structure
763 // and there's no way of recognizing if some item has subitems or not.
764 // We set the icon later: when we find an item with level=n, we know
765 // that the last item with level=n-1 was folder with subitems, so we
766 // set its icon accordingly
3379ed37 767 bool imaged[MAX_ROOTS];
4f9297b0 768 m_ContentsBox->DeleteAllItems();
0c55409f 769
576507e2
VS
770 // Don't show (Help) root if there's only one boook
771 if (booksCnt > 1)
772 {
773 roots[0] = m_ContentsBox->AddRoot(_("(Help)"));
774 m_ContentsBox->SetItemImage(roots[0], IMG_RootFolder);
775 m_ContentsBox->SetItemSelectedImage(roots[0], IMG_RootFolder);
776 imaged[0] = TRUE;
777 }
8ec2b484 778
da4cc40c 779 for (it = m_Data->GetContents(), i = 0; i < cnt; i++, it++)
4f9297b0 780 {
576507e2 781 // Handle books:
da4cc40c 782 if (it->m_Level == 0)
576507e2
VS
783 {
784 // special case, only one book, make it tree's root:
785 if (booksCnt == 1)
786 {
787 roots[0] = roots[1] = m_ContentsBox->AddRoot(
0c55409f 788 it->m_Name, IMG_Book, -1,
576507e2 789 new wxHtmlHelpTreeItemData(i));
0c55409f
VS
790 imaged[0] = imaged[1] = TRUE;
791 m_ContentsBox->SetItemBold(roots[1], TRUE);
576507e2
VS
792 }
793 // multiple books:
794 else
795 {
796 if (m_hfStyle & wxHF_MERGE_BOOKS)
797 // VS: we don't want book nodes, books' content should
798 // appear under tree's root. This line will create "fake"
799 // record about book node so that the rest of this look
800 // will believe there really _is_ book node and will
801 // behave correctly.
802 roots[1] = roots[0];
803 else
804 {
805 roots[1] = m_ContentsBox->AppendItem(roots[0],
3379ed37 806 it->m_Name, IMG_Book, -1,
576507e2
VS
807 new wxHtmlHelpTreeItemData(i));
808 m_ContentsBox->SetItemBold(roots[1], TRUE);
809 }
810 imaged[1] = TRUE;
811 }
4f9297b0 812 }
576507e2 813 // ...and their contents:
3379ed37 814 else
576507e2
VS
815 {
816 roots[it->m_Level + 1] = m_ContentsBox->AppendItem(
3379ed37 817 roots[it->m_Level], it->m_Name, IMG_Page,
576507e2 818 -1, new wxHtmlHelpTreeItemData(i));
3379ed37 819 imaged[it->m_Level + 1] = FALSE;
576507e2 820 }
4f9297b0 821
576507e2
VS
822 m_PagesHash->Put(it->GetFullPath(),
823 new wxHtmlHelpHashData(i, roots[it->m_Level + 1]));
824
825 // Set the icon for the node one level up in the hiearachy,
826 // unless already done (see comment above imaged[] declaration)
da4cc40c 827 if (!imaged[it->m_Level])
3379ed37 828 {
576507e2
VS
829 int image = IMG_Folder;
830 if (m_hfStyle & wxHF_ICONS_BOOK)
831 image = IMG_Book;
832 else if (m_hfStyle & wxHF_ICONS_BOOK_CHAPTER)
833 image = (it->m_Level == 1) ? IMG_Book : IMG_Folder;
834 m_ContentsBox->SetItemImage(roots[it->m_Level], image);
835 m_ContentsBox->SetItemSelectedImage(roots[it->m_Level], image);
4f9297b0 836 imaged[it->m_Level] = TRUE;
8ec2b484
HH
837 }
838 }
576507e2 839
4f9297b0 840 m_ContentsBox->Expand(roots[0]);
8ec2b484
HH
841}
842
843
b5a7b000 844void wxHtmlHelpFrame::CreateIndex()
8ec2b484 845{
f0b6a33f 846 if (! m_IndexList)
d5bb85a0 847 return ;
8ec2b484 848
f0b6a33f 849 m_IndexList->Clear();
8ec2b484
HH
850
851 int cnt = m_Data->GetIndexCnt();
f6bcfd97 852
240c2873
VS
853 wxString cnttext;
854 if (cnt > INDEX_IS_SMALL) cnttext.Printf(_("%i of %i"), 0, cnt);
855 else cnttext.Printf(_("%i of %i"), cnt, cnt);
4f9297b0 856 m_IndexCountInfo->SetLabel(cnttext);
f0b6a33f 857 if (cnt > INDEX_IS_SMALL) return;
f6bcfd97 858
8ec2b484
HH
859 wxHtmlContentsItem* index = m_Data->GetIndex();
860
f6bcfd97 861 for (int i = 0; i < cnt; i++)
4f9297b0 862 m_IndexList->Append(index[i].m_Name, (char*)(index + i));
8ec2b484
HH
863}
864
865void wxHtmlHelpFrame::CreateSearch()
866{
867 if (! (m_SearchList && m_SearchChoice))
d5bb85a0 868 return ;
4f9297b0
VS
869 m_SearchList->Clear();
870 m_SearchChoice->Clear();
871 m_SearchChoice->Append(_("Search in all books"));
8ec2b484
HH
872 const wxHtmlBookRecArray& bookrec = m_Data->GetBookRecArray();
873 int i, cnt = bookrec.GetCount();
d5bb85a0
VS
874 for (i = 0; i < cnt; i++)
875 m_SearchChoice->Append(bookrec[i].GetTitle());
8ec2b484
HH
876 m_SearchChoice->SetSelection(0);
877}
878
879
b5a7b000 880void wxHtmlHelpFrame::RefreshLists()
8ec2b484 881{
b5a7b000
VS
882 CreateContents();
883 CreateIndex();
8ec2b484
HH
884 CreateSearch();
885}
886
887void wxHtmlHelpFrame::ReadCustomization(wxConfigBase *cfg, const wxString& path)
888{
889 wxString oldpath;
890 wxString tmp;
891
da4cc40c 892 if (path != wxEmptyString)
4f9297b0
VS
893 {
894 oldpath = cfg->GetPath();
895 cfg->SetPath(_T("/") + path);
8ec2b484
HH
896 }
897
4f9297b0
VS
898 m_Cfg.navig_on = cfg->Read(wxT("hcNavigPanel"), m_Cfg.navig_on) != 0;
899 m_Cfg.sashpos = cfg->Read(wxT("hcSashPos"), m_Cfg.sashpos);
900 m_Cfg.x = cfg->Read(wxT("hcX"), m_Cfg.x);
901 m_Cfg.y = cfg->Read(wxT("hcY"), m_Cfg.y);
902 m_Cfg.w = cfg->Read(wxT("hcW"), m_Cfg.w);
903 m_Cfg.h = cfg->Read(wxT("hcH"), m_Cfg.h);
8ec2b484 904
4f9297b0
VS
905 m_FixedFace = cfg->Read(wxT("hcFixedFace"), m_FixedFace);
906 m_NormalFace = cfg->Read(wxT("hcNormalFace"), m_NormalFace);
907 m_FontSize = cfg->Read(wxT("hcFontSize"), m_FontSize);
83efdf33 908
382e6efe
VS
909 {
910 int i;
911 int cnt;
912 wxString val, s;
f6bcfd97 913
4f9297b0 914 cnt = cfg->Read(wxT("hcBookmarksCnt"), 0L);
da4cc40c 915 if (cnt != 0)
3379ed37 916 {
382e6efe
VS
917 m_BookmarksNames.Clear();
918 m_BookmarksPages.Clear();
da4cc40c 919 if (m_Bookmarks)
3379ed37 920 {
4f9297b0
VS
921 m_Bookmarks->Clear();
922 m_Bookmarks->Append(_("(bookmarks)"));
382e6efe 923 }
f6bcfd97 924
da4cc40c 925 for (i = 0; i < cnt; i++)
3379ed37 926 {
0413cec5 927 val.Printf(wxT("hcBookmark_%i"), i);
4f9297b0 928 s = cfg->Read(val);
382e6efe 929 m_BookmarksNames.Add(s);
4f9297b0 930 if (m_Bookmarks) m_Bookmarks->Append(s);
0413cec5 931 val.Printf(wxT("hcBookmark_%i_url"), i);
4f9297b0 932 s = cfg->Read(val);
382e6efe
VS
933 m_BookmarksPages.Add(s);
934 }
935 }
936 }
937
8ec2b484 938 if (m_HtmlWin)
3e5296e7 939 m_HtmlWin->ReadCustomization(cfg);
8ec2b484
HH
940
941 if (path != wxEmptyString)
4f9297b0 942 cfg->SetPath(oldpath);
8ec2b484
HH
943}
944
945void wxHtmlHelpFrame::WriteCustomization(wxConfigBase *cfg, const wxString& path)
946{
947 wxString oldpath;
948 wxString tmp;
8ec2b484 949
da4cc40c 950 if (path != wxEmptyString)
4f9297b0
VS
951 {
952 oldpath = cfg->GetPath();
953 cfg->SetPath(_T("/") + path);
8ec2b484
HH
954 }
955
4f9297b0
VS
956 cfg->Write(wxT("hcNavigPanel"), m_Cfg.navig_on);
957 cfg->Write(wxT("hcSashPos"), (long)m_Cfg.sashpos);
958 cfg->Write(wxT("hcX"), (long)m_Cfg.x);
959 cfg->Write(wxT("hcY"), (long)m_Cfg.y);
960 cfg->Write(wxT("hcW"), (long)m_Cfg.w);
961 cfg->Write(wxT("hcH"), (long)m_Cfg.h);
962 cfg->Write(wxT("hcFixedFace"), m_FixedFace);
963 cfg->Write(wxT("hcNormalFace"), m_NormalFace);
964 cfg->Write(wxT("hcFontSize"), (long)m_FontSize);
965
da4cc40c 966 if (m_Bookmarks)
4f9297b0 967 {
382e6efe
VS
968 int i;
969 int cnt = m_BookmarksNames.GetCount();
970 wxString val;
f6bcfd97 971
4f9297b0 972 cfg->Write(wxT("hcBookmarksCnt"), (long)cnt);
da4cc40c 973 for (i = 0; i < cnt; i++)
3379ed37 974 {
0413cec5 975 val.Printf(wxT("hcBookmark_%i"), i);
4f9297b0 976 cfg->Write(val, m_BookmarksNames[i]);
0413cec5 977 val.Printf(wxT("hcBookmark_%i_url"), i);
4f9297b0 978 cfg->Write(val, m_BookmarksPages[i]);
382e6efe
VS
979 }
980 }
8ec2b484
HH
981
982 if (m_HtmlWin)
3e5296e7 983 m_HtmlWin->WriteCustomization(cfg);
8ec2b484
HH
984
985 if (path != wxEmptyString)
4f9297b0 986 cfg->SetPath(oldpath);
8ec2b484
HH
987}
988
989
83efdf33
VS
990
991
992
8eb2940f 993static void SetFontsToHtmlWin(wxHtmlWindow *win, wxString scalf, wxString fixf, int size)
83efdf33 994{
f6bcfd97 995 static int f_sizes[5][7] =
83efdf33 996 {
0646614d 997 { 6, 7, 9, 12, 14, 16, 19},
f151e8b5 998 { 8, 9, 12, 14, 16, 19, 22},
83efdf33 999 {10, 12, 14, 16, 19, 24, 32},
0646614d
VS
1000 {14, 16, 18, 24, 32, 38, 45},
1001 {16, 20, 24, 32, 38, 45, 50}
83efdf33 1002 };
f151e8b5 1003
4f9297b0 1004 win->SetFonts(scalf, fixf, f_sizes[size]);
83efdf33
VS
1005}
1006
1007
1008class wxHtmlHelpFrameOptionsDialog : public wxDialog
1009{
1010 public:
f151e8b5 1011 wxComboBox *NormalFont, *FixedFont;
83efdf33
VS
1012 wxRadioBox *RadioBox;
1013 wxHtmlWindow *TestWin;
1014
1015 wxHtmlHelpFrameOptionsDialog(wxWindow *parent) : wxDialog(parent, -1, wxString(_("Help Browser Options")))
1016 {
0646614d 1017 wxString choices[5] = {_("very small"), _("small"), _("medium"), _("large"), _("very large")};
8eb2940f 1018 wxBoxSizer *topsizer, *sizer, *sizer2;
83efdf33
VS
1019
1020 topsizer = new wxBoxSizer(wxVERTICAL);
1021
1022 sizer = new wxBoxSizer(wxHORIZONTAL);
1023
6f67eafe 1024 sizer2 = new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Normal font:")), wxVERTICAL);
4f9297b0 1025 sizer2->Add(NormalFont = new wxComboBox(this, -1, wxEmptyString, wxDefaultPosition,
f6bcfd97 1026 wxSize(200, 200),
382e6efe 1027 0, NULL, wxCB_DROPDOWN | wxCB_READONLY),
83efdf33
VS
1028 1, wxEXPAND | wxLEFT | wxRIGHT, 10);
1029
4f9297b0 1030 sizer->Add(sizer2, 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10);
83efdf33 1031
6f67eafe 1032 sizer2 = new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Fixed font:")), wxVERTICAL);
4f9297b0 1033 sizer2->Add(FixedFont = new wxComboBox(this, -1, wxEmptyString, wxDefaultPosition,
f6bcfd97
BP
1034 wxSize(200, 200),
1035 0, NULL, wxCB_DROPDOWN | wxCB_READONLY),
83efdf33
VS
1036 1, wxEXPAND | wxLEFT | wxRIGHT, 10);
1037
4f9297b0 1038 sizer->Add(sizer2, 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10);
83efdf33 1039
4f9297b0 1040 topsizer->Add(sizer);
83efdf33 1041
4f9297b0 1042 topsizer->Add(RadioBox = new wxRadioBox(this, -1, _("Font size:"),
f6bcfd97 1043 wxDefaultPosition, wxDefaultSize, 5, choices, 5),
6f67eafe 1044 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10);
f6bcfd97 1045
4f9297b0 1046 topsizer->Add(new wxStaticText(this, -1, _("Preview:")),
83efdf33 1047 0, wxLEFT | wxTOP, 10);
4f9297b0 1048 topsizer->Add(TestWin = new wxHtmlWindow(this, -1, wxDefaultPosition, wxSize(-1, 150)),
6f67eafe 1049 1, wxEXPAND | wxLEFT|wxTOP|wxRIGHT, 10);
83efdf33
VS
1050
1051 sizer = new wxBoxSizer(wxHORIZONTAL);
4f9297b0
VS
1052 sizer->Add(new wxButton(this, wxID_OK, _("OK")), 0, wxALL, 10);
1053 sizer->Add(new wxButton(this, wxID_CANCEL, _("Cancel")), 0, wxALL, 10);
1054 topsizer->Add(sizer, 0, wxALIGN_RIGHT);
83efdf33
VS
1055
1056 SetAutoLayout(TRUE);
1057 SetSizer(topsizer);
4f9297b0 1058 topsizer->Fit(this);
83efdf33
VS
1059 Centre(wxBOTH);
1060 }
f6bcfd97 1061
83efdf33
VS
1062
1063 void UpdateTestWin()
1064 {
1065 wxBusyCursor bcur;
f6bcfd97 1066 SetFontsToHtmlWin(TestWin,
4f9297b0
VS
1067 NormalFont->GetStringSelection(),
1068 FixedFont->GetStringSelection(),
1069 RadioBox->GetSelection());
1070 TestWin->SetPage(_(
f6bcfd97
BP
1071"<html><body>\
1072Normal face<br>(and <u>underlined</u>. <i>Italic face.</i> \
1073<b>Bold face.</b> <b><i>Bold italic face.</i></b><br>\
1074<font size=-2>font size -2</font><br>\
1075<font size=-1>font size -1</font><br>\
1076<font size=+0>font size +0</font><br>\
1077<font size=+1>font size +1</font><br>\
1078<font size=+2>font size +2</font><br>\
1079<font size=+3>font size +3</font><br>\
1080<font size=+4>font size +4</font><br>\
1081\
1082<p><tt>Fixed size face.<br> <b>bold</b> <i>italic</i> \
1083<b><i>bold italic <u>underlined</u></i></b><br>\
1084<font size=-2>font size -2</font><br>\
1085<font size=-1>font size -1</font><br>\
1086<font size=+0>font size +0</font><br>\
1087<font size=+1>font size +1</font><br>\
1088<font size=+2>font size +2</font><br>\
1089<font size=+3>font size +3</font><br>\
1090<font size=+4>font size +4</font></tt>\
1091</body></html>"
1092 ));
83efdf33
VS
1093 }
1094
33ac7e6f 1095 void OnUpdate(wxCommandEvent& WXUNUSED(event))
83efdf33
VS
1096 {
1097 UpdateTestWin();
1098 }
1099
1100 DECLARE_EVENT_TABLE()
1101};
1102
1103BEGIN_EVENT_TABLE(wxHtmlHelpFrameOptionsDialog, wxDialog)
f151e8b5 1104 EVT_COMBOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate)
83efdf33 1105 EVT_RADIOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate)
83efdf33
VS
1106END_EVENT_TABLE()
1107
1108
1109void wxHtmlHelpFrame::OptionsDialog()
1110{
1111 wxHtmlHelpFrameOptionsDialog dlg(this);
1112 unsigned i;
f6bcfd97 1113
da4cc40c 1114 if (m_NormalFonts == NULL)
4f9297b0 1115 {
83efdf33
VS
1116 wxFontEnumerator enu;
1117 enu.EnumerateFacenames();
1118 m_NormalFonts = new wxArrayString;
1119 *m_NormalFonts = *enu.GetFacenames();
4f9297b0 1120 m_NormalFonts->Sort();
83efdf33 1121 }
da4cc40c 1122 if (m_FixedFonts == NULL)
4f9297b0 1123 {
83efdf33
VS
1124 wxFontEnumerator enu;
1125 enu.EnumerateFacenames(wxFONTENCODING_SYSTEM, TRUE);
1126 m_FixedFonts = new wxArrayString;
1127 *m_FixedFonts = *enu.GetFacenames();
4f9297b0 1128 m_FixedFonts->Sort();
83efdf33 1129 }
f6bcfd97 1130
4f9297b0
VS
1131 for (i = 0; i < m_NormalFonts->GetCount(); i++)
1132 dlg.NormalFont->Append((*m_NormalFonts)[i]);
1133 for (i = 0; i < m_FixedFonts->GetCount(); i++)
1134 dlg.FixedFont->Append((*m_FixedFonts)[i]);
1135 if (!m_NormalFace.IsEmpty()) dlg.NormalFont->SetStringSelection(m_NormalFace);
1136 else dlg.NormalFont->SetSelection(0);
1137 if (!m_FixedFace.IsEmpty()) dlg.FixedFont->SetStringSelection(m_FixedFace);
1138 else dlg.FixedFont->SetSelection(0);
1139 dlg.RadioBox->SetSelection(m_FontSize);
83efdf33 1140 dlg.UpdateTestWin();
f6bcfd97 1141
da4cc40c 1142 if (dlg.ShowModal() == wxID_OK)
4f9297b0
VS
1143 {
1144 m_NormalFace = dlg.NormalFont->GetStringSelection();
1145 m_FixedFace = dlg.FixedFont->GetStringSelection();
1146 m_FontSize = dlg.RadioBox->GetSelection();
8eb2940f 1147 SetFontsToHtmlWin(m_HtmlWin, m_NormalFace, m_FixedFace, m_FontSize);
83efdf33
VS
1148 }
1149}
1150
1151
1152
0646614d
VS
1153void wxHtmlHelpFrame::NotifyPageChanged()
1154{
1155 if (m_UpdateContents && m_PagesHash)
1156 {
4f9297b0 1157 wxString an = m_HtmlWin->GetOpenedAnchor();
0646614d
VS
1158 wxHtmlHelpHashData *ha;
1159 if (an.IsEmpty())
4f9297b0 1160 ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage());
0646614d 1161 else
4f9297b0 1162 ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage() + wxT("#") + an);
0646614d
VS
1163 if (ha)
1164 {
1165 bool olduc = m_UpdateContents;
1166 m_UpdateContents = FALSE;
4f9297b0
VS
1167 m_ContentsBox->SelectItem(ha->m_Id);
1168 m_ContentsBox->EnsureVisible(ha->m_Id);
0646614d
VS
1169 m_UpdateContents = olduc;
1170 }
1171 }
1172}
1173
83efdf33
VS
1174
1175
8ec2b484
HH
1176/*
1177EVENT HANDLING :
1178*/
1179
1180
1181void wxHtmlHelpFrame::OnToolbar(wxCommandEvent& event)
1182{
da4cc40c 1183 switch (event.GetId())
4f9297b0 1184 {
8ec2b484 1185 case wxID_HTML_BACK :
4f9297b0 1186 m_HtmlWin->HistoryBack();
0646614d 1187 NotifyPageChanged();
8ec2b484 1188 break;
382e6efe 1189
8ec2b484 1190 case wxID_HTML_FORWARD :
4f9297b0 1191 m_HtmlWin->HistoryForward();
0646614d
VS
1192 NotifyPageChanged();
1193 break;
f6bcfd97
BP
1194
1195 case wxID_HTML_UP :
1196 if (m_PagesHash)
0646614d 1197 {
4f9297b0 1198 wxString an = m_HtmlWin->GetOpenedAnchor();
0646614d
VS
1199 wxHtmlHelpHashData *ha;
1200 if (an.IsEmpty())
4f9297b0 1201 ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage());
0646614d 1202 else
4f9297b0
VS
1203 ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage() + wxT("#") + an);
1204 if (ha && ha->m_Index > 0)
0646614d 1205 {
4f9297b0 1206 wxHtmlContentsItem *it = m_Data->GetContents() + (ha->m_Index - 1);
7df9fbc3
JS
1207 if (it->m_Page[0] != 0)
1208 {
468ae730 1209 m_HtmlWin->LoadPage(it->GetFullPath());
7df9fbc3
JS
1210 NotifyPageChanged();
1211 }
0646614d
VS
1212 }
1213 }
1214 break;
1215
f6bcfd97
BP
1216 case wxID_HTML_UPNODE :
1217 if (m_PagesHash)
0646614d 1218 {
4f9297b0 1219 wxString an = m_HtmlWin->GetOpenedAnchor();
0646614d
VS
1220 wxHtmlHelpHashData *ha;
1221 if (an.IsEmpty())
4f9297b0 1222 ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage());
0646614d 1223 else
4f9297b0
VS
1224 ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage() + wxT("#") + an);
1225 if (ha && ha->m_Index > 0)
0646614d 1226 {
4f9297b0 1227 int level = m_Data->GetContents()[ha->m_Index].m_Level - 1;
0646614d 1228 wxHtmlContentsItem *it;
4f9297b0 1229 int ind = ha->m_Index - 1;
f6bcfd97 1230
4f9297b0
VS
1231 it = m_Data->GetContents() + ind;
1232 while (ind >= 0 && it->m_Level != level) ind--, it--;
0646614d
VS
1233 if (ind >= 0)
1234 {
7df9fbc3
JS
1235 if (it->m_Page[0] != 0)
1236 {
468ae730 1237 m_HtmlWin->LoadPage(it->GetFullPath());
7df9fbc3
JS
1238 NotifyPageChanged();
1239 }
0646614d
VS
1240 }
1241 }
1242 }
1243 break;
1244
f6bcfd97
BP
1245 case wxID_HTML_DOWN :
1246 if (m_PagesHash)
0646614d 1247 {
4f9297b0 1248 wxString an = m_HtmlWin->GetOpenedAnchor();
721ab905 1249 wxString adr;
0646614d 1250 wxHtmlHelpHashData *ha;
f6bcfd97 1251
4f9297b0
VS
1252 if (an.IsEmpty()) adr = m_HtmlWin->GetOpenedPage();
1253 else adr = m_HtmlWin->GetOpenedPage() + wxT("#") + an;
721ab905 1254
4f9297b0 1255 ha = (wxHtmlHelpHashData*) m_PagesHash->Get(adr);
0646614d 1256
4f9297b0 1257 if (ha && ha->m_Index < m_Data->GetContentsCnt() - 1)
0646614d 1258 {
4f9297b0 1259 wxHtmlContentsItem *it = m_Data->GetContents() + (ha->m_Index + 1);
f6bcfd97 1260
468ae730 1261 while (it->GetFullPath() == adr) it++;
7df9fbc3
JS
1262
1263 if (it->m_Page[0] != 0)
1264 {
468ae730 1265 m_HtmlWin->LoadPage(it->GetFullPath());
7df9fbc3
JS
1266 NotifyPageChanged();
1267 }
0646614d
VS
1268 }
1269 }
8ec2b484 1270 break;
382e6efe 1271
8ec2b484 1272 case wxID_HTML_PANEL :
0646614d
VS
1273 {
1274 if (! (m_Splitter && m_NavigPan))
1275 return ;
da4cc40c 1276 if (m_Splitter->IsSplit())
3379ed37 1277 {
4f9297b0
VS
1278 m_Cfg.sashpos = m_Splitter->GetSashPosition();
1279 m_Splitter->Unsplit(m_NavigPan);
0646614d 1280 m_Cfg.navig_on = FALSE;
da4cc40c 1281 }
3379ed37
VZ
1282 else
1283 {
4f9297b0
VS
1284 m_NavigPan->Show(TRUE);
1285 m_HtmlWin->Show(TRUE);
1286 m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
0646614d
VS
1287 m_Cfg.navig_on = TRUE;
1288 }
8ec2b484
HH
1289 }
1290 break;
382e6efe 1291
83efdf33
VS
1292 case wxID_HTML_OPTIONS :
1293 OptionsDialog();
1294 break;
f6bcfd97
BP
1295
1296 case wxID_HTML_BOOKMARKSADD :
382e6efe
VS
1297 {
1298 wxString item;
1299 wxString url;
f6bcfd97 1300
4f9297b0
VS
1301 item = m_HtmlWin->GetOpenedPageTitle();
1302 url = m_HtmlWin->GetOpenedPage();
da4cc40c 1303 if (item == wxEmptyString)
3379ed37 1304 item = url.AfterLast(wxT('/'));
da4cc40c 1305 if (m_BookmarksPages.Index(url) == wxNOT_FOUND)
3379ed37 1306 {
4f9297b0 1307 m_Bookmarks->Append(item);
382e6efe
VS
1308 m_BookmarksNames.Add(item);
1309 m_BookmarksPages.Add(url);
1310 }
1311 }
1312 break;
f6bcfd97
BP
1313
1314 case wxID_HTML_BOOKMARKSREMOVE :
382e6efe
VS
1315 {
1316 wxString item;
1317 int pos;
f6bcfd97 1318
4f9297b0 1319 item = m_Bookmarks->GetStringSelection();
382e6efe 1320 pos = m_BookmarksNames.Index(item);
da4cc40c 1321 if (pos != wxNOT_FOUND)
3379ed37 1322 {
382e6efe
VS
1323 m_BookmarksNames.Remove(pos);
1324 m_BookmarksPages.Remove(pos);
4f9297b0 1325 m_Bookmarks->Delete(m_Bookmarks->GetSelection());
382e6efe
VS
1326 }
1327 }
1328 break;
0646614d
VS
1329
1330#if wxUSE_PRINTING_ARCHITECTURE
1331 case wxID_HTML_PRINT :
1332 {
f6bcfd97 1333 if (m_Printer == NULL)
0646614d 1334 m_Printer = new wxHtmlEasyPrinting(_("Help Printing"), this);
4f9297b0 1335 if (!m_HtmlWin->GetOpenedPage())
f5ba273e
VS
1336 wxLogWarning(_("Cannot print empty page."));
1337 else
4f9297b0 1338 m_Printer->PrintFile(m_HtmlWin->GetOpenedPage());
0646614d
VS
1339 }
1340 break;
1341#endif
1342
1343 case wxID_HTML_OPENFILE :
1344 {
f6bcfd97
BP
1345 wxString s = wxFileSelector(_("Open HTML document"),
1346 wxEmptyString,
1347 wxEmptyString,
1348 wxEmptyString,
1349 _(
1350"HTML files (*.htm)|*.htm|HTML files (*.html)|*.html|\
1351Help books (*.htb)|*.htb|Help books (*.zip)|*.zip|\
1352HTML Help Project (*.hhp)|*.hhp|\
1353All files (*.*)|*"
1354 ),
1355 wxOPEN | wxFILE_MUST_EXIST,
1356 this);
0646614d
VS
1357 if (!s.IsEmpty())
1358 {
1359 wxString ext = s.Right(4).Lower();
1360 if (ext == _T(".zip") || ext == _T(".htb") || ext == _T(".hhp"))
1361 {
1362 wxBusyCursor bcur;
4f9297b0 1363 m_Data->AddBook(s);
0646614d
VS
1364 RefreshLists();
1365 }
1366 else
4f9297b0 1367 m_HtmlWin->LoadPage(s);
0646614d
VS
1368 }
1369 }
1370 break;
8ec2b484
HH
1371 }
1372}
1373
1374
1375
1376void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent& event)
1377{
1378 wxHtmlHelpTreeItemData *pg;
0646614d 1379 wxHtmlContentsItem *it;
8ec2b484 1380
4f9297b0 1381 pg = (wxHtmlHelpTreeItemData*) m_ContentsBox->GetItemData(event.GetItem());
f6bcfd97
BP
1382
1383 if (pg && m_UpdateContents)
0646614d 1384 {
4f9297b0 1385 it = m_Data->GetContents() + (pg->m_Id);
0646614d 1386 m_UpdateContents = FALSE;
7df9fbc3 1387 if (it->m_Page[0] != 0)
468ae730 1388 m_HtmlWin->LoadPage(it->GetFullPath());
0646614d
VS
1389 m_UpdateContents = TRUE;
1390 }
8ec2b484
HH
1391}
1392
1393
1394
a4c97004 1395void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent& WXUNUSED(event))
8ec2b484 1396{
4f9297b0 1397 wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_IndexList->GetClientData(m_IndexList->GetSelection());
7df9fbc3 1398 if (it->m_Page[0] != 0)
468ae730 1399 m_HtmlWin->LoadPage(it->GetFullPath());
0646614d 1400 NotifyPageChanged();
8ec2b484
HH
1401}
1402
1403
f0b6a33f
VS
1404void wxHtmlHelpFrame::OnIndexFind(wxCommandEvent& event)
1405{
4f9297b0 1406 wxString sr = m_IndexText->GetLineText(0);
240c2873 1407 sr.MakeLower();
f6bcfd97 1408 if (sr == wxEmptyString)
4f9297b0 1409 {
f0b6a33f 1410 OnIndexAll(event);
4f9297b0 1411 }
da4cc40c 1412 else
4f9297b0 1413 {
f0b6a33f
VS
1414 wxBusyCursor bcur;
1415 const wxChar *cstr = sr.c_str();
33ac7e6f 1416 wxChar mybuff[512];
3379ed37 1417 wxChar *ptr;
f0b6a33f 1418 bool first = TRUE;
f6bcfd97 1419
f0b6a33f
VS
1420 m_IndexList->Clear();
1421 int cnt = m_Data->GetIndexCnt();
1422 wxHtmlContentsItem* index = m_Data->GetIndex();
1423
240c2873 1424 int displ = 0;
f0b6a33f 1425 for (int i = 0; i < cnt; i++)
240c2873
VS
1426 {
1427 wxStrncpy(mybuff, index[i].m_Name, 512);
f6bcfd97
BP
1428 mybuff[511] = _T('\0');
1429 for (ptr = mybuff; *ptr != 0; ptr++)
1430 if (*ptr >= _T('A') && *ptr <= _T('Z'))
1431 *ptr -= (wxChar)(_T('A') - _T('a'));
da4cc40c 1432 if (wxStrstr(mybuff, cstr) != NULL)
3379ed37 1433 {
4f9297b0 1434 m_IndexList->Append(index[i].m_Name, (char*)(index + i));
240c2873 1435 displ++;
da4cc40c 1436 if (first)
3379ed37 1437 {
7df9fbc3 1438 if (index[i].m_Page[0] != 0)
468ae730 1439 m_HtmlWin->LoadPage(index[i].GetFullPath());
0646614d 1440 NotifyPageChanged();
f0b6a33f
VS
1441 first = FALSE;
1442 }
1443 }
240c2873
VS
1444 }
1445
1446 wxString cnttext;
1447 cnttext.Printf(_("%i of %i"), displ, cnt);
4f9297b0 1448 m_IndexCountInfo->SetLabel(cnttext);
f0b6a33f 1449
4f9297b0
VS
1450 m_IndexText->SetSelection(0, sr.Length());
1451 m_IndexText->SetFocus();
f0b6a33f
VS
1452 }
1453}
1454
1455void wxHtmlHelpFrame::OnIndexAll(wxCommandEvent& WXUNUSED(event))
1456{
1457 wxBusyCursor bcur;
f6bcfd97 1458
f0b6a33f
VS
1459 m_IndexList->Clear();
1460 int cnt = m_Data->GetIndexCnt();
1461 bool first = TRUE;
1462 wxHtmlContentsItem* index = m_Data->GetIndex();
1463
da4cc40c 1464 for (int i = 0; i < cnt; i++)
4f9297b0
VS
1465 {
1466 m_IndexList->Append(index[i].m_Name, (char*)(index + i));
da4cc40c 1467 if (first)
3379ed37 1468 {
7df9fbc3 1469 if (index[i].m_Page[0] != 0)
468ae730 1470 m_HtmlWin->LoadPage(index[i].GetFullPath());
0646614d 1471 NotifyPageChanged();
f0b6a33f
VS
1472 first = FALSE;
1473 }
1474 }
240c2873
VS
1475
1476 wxString cnttext;
1477 cnttext.Printf(_("%i of %i"), cnt, cnt);
4f9297b0 1478 m_IndexCountInfo->SetLabel(cnttext);
f0b6a33f
VS
1479}
1480
8ec2b484 1481
a4c97004 1482void wxHtmlHelpFrame::OnSearchSel(wxCommandEvent& WXUNUSED(event))
8ec2b484 1483{
4f9297b0 1484 wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_SearchList->GetClientData(m_SearchList->GetSelection());
f6bcfd97 1485 if (it)
0646614d 1486 {
7df9fbc3 1487 if (it->m_Page[0] != 0)
468ae730 1488 m_HtmlWin->LoadPage(it->GetFullPath());
0646614d
VS
1489 NotifyPageChanged();
1490 }
8ec2b484
HH
1491}
1492
a4c97004 1493void wxHtmlHelpFrame::OnSearch(wxCommandEvent& WXUNUSED(event))
8ec2b484 1494{
4f9297b0 1495 wxString sr = m_SearchText->GetLineText(0);
8ec2b484
HH
1496
1497 if (sr != wxEmptyString) KeywordSearch(sr);
1498}
1499
382e6efe
VS
1500void wxHtmlHelpFrame::OnBookmarksSel(wxCommandEvent& WXUNUSED(event))
1501{
4f9297b0 1502 wxString sr = m_Bookmarks->GetStringSelection();
382e6efe 1503
ae80f837 1504 if (sr != wxEmptyString && sr != _("(bookmarks)"))
0646614d 1505 {
4f9297b0 1506 m_HtmlWin->LoadPage(m_BookmarksPages[m_BookmarksNames.Index(sr)]);
0646614d
VS
1507 NotifyPageChanged();
1508 }
382e6efe
VS
1509}
1510
8ec2b484
HH
1511void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent& evt)
1512{
68364659
VS
1513 GetSize(&m_Cfg.w, &m_Cfg.h);
1514 GetPosition(&m_Cfg.x, &m_Cfg.y);
5c172c17 1515
4f9297b0 1516 if (m_Splitter && m_Cfg.navig_on) m_Cfg.sashpos = m_Splitter->GetSashPosition();
68364659 1517
d5bb85a0
VS
1518 if (m_Config)
1519 WriteCustomization(m_Config, m_ConfigRoot);
68364659 1520
b4414c1f
JS
1521 if (m_helpController && m_helpController->IsKindOf(CLASSINFO(wxHtmlHelpController)))
1522 {
1523 ((wxHtmlHelpController*) m_helpController)->OnCloseFrame(evt);
1524 }
1525
8ec2b484
HH
1526 evt.Skip();
1527}
1528
1529BEGIN_EVENT_TABLE(wxHtmlHelpFrame, wxFrame)
ae80f837
VS
1530 EVT_TOOL_RANGE(wxID_HTML_PANEL, wxID_HTML_OPTIONS, wxHtmlHelpFrame::OnToolbar)
1531 EVT_BUTTON(wxID_HTML_BOOKMARKSREMOVE, wxHtmlHelpFrame::OnToolbar)
1532 EVT_BUTTON(wxID_HTML_BOOKMARKSADD, wxHtmlHelpFrame::OnToolbar)
8ec2b484
HH
1533 EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL, wxHtmlHelpFrame::OnContentsSel)
1534 EVT_LISTBOX(wxID_HTML_INDEXLIST, wxHtmlHelpFrame::OnIndexSel)
1535 EVT_LISTBOX(wxID_HTML_SEARCHLIST, wxHtmlHelpFrame::OnSearchSel)
1536 EVT_BUTTON(wxID_HTML_SEARCHBUTTON, wxHtmlHelpFrame::OnSearch)
1537 EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT, wxHtmlHelpFrame::OnSearch)
f0b6a33f
VS
1538 EVT_BUTTON(wxID_HTML_INDEXBUTTON, wxHtmlHelpFrame::OnIndexFind)
1539 EVT_TEXT_ENTER(wxID_HTML_INDEXTEXT, wxHtmlHelpFrame::OnIndexFind)
1540 EVT_BUTTON(wxID_HTML_INDEXBUTTONALL, wxHtmlHelpFrame::OnIndexAll)
382e6efe 1541 EVT_COMBOBOX(wxID_HTML_BOOKMARKSLIST, wxHtmlHelpFrame::OnBookmarksSel)
f6bcfd97 1542 EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow)
8ec2b484
HH
1543END_EVENT_TABLE()
1544
3379ed37
VZ
1545#endif // wxUSE_WXHTML_HELP
1546