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