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