1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHtmlHelpFrame
4 // Notes: Based on htmlhelp.cpp, implementing a monolithic
5 // HTML Help controller class, by Vaclav Slavik
6 // Author: Harm van der Heijden and Vaclav Slavik
8 // Copyright: (c) Harm van der Heijden and Vaclav Slavik
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "helpfrm.h"
16 // For compilers that support precompilation, includes "wx.h"
18 #include "wx/wxprec.h"
30 #include "wx/object.h"
33 #include "wx/bmpbuttn.h"
34 #include "wx/statbox.h"
35 #include "wx/radiobox.h"
40 #include "wx/msgdlg.h"
43 #include "wx/html/helpfrm.h"
44 #include "wx/html/helpctrl.h"
45 #include "wx/textctrl.h"
46 #include "wx/notebook.h"
47 #include "wx/imaglist.h"
48 #include "wx/treectrl.h"
49 #include "wx/tokenzr.h"
50 #include "wx/wfstream.h"
51 #include "wx/html/htmlwin.h"
52 #include "wx/busyinfo.h"
53 #include "wx/progdlg.h"
54 #include "wx/toolbar.h"
55 #include "wx/fontenum.h"
56 #include "wx/stream.h"
57 #include "wx/filedlg.h"
58 #include "wx/artprov.h"
59 #include "wx/spinctrl.h"
61 // what is considered "small index"?
62 #define INDEX_IS_SMALL 100
64 /* Motif defines this as a macro */
69 //--------------------------------------------------------------------------
70 // wxHtmlHelpTreeItemData (private)
71 //--------------------------------------------------------------------------
73 class wxHtmlHelpTreeItemData
: public wxTreeItemData
76 #if defined(__VISAGECPP__)
77 // VA needs a default ctor for some reason....
78 wxHtmlHelpTreeItemData() : wxTreeItemData()
81 wxHtmlHelpTreeItemData(int id
) : wxTreeItemData()
88 //--------------------------------------------------------------------------
89 // wxHtmlHelpHashData (private)
90 //--------------------------------------------------------------------------
92 class wxHtmlHelpHashData
: public wxObject
95 wxHtmlHelpHashData(int index
, wxTreeItemId id
) : wxObject()
96 { m_Index
= index
; m_Id
= id
;}
97 ~wxHtmlHelpHashData() {}
104 //--------------------------------------------------------------------------
105 // wxHtmlHelpHtmlWindow (private)
106 //--------------------------------------------------------------------------
108 class wxHtmlHelpHtmlWindow
: public wxHtmlWindow
111 wxHtmlHelpHtmlWindow(wxHtmlHelpFrame
*fr
, wxWindow
*parent
) : wxHtmlWindow(parent
), m_Frame(fr
) {}
113 virtual void OnLinkClicked(const wxHtmlLinkInfo
& link
)
115 wxHtmlWindow::OnLinkClicked(link
);
116 m_Frame
->NotifyPageChanged();
120 wxHtmlHelpFrame
*m_Frame
;
122 DECLARE_NO_COPY_CLASS(wxHtmlHelpHtmlWindow
)
127 //---------------------------------------------------------------------------
129 //---------------------------------------------------------------------------
134 //wxID_HTML_HELPFRAME = wxID_HIGHEST + 1,
135 wxID_HTML_PANEL
= wxID_HIGHEST
+ 2,
144 wxID_HTML_BOOKMARKSLIST
,
145 wxID_HTML_BOOKMARKSADD
,
146 wxID_HTML_BOOKMARKSREMOVE
,
151 wxID_HTML_INDEXBUTTON
,
152 wxID_HTML_INDEXBUTTONALL
,
154 wxID_HTML_SEARCHPAGE
,
155 wxID_HTML_SEARCHTEXT
,
156 wxID_HTML_SEARCHLIST
,
157 wxID_HTML_SEARCHBUTTON
,
158 wxID_HTML_SEARCHCHOICE
,
163 IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpFrame
, wxFrame
)
165 wxHtmlHelpFrame::wxHtmlHelpFrame(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
166 int style
, wxHtmlHelpData
* data
)
169 Create(parent
, id
, title
, style
);
172 void wxHtmlHelpFrame::Init(wxHtmlHelpData
* data
)
177 m_DataCreated
= FALSE
;
180 m_Data
= new wxHtmlHelpData();
181 m_DataCreated
= TRUE
;
184 m_ContentsBox
= NULL
;
186 m_IndexButton
= NULL
;
187 m_IndexButtonAll
= NULL
;
190 m_SearchButton
= NULL
;
192 m_SearchChoice
= NULL
;
193 m_IndexCountInfo
= NULL
;
196 m_NavigNotebook
= NULL
;
199 m_SearchCaseSensitive
= NULL
;
200 m_SearchWholeWords
= NULL
;
203 m_ConfigRoot
= wxEmptyString
;
205 m_Cfg
.x
= m_Cfg
.y
= 0;
209 m_Cfg
.navig_on
= TRUE
;
211 m_NormalFonts
= m_FixedFonts
= NULL
;
212 m_NormalFace
= m_FixedFace
= wxEmptyString
;
219 #if wxUSE_PRINTING_ARCHITECTURE
224 m_UpdateContents
= TRUE
;
225 m_helpController
= (wxHelpControllerBase
*) NULL
;
228 // Create: builds the GUI components.
229 // with the style flag it's possible to toggle the toolbar, contents, index and search
231 // m_HtmlWin will *always* be created, but it's important to realize that
232 // m_ContentsBox, m_IndexList, m_SearchList, m_SearchButton, m_SearchText and
233 // m_SearchButton may be NULL.
234 // moreover, if no contents, index or searchpage is needed, m_Splitter and
235 // m_NavigPan will be NULL too (with m_HtmlWin directly connected to the frame)
237 bool wxHtmlHelpFrame::Create(wxWindow
* parent
, wxWindowID id
,
238 const wxString
& WXUNUSED(title
), int style
)
242 wxImageList
*ContentsImageList
= new wxImageList(16, 16);
243 ContentsImageList
->Add(wxArtProvider::GetIcon(wxART_HELP_BOOK
, wxART_HELP_BROWSER
));
244 ContentsImageList
->Add(wxArtProvider::GetIcon(wxART_HELP_FOLDER
, wxART_HELP_BROWSER
));
245 ContentsImageList
->Add(wxArtProvider::GetIcon(wxART_HELP_PAGE
, wxART_HELP_BROWSER
));
247 // Do the config in two steps. We read the HtmlWindow customization after we
248 // create the window.
250 ReadCustomization(m_Config
, m_ConfigRoot
);
252 wxFrame::Create(parent
, id
, _("Help"),
253 wxPoint(m_Cfg
.x
, m_Cfg
.y
), wxSize(m_Cfg
.w
, m_Cfg
.h
),
254 wxDEFAULT_FRAME_STYLE
, wxT("wxHtmlHelp"));
256 GetPosition(&m_Cfg
.x
, &m_Cfg
.y
);
258 SetIcon(wxArtProvider::GetIcon(wxART_HELP
, wxART_HELP_BROWSER
));
260 // On the Mac, each modeless frame must have a menubar.
261 // TODO: add more menu items, and perhaps add a style to show
262 // the menubar: compulsory on the Mac, optional elsewhere.
264 wxMenuBar
* menuBar
= new wxMenuBar
;
266 wxMenu
* fileMenu
= new wxMenu
;
267 fileMenu
->Append(wxID_HTML_OPENFILE
, _("&Open..."));
268 fileMenu
->AppendSeparator();
269 fileMenu
->Append(wxID_CLOSE
, _("&Close"));
271 wxMenu
* helpMenu
= new wxMenu
;
272 helpMenu
->Append(wxID_ABOUT
, _("&About..."));
274 menuBar
->Append(fileMenu
,_("File"));
275 menuBar
->Append(helpMenu
,_("Help"));
279 int notebook_page
= 0;
284 if (style
& (wxHF_TOOLBAR
| wxHF_FLAT_TOOLBAR
))
286 wxToolBar
*toolBar
= CreateToolBar(wxNO_BORDER
| wxTB_HORIZONTAL
|
288 (style
& wxHF_FLAT_TOOLBAR
? wxTB_FLAT
: 0));
289 toolBar
->SetMargins( 2, 2 );
290 AddToolbarButtons(toolBar
, style
);
294 wxSizer
*navigSizer
= NULL
;
296 if (style
& (wxHF_CONTENTS
| wxHF_INDEX
| wxHF_SEARCH
))
298 // traditional help controller; splitter window with html page on the
299 // right and a notebook containing various pages on the left
300 m_Splitter
= new wxSplitterWindow(this);
302 m_HtmlWin
= new wxHtmlHelpHtmlWindow(this, m_Splitter
);
303 m_NavigPan
= new wxPanel(m_Splitter
, -1);
304 m_NavigNotebook
= new wxNotebook(m_NavigPan
, wxID_HTML_NOTEBOOK
,
305 wxDefaultPosition
, wxDefaultSize
);
306 wxNotebookSizer
*nbs
= new wxNotebookSizer(m_NavigNotebook
);
308 navigSizer
= new wxBoxSizer(wxVERTICAL
);
309 navigSizer
->Add(nbs
, 1, wxEXPAND
);
311 m_NavigPan
->SetAutoLayout(TRUE
);
312 m_NavigPan
->SetSizer(navigSizer
);
315 { // only html window, no notebook with index,contents etc
316 m_HtmlWin
= new wxHtmlWindow(this);
319 m_HtmlWin
->SetRelatedFrame(this, m_TitleFormat
);
320 m_HtmlWin
->SetRelatedStatusBar(0);
322 m_HtmlWin
->ReadCustomization(m_Config
, m_ConfigRoot
);
324 // contents tree panel?
325 if ( style
& wxHF_CONTENTS
)
327 wxWindow
*dummy
= new wxPanel(m_NavigNotebook
, wxID_HTML_INDEXPAGE
);
328 wxSizer
*topsizer
= new wxBoxSizer(wxVERTICAL
);
330 topsizer
->Add(0, 10);
332 dummy
->SetAutoLayout(TRUE
);
333 dummy
->SetSizer(topsizer
);
335 if ( style
& wxHF_BOOKMARKS
)
337 m_Bookmarks
= new wxComboBox(dummy
, wxID_HTML_BOOKMARKSLIST
,
339 wxDefaultPosition
, wxDefaultSize
,
340 0, NULL
, wxCB_READONLY
| wxCB_SORT
);
341 m_Bookmarks
->Append(_("(bookmarks)"));
342 for (unsigned i
= 0; i
< m_BookmarksNames
.GetCount(); i
++)
343 m_Bookmarks
->Append(m_BookmarksNames
[i
]);
344 m_Bookmarks
->SetSelection(0);
346 wxBitmapButton
*bmpbt1
, *bmpbt2
;
347 bmpbt1
= new wxBitmapButton(dummy
, wxID_HTML_BOOKMARKSADD
,
348 wxArtProvider::GetBitmap(wxART_ADD_BOOKMARK
,
349 wxART_HELP_BROWSER
));
350 bmpbt2
= new wxBitmapButton(dummy
, wxID_HTML_BOOKMARKSREMOVE
,
351 wxArtProvider::GetBitmap(wxART_DEL_BOOKMARK
,
352 wxART_HELP_BROWSER
));
354 bmpbt1
->SetToolTip(_("Add current page to bookmarks"));
355 bmpbt2
->SetToolTip(_("Remove current page from bookmarks"));
356 #endif // wxUSE_TOOLTIPS
358 wxSizer
*sizer
= new wxBoxSizer(wxHORIZONTAL
);
360 sizer
->Add(m_Bookmarks
, 1, wxALIGN_CENTRE_VERTICAL
| wxRIGHT
, 5);
361 sizer
->Add(bmpbt1
, 0, wxALIGN_CENTRE_VERTICAL
| wxRIGHT
, 2);
362 sizer
->Add(bmpbt2
, 0, wxALIGN_CENTRE_VERTICAL
, 0);
364 topsizer
->Add(sizer
, 0, wxEXPAND
| wxLEFT
| wxBOTTOM
| wxRIGHT
, 10);
367 m_ContentsBox
= new wxTreeCtrl(dummy
, wxID_HTML_TREECTRL
,
368 wxDefaultPosition
, wxDefaultSize
,
370 wxTR_HAS_BUTTONS
| wxTR_HIDE_ROOT
|
373 m_ContentsBox
->AssignImageList(ContentsImageList
);
375 topsizer
->Add(m_ContentsBox
, 1, wxEXPAND
| wxLEFT
| wxBOTTOM
| wxRIGHT
, 2);
377 m_NavigNotebook
->AddPage(dummy
, _("Contents"));
378 m_ContentsPage
= notebook_page
++;
381 // index listbox panel?
382 if ( style
& wxHF_INDEX
)
384 wxWindow
*dummy
= new wxPanel(m_NavigNotebook
, wxID_HTML_INDEXPAGE
);
385 wxSizer
*topsizer
= new wxBoxSizer(wxVERTICAL
);
387 dummy
->SetAutoLayout(TRUE
);
388 dummy
->SetSizer(topsizer
);
390 m_IndexText
= new wxTextCtrl(dummy
, wxID_HTML_INDEXTEXT
, wxEmptyString
,
391 wxDefaultPosition
, wxDefaultSize
,
393 m_IndexButton
= new wxButton(dummy
, wxID_HTML_INDEXBUTTON
, _("Find"));
394 m_IndexButtonAll
= new wxButton(dummy
, wxID_HTML_INDEXBUTTONALL
,
396 m_IndexCountInfo
= new wxStaticText(dummy
, wxID_HTML_COUNTINFO
,
397 wxEmptyString
, wxDefaultPosition
,
399 wxALIGN_RIGHT
| wxST_NO_AUTORESIZE
);
400 m_IndexList
= new wxListBox(dummy
, wxID_HTML_INDEXLIST
,
401 wxDefaultPosition
, wxDefaultSize
,
402 0, NULL
, wxLB_SINGLE
);
405 m_IndexButton
->SetToolTip(_("Display all index items that contain given substring. Search is case insensitive."));
406 m_IndexButtonAll
->SetToolTip(_("Show all items in index"));
407 #endif //wxUSE_TOOLTIPS
409 topsizer
->Add(m_IndexText
, 0, wxEXPAND
| wxALL
, 10);
410 wxSizer
*btsizer
= new wxBoxSizer(wxHORIZONTAL
);
411 btsizer
->Add(m_IndexButton
, 0, wxRIGHT
, 2);
412 btsizer
->Add(m_IndexButtonAll
);
413 topsizer
->Add(btsizer
, 0,
414 wxALIGN_RIGHT
| wxLEFT
| wxRIGHT
| wxBOTTOM
, 10);
415 topsizer
->Add(m_IndexCountInfo
, 0, wxEXPAND
| wxLEFT
| wxRIGHT
, 2);
416 topsizer
->Add(m_IndexList
, 1, wxEXPAND
| wxALL
, 2);
418 m_NavigNotebook
->AddPage(dummy
, _("Index"));
419 m_IndexPage
= notebook_page
++;
422 // search list panel?
423 if ( style
& wxHF_SEARCH
)
425 wxWindow
*dummy
= new wxPanel(m_NavigNotebook
, wxID_HTML_INDEXPAGE
);
426 wxSizer
*sizer
= new wxBoxSizer(wxVERTICAL
);
428 dummy
->SetAutoLayout(TRUE
);
429 dummy
->SetSizer(sizer
);
431 m_SearchText
= new wxTextCtrl(dummy
, wxID_HTML_SEARCHTEXT
,
433 wxDefaultPosition
, wxDefaultSize
,
435 m_SearchChoice
= new wxChoice(dummy
, wxID_HTML_SEARCHCHOICE
,
436 wxDefaultPosition
, wxDefaultSize
);
437 m_SearchCaseSensitive
= new wxCheckBox(dummy
, -1, _("Case sensitive"));
438 m_SearchWholeWords
= new wxCheckBox(dummy
, -1, _("Whole words only"));
439 m_SearchButton
= new wxButton(dummy
, wxID_HTML_SEARCHBUTTON
, _("Search"));
441 m_SearchButton
->SetToolTip(_("Search contents of help book(s) for all occurences of the text you typed above"));
442 #endif //wxUSE_TOOLTIPS
443 m_SearchList
= new wxListBox(dummy
, wxID_HTML_SEARCHLIST
,
444 wxDefaultPosition
, wxDefaultSize
,
445 0, NULL
, wxLB_SINGLE
);
447 sizer
->Add(m_SearchText
, 0, wxEXPAND
| wxALL
, 10);
448 sizer
->Add(m_SearchChoice
, 0, wxEXPAND
| wxLEFT
| wxRIGHT
| wxBOTTOM
, 10);
449 sizer
->Add(m_SearchCaseSensitive
, 0, wxLEFT
| wxRIGHT
, 10);
450 sizer
->Add(m_SearchWholeWords
, 0, wxLEFT
| wxRIGHT
, 10);
451 sizer
->Add(m_SearchButton
, 0, wxALL
| wxALIGN_RIGHT
, 8);
452 sizer
->Add(m_SearchList
, 1, wxALL
| wxEXPAND
, 2);
454 m_NavigNotebook
->AddPage(dummy
, _("Search"));
455 m_SearchPage
= notebook_page
++;
458 m_HtmlWin
->Show(TRUE
);
464 navigSizer
->SetSizeHints(m_NavigPan
);
465 m_NavigPan
->Layout();
469 if ( m_NavigPan
&& m_Splitter
)
471 m_Splitter
->SetMinimumPaneSize(20);
472 if ( m_Cfg
.navig_on
)
473 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
475 if ( m_Cfg
.navig_on
)
477 m_NavigPan
->Show(TRUE
);
478 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
482 m_NavigPan
->Show(FALSE
);
483 m_Splitter
->Initialize(m_HtmlWin
);
490 wxHtmlHelpFrame::~wxHtmlHelpFrame()
492 // PopEventHandler(); // wxhtmlhelpcontroller (not any more!)
495 if (m_NormalFonts
) delete m_NormalFonts
;
496 if (m_FixedFonts
) delete m_FixedFonts
;
497 if (m_PagesHash
) delete m_PagesHash
;
501 void wxHtmlHelpFrame::AddToolbarButtons(wxToolBar
*toolBar
, int style
)
503 wxBitmap wpanelBitmap
=
504 wxArtProvider::GetBitmap(wxART_HELP_SIDE_PANEL
, wxART_HELP_BROWSER
);
505 wxBitmap wbackBitmap
=
506 wxArtProvider::GetBitmap(wxART_GO_BACK
, wxART_HELP_BROWSER
);
507 wxBitmap wforwardBitmap
=
508 wxArtProvider::GetBitmap(wxART_GO_FORWARD
, wxART_HELP_BROWSER
);
509 wxBitmap wupnodeBitmap
=
510 wxArtProvider::GetBitmap(wxART_GO_TO_PARENT
, wxART_HELP_BROWSER
);
512 wxArtProvider::GetBitmap(wxART_GO_UP
, wxART_HELP_BROWSER
);
513 wxBitmap wdownBitmap
=
514 wxArtProvider::GetBitmap(wxART_GO_DOWN
, wxART_HELP_BROWSER
);
515 wxBitmap wopenBitmap
=
516 wxArtProvider::GetBitmap(wxART_FILE_OPEN
, wxART_HELP_BROWSER
);
517 wxBitmap wprintBitmap
=
518 wxArtProvider::GetBitmap(wxART_PRINT
, wxART_HELP_BROWSER
);
519 wxBitmap woptionsBitmap
=
520 wxArtProvider::GetBitmap(wxART_HELP_SETTINGS
, wxART_HELP_BROWSER
);
522 wxASSERT_MSG( (wpanelBitmap
.Ok() && wbackBitmap
.Ok() &&
523 wforwardBitmap
.Ok() && wupnodeBitmap
.Ok() &&
524 wupBitmap
.Ok() && wdownBitmap
.Ok() &&
525 wopenBitmap
.Ok() && wprintBitmap
.Ok() &&
526 woptionsBitmap
.Ok()),
527 wxT("One or more HTML help frame toolbar bitmap could not be loaded.")) ;
530 toolBar
->AddTool(wxID_HTML_PANEL
, wpanelBitmap
, wxNullBitmap
,
531 FALSE
, -1, -1, (wxObject
*) NULL
,
532 _("Show/hide navigation panel"));
534 toolBar
->AddSeparator();
535 toolBar
->AddTool(wxID_HTML_BACK
, wbackBitmap
, wxNullBitmap
,
536 FALSE
, -1, -1, (wxObject
*) NULL
,
538 toolBar
->AddTool(wxID_HTML_FORWARD
, wforwardBitmap
, wxNullBitmap
,
539 FALSE
, -1, -1, (wxObject
*) NULL
,
541 toolBar
->AddSeparator();
543 toolBar
->AddTool(wxID_HTML_UPNODE
, wupnodeBitmap
, wxNullBitmap
,
544 FALSE
, -1, -1, (wxObject
*) NULL
,
545 _("Go one level up in document hierarchy"));
546 toolBar
->AddTool(wxID_HTML_UP
, wupBitmap
, wxNullBitmap
,
547 FALSE
, -1, -1, (wxObject
*) NULL
,
549 toolBar
->AddTool(wxID_HTML_DOWN
, wdownBitmap
, wxNullBitmap
,
550 FALSE
, -1, -1, (wxObject
*) NULL
,
553 if ((style
& wxHF_PRINT
) || (style
& wxHF_OPEN_FILES
))
554 toolBar
->AddSeparator();
556 if (style
& wxHF_OPEN_FILES
)
557 toolBar
->AddTool(wxID_HTML_OPENFILE
, wopenBitmap
, wxNullBitmap
,
558 FALSE
, -1, -1, (wxObject
*) NULL
,
559 _("Open HTML document"));
561 #if wxUSE_PRINTING_ARCHITECTURE
562 if (style
& wxHF_PRINT
)
563 toolBar
->AddTool(wxID_HTML_PRINT
, wprintBitmap
, wxNullBitmap
,
564 FALSE
, -1, -1, (wxObject
*) NULL
,
565 _("Print this page"));
568 toolBar
->AddSeparator();
569 toolBar
->AddTool(wxID_HTML_OPTIONS
, woptionsBitmap
, wxNullBitmap
,
570 FALSE
, -1, -1, (wxObject
*) NULL
,
571 _("Display options dialog"));
575 void wxHtmlHelpFrame::SetTitleFormat(const wxString
& format
)
578 m_HtmlWin
->SetRelatedFrame(this, format
);
579 m_TitleFormat
= format
;
583 bool wxHtmlHelpFrame::Display(const wxString
& x
)
585 wxString url
= m_Data
->FindPageByName(x
);
588 m_HtmlWin
->LoadPage(url
);
595 bool wxHtmlHelpFrame::Display(const int id
)
597 wxString url
= m_Data
->FindPageById(id
);
600 m_HtmlWin
->LoadPage(url
);
609 bool wxHtmlHelpFrame::DisplayContents()
613 if (!m_Splitter
->IsSplit())
615 m_NavigPan
->Show(TRUE
);
616 m_HtmlWin
->Show(TRUE
);
617 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
618 m_Cfg
.navig_on
= TRUE
;
620 m_NavigNotebook
->SetSelection(0);
621 if (m_Data
->GetBookRecArray().GetCount() > 0)
623 wxHtmlBookRecord
& book
= m_Data
->GetBookRecArray()[0];
624 if (!book
.GetStart().IsEmpty())
625 m_HtmlWin
->LoadPage(book
.GetFullPath(book
.GetStart()));
632 bool wxHtmlHelpFrame::DisplayIndex()
636 if (!m_Splitter
->IsSplit())
638 m_NavigPan
->Show(TRUE
);
639 m_HtmlWin
->Show(TRUE
);
640 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
642 m_NavigNotebook
->SetSelection(1);
643 if (m_Data
->GetBookRecArray().GetCount() > 0)
645 wxHtmlBookRecord
& book
= m_Data
->GetBookRecArray()[0];
646 if (!book
.GetStart().IsEmpty())
647 m_HtmlWin
->LoadPage(book
.GetFullPath(book
.GetStart()));
654 bool wxHtmlHelpFrame::KeywordSearch(const wxString
& keyword
)
656 if (! (m_SearchList
&& m_SearchButton
&& m_SearchText
&& m_SearchChoice
))
659 int foundcnt
= 0, curi
;
661 wxString book
= wxEmptyString
;
663 if (!m_Splitter
->IsSplit())
665 m_NavigPan
->Show(TRUE
);
666 m_HtmlWin
->Show(TRUE
);
667 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
669 m_NavigNotebook
->SetSelection(m_SearchPage
);
670 m_SearchList
->Clear();
671 m_SearchText
->SetValue(keyword
);
672 m_SearchButton
->Enable(FALSE
);
674 if (m_SearchChoice
->GetSelection() != 0)
675 book
= m_SearchChoice
->GetStringSelection();
677 wxHtmlSearchStatus
status(m_Data
, keyword
,
678 m_SearchCaseSensitive
->GetValue(), m_SearchWholeWords
->GetValue(),
681 wxProgressDialog
progress(_("Searching..."), _("No matching page found yet"),
682 status
.GetMaxIndex(), this,
683 wxPD_APP_MODAL
| wxPD_CAN_ABORT
| wxPD_AUTO_HIDE
);
685 while (status
.IsActive())
687 curi
= status
.GetCurIndex();
688 if (curi
% 32 == 0 && progress
.Update(curi
) == FALSE
)
692 foundstr
.Printf(_("Found %i matches"), ++foundcnt
);
693 progress
.Update(status
.GetCurIndex(), foundstr
);
694 m_SearchList
->Append(status
.GetName(), status
.GetContentsItem());
698 m_SearchButton
->Enable(TRUE
);
699 m_SearchText
->SetSelection(0, keyword
.Length());
700 m_SearchText
->SetFocus();
703 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_SearchList
->GetClientData(0);
706 m_HtmlWin
->LoadPage(it
->GetFullPath());
710 return (foundcnt
> 0);
713 void wxHtmlHelpFrame::CreateContents()
718 m_ContentsBox
->Clear();
720 if (m_PagesHash
) delete m_PagesHash
;
721 m_PagesHash
= new wxHashTable(wxKEY_STRING
, 2 * m_Data
->GetContentsCnt());
722 m_PagesHash
->DeleteContents(TRUE
);
724 int cnt
= m_Data
->GetContentsCnt();
727 wxHtmlContentsItem
*it
;
729 const int MAX_ROOTS
= 64;
730 wxTreeItemId roots
[MAX_ROOTS
];
731 // VS: this array holds information about whether we've set item icon at
732 // given level. This is neccessary because m_Data has flat structure
733 // and there's no way of recognizing if some item has subitems or not.
734 // We set the icon later: when we find an item with level=n, we know
735 // that the last item with level=n-1 was folder with subitems, so we
736 // set its icon accordingly
737 bool imaged
[MAX_ROOTS
];
738 m_ContentsBox
->DeleteAllItems();
740 roots
[0] = m_ContentsBox
->AddRoot(_("(Help)"));
743 for (it
= m_Data
->GetContents(), i
= 0; i
< cnt
; i
++, it
++)
746 if (it
->m_Level
== 0)
748 if (m_hfStyle
& wxHF_MERGE_BOOKS
)
749 // VS: we don't want book nodes, books' content should
750 // appear under tree's root. This line will create "fake"
751 // record about book node so that the rest of this look
752 // will believe there really _is_ book node and will
757 roots
[1] = m_ContentsBox
->AppendItem(roots
[0],
758 it
->m_Name
, IMG_Book
, -1,
759 new wxHtmlHelpTreeItemData(i
));
760 m_ContentsBox
->SetItemBold(roots
[1], TRUE
);
764 // ...and their contents:
767 roots
[it
->m_Level
+ 1] = m_ContentsBox
->AppendItem(
768 roots
[it
->m_Level
], it
->m_Name
, IMG_Page
,
769 -1, new wxHtmlHelpTreeItemData(i
));
770 imaged
[it
->m_Level
+ 1] = FALSE
;
773 m_PagesHash
->Put(it
->GetFullPath(),
774 new wxHtmlHelpHashData(i
, roots
[it
->m_Level
+ 1]));
776 // Set the icon for the node one level up in the hiearachy,
777 // unless already done (see comment above imaged[] declaration)
778 if (!imaged
[it
->m_Level
])
780 int image
= IMG_Folder
;
781 if (m_hfStyle
& wxHF_ICONS_BOOK
)
783 else if (m_hfStyle
& wxHF_ICONS_BOOK_CHAPTER
)
784 image
= (it
->m_Level
== 1) ? IMG_Book
: IMG_Folder
;
785 m_ContentsBox
->SetItemImage(roots
[it
->m_Level
], image
);
786 m_ContentsBox
->SetItemSelectedImage(roots
[it
->m_Level
], image
);
787 imaged
[it
->m_Level
] = TRUE
;
793 void wxHtmlHelpFrame::CreateIndex()
798 m_IndexList
->Clear();
800 int cnt
= m_Data
->GetIndexCnt();
803 if (cnt
> INDEX_IS_SMALL
) cnttext
.Printf(_("%i of %i"), 0, cnt
);
804 else cnttext
.Printf(_("%i of %i"), cnt
, cnt
);
805 m_IndexCountInfo
->SetLabel(cnttext
);
806 if (cnt
> INDEX_IS_SMALL
) return;
808 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
810 for (int i
= 0; i
< cnt
; i
++)
811 m_IndexList
->Append(index
[i
].m_Name
, (char*)(index
+ i
));
814 void wxHtmlHelpFrame::CreateSearch()
816 if (! (m_SearchList
&& m_SearchChoice
))
818 m_SearchList
->Clear();
819 m_SearchChoice
->Clear();
820 m_SearchChoice
->Append(_("Search in all books"));
821 const wxHtmlBookRecArray
& bookrec
= m_Data
->GetBookRecArray();
822 int i
, cnt
= bookrec
.GetCount();
823 for (i
= 0; i
< cnt
; i
++)
824 m_SearchChoice
->Append(bookrec
[i
].GetTitle());
825 m_SearchChoice
->SetSelection(0);
829 void wxHtmlHelpFrame::RefreshLists()
836 void wxHtmlHelpFrame::ReadCustomization(wxConfigBase
*cfg
, const wxString
& path
)
841 if (path
!= wxEmptyString
)
843 oldpath
= cfg
->GetPath();
844 cfg
->SetPath(_T("/") + path
);
847 m_Cfg
.navig_on
= cfg
->Read(wxT("hcNavigPanel"), m_Cfg
.navig_on
) != 0;
848 m_Cfg
.sashpos
= cfg
->Read(wxT("hcSashPos"), m_Cfg
.sashpos
);
849 m_Cfg
.x
= cfg
->Read(wxT("hcX"), m_Cfg
.x
);
850 m_Cfg
.y
= cfg
->Read(wxT("hcY"), m_Cfg
.y
);
851 m_Cfg
.w
= cfg
->Read(wxT("hcW"), m_Cfg
.w
);
852 m_Cfg
.h
= cfg
->Read(wxT("hcH"), m_Cfg
.h
);
854 m_FixedFace
= cfg
->Read(wxT("hcFixedFace"), m_FixedFace
);
855 m_NormalFace
= cfg
->Read(wxT("hcNormalFace"), m_NormalFace
);
856 m_FontSize
= cfg
->Read(wxT("hcBaseFontSize"), m_FontSize
);
863 cnt
= cfg
->Read(wxT("hcBookmarksCnt"), 0L);
866 m_BookmarksNames
.Clear();
867 m_BookmarksPages
.Clear();
870 m_Bookmarks
->Clear();
871 m_Bookmarks
->Append(_("(bookmarks)"));
874 for (i
= 0; i
< cnt
; i
++)
876 val
.Printf(wxT("hcBookmark_%i"), i
);
878 m_BookmarksNames
.Add(s
);
879 if (m_Bookmarks
) m_Bookmarks
->Append(s
);
880 val
.Printf(wxT("hcBookmark_%i_url"), i
);
882 m_BookmarksPages
.Add(s
);
888 m_HtmlWin
->ReadCustomization(cfg
);
890 if (path
!= wxEmptyString
)
891 cfg
->SetPath(oldpath
);
894 void wxHtmlHelpFrame::WriteCustomization(wxConfigBase
*cfg
, const wxString
& path
)
899 if (path
!= wxEmptyString
)
901 oldpath
= cfg
->GetPath();
902 cfg
->SetPath(_T("/") + path
);
905 cfg
->Write(wxT("hcNavigPanel"), m_Cfg
.navig_on
);
906 cfg
->Write(wxT("hcSashPos"), (long)m_Cfg
.sashpos
);
909 // Don't write if iconized as this would make the window
910 // disappear next time it is shown!
911 cfg
->Write(wxT("hcX"), (long)m_Cfg
.x
);
912 cfg
->Write(wxT("hcY"), (long)m_Cfg
.y
);
913 cfg
->Write(wxT("hcW"), (long)m_Cfg
.w
);
914 cfg
->Write(wxT("hcH"), (long)m_Cfg
.h
);
916 cfg
->Write(wxT("hcFixedFace"), m_FixedFace
);
917 cfg
->Write(wxT("hcNormalFace"), m_NormalFace
);
918 cfg
->Write(wxT("hcBaseFontSize"), (long)m_FontSize
);
923 int cnt
= m_BookmarksNames
.GetCount();
926 cfg
->Write(wxT("hcBookmarksCnt"), (long)cnt
);
927 for (i
= 0; i
< cnt
; i
++)
929 val
.Printf(wxT("hcBookmark_%i"), i
);
930 cfg
->Write(val
, m_BookmarksNames
[i
]);
931 val
.Printf(wxT("hcBookmark_%i_url"), i
);
932 cfg
->Write(val
, m_BookmarksPages
[i
]);
937 m_HtmlWin
->WriteCustomization(cfg
);
939 if (path
!= wxEmptyString
)
940 cfg
->SetPath(oldpath
);
947 static void SetFontsToHtmlWin(wxHtmlWindow
*win
, wxString scalf
, wxString fixf
, int size
)
950 f_sizes
[0] = int(size
* 0.6);
951 f_sizes
[1] = int(size
* 0.8);
953 f_sizes
[3] = int(size
* 1.2);
954 f_sizes
[4] = int(size
* 1.4);
955 f_sizes
[5] = int(size
* 1.6);
956 f_sizes
[6] = int(size
* 1.8);
958 win
->SetFonts(scalf
, fixf
, f_sizes
);
962 class wxHtmlHelpFrameOptionsDialog
: public wxDialog
965 wxComboBox
*NormalFont
, *FixedFont
;
966 wxSpinCtrl
*FontSize
;
967 wxHtmlWindow
*TestWin
;
969 wxHtmlHelpFrameOptionsDialog(wxWindow
*parent
)
970 : wxDialog(parent
, -1, wxString(_("Help Browser Options")))
972 wxBoxSizer
*topsizer
= new wxBoxSizer(wxVERTICAL
);
973 wxFlexGridSizer
*sizer
= new wxFlexGridSizer(2, 3, 2, 5);
975 sizer
->Add(new wxStaticText(this, -1, _("Normal font:")));
976 sizer
->Add(new wxStaticText(this, -1, _("Fixed font:")));
977 sizer
->Add(new wxStaticText(this, -1, _("Font size:")));
979 sizer
->Add(NormalFont
= new wxComboBox(this, -1, wxEmptyString
, wxDefaultPosition
,
981 0, NULL
, wxCB_DROPDOWN
| wxCB_READONLY
));
983 sizer
->Add(FixedFont
= new wxComboBox(this, -1, wxEmptyString
, wxDefaultPosition
,
985 0, NULL
, wxCB_DROPDOWN
| wxCB_READONLY
));
987 sizer
->Add(FontSize
= new wxSpinCtrl(this, -1));
988 FontSize
->SetRange(2, 100);
990 topsizer
->Add(sizer
, 0, wxLEFT
|wxRIGHT
|wxTOP
, 10);
992 topsizer
->Add(new wxStaticText(this, -1, _("Preview:")),
993 0, wxLEFT
| wxTOP
, 10);
994 topsizer
->Add(TestWin
= new wxHtmlWindow(this, -1, wxDefaultPosition
, wxSize(20, 150),
995 wxHW_SCROLLBAR_AUTO
| wxSUNKEN_BORDER
),
996 1, wxEXPAND
| wxLEFT
|wxTOP
|wxRIGHT
, 10);
998 wxBoxSizer
*sizer2
= new wxBoxSizer(wxHORIZONTAL
);
1000 sizer2
->Add(ok
= new wxButton(this, wxID_OK
, _("OK")), 0, wxALL
, 10);
1002 sizer2
->Add(new wxButton(this, wxID_CANCEL
, _("Cancel")), 0, wxALL
, 10);
1003 topsizer
->Add(sizer2
, 0, wxALIGN_RIGHT
);
1005 SetAutoLayout(TRUE
);
1007 topsizer
->Fit(this);
1012 void UpdateTestWin()
1015 SetFontsToHtmlWin(TestWin
,
1016 NormalFont
->GetStringSelection(),
1017 FixedFont
->GetStringSelection(),
1018 FontSize
->GetValue());
1022 Normal face<br>(and <u>underlined</u>. <i>Italic face.</i> \
1023 <b>Bold face.</b> <b><i>Bold italic face.</i></b><br>\
1024 <font size=-2>font size -2</font><br>\
1025 <font size=-1>font size -1</font><br>\
1026 <font size=+0>font size +0</font><br>\
1027 <font size=+1>font size +1</font><br>\
1028 <font size=+2>font size +2</font><br>\
1029 <font size=+3>font size +3</font><br>\
1030 <font size=+4>font size +4</font><br>\
1032 <p><tt>Fixed size face.<br> <b>bold</b> <i>italic</i> \
1033 <b><i>bold italic <u>underlined</u></i></b><br>\
1034 <font size=-2>font size -2</font><br>\
1035 <font size=-1>font size -1</font><br>\
1036 <font size=+0>font size +0</font><br>\
1037 <font size=+1>font size +1</font><br>\
1038 <font size=+2>font size +2</font><br>\
1039 <font size=+3>font size +3</font><br>\
1040 <font size=+4>font size +4</font></tt>\
1041 </table></body></html>"
1045 void OnUpdate(wxCommandEvent
& WXUNUSED(event
))
1049 void OnUpdateSpin(wxSpinEvent
& WXUNUSED(event
))
1054 DECLARE_EVENT_TABLE()
1055 DECLARE_NO_COPY_CLASS(wxHtmlHelpFrameOptionsDialog
)
1058 BEGIN_EVENT_TABLE(wxHtmlHelpFrameOptionsDialog
, wxDialog
)
1059 EVT_COMBOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate
)
1060 EVT_SPINCTRL(-1, wxHtmlHelpFrameOptionsDialog::OnUpdateSpin
)
1064 void wxHtmlHelpFrame::OptionsDialog()
1066 wxHtmlHelpFrameOptionsDialog
dlg(this);
1069 if (m_NormalFonts
== NULL
)
1071 wxFontEnumerator enu
;
1072 enu
.EnumerateFacenames();
1073 m_NormalFonts
= new wxArrayString
;
1074 *m_NormalFonts
= *enu
.GetFacenames();
1075 m_NormalFonts
->Sort();
1077 if (m_FixedFonts
== NULL
)
1079 wxFontEnumerator enu
;
1080 enu
.EnumerateFacenames(wxFONTENCODING_SYSTEM
, TRUE
);
1081 m_FixedFonts
= new wxArrayString
;
1082 *m_FixedFonts
= *enu
.GetFacenames();
1083 m_FixedFonts
->Sort();
1086 // VS: We want to show the font that is actually used by wxHtmlWindow.
1087 // If customization dialog wasn't used yet, facenames are empty and
1088 // wxHtmlWindow uses default fonts -- let's find out what they
1089 // are so that we can pass them to the dialog:
1090 if (m_NormalFace
.empty())
1092 wxFont
fnt(m_FontSize
, wxSWISS
, wxNORMAL
, wxNORMAL
, FALSE
);
1093 m_NormalFace
= fnt
.GetFaceName();
1095 if (m_FixedFace
.empty())
1097 wxFont
fnt(m_FontSize
, wxMODERN
, wxNORMAL
, wxNORMAL
, FALSE
);
1098 m_FixedFace
= fnt
.GetFaceName();
1101 for (i
= 0; i
< m_NormalFonts
->GetCount(); i
++)
1102 dlg
.NormalFont
->Append((*m_NormalFonts
)[i
]);
1103 for (i
= 0; i
< m_FixedFonts
->GetCount(); i
++)
1104 dlg
.FixedFont
->Append((*m_FixedFonts
)[i
]);
1105 if (!m_NormalFace
.empty())
1106 dlg
.NormalFont
->SetStringSelection(m_NormalFace
);
1108 dlg
.NormalFont
->SetSelection(0);
1109 if (!m_FixedFace
.empty())
1110 dlg
.FixedFont
->SetStringSelection(m_FixedFace
);
1112 dlg
.FixedFont
->SetSelection(0);
1113 dlg
.FontSize
->SetValue(m_FontSize
);
1114 dlg
.UpdateTestWin();
1116 if (dlg
.ShowModal() == wxID_OK
)
1118 m_NormalFace
= dlg
.NormalFont
->GetStringSelection();
1119 m_FixedFace
= dlg
.FixedFont
->GetStringSelection();
1120 m_FontSize
= dlg
.FontSize
->GetValue();
1121 SetFontsToHtmlWin(m_HtmlWin
, m_NormalFace
, m_FixedFace
, m_FontSize
);
1127 void wxHtmlHelpFrame::NotifyPageChanged()
1129 if (m_UpdateContents
&& m_PagesHash
)
1131 wxString an
= m_HtmlWin
->GetOpenedAnchor();
1132 wxHtmlHelpHashData
*ha
;
1134 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage());
1136 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage() + wxT("#") + an
);
1139 bool olduc
= m_UpdateContents
;
1140 m_UpdateContents
= FALSE
;
1141 m_ContentsBox
->SelectItem(ha
->m_Id
);
1142 m_ContentsBox
->EnsureVisible(ha
->m_Id
);
1143 m_UpdateContents
= olduc
;
1155 void wxHtmlHelpFrame::OnActivate(wxActivateEvent
& event
)
1157 // This saves one mouse click when using the
1158 // wxHTML for context sensitive help systems
1160 // NB: wxActivateEvent is a bit broken in wxGTK
1161 // and is sometimes sent when it should not be
1162 if (event
.GetActive() && m_HtmlWin
)
1163 m_HtmlWin
->SetFocus();
1169 void wxHtmlHelpFrame::OnToolbar(wxCommandEvent
& event
)
1171 switch (event
.GetId())
1173 case wxID_HTML_BACK
:
1174 m_HtmlWin
->HistoryBack();
1175 NotifyPageChanged();
1178 case wxID_HTML_FORWARD
:
1179 m_HtmlWin
->HistoryForward();
1180 NotifyPageChanged();
1186 wxString an
= m_HtmlWin
->GetOpenedAnchor();
1187 wxHtmlHelpHashData
*ha
;
1189 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage());
1191 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage() + wxT("#") + an
);
1192 if (ha
&& ha
->m_Index
> 0)
1194 wxHtmlContentsItem
*it
= m_Data
->GetContents() + (ha
->m_Index
- 1);
1195 if (it
->m_Page
[0] != 0)
1197 m_HtmlWin
->LoadPage(it
->GetFullPath());
1198 NotifyPageChanged();
1204 case wxID_HTML_UPNODE
:
1207 wxString an
= m_HtmlWin
->GetOpenedAnchor();
1208 wxHtmlHelpHashData
*ha
;
1210 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage());
1212 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage() + wxT("#") + an
);
1213 if (ha
&& ha
->m_Index
> 0)
1215 int level
= m_Data
->GetContents()[ha
->m_Index
].m_Level
- 1;
1216 wxHtmlContentsItem
*it
;
1217 int ind
= ha
->m_Index
- 1;
1219 it
= m_Data
->GetContents() + ind
;
1220 while (ind
>= 0 && it
->m_Level
!= level
) ind
--, it
--;
1223 if (it
->m_Page
[0] != 0)
1225 m_HtmlWin
->LoadPage(it
->GetFullPath());
1226 NotifyPageChanged();
1233 case wxID_HTML_DOWN
:
1236 wxString an
= m_HtmlWin
->GetOpenedAnchor();
1238 wxHtmlHelpHashData
*ha
;
1240 if (an
.IsEmpty()) adr
= m_HtmlWin
->GetOpenedPage();
1241 else adr
= m_HtmlWin
->GetOpenedPage() + wxT("#") + an
;
1243 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(adr
);
1245 if (ha
&& ha
->m_Index
< m_Data
->GetContentsCnt() - 1)
1247 wxHtmlContentsItem
*it
= m_Data
->GetContents() + (ha
->m_Index
+ 1);
1249 while (it
->GetFullPath() == adr
) it
++;
1251 if (it
->m_Page
[0] != 0)
1253 m_HtmlWin
->LoadPage(it
->GetFullPath());
1254 NotifyPageChanged();
1260 case wxID_HTML_PANEL
:
1262 if (! (m_Splitter
&& m_NavigPan
))
1264 if (m_Splitter
->IsSplit())
1266 m_Cfg
.sashpos
= m_Splitter
->GetSashPosition();
1267 m_Splitter
->Unsplit(m_NavigPan
);
1268 m_Cfg
.navig_on
= FALSE
;
1272 m_NavigPan
->Show(TRUE
);
1273 m_HtmlWin
->Show(TRUE
);
1274 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
1275 m_Cfg
.navig_on
= TRUE
;
1280 case wxID_HTML_OPTIONS
:
1284 case wxID_HTML_BOOKMARKSADD
:
1289 item
= m_HtmlWin
->GetOpenedPageTitle();
1290 url
= m_HtmlWin
->GetOpenedPage();
1291 if (item
== wxEmptyString
)
1292 item
= url
.AfterLast(wxT('/'));
1293 if (m_BookmarksPages
.Index(url
) == wxNOT_FOUND
)
1295 m_Bookmarks
->Append(item
);
1296 m_BookmarksNames
.Add(item
);
1297 m_BookmarksPages
.Add(url
);
1302 case wxID_HTML_BOOKMARKSREMOVE
:
1307 item
= m_Bookmarks
->GetStringSelection();
1308 pos
= m_BookmarksNames
.Index(item
);
1309 if (pos
!= wxNOT_FOUND
)
1311 m_BookmarksNames
.Remove(pos
);
1312 m_BookmarksPages
.Remove(pos
);
1313 m_Bookmarks
->Delete(m_Bookmarks
->GetSelection());
1318 #if wxUSE_PRINTING_ARCHITECTURE
1319 case wxID_HTML_PRINT
:
1321 if (m_Printer
== NULL
)
1322 m_Printer
= new wxHtmlEasyPrinting(_("Help Printing"), this);
1323 if (!m_HtmlWin
->GetOpenedPage())
1324 wxLogWarning(_("Cannot print empty page."));
1326 m_Printer
->PrintFile(m_HtmlWin
->GetOpenedPage());
1331 case wxID_HTML_OPENFILE
:
1333 wxString s
= wxFileSelector(_("Open HTML document"),
1338 "HTML files (*.htm)|*.htm|HTML files (*.html)|*.html|\
1339 Help books (*.htb)|*.htb|Help books (*.zip)|*.zip|\
1340 HTML Help Project (*.hhp)|*.hhp|\
1343 wxOPEN
| wxFILE_MUST_EXIST
,
1347 wxString ext
= s
.Right(4).Lower();
1348 if (ext
== _T(".zip") || ext
== _T(".htb") || ext
== _T(".hhp"))
1355 m_HtmlWin
->LoadPage(s
);
1364 void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent
& event
)
1366 wxHtmlHelpTreeItemData
*pg
;
1367 wxHtmlContentsItem
*it
;
1369 pg
= (wxHtmlHelpTreeItemData
*) m_ContentsBox
->GetItemData(event
.GetItem());
1371 if (pg
&& m_UpdateContents
)
1373 it
= m_Data
->GetContents() + (pg
->m_Id
);
1374 m_UpdateContents
= FALSE
;
1375 if (it
->m_Page
[0] != 0)
1376 m_HtmlWin
->LoadPage(it
->GetFullPath());
1377 m_UpdateContents
= TRUE
;
1383 void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent
& WXUNUSED(event
))
1385 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_IndexList
->GetClientData(m_IndexList
->GetSelection());
1386 if (it
->m_Page
[0] != 0)
1387 m_HtmlWin
->LoadPage(it
->GetFullPath());
1388 NotifyPageChanged();
1392 void wxHtmlHelpFrame::OnIndexFind(wxCommandEvent
& event
)
1394 wxString sr
= m_IndexText
->GetLineText(0);
1396 if (sr
== wxEmptyString
)
1403 const wxChar
*cstr
= sr
.c_str();
1408 m_IndexList
->Clear();
1409 int cnt
= m_Data
->GetIndexCnt();
1410 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
1413 for (int i
= 0; i
< cnt
; i
++)
1415 wxStrncpy(mybuff
, index
[i
].m_Name
, 512);
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'));
1420 if (wxStrstr(mybuff
, cstr
) != NULL
)
1422 m_IndexList
->Append(index
[i
].m_Name
, (char*)(index
+ i
));
1426 if (index
[i
].m_Page
[0] != 0)
1427 m_HtmlWin
->LoadPage(index
[i
].GetFullPath());
1428 NotifyPageChanged();
1435 cnttext
.Printf(_("%i of %i"), displ
, cnt
);
1436 m_IndexCountInfo
->SetLabel(cnttext
);
1438 m_IndexText
->SetSelection(0, sr
.Length());
1439 m_IndexText
->SetFocus();
1443 void wxHtmlHelpFrame::OnIndexAll(wxCommandEvent
& WXUNUSED(event
))
1447 m_IndexList
->Clear();
1448 int cnt
= m_Data
->GetIndexCnt();
1450 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
1452 for (int i
= 0; i
< cnt
; i
++)
1454 m_IndexList
->Append(index
[i
].m_Name
, (char*)(index
+ i
));
1457 if (index
[i
].m_Page
[0] != 0)
1458 m_HtmlWin
->LoadPage(index
[i
].GetFullPath());
1459 NotifyPageChanged();
1465 cnttext
.Printf(_("%i of %i"), cnt
, cnt
);
1466 m_IndexCountInfo
->SetLabel(cnttext
);
1470 void wxHtmlHelpFrame::OnSearchSel(wxCommandEvent
& WXUNUSED(event
))
1472 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_SearchList
->GetClientData(m_SearchList
->GetSelection());
1475 if (it
->m_Page
[0] != 0)
1476 m_HtmlWin
->LoadPage(it
->GetFullPath());
1477 NotifyPageChanged();
1481 void wxHtmlHelpFrame::OnSearch(wxCommandEvent
& WXUNUSED(event
))
1483 wxString sr
= m_SearchText
->GetLineText(0);
1485 if (sr
!= wxEmptyString
) KeywordSearch(sr
);
1488 void wxHtmlHelpFrame::OnBookmarksSel(wxCommandEvent
& WXUNUSED(event
))
1490 wxString sr
= m_Bookmarks
->GetStringSelection();
1492 if (sr
!= wxEmptyString
&& sr
!= _("(bookmarks)"))
1494 m_HtmlWin
->LoadPage(m_BookmarksPages
[m_BookmarksNames
.Index(sr
)]);
1495 NotifyPageChanged();
1499 void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent
& evt
)
1501 GetSize(&m_Cfg
.w
, &m_Cfg
.h
);
1502 GetPosition(&m_Cfg
.x
, &m_Cfg
.y
);
1511 if (m_Splitter
&& m_Cfg
.navig_on
) m_Cfg
.sashpos
= m_Splitter
->GetSashPosition();
1514 WriteCustomization(m_Config
, m_ConfigRoot
);
1516 if (m_helpController
&& m_helpController
->IsKindOf(CLASSINFO(wxHtmlHelpController
)))
1518 ((wxHtmlHelpController
*) m_helpController
)->OnCloseFrame(evt
);
1525 void wxHtmlHelpFrame::OnClose(wxCommandEvent
& event
)
1530 void wxHtmlHelpFrame::OnAbout(wxCommandEvent
& event
)
1532 wxMessageBox(wxT("wxWindows HTML Help Viewer (c) 1998-2003, Vaclav Slavik et al"), wxT("HelpView"),
1533 wxICON_INFORMATION
|wxOK
, this);
1537 BEGIN_EVENT_TABLE(wxHtmlHelpFrame
, wxFrame
)
1538 EVT_ACTIVATE(wxHtmlHelpFrame::OnActivate
)
1539 EVT_TOOL_RANGE(wxID_HTML_PANEL
, wxID_HTML_OPTIONS
, wxHtmlHelpFrame::OnToolbar
)
1540 EVT_BUTTON(wxID_HTML_BOOKMARKSREMOVE
, wxHtmlHelpFrame::OnToolbar
)
1541 EVT_BUTTON(wxID_HTML_BOOKMARKSADD
, wxHtmlHelpFrame::OnToolbar
)
1542 EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL
, wxHtmlHelpFrame::OnContentsSel
)
1543 EVT_LISTBOX(wxID_HTML_INDEXLIST
, wxHtmlHelpFrame::OnIndexSel
)
1544 EVT_LISTBOX(wxID_HTML_SEARCHLIST
, wxHtmlHelpFrame::OnSearchSel
)
1545 EVT_BUTTON(wxID_HTML_SEARCHBUTTON
, wxHtmlHelpFrame::OnSearch
)
1546 EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT
, wxHtmlHelpFrame::OnSearch
)
1547 EVT_BUTTON(wxID_HTML_INDEXBUTTON
, wxHtmlHelpFrame::OnIndexFind
)
1548 EVT_TEXT_ENTER(wxID_HTML_INDEXTEXT
, wxHtmlHelpFrame::OnIndexFind
)
1549 EVT_BUTTON(wxID_HTML_INDEXBUTTONALL
, wxHtmlHelpFrame::OnIndexAll
)
1550 EVT_COMBOBOX(wxID_HTML_BOOKMARKSLIST
, wxHtmlHelpFrame::OnBookmarksSel
)
1551 EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow
)
1553 EVT_MENU(wxID_CLOSE
, wxHtmlHelpFrame::OnClose
)
1554 EVT_MENU(wxID_ABOUT
, wxHtmlHelpFrame::OnAbout
)
1559 #endif // wxUSE_WXHTML_HELP