]> git.saurik.com Git - wxWidgets.git/blame - src/html/helpfrm.cpp
removed show_progress argument in some private functions -- was never used
[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
26#if wxUSE_HTML
8ec2b484 27#ifndef WXPRECOMP
3096bd2f 28#include "wx/wx.h"
8ec2b484
HH
29#endif
30
31#include "wx/html/helpfrm.h"
32#include "wx/notebook.h"
33#include "wx/imaglist.h"
34#include "wx/treectrl.h"
35#include "wx/tokenzr.h"
36#include "wx/wfstream.h"
37#include "wx/html/htmlwin.h"
38#include "wx/busyinfo.h"
39#include "wx/progdlg.h"
2bd5bbc9 40#include "wx/toolbar.h"
83efdf33 41#include "wx/fontenum.h"
8ec2b484
HH
42
43// Bitmaps:
44
45#ifndef __WXMSW__
83efdf33
VS
46#include "bitmaps/wpanel.xpm"
47#include "bitmaps/wback.xpm"
48#include "bitmaps/wforward.xpm"
49#include "bitmaps/wbook.xpm"
50#include "bitmaps/woptions.xpm"
51#include "bitmaps/wfolder.xpm"
52#include "bitmaps/wpage.xpm"
53#include "bitmaps/whelp.xpm"
54#include "bitmaps/whlproot.xpm"
382e6efe
VS
55#include "bitmaps/wbkadd.xpm"
56#include "bitmaps/wbkdel.xpm"
8ec2b484
HH
57#endif
58
59#include "wx/stream.h"
60
61// number of times that the contents/index creation progress dialog
62// is updated.
d5bb85a0 63#define PROGRESS_STEP 40
8ec2b484 64
f0b6a33f
VS
65// what is considered "small index"?
66#define INDEX_IS_SMALL 100
67
68
8ec2b484 69//--------------------------------------------------------------------------
382e6efe 70// wxHtmlHelpTreeItemData (private)
8ec2b484
HH
71//--------------------------------------------------------------------------
72
73class wxHtmlHelpTreeItemData : public wxTreeItemData
74{
75 private:
76 wxString m_Page;
77
78 public:
d5bb85a0 79 wxHtmlHelpTreeItemData(wxHtmlContentsItem *it) : wxTreeItemData()
382e6efe
VS
80 {
81 m_Page = it -> m_Book -> GetBasePath() + it -> m_Page;
82 }
d5bb85a0 83 const wxString& GetPage() { return m_Page; }
8ec2b484
HH
84};
85
382e6efe
VS
86
87
88
8ec2b484
HH
89//---------------------------------------------------------------------------
90// wxHtmlHelpFrame
91//---------------------------------------------------------------------------
92
93IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpFrame, wxFrame)
94
95wxHtmlHelpFrame::wxHtmlHelpFrame(wxWindow* parent, wxWindowID id, const wxString& title,
d5bb85a0 96 int style, wxHtmlHelpData* data)
8ec2b484
HH
97{
98 Init(data);
99 Create(parent, id, title, style);
100}
d5bb85a0 101
8ec2b484
HH
102void wxHtmlHelpFrame::Init(wxHtmlHelpData* data)
103{
104 if (data) {
d5bb85a0
VS
105 m_Data = data;
106 m_DataCreated = FALSE;
107 } else {
108 m_Data = new wxHtmlHelpData();
109 m_DataCreated = TRUE;
8ec2b484
HH
110 }
111
68364659 112 m_ContentsImageList = new wxImageList(16, 16);
83efdf33
VS
113 m_ContentsImageList -> Add(wxICON(wbook));
114 m_ContentsImageList -> Add(wxICON(wfolder));
115 m_ContentsImageList -> Add(wxICON(wpage));
116 m_ContentsImageList -> Add(wxICON(whlproot));
8ec2b484
HH
117
118 m_ContentsBox = NULL;
f0b6a33f
VS
119 m_IndexList = NULL;
120 m_IndexButton = NULL;
121 m_IndexButtonAll = NULL;
122 m_IndexText = NULL;
8ec2b484
HH
123 m_SearchList = NULL;
124 m_SearchButton = NULL;
125 m_SearchText = NULL;
126 m_SearchChoice = NULL;
240c2873 127 m_IndexCountInfo = NULL;
8ec2b484
HH
128 m_Splitter = NULL;
129 m_NavigPan = NULL;
130 m_HtmlWin = NULL;
382e6efe 131 m_Bookmarks = NULL;
c4971147
VS
132 m_SearchCaseSensitive = NULL;
133 m_SearchWholeWords = NULL;
134
8ec2b484
HH
135 m_Config = NULL;
136 m_ConfigRoot = wxEmptyString;
137
138 m_Cfg.x = m_Cfg.y = 0;
d5bb85a0
VS
139 m_Cfg.w = 700;
140 m_Cfg.h = 480;
8ec2b484
HH
141 m_Cfg.sashpos = 240;
142 m_Cfg.navig_on = TRUE;
83efdf33
VS
143
144 m_NormalFonts = m_FixedFonts = NULL;
145 m_FontSize = 1;
146 m_NormalFace = m_FixedFace = wxEmptyString;
8ec2b484
HH
147}
148
d5bb85a0
VS
149// Create: builds the GUI components.
150// with the style flag it's possible to toggle the toolbar, contents, index and search
151// controls.
152// m_HtmlWin will *always* be created, but it's important to realize that
f0b6a33f 153// m_ContentsBox, m_IndexList, m_SearchList, m_SearchButton, m_SearchText and
d5bb85a0
VS
154// m_SearchButton may be NULL.
155// moreover, if no contents, index or searchpage is needed, m_Splitter and
156// m_NavigPan will be NULL too (with m_HtmlWin directly connected to the frame)
157
8ec2b484 158bool wxHtmlHelpFrame::Create(wxWindow* parent, wxWindowID id, const wxString& title,
d5bb85a0 159 int style)
8ec2b484
HH
160{
161 // Do the config in two steps. We read the HtmlWindow customization after we
162 // create the window.
d5bb85a0
VS
163 if (m_Config)
164 ReadCustomization(m_Config, m_ConfigRoot);
8ec2b484 165
8eb2940f 166 wxFrame::Create(parent, id, _("Help"), wxPoint(m_Cfg.x, m_Cfg.y), wxSize(m_Cfg.w, m_Cfg.h), wxDEFAULT_FRAME_STYLE, "wxHtmlHelp");
8ec2b484 167
5c172c17
VS
168 GetPosition(&m_Cfg.x, &m_Cfg.y);
169
83efdf33 170 SetIcon(wxICON(whelp));
9ffdee80 171
8ec2b484
HH
172 int notebook_page = 0;
173
174 CreateStatusBar();
175
176 // toolbar?
177 if (style & wxHF_TOOLBAR) {
83efdf33 178 wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_DOCKABLE);
00655497 179 toolBar->SetMargins( 2, 2 );
d5bb85a0 180
83efdf33
VS
181 toolBar -> AddTool(wxID_HTML_PANEL, wxBITMAP(wpanel), wxNullBitmap,
182 FALSE, -1, -1, (wxObject *) NULL,
d5bb85a0 183 _("Show/hide navigation panel"));
d5bb85a0 184 toolBar -> AddSeparator();
83efdf33
VS
185 toolBar -> AddTool(wxID_HTML_BACK, wxBITMAP(wback), wxNullBitmap,
186 FALSE, -1, -1, (wxObject *) NULL,
d5bb85a0 187 _("Go back to the previous HTML page"));
83efdf33
VS
188 toolBar -> AddTool(wxID_HTML_FORWARD, wxBITMAP(wforward), wxNullBitmap,
189 FALSE, -1, -1, (wxObject *) NULL,
d5bb85a0 190 _("Go forward to the next HTML page"));
382e6efe
VS
191 toolBar -> AddSeparator();
192
193 if (style & wxHF_BOOKMARKS) {
194 m_Bookmarks = new wxComboBox(toolBar, wxID_HTML_BOOKMARKSLIST, wxEmptyString,
d984207c 195 wxDefaultPosition, wxSize(300,-1), 0, NULL, wxCB_READONLY | wxCB_SORT);
382e6efe
VS
196 m_Bookmarks -> Append(_("<bookmarks>"));
197 for (unsigned i = 0; i < m_BookmarksNames.GetCount(); i++)
198 m_Bookmarks -> Append(m_BookmarksNames[i]);
199 m_Bookmarks -> SetSelection(0);
200 toolBar -> AddControl(m_Bookmarks);
00655497
RR
201#ifdef __WXGTK__
202 toolBar -> AddSeparator();
203#endif
382e6efe
VS
204 toolBar -> AddTool(wxID_HTML_BOOKMARKSADD, wxBITMAP(wbkadd), wxNullBitmap,
205 FALSE, -1, -1, (wxObject *) NULL,
206 _("Add current page to bookmarks"));
207 toolBar -> AddTool(wxID_HTML_BOOKMARKSREMOVE, wxBITMAP(wbkdel), wxNullBitmap,
208 FALSE, -1, -1, (wxObject *) NULL,
209 _("Remove current page from bookmarks"));
210 }
d5bb85a0 211
83efdf33
VS
212 toolBar -> AddSeparator();
213 toolBar -> AddTool(wxID_HTML_OPTIONS, wxBITMAP(woptions), wxNullBitmap,
214 FALSE, -1, -1, (wxObject *) NULL,
215 _("Display options dialog"));
d5bb85a0 216
83efdf33 217 toolBar -> Realize();
8ec2b484 218 }
d5bb85a0 219
8ec2b484 220 if (style & (wxHF_CONTENTS | wxHF_INDEX | wxHF_SEARCH)) {
d5bb85a0
VS
221 // traditional help controller; splitter window with html page on the
222 // right and a notebook containing various pages on the left
223 m_Splitter = new wxSplitterWindow(this);
224
225 m_HtmlWin = new wxHtmlWindow(m_Splitter);
226 m_NavigPan = new wxNotebook(m_Splitter, wxID_HTML_NOTEBOOK,
227 wxDefaultPosition, wxDefaultSize);
228 } else { // only html window, no notebook with index,contents etc
229 m_HtmlWin = new wxHtmlWindow(this);
8ec2b484
HH
230 }
231
232 m_HtmlWin -> SetRelatedFrame(this, m_TitleFormat);
233 m_HtmlWin -> SetRelatedStatusBar(0);
d5bb85a0
VS
234 if (m_Config)
235 m_HtmlWin -> ReadCustomization(m_Config, m_ConfigRoot);
8ec2b484
HH
236
237 // contents tree panel?
238 if (style & wxHF_CONTENTS) {
d5bb85a0
VS
239 m_ContentsBox = new wxTreeCtrl(m_NavigPan, wxID_HTML_TREECTRL,
240 wxDefaultPosition, wxDefaultSize,
241 wxTR_HAS_BUTTONS | wxSUNKEN_BORDER);
242 m_ContentsBox -> SetImageList(m_ContentsImageList);
243 m_NavigPan -> AddPage(m_ContentsBox, _("Contents"));
244 m_ContentsPage = notebook_page++;
8ec2b484
HH
245 }
246
247 // index listbox panel?
248 if (style & wxHF_INDEX) {
d5bb85a0 249 wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_INDEXPAGE);
f0b6a33f 250
d5bb85a0 251 wxLayoutConstraints *b1 = new wxLayoutConstraints;
f0b6a33f
VS
252 m_IndexText = new wxTextCtrl(dummy, wxID_HTML_INDEXTEXT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
253 b1 -> top.SameAs (dummy, wxTop, 10);
254 b1 -> left.SameAs (dummy, wxLeft, 10);
255 b1 -> right.SameAs (dummy, wxRight, 10);
256 b1 -> height.AsIs();
257 m_IndexText -> SetConstraints(b1);
258
259 wxLayoutConstraints *b4 = new wxLayoutConstraints;
260 m_IndexButtonAll = new wxButton(dummy, wxID_HTML_INDEXBUTTONALL, _("Show all"));
7618e374 261
f0b6a33f
VS
262 b4 -> top.Below (m_IndexText, 10);
263 b4 -> right.SameAs (dummy, wxRight, 10);
264 b4 -> width.AsIs();
265 b4 -> height.AsIs();
266 m_IndexButtonAll -> SetConstraints(b4);
267
268 wxLayoutConstraints *b2 = new wxLayoutConstraints;
269 m_IndexButton = new wxButton(dummy, wxID_HTML_INDEXBUTTON, _("Find"));
f0b6a33f
VS
270 b2 -> top.Below (m_IndexText, 10);
271 b2 -> right.LeftOf (m_IndexButtonAll, 10);
272 b2 -> width.AsIs();
273 b2 -> height.AsIs();
274 m_IndexButton -> SetConstraints(b2);
275
240c2873
VS
276 wxLayoutConstraints *b5 = new wxLayoutConstraints;
277 m_IndexCountInfo = new wxStaticText(dummy, wxID_HTML_COUNTINFO, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
278
279 b5 -> top.Below (m_IndexButton, 5);
280 b5 -> right.SameAs (dummy, wxRight, 10);
281 b5 -> left.SameAs (dummy, wxLeft, 10);
282 b5 -> height.AsIs();
283 m_IndexCountInfo -> SetConstraints(b5);
284
f0b6a33f
VS
285 wxLayoutConstraints *b3 = new wxLayoutConstraints;
286 m_IndexList = new wxListBox(dummy, wxID_HTML_INDEXLIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE | wxLB_ALWAYS_SB);
240c2873 287 b3 -> top.Below (m_IndexCountInfo, 5);
f0b6a33f
VS
288 b3 -> left.SameAs (dummy, wxLeft, 0);
289 b3 -> right.SameAs (dummy, wxRight, 0);
290 b3 -> bottom.SameAs (dummy, wxBottom, 0);
291 m_IndexList -> SetConstraints(b3);
292
7618e374
VS
293#if wxUSE_TOOLTIPS
294 m_IndexButtonAll -> SetToolTip(_("Show all items in index"));
240c2873 295 m_IndexButton -> SetToolTip(_("Display all index items that contain given substring. Search is case insensitive."));
7618e374
VS
296#endif //wxUSE_TOOLTIPS
297
d5bb85a0 298 dummy -> SetAutoLayout(TRUE);
f0b6a33f
VS
299 dummy -> Layout();
300
d5bb85a0
VS
301 m_NavigPan -> AddPage(dummy, _("Index"));
302 m_IndexPage = notebook_page++;
8ec2b484
HH
303 }
304
305 // search list panel?
306 if (style & wxHF_SEARCH) {
d5bb85a0
VS
307 wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_SEARCHPAGE);
308
309 wxLayoutConstraints *b1 = new wxLayoutConstraints;
f0b6a33f 310 m_SearchText = new wxTextCtrl(dummy, wxID_HTML_SEARCHTEXT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
d5bb85a0
VS
311 b1 -> top.SameAs (dummy, wxTop, 10);
312 b1 -> left.SameAs (dummy, wxLeft, 10);
313 b1 -> right.SameAs (dummy, wxRight, 10);
314 b1 -> height.AsIs();
315 m_SearchText -> SetConstraints(b1);
316
317 wxLayoutConstraints *b2 = new wxLayoutConstraints;
318 m_SearchButton = new wxButton(dummy, wxID_HTML_SEARCHBUTTON, _("Search"));
7618e374 319#if wxUSE_TOOLTIPS
f0b6a33f 320 m_SearchButton -> SetToolTip(_("Search contents of help book(s) for all occurences of the text you typed above"));
7618e374 321#endif //wxUSE_TOOLTIPS
d5bb85a0
VS
322 b2 -> top.Below (m_SearchText, 10);
323 b2 -> left.SameAs (dummy, wxLeft, 10);
324 b2 -> width.AsIs();
325 b2 -> height.AsIs();
326 m_SearchButton -> SetConstraints(b2);
327
d5bb85a0
VS
328 wxLayoutConstraints *b4 = new wxLayoutConstraints;
329 m_SearchChoice = new wxChoice(dummy, wxID_HTML_SEARCHCHOICE, wxDefaultPosition,
330 wxDefaultSize);
331 b4 -> top.Below (m_SearchText, 10);
332 b4 -> left.SameAs (m_SearchButton, wxRight, 10);
333 b4 -> right.SameAs (dummy, wxRight, 10);
334 b4 -> height.AsIs();
335 m_SearchChoice -> SetConstraints(b4);
336
c4971147
VS
337 wxLayoutConstraints *b5 = new wxLayoutConstraints;
338 m_SearchCaseSensitive = new wxCheckBox(dummy, -1, _("Case sensitive"));
339 b5 -> top.Below (m_SearchButton, 10);
340 b5 -> left.SameAs (dummy, wxLeft, 10);
341 b5 -> right.SameAs (dummy, wxRight, 10);
342 b5 -> height.AsIs ();
343 m_SearchCaseSensitive -> SetConstraints(b5);
344
345 wxLayoutConstraints *b6 = new wxLayoutConstraints;
346 m_SearchWholeWords = new wxCheckBox(dummy, -1, _("Whole words only"));
347 b6 -> top.Below (m_SearchCaseSensitive, 0);
348 b6 -> left.SameAs (dummy, wxLeft, 10);
349 b6 -> right.SameAs (dummy, wxRight, 10);
350 b6 -> height.AsIs ();
351 m_SearchWholeWords -> SetConstraints(b6);
352
954269e6 353 wxLayoutConstraints *b3 = new wxLayoutConstraints;
f0b6a33f 354 m_SearchList = new wxListBox(dummy, wxID_HTML_SEARCHLIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE | wxLB_ALWAYS_SB);
c4971147 355 b3 -> top.Below (m_SearchWholeWords, 10);
954269e6
VS
356 b3 -> left.SameAs (dummy, wxLeft, 0);
357 b3 -> right.SameAs (dummy, wxRight, 0);
358 b3 -> bottom.SameAs (dummy, wxBottom, 0);
359 m_SearchList -> SetConstraints(b3);
360
d5bb85a0
VS
361 dummy -> SetAutoLayout(TRUE);
362 dummy -> Layout();
363 m_NavigPan -> AddPage(dummy, _("Search"));
364 m_SearchPage = notebook_page++;
8ec2b484 365 }
c32bfc10 366 m_HtmlWin -> Show(TRUE);
8ec2b484 367
b5a7b000 368 RefreshLists();
8ec2b484
HH
369
370 // showtime
371 if (m_NavigPan && m_Splitter) {
d5bb85a0 372 m_Splitter -> SetMinimumPaneSize(20);
f38374d0
DW
373 if (m_Cfg.navig_on)
374 m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
375 else {
376 m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
377 m_Splitter -> Unsplit();
378 }
c32bfc10
VS
379 if (m_Cfg.navig_on) {
380 m_NavigPan -> Show(TRUE);
d5bb85a0 381 m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
c32bfc10 382 }
68364659 383 else {
c32bfc10
VS
384 m_NavigPan -> Show(FALSE);
385 m_Splitter -> Initialize(m_HtmlWin);
68364659 386 }
8ec2b484 387 }
8ec2b484
HH
388 return TRUE;
389}
390
391wxHtmlHelpFrame::~wxHtmlHelpFrame()
392{
393 delete m_ContentsImageList;
394 if (m_DataCreated)
d5bb85a0 395 delete m_Data;
83efdf33
VS
396 if (m_NormalFonts) delete m_NormalFonts;
397 if (m_FixedFonts) delete m_FixedFonts;
8ec2b484
HH
398}
399
400bool wxHtmlHelpFrame::Display(const wxString& x)
401{
402 wxString url = m_Data->FindPageByName(x);
403 if (! url.IsEmpty()) {
d5bb85a0
VS
404 m_HtmlWin->LoadPage(url);
405 return TRUE;
8ec2b484
HH
406 }
407 return FALSE;
408}
409
410bool wxHtmlHelpFrame::Display(const int id)
411{
412 wxString url = m_Data->FindPageById(id);
413 if (! url.IsEmpty()) {
d5bb85a0
VS
414 m_HtmlWin->LoadPage(url);
415 return TRUE;
8ec2b484
HH
416 }
417 return FALSE;
418}
419
420
421
422bool wxHtmlHelpFrame::DisplayContents()
423{
424 if (! m_ContentsBox)
d5bb85a0 425 return FALSE;
8ec2b484 426 if (!m_Splitter -> IsSplit()) {
d5bb85a0
VS
427 m_NavigPan -> Show(TRUE);
428 m_HtmlWin -> Show(TRUE);
429 m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
c32bfc10 430 m_Cfg.navig_on = TRUE;
8ec2b484
HH
431 }
432 m_NavigPan -> SetSelection(0);
433 return TRUE;
434}
435
436
437
438bool wxHtmlHelpFrame::DisplayIndex()
439{
f0b6a33f 440 if (! m_IndexList)
d5bb85a0 441 return FALSE;
8ec2b484 442 if (!m_Splitter -> IsSplit()) {
d5bb85a0
VS
443 m_NavigPan -> Show(TRUE);
444 m_HtmlWin -> Show(TRUE);
445 m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
8ec2b484
HH
446 }
447 m_NavigPan -> SetSelection(1);
448 return TRUE;
449}
450
451bool wxHtmlHelpFrame::KeywordSearch(const wxString& keyword)
452{
453 if (! (m_SearchList && m_SearchButton && m_SearchText && m_SearchChoice))
d5bb85a0 454 return FALSE;
8ec2b484 455
c4971147 456 int foundcnt = 0, curi;
8ec2b484
HH
457 wxString foundstr;
458 wxString book = wxEmptyString;
459
460 if (!m_Splitter -> IsSplit()) {
d5bb85a0
VS
461 m_NavigPan -> Show(TRUE);
462 m_HtmlWin -> Show(TRUE);
463 m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
8ec2b484
HH
464 }
465 m_NavigPan -> SetSelection(m_SearchPage);
466 m_SearchList -> Clear();
467 m_SearchText -> SetValue(keyword);
468 m_SearchButton -> Enable(FALSE);
469
470 if (m_SearchChoice->GetSelection() != 0)
d5bb85a0 471 book = m_SearchChoice->GetStringSelection();
8ec2b484 472
c4971147
VS
473 wxHtmlSearchStatus status(m_Data, keyword,
474 m_SearchCaseSensitive -> GetValue(), m_SearchWholeWords -> GetValue(),
475 book);
8ec2b484 476
d5bb85a0
VS
477 wxProgressDialog progress(_("Searching..."), _("No matching page found yet"),
478 status.GetMaxIndex(), this,
2686e01b 479 wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_AUTO_HIDE | wxGA_SMOOTH);
8ec2b484
HH
480
481 while (status.IsActive()) {
c4971147 482 curi = status.GetCurIndex();
b5a7b000 483 if (curi % 32 == 0 && progress.Update(curi) == FALSE)
d5bb85a0
VS
484 break;
485 if (status.Search()) {
486 foundstr.Printf(_("Found %i matches"), ++foundcnt);
487 progress.Update(status.GetCurIndex(), foundstr);
488 m_SearchList -> Append(status.GetName(), status.GetContentsItem());
489 }
8ec2b484
HH
490 }
491
492 m_SearchButton -> Enable(TRUE);
493 m_SearchText -> SetSelection(0, keyword.Length());
494 m_SearchText -> SetFocus();
495 if (foundcnt) {
496 wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_SearchList -> GetClientData(0);
497 if (it) m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page);
498 }
499 return (foundcnt > 0);
500}
501
502#define MAX_ROOTS 64
503
b5a7b000 504void wxHtmlHelpFrame::CreateContents()
8ec2b484
HH
505{
506 if (! m_ContentsBox)
d5bb85a0 507 return ;
8ec2b484 508
8ec2b484
HH
509 m_ContentsBox->Clear();
510
511 int cnt = m_Data->GetContentsCnt();
8ec2b484
HH
512 int i;
513
83efdf33 514 wxHtmlContentsItem *it;
d5bb85a0 515
8ec2b484
HH
516 wxTreeItemId roots[MAX_ROOTS];
517 bool imaged[MAX_ROOTS];
518
519 m_ContentsBox -> DeleteAllItems();
520 roots[0] = m_ContentsBox -> AddRoot(_("(Help)"));
5c172c17
VS
521 m_ContentsBox -> SetItemImage(roots[0], IMG_RootFolder);
522 m_ContentsBox -> SetItemSelectedImage(roots[0], IMG_RootFolder);
8ec2b484
HH
523 imaged[0] = TRUE;
524
83efdf33 525 for (it = m_Data->GetContents(), i = 0; i < cnt; i++, it++) {
382e6efe 526 roots[it -> m_Level + 1] = m_ContentsBox -> AppendItem(
d5bb85a0
VS
527 roots[it -> m_Level], it -> m_Name, IMG_Page, -1,
528 new wxHtmlHelpTreeItemData(it));
8ec2b484
HH
529
530 if (it -> m_Level == 0) {
531 m_ContentsBox -> SetItemBold(roots[1], TRUE);
532 m_ContentsBox -> SetItemImage(roots[1], IMG_Book);
533 m_ContentsBox -> SetItemSelectedImage(roots[1], IMG_Book);
534 imaged[1] = TRUE;
d5bb85a0 535 } else imaged[it -> m_Level + 1] = FALSE;
8ec2b484
HH
536
537 if (!imaged[it -> m_Level]) {
538 m_ContentsBox -> SetItemImage(roots[it -> m_Level], IMG_Folder);
539 m_ContentsBox -> SetItemSelectedImage(roots[it -> m_Level], IMG_Folder);
540 imaged[it -> m_Level] = TRUE;
541 }
542 }
8ec2b484
HH
543 m_ContentsBox -> Expand(roots[0]);
544}
545
546
b5a7b000 547void wxHtmlHelpFrame::CreateIndex()
8ec2b484 548{
f0b6a33f 549 if (! m_IndexList)
d5bb85a0 550 return ;
8ec2b484 551
f0b6a33f 552 m_IndexList->Clear();
8ec2b484
HH
553
554 int cnt = m_Data->GetIndexCnt();
f0b6a33f 555
240c2873
VS
556 wxString cnttext;
557 if (cnt > INDEX_IS_SMALL) cnttext.Printf(_("%i of %i"), 0, cnt);
558 else cnttext.Printf(_("%i of %i"), cnt, cnt);
559 m_IndexCountInfo -> SetLabel(cnttext);
f0b6a33f
VS
560 if (cnt > INDEX_IS_SMALL) return;
561
8ec2b484
HH
562 wxHtmlContentsItem* index = m_Data->GetIndex();
563
b5a7b000 564 for (int i = 0; i < cnt; i++)
f0b6a33f 565 m_IndexList -> Append(index[i].m_Name, (char*)(index + i));
8ec2b484
HH
566}
567
568void wxHtmlHelpFrame::CreateSearch()
569{
570 if (! (m_SearchList && m_SearchChoice))
d5bb85a0 571 return ;
8ec2b484
HH
572 m_SearchList -> Clear();
573 m_SearchChoice -> Clear();
574 m_SearchChoice -> Append(_("all books"));
575 const wxHtmlBookRecArray& bookrec = m_Data->GetBookRecArray();
576 int i, cnt = bookrec.GetCount();
d5bb85a0
VS
577 for (i = 0; i < cnt; i++)
578 m_SearchChoice->Append(bookrec[i].GetTitle());
8ec2b484
HH
579 m_SearchChoice->SetSelection(0);
580}
581
582
b5a7b000 583void wxHtmlHelpFrame::RefreshLists()
8ec2b484 584{
b5a7b000
VS
585 CreateContents();
586 CreateIndex();
8ec2b484
HH
587 CreateSearch();
588}
589
590void wxHtmlHelpFrame::ReadCustomization(wxConfigBase *cfg, const wxString& path)
591{
592 wxString oldpath;
593 wxString tmp;
594
595 if (path != wxEmptyString) {
596 oldpath = cfg -> GetPath();
3e5296e7 597 cfg -> SetPath(_T("/") + path);
8ec2b484
HH
598 }
599
600 m_Cfg.navig_on = cfg -> Read("hcNavigPanel", m_Cfg.navig_on) != 0;
601 m_Cfg.sashpos = cfg -> Read("hcSashPos", m_Cfg.sashpos);
602 m_Cfg.x = cfg -> Read("hcX", m_Cfg.x);
603 m_Cfg.y = cfg -> Read("hcY", m_Cfg.y);
604 m_Cfg.w = cfg -> Read("hcW", m_Cfg.w);
605 m_Cfg.h = cfg -> Read("hcH", m_Cfg.h);
8ec2b484 606
83efdf33
VS
607 m_FixedFace = cfg -> Read("hcFixedFace", m_FixedFace);
608 m_NormalFace = cfg -> Read("hcNormalFace", m_NormalFace);
609 m_FontSize = cfg -> Read("hcFontSize", m_FontSize);
83efdf33 610
382e6efe
VS
611 {
612 int i;
613 int cnt;
614 wxString val, s;
615
616 cnt = cfg -> Read("hcBookmarksCnt", 0L);
617 if (cnt != 0) {
618 m_BookmarksNames.Clear();
619 m_BookmarksPages.Clear();
620 if (m_Bookmarks) {
621 m_Bookmarks -> Clear();
622 m_Bookmarks -> Append(_("<bookmarks>"));
623 }
624
625 for (i = 0; i < cnt; i++) {
0413cec5 626 val.Printf(wxT("hcBookmark_%i"), i);
382e6efe
VS
627 s = cfg -> Read(val);
628 m_BookmarksNames.Add(s);
629 if (m_Bookmarks) m_Bookmarks -> Append(s);
0413cec5 630 val.Printf(wxT("hcBookmark_%i_url"), i);
382e6efe
VS
631 s = cfg -> Read(val);
632 m_BookmarksPages.Add(s);
633 }
634 }
635 }
636
8ec2b484 637 if (m_HtmlWin)
3e5296e7 638 m_HtmlWin->ReadCustomization(cfg);
8ec2b484
HH
639
640 if (path != wxEmptyString)
641 cfg -> SetPath(oldpath);
642}
643
644void wxHtmlHelpFrame::WriteCustomization(wxConfigBase *cfg, const wxString& path)
645{
646 wxString oldpath;
647 wxString tmp;
8ec2b484
HH
648
649 if (path != wxEmptyString) {
650 oldpath = cfg -> GetPath();
3e5296e7 651 cfg -> SetPath(_T("/") + path);
8ec2b484
HH
652 }
653
654 cfg -> Write("hcNavigPanel", m_Cfg.navig_on);
655 cfg -> Write("hcSashPos", (long)m_Cfg.sashpos);
656 cfg -> Write("hcX", (long)m_Cfg.x);
657 cfg -> Write("hcY", (long)m_Cfg.y);
658 cfg -> Write("hcW", (long)m_Cfg.w);
659 cfg -> Write("hcH", (long)m_Cfg.h);
83efdf33
VS
660 cfg -> Write("hcFixedFace", m_FixedFace);
661 cfg -> Write("hcNormalFace", m_NormalFace);
662 cfg -> Write("hcFontSize", (long)m_FontSize);
382e6efe
VS
663
664 if (m_Bookmarks) {
665 int i;
666 int cnt = m_BookmarksNames.GetCount();
667 wxString val;
668
669 cfg -> Write("hcBookmarksCnt", (long)cnt);
670 for (i = 0; i < cnt; i++) {
0413cec5 671 val.Printf(wxT("hcBookmark_%i"), i);
382e6efe 672 cfg -> Write(val, m_BookmarksNames[i]);
0413cec5 673 val.Printf(wxT("hcBookmark_%i_url"), i);
382e6efe
VS
674 cfg -> Write(val, m_BookmarksPages[i]);
675 }
676 }
8ec2b484
HH
677
678 if (m_HtmlWin)
3e5296e7 679 m_HtmlWin->WriteCustomization(cfg);
8ec2b484
HH
680
681 if (path != wxEmptyString)
682 cfg -> SetPath(oldpath);
683}
684
685
83efdf33
VS
686
687
688
8eb2940f 689static void SetFontsToHtmlWin(wxHtmlWindow *win, wxString scalf, wxString fixf, int size)
83efdf33 690{
83efdf33
VS
691 static int f_sizes[3][7] =
692 {
f151e8b5 693 { 8, 9, 12, 14, 16, 19, 22},
83efdf33 694 {10, 12, 14, 16, 19, 24, 32},
83efdf33
VS
695 {14, 16, 18, 24, 32, 38, 45}
696 };
f151e8b5 697
8eb2940f 698 win -> SetFonts(scalf, fixf, f_sizes[size]);
83efdf33
VS
699}
700
701
702class wxHtmlHelpFrameOptionsDialog : public wxDialog
703{
704 public:
f151e8b5 705 wxComboBox *NormalFont, *FixedFont;
83efdf33
VS
706 wxRadioBox *RadioBox;
707 wxHtmlWindow *TestWin;
708
709 wxHtmlHelpFrameOptionsDialog(wxWindow *parent) : wxDialog(parent, -1, wxString(_("Help Browser Options")))
710 {
f151e8b5 711 wxString choices[3] = {_("small"), _("medium"), _("large")};
8eb2940f 712 wxBoxSizer *topsizer, *sizer, *sizer2;
83efdf33
VS
713
714 topsizer = new wxBoxSizer(wxVERTICAL);
715
716 sizer = new wxBoxSizer(wxHORIZONTAL);
717
6f67eafe 718 sizer2 = new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Normal font:")), wxVERTICAL);
382e6efe 719 sizer2 -> Add(NormalFont = new wxComboBox(this, -1, wxEmptyString, wxDefaultPosition,
382e6efe 720 wxSize(200, 200),
382e6efe 721 0, NULL, wxCB_DROPDOWN | wxCB_READONLY),
83efdf33
VS
722 1, wxEXPAND | wxLEFT | wxRIGHT, 10);
723
6f67eafe 724 sizer -> Add(sizer2, 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10);
83efdf33 725
6f67eafe 726 sizer2 = new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Fixed font:")), wxVERTICAL);
382e6efe 727 sizer2 -> Add(FixedFont = new wxComboBox(this, -1, wxEmptyString, wxDefaultPosition,
382e6efe 728 wxSize(200, 200),
382e6efe 729 0, NULL, wxCB_DROPDOWN | wxCB_READONLY),
83efdf33
VS
730 1, wxEXPAND | wxLEFT | wxRIGHT, 10);
731
6f67eafe 732 sizer -> Add(sizer2, 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10);
83efdf33
VS
733
734 topsizer -> Add(sizer);
735
736 topsizer -> Add(RadioBox = new wxRadioBox(this, -1, _("Font size:"),
737 wxDefaultPosition, wxDefaultSize, 3, choices, 3),
6f67eafe 738 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10);
83efdf33
VS
739
740 topsizer -> Add(new wxStaticText(this, -1, _("Preview:")),
741 0, wxLEFT | wxTOP, 10);
742 topsizer -> Add(TestWin = new wxHtmlWindow(this, -1, wxDefaultPosition, wxSize(-1, 150)),
6f67eafe 743 1, wxEXPAND | wxLEFT|wxTOP|wxRIGHT, 10);
83efdf33
VS
744
745 sizer = new wxBoxSizer(wxHORIZONTAL);
746 sizer -> Add(new wxButton(this, wxID_OK, _("OK")), 0, wxALL, 10);
747 sizer -> Add(new wxButton(this, wxID_CANCEL, _("Cancel")), 0, wxALL, 10);
748 topsizer -> Add(sizer, 0, wxALIGN_RIGHT);
749
750 SetAutoLayout(TRUE);
751 SetSizer(topsizer);
752 topsizer -> Fit(this);
753 Centre(wxBOTH);
754 }
755
756
757 void UpdateTestWin()
758 {
759 wxBusyCursor bcur;
760 SetFontsToHtmlWin(TestWin,
8eb2940f
VS
761 NormalFont -> GetStringSelection(),
762 FixedFont -> GetStringSelection(),
83efdf33
VS
763 RadioBox -> GetSelection());
764 TestWin -> SetPage(_("<html><body>"
765 "Normal face<br>(and <u>underlined</u>. <i>Italic face.</i> "
766 "<b>Bold face.</b> <b><i>Bold italic face.</i></b><br>"
767 "<font size=-2>font size -2</font><br>"
768 "<font size=-1>font size -1</font><br>"
769 "<font size=+0>font size +0</font><br>"
770 "<font size=+1>font size +1</font><br>"
771 "<font size=+2>font size +2</font><br>"
772 "<font size=+3>font size +3</font><br>"
773 "<font size=+4>font size +4</font><br>"
774
775 "<p><tt>Fixed size face.<br> <b>bold</b> <i>italic</i> "
74cfc369 776 "<b><i>bold italic <u>underlined</u></i></b><br>"
83efdf33
VS
777 "<font size=-2>font size -2</font><br>"
778 "<font size=-1>font size -1</font><br>"
779 "<font size=+0>font size +0</font><br>"
780 "<font size=+1>font size +1</font><br>"
781 "<font size=+2>font size +2</font><br>"
782 "<font size=+3>font size +3</font><br>"
74cfc369 783 "<font size=+4>font size +4</font></tt>"
83efdf33
VS
784 "</body></html>"));
785 }
786
787 void OnUpdate(wxCloseEvent& event)
788 {
789 UpdateTestWin();
790 }
791
792 DECLARE_EVENT_TABLE()
793};
794
795BEGIN_EVENT_TABLE(wxHtmlHelpFrameOptionsDialog, wxDialog)
f151e8b5 796 EVT_COMBOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate)
83efdf33 797 EVT_RADIOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate)
83efdf33
VS
798END_EVENT_TABLE()
799
800
801void wxHtmlHelpFrame::OptionsDialog()
802{
803 wxHtmlHelpFrameOptionsDialog dlg(this);
804 unsigned i;
805
806 if (m_NormalFonts == NULL) {
807 wxFontEnumerator enu;
808 enu.EnumerateFacenames();
809 m_NormalFonts = new wxArrayString;
810 *m_NormalFonts = *enu.GetFacenames();
811 m_NormalFonts -> Sort();
812 }
813 if (m_FixedFonts == NULL) {
814 wxFontEnumerator enu;
815 enu.EnumerateFacenames(wxFONTENCODING_SYSTEM, TRUE);
816 m_FixedFonts = new wxArrayString;
817 *m_FixedFonts = *enu.GetFacenames();
818 m_FixedFonts -> Sort();
819 }
820
821 for (i = 0; i < m_NormalFonts -> GetCount(); i++)
822 dlg.NormalFont -> Append((*m_NormalFonts)[i]);
823 for (i = 0; i < m_FixedFonts -> GetCount(); i++)
824 dlg.FixedFont -> Append((*m_FixedFonts)[i]);
825 if (!m_NormalFace.IsEmpty()) dlg.NormalFont -> SetStringSelection(m_NormalFace);
826 else dlg.NormalFont -> SetSelection(0);
827 if (!m_FixedFace.IsEmpty()) dlg.FixedFont -> SetStringSelection(m_FixedFace);
828 else dlg.FixedFont -> SetSelection(0);
829 dlg.RadioBox -> SetSelection(m_FontSize);
83efdf33
VS
830 dlg.UpdateTestWin();
831
832 if (dlg.ShowModal() == wxID_OK) {
833 m_NormalFace = dlg.NormalFont -> GetStringSelection();
834 m_FixedFace = dlg.FixedFont -> GetStringSelection();
835 m_FontSize = dlg.RadioBox -> GetSelection();
8eb2940f 836 SetFontsToHtmlWin(m_HtmlWin, m_NormalFace, m_FixedFace, m_FontSize);
83efdf33
VS
837 }
838}
839
840
841
842
843
8ec2b484
HH
844/*
845EVENT HANDLING :
846*/
847
848
849void wxHtmlHelpFrame::OnToolbar(wxCommandEvent& event)
850{
851 switch (event.GetId()) {
382e6efe 852
8ec2b484
HH
853 case wxID_HTML_BACK :
854 m_HtmlWin -> HistoryBack();
855 break;
382e6efe 856
8ec2b484
HH
857 case wxID_HTML_FORWARD :
858 m_HtmlWin -> HistoryForward();
859 break;
382e6efe 860
8ec2b484 861 case wxID_HTML_PANEL :
d5bb85a0
VS
862 if (! (m_Splitter && m_NavigPan))
863 return ;
8ec2b484
HH
864 if (m_Splitter -> IsSplit()) {
865 m_Cfg.sashpos = m_Splitter -> GetSashPosition();
866 m_Splitter -> Unsplit(m_NavigPan);
68364659 867 m_Cfg.navig_on = FALSE;
d5bb85a0 868 } else {
8ec2b484
HH
869 m_NavigPan -> Show(TRUE);
870 m_HtmlWin -> Show(TRUE);
871 m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
68364659 872 m_Cfg.navig_on = TRUE;
8ec2b484
HH
873 }
874 break;
382e6efe 875
83efdf33
VS
876 case wxID_HTML_OPTIONS :
877 OptionsDialog();
878 break;
382e6efe
VS
879
880 case wxID_HTML_BOOKMARKSADD :
881 {
882 wxString item;
883 wxString url;
884
885 item = m_HtmlWin -> GetOpenedPageTitle();
886 url = m_HtmlWin -> GetOpenedPage();
887 if (item == wxEmptyString) item = url.AfterLast(wxT('/'));
888 if (m_BookmarksPages.Index(url) == wxNOT_FOUND) {
889 m_Bookmarks -> Append(item);
890 m_BookmarksNames.Add(item);
891 m_BookmarksPages.Add(url);
892 }
893 }
894 break;
895
896 case wxID_HTML_BOOKMARKSREMOVE :
897 {
898 wxString item;
899 int pos;
900
901 item = m_Bookmarks -> GetStringSelection();
902 pos = m_BookmarksNames.Index(item);
903 if (pos != wxNOT_FOUND) {
904 m_BookmarksNames.Remove(pos);
905 m_BookmarksPages.Remove(pos);
906 m_Bookmarks -> Delete(m_Bookmarks -> GetSelection());
907 }
908 }
909 break;
8ec2b484
HH
910 }
911}
912
913
914
915void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent& event)
916{
917 wxHtmlHelpTreeItemData *pg;
918
919 pg = (wxHtmlHelpTreeItemData*) m_ContentsBox -> GetItemData(event.GetItem());
920 if (pg) m_HtmlWin -> LoadPage(pg -> GetPage());
921}
922
923
924
a4c97004 925void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent& WXUNUSED(event))
8ec2b484 926{
f0b6a33f 927 wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_IndexList -> GetClientData(m_IndexList -> GetSelection());
c32bfc10 928 m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page);
8ec2b484
HH
929}
930
931
f0b6a33f
VS
932void wxHtmlHelpFrame::OnIndexFind(wxCommandEvent& event)
933{
934 wxString sr = m_IndexText -> GetLineText(0);
240c2873 935 sr.MakeLower();
f0b6a33f
VS
936 if (sr == wxEmptyString)
937 OnIndexAll(event);
938
939 else {
940 wxBusyCursor bcur;
941 const wxChar *cstr = sr.c_str();
240c2873 942 wxChar mybuff[512], *ptr;
f0b6a33f
VS
943 bool first = TRUE;
944
945 m_IndexList->Clear();
946 int cnt = m_Data->GetIndexCnt();
947 wxHtmlContentsItem* index = m_Data->GetIndex();
948
240c2873 949 int displ = 0;
f0b6a33f 950 for (int i = 0; i < cnt; i++)
240c2873
VS
951 {
952 wxStrncpy(mybuff, index[i].m_Name, 512);
953 mybuff[511] = 0;
954 for (ptr = mybuff; *ptr != 0; ptr++)
955 if (*ptr >= 'A' && *ptr <= 'Z') *ptr -= 'A' - 'a';
956 if (wxStrstr(mybuff, cstr) != NULL) {
f0b6a33f 957 m_IndexList -> Append(index[i].m_Name, (char*)(index + i));
240c2873 958 displ++;
f0b6a33f
VS
959 if (first) {
960 m_HtmlWin -> LoadPage(index[i].m_Book -> GetBasePath() + index[i].m_Page);
961 first = FALSE;
962 }
963 }
240c2873
VS
964 }
965
966 wxString cnttext;
967 cnttext.Printf(_("%i of %i"), displ, cnt);
968 m_IndexCountInfo -> SetLabel(cnttext);
f0b6a33f
VS
969
970 m_IndexText -> SetSelection(0, sr.Length());
971 m_IndexText -> SetFocus();
972 }
973}
974
975void wxHtmlHelpFrame::OnIndexAll(wxCommandEvent& WXUNUSED(event))
976{
977 wxBusyCursor bcur;
978
979 m_IndexList->Clear();
980 int cnt = m_Data->GetIndexCnt();
981 bool first = TRUE;
982 wxHtmlContentsItem* index = m_Data->GetIndex();
983
984 for (int i = 0; i < cnt; i++) {
985 m_IndexList -> Append(index[i].m_Name, (char*)(index + i));
986 if (first) {
987 m_HtmlWin -> LoadPage(index[i].m_Book -> GetBasePath() + index[i].m_Page);
988 first = FALSE;
989 }
990 }
240c2873
VS
991
992 wxString cnttext;
993 cnttext.Printf(_("%i of %i"), cnt, cnt);
994 m_IndexCountInfo -> SetLabel(cnttext);
f0b6a33f
VS
995}
996
8ec2b484 997
a4c97004 998void wxHtmlHelpFrame::OnSearchSel(wxCommandEvent& WXUNUSED(event))
8ec2b484
HH
999{
1000 wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_SearchList -> GetClientData(m_SearchList -> GetSelection());
1001 if (it) m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page);
1002}
1003
a4c97004 1004void wxHtmlHelpFrame::OnSearch(wxCommandEvent& WXUNUSED(event))
8ec2b484
HH
1005{
1006 wxString sr = m_SearchText -> GetLineText(0);
1007
1008 if (sr != wxEmptyString) KeywordSearch(sr);
1009}
1010
382e6efe
VS
1011void wxHtmlHelpFrame::OnBookmarksSel(wxCommandEvent& WXUNUSED(event))
1012{
1013 wxString sr = m_Bookmarks -> GetStringSelection();
1014
1015 if (sr != wxEmptyString && sr != _("<bookmarks>"))
1016 m_HtmlWin -> LoadPage(m_BookmarksPages[m_BookmarksNames.Index(sr)]);
1017}
1018
8ec2b484
HH
1019void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent& evt)
1020{
68364659
VS
1021 GetSize(&m_Cfg.w, &m_Cfg.h);
1022 GetPosition(&m_Cfg.x, &m_Cfg.y);
5c172c17 1023
68364659
VS
1024 if (m_Splitter && m_Cfg.navig_on) m_Cfg.sashpos = m_Splitter -> GetSashPosition();
1025
d5bb85a0
VS
1026 if (m_Config)
1027 WriteCustomization(m_Config, m_ConfigRoot);
68364659 1028
8ec2b484
HH
1029 evt.Skip();
1030}
1031
1032BEGIN_EVENT_TABLE(wxHtmlHelpFrame, wxFrame)
382e6efe 1033 EVT_TOOL_RANGE(wxID_HTML_PANEL, wxID_HTML_BOOKMARKSREMOVE, wxHtmlHelpFrame::OnToolbar)
8ec2b484
HH
1034 EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL, wxHtmlHelpFrame::OnContentsSel)
1035 EVT_LISTBOX(wxID_HTML_INDEXLIST, wxHtmlHelpFrame::OnIndexSel)
1036 EVT_LISTBOX(wxID_HTML_SEARCHLIST, wxHtmlHelpFrame::OnSearchSel)
1037 EVT_BUTTON(wxID_HTML_SEARCHBUTTON, wxHtmlHelpFrame::OnSearch)
1038 EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT, wxHtmlHelpFrame::OnSearch)
f0b6a33f
VS
1039 EVT_BUTTON(wxID_HTML_INDEXBUTTON, wxHtmlHelpFrame::OnIndexFind)
1040 EVT_TEXT_ENTER(wxID_HTML_INDEXTEXT, wxHtmlHelpFrame::OnIndexFind)
1041 EVT_BUTTON(wxID_HTML_INDEXBUTTONALL, wxHtmlHelpFrame::OnIndexAll)
382e6efe
VS
1042 EVT_COMBOBOX(wxID_HTML_BOOKMARKSLIST, wxHtmlHelpFrame::OnBookmarksSel)
1043 EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow)
8ec2b484
HH
1044END_EVENT_TABLE()
1045
1046#endif