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
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"
38 #include "wx/html/helpfrm.h"
39 #include "wx/html/helpctrl.h"
40 #include "wx/textctrl.h"
41 #include "wx/notebook.h"
42 #include "wx/imaglist.h"
43 #include "wx/treectrl.h"
44 #include "wx/tokenzr.h"
45 #include "wx/wfstream.h"
46 #include "wx/html/htmlwin.h"
47 #include "wx/busyinfo.h"
48 #include "wx/progdlg.h"
49 #include "wx/toolbar.h"
50 #include "wx/fontenum.h"
51 #include "wx/stream.h"
52 #include "wx/filedlg.h"
57 // XPM hack: make the arrays const
58 #define static static const
60 #include "bitmaps/wpanel.xpm"
61 #include "bitmaps/wback.xpm"
62 #include "bitmaps/wforward.xpm"
63 #include "bitmaps/wbook.xpm"
64 #include "bitmaps/woptions.xpm"
65 #include "bitmaps/wfolder.xpm"
66 #include "bitmaps/wpage.xpm"
67 #include "bitmaps/whelp.xpm"
68 #include "bitmaps/whlproot.xpm"
69 #include "bitmaps/wbkadd.xpm"
70 #include "bitmaps/wbkdel.xpm"
71 #include "bitmaps/wup.xpm"
72 #include "bitmaps/wupnode.xpm"
73 #include "bitmaps/wdown.xpm"
74 #include "bitmaps/wopen.xpm"
75 #include "bitmaps/wprint.xpm"
80 // what is considered "small index"?
81 #define INDEX_IS_SMALL 100
83 /* Motif defines this as a macro */
88 //--------------------------------------------------------------------------
89 // wxHtmlHelpTreeItemData (private)
90 //--------------------------------------------------------------------------
92 class wxHtmlHelpTreeItemData
: public wxTreeItemData
95 #if defined(__VISAGECPP__)
96 // VA needs a default ctor for some reason....
97 wxHtmlHelpTreeItemData() : wxTreeItemData()
100 wxHtmlHelpTreeItemData(int id
) : wxTreeItemData()
107 //--------------------------------------------------------------------------
108 // wxHtmlHelpHashData (private)
109 //--------------------------------------------------------------------------
111 class wxHtmlHelpHashData
: public wxObject
114 wxHtmlHelpHashData(int index
, wxTreeItemId id
) : wxObject()
115 { m_Index
= index
; m_Id
= id
;}
116 ~wxHtmlHelpHashData() {}
123 //--------------------------------------------------------------------------
124 // wxHtmlHelpHtmlWindow (private)
125 //--------------------------------------------------------------------------
127 class wxHtmlHelpHtmlWindow
: public wxHtmlWindow
130 wxHtmlHelpHtmlWindow(wxHtmlHelpFrame
*fr
, wxWindow
*parent
) : wxHtmlWindow(parent
), m_Frame(fr
) {}
132 virtual void OnLinkClicked(const wxHtmlLinkInfo
& link
)
134 wxHtmlWindow::OnLinkClicked(link
);
135 m_Frame
->NotifyPageChanged();
139 wxHtmlHelpFrame
*m_Frame
;
144 //---------------------------------------------------------------------------
146 //---------------------------------------------------------------------------
151 //wxID_HTML_HELPFRAME = wxID_HIGHEST + 1,
152 wxID_HTML_PANEL
= wxID_HIGHEST
+ 2,
161 wxID_HTML_BOOKMARKSLIST
,
162 wxID_HTML_BOOKMARKSADD
,
163 wxID_HTML_BOOKMARKSREMOVE
,
168 wxID_HTML_INDEXBUTTON
,
169 wxID_HTML_INDEXBUTTONALL
,
171 wxID_HTML_SEARCHPAGE
,
172 wxID_HTML_SEARCHTEXT
,
173 wxID_HTML_SEARCHLIST
,
174 wxID_HTML_SEARCHBUTTON
,
175 wxID_HTML_SEARCHCHOICE
,
180 IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpFrame
, wxFrame
)
182 wxHtmlHelpFrame::wxHtmlHelpFrame(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
183 int style
, wxHtmlHelpData
* data
)
186 Create(parent
, id
, title
, style
);
189 void wxHtmlHelpFrame::Init(wxHtmlHelpData
* data
)
194 m_DataCreated
= FALSE
;
197 m_Data
= new wxHtmlHelpData();
198 m_DataCreated
= TRUE
;
201 m_ContentsBox
= NULL
;
203 m_IndexButton
= NULL
;
204 m_IndexButtonAll
= NULL
;
207 m_SearchButton
= NULL
;
209 m_SearchChoice
= NULL
;
210 m_IndexCountInfo
= NULL
;
213 m_NavigNotebook
= NULL
;
216 m_SearchCaseSensitive
= NULL
;
217 m_SearchWholeWords
= NULL
;
220 m_ConfigRoot
= wxEmptyString
;
222 m_Cfg
.x
= m_Cfg
.y
= 0;
226 m_Cfg
.navig_on
= TRUE
;
228 m_NormalFonts
= m_FixedFonts
= NULL
;
229 m_NormalFace
= m_FixedFace
= wxEmptyString
;
232 #if wxUSE_PRINTING_ARCHITECTURE
237 m_UpdateContents
= TRUE
;
238 m_helpController
= (wxHelpControllerBase
*) NULL
;
241 // Create: builds the GUI components.
242 // with the style flag it's possible to toggle the toolbar, contents, index and search
244 // m_HtmlWin will *always* be created, but it's important to realize that
245 // m_ContentsBox, m_IndexList, m_SearchList, m_SearchButton, m_SearchText and
246 // m_SearchButton may be NULL.
247 // moreover, if no contents, index or searchpage is needed, m_Splitter and
248 // m_NavigPan will be NULL too (with m_HtmlWin directly connected to the frame)
250 bool wxHtmlHelpFrame::Create(wxWindow
* parent
, wxWindowID id
,
251 const wxString
& WXUNUSED(title
), int style
)
255 wxImageList
*ContentsImageList
= new wxImageList(16, 16);
256 ContentsImageList
->Add(wxICON(wbook
));
257 ContentsImageList
->Add(wxICON(wfolder
));
258 ContentsImageList
->Add(wxICON(wpage
));
259 ContentsImageList
->Add(wxICON(whlproot
));
261 // Do the config in two steps. We read the HtmlWindow customization after we
262 // create the window.
264 ReadCustomization(m_Config
, m_ConfigRoot
);
266 wxFrame::Create(parent
, id
, _("Help"),
267 wxPoint(m_Cfg
.x
, m_Cfg
.y
), wxSize(m_Cfg
.w
, m_Cfg
.h
),
268 wxDEFAULT_FRAME_STYLE
, wxT("wxHtmlHelp"));
270 GetPosition(&m_Cfg
.x
, &m_Cfg
.y
);
272 SetIcon(wxICON(whelp
));
274 int notebook_page
= 0;
279 if (style
& (wxHF_TOOLBAR
| wxHF_FLAT_TOOLBAR
))
281 wxToolBar
*toolBar
= CreateToolBar(wxNO_BORDER
| wxTB_HORIZONTAL
|
283 (style
& wxHF_FLAT_TOOLBAR
? wxTB_FLAT
: 0));
284 toolBar
->SetMargins( 2, 2 );
285 AddToolbarButtons(toolBar
, style
);
289 wxSizer
*navigSizer
= NULL
;
291 if (style
& (wxHF_CONTENTS
| wxHF_INDEX
| wxHF_SEARCH
))
293 // traditional help controller; splitter window with html page on the
294 // right and a notebook containing various pages on the left
295 m_Splitter
= new wxSplitterWindow(this);
297 m_HtmlWin
= new wxHtmlHelpHtmlWindow(this, m_Splitter
);
298 m_NavigPan
= new wxPanel(m_Splitter
, -1);
299 m_NavigNotebook
= new wxNotebook(m_NavigPan
, wxID_HTML_NOTEBOOK
,
300 wxDefaultPosition
, wxDefaultSize
);
301 wxNotebookSizer
*nbs
= new wxNotebookSizer(m_NavigNotebook
);
303 navigSizer
= new wxBoxSizer(wxVERTICAL
);
304 navigSizer
->Add(nbs
, 1, wxEXPAND
);
306 m_NavigPan
->SetAutoLayout(TRUE
);
307 m_NavigPan
->SetSizer(navigSizer
);
310 { // only html window, no notebook with index,contents etc
311 m_HtmlWin
= new wxHtmlWindow(this);
314 m_HtmlWin
->SetRelatedFrame(this, m_TitleFormat
);
315 m_HtmlWin
->SetRelatedStatusBar(0);
317 m_HtmlWin
->ReadCustomization(m_Config
, m_ConfigRoot
);
319 // contents tree panel?
320 if ( style
& wxHF_CONTENTS
)
322 wxWindow
*dummy
= new wxPanel(m_NavigNotebook
, wxID_HTML_INDEXPAGE
);
323 wxSizer
*topsizer
= new wxBoxSizer(wxVERTICAL
);
325 topsizer
->Add(0, 10);
327 dummy
->SetAutoLayout(TRUE
);
328 dummy
->SetSizer(topsizer
);
330 if ( style
& wxHF_BOOKMARKS
)
332 m_Bookmarks
= new wxComboBox(dummy
, wxID_HTML_BOOKMARKSLIST
,
334 wxDefaultPosition
, wxDefaultSize
,
335 0, NULL
, wxCB_READONLY
| wxCB_SORT
);
336 m_Bookmarks
->Append(_("(bookmarks)"));
337 for (unsigned i
= 0; i
< m_BookmarksNames
.GetCount(); i
++)
338 m_Bookmarks
->Append(m_BookmarksNames
[i
]);
339 m_Bookmarks
->SetSelection(0);
341 wxBitmapButton
*bmpbt1
, *bmpbt2
;
342 bmpbt1
= new wxBitmapButton(dummy
, wxID_HTML_BOOKMARKSADD
,
344 wxDefaultPosition
, wxSize(20,20));
345 bmpbt2
= new wxBitmapButton(dummy
, wxID_HTML_BOOKMARKSREMOVE
,
347 wxDefaultPosition
, wxSize(20,20));
349 bmpbt1
->SetToolTip(_("Add current page to bookmarks"));
350 bmpbt2
->SetToolTip(_("Remove current page from bookmarks"));
351 #endif // wxUSE_TOOLTIPS
353 wxSizer
*sizer
= new wxBoxSizer(wxHORIZONTAL
);
355 sizer
->Add(m_Bookmarks
, 1, wxRIGHT
, 5);
356 sizer
->Add(bmpbt1
, 0, wxRIGHT
, 2);
357 sizer
->Add(bmpbt2
, 0, 0, 0);
359 topsizer
->Add(sizer
, 0, wxEXPAND
| wxLEFT
| wxBOTTOM
| wxRIGHT
, 10);
362 m_ContentsBox
= new wxTreeCtrl(dummy
, wxID_HTML_TREECTRL
,
363 wxDefaultPosition
, wxDefaultSize
,
365 wxTR_HAS_BUTTONS
| wxTR_HIDE_ROOT
|
368 m_ContentsBox
->AssignImageList(ContentsImageList
);
370 topsizer
->Add(m_ContentsBox
, 1, wxEXPAND
| wxLEFT
| wxBOTTOM
| wxRIGHT
, 2);
372 m_NavigNotebook
->AddPage(dummy
, _("Contents"));
373 m_ContentsPage
= notebook_page
++;
376 // index listbox panel?
377 if ( style
& wxHF_INDEX
)
379 wxWindow
*dummy
= new wxPanel(m_NavigNotebook
, wxID_HTML_INDEXPAGE
);
380 wxSizer
*topsizer
= new wxBoxSizer(wxVERTICAL
);
382 dummy
->SetAutoLayout(TRUE
);
383 dummy
->SetSizer(topsizer
);
385 m_IndexText
= new wxTextCtrl(dummy
, wxID_HTML_INDEXTEXT
, wxEmptyString
,
386 wxDefaultPosition
, wxDefaultSize
,
388 m_IndexButton
= new wxButton(dummy
, wxID_HTML_INDEXBUTTON
, _("Find"));
389 m_IndexButtonAll
= new wxButton(dummy
, wxID_HTML_INDEXBUTTONALL
,
391 m_IndexCountInfo
= new wxStaticText(dummy
, wxID_HTML_COUNTINFO
,
392 wxEmptyString
, wxDefaultPosition
,
394 wxALIGN_RIGHT
| wxST_NO_AUTORESIZE
);
395 m_IndexList
= new wxListBox(dummy
, wxID_HTML_INDEXLIST
,
396 wxDefaultPosition
, wxDefaultSize
,
397 0, NULL
, wxLB_SINGLE
);
400 m_IndexButton
->SetToolTip(_("Display all index items that contain given substring. Search is case insensitive."));
401 m_IndexButtonAll
->SetToolTip(_("Show all items in index"));
402 #endif //wxUSE_TOOLTIPS
404 topsizer
->Add(m_IndexText
, 0, wxEXPAND
| wxALL
, 10);
405 wxSizer
*btsizer
= new wxBoxSizer(wxHORIZONTAL
);
406 btsizer
->Add(m_IndexButton
, 0, wxRIGHT
, 2);
407 btsizer
->Add(m_IndexButtonAll
);
408 topsizer
->Add(btsizer
, 0,
409 wxALIGN_RIGHT
| wxLEFT
| wxRIGHT
| wxBOTTOM
, 10);
410 topsizer
->Add(m_IndexCountInfo
, 0, wxEXPAND
| wxLEFT
| wxRIGHT
, 2);
411 topsizer
->Add(m_IndexList
, 1, wxEXPAND
| wxALL
, 2);
413 m_NavigNotebook
->AddPage(dummy
, _("Index"));
414 m_IndexPage
= notebook_page
++;
417 // search list panel?
418 if ( style
& wxHF_SEARCH
)
420 wxWindow
*dummy
= new wxPanel(m_NavigNotebook
, wxID_HTML_INDEXPAGE
);
421 wxSizer
*sizer
= new wxBoxSizer(wxVERTICAL
);
423 dummy
->SetAutoLayout(TRUE
);
424 dummy
->SetSizer(sizer
);
426 m_SearchText
= new wxTextCtrl(dummy
, wxID_HTML_SEARCHTEXT
,
428 wxDefaultPosition
, wxDefaultSize
,
430 m_SearchChoice
= new wxChoice(dummy
, wxID_HTML_SEARCHCHOICE
,
431 wxDefaultPosition
, wxDefaultSize
);
432 m_SearchCaseSensitive
= new wxCheckBox(dummy
, -1, _("Case sensitive"));
433 m_SearchWholeWords
= new wxCheckBox(dummy
, -1, _("Whole words only"));
434 m_SearchButton
= new wxButton(dummy
, wxID_HTML_SEARCHBUTTON
, _("Search"));
436 m_SearchButton
->SetToolTip(_("Search contents of help book(s) for all occurences of the text you typed above"));
437 #endif //wxUSE_TOOLTIPS
438 m_SearchList
= new wxListBox(dummy
, wxID_HTML_SEARCHLIST
,
439 wxDefaultPosition
, wxDefaultSize
,
440 0, NULL
, wxLB_SINGLE
);
442 sizer
->Add(m_SearchText
, 0, wxEXPAND
| wxALL
, 10);
443 sizer
->Add(m_SearchChoice
, 0, wxEXPAND
| wxLEFT
| wxRIGHT
| wxBOTTOM
, 10);
444 sizer
->Add(m_SearchCaseSensitive
, 0, wxLEFT
| wxRIGHT
, 10);
445 sizer
->Add(m_SearchWholeWords
, 0, wxLEFT
| wxRIGHT
, 10);
446 sizer
->Add(m_SearchButton
, 0, wxALL
| wxALIGN_RIGHT
, 8);
447 sizer
->Add(m_SearchList
, 1, wxALL
| wxEXPAND
, 2);
449 m_NavigNotebook
->AddPage(dummy
, _("Search"));
450 m_SearchPage
= notebook_page
++;
453 m_HtmlWin
->Show(TRUE
);
459 navigSizer
->SetSizeHints(m_NavigPan
);
460 m_NavigPan
->Layout();
464 if ( m_NavigPan
&& m_Splitter
)
466 m_Splitter
->SetMinimumPaneSize(20);
467 if ( m_Cfg
.navig_on
)
468 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
470 if ( m_Cfg
.navig_on
)
472 m_NavigPan
->Show(TRUE
);
473 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
477 m_NavigPan
->Show(FALSE
);
478 m_Splitter
->Initialize(m_HtmlWin
);
485 wxHtmlHelpFrame::~wxHtmlHelpFrame()
487 // PopEventHandler(); // wxhtmlhelpcontroller (not any more!)
490 if (m_NormalFonts
) delete m_NormalFonts
;
491 if (m_FixedFonts
) delete m_FixedFonts
;
492 if (m_PagesHash
) delete m_PagesHash
;
496 void wxHtmlHelpFrame::AddToolbarButtons(wxToolBar
*toolBar
, int style
)
498 wxBitmap wpanelBitmap
= wxBITMAP(wpanel
);
499 wxBitmap wbackBitmap
= wxBITMAP(wback
);
500 wxBitmap wforwardBitmap
= wxBITMAP(wforward
);
501 wxBitmap wupnodeBitmap
= wxBITMAP(wupnode
);
502 wxBitmap wupBitmap
= wxBITMAP(wup
);
503 wxBitmap wdownBitmap
= wxBITMAP(wdown
);
504 wxBitmap wopenBitmap
= wxBITMAP(wopen
);
505 wxBitmap wprintBitmap
= wxBITMAP(wprint
);
506 wxBitmap woptionsBitmap
= wxBITMAP(woptions
);
508 wxASSERT_MSG( (wpanelBitmap
.Ok() && wbackBitmap
.Ok() &&
509 wforwardBitmap
.Ok() && wupnodeBitmap
.Ok() &&
510 wupBitmap
.Ok() && wdownBitmap
.Ok() &&
511 wopenBitmap
.Ok() && wprintBitmap
.Ok() &&
512 woptionsBitmap
.Ok()),
513 wxT("One or more HTML help frame toolbar bitmap could not be loaded.")) ;
516 toolBar
->AddTool(wxID_HTML_PANEL
, wpanelBitmap
, wxNullBitmap
,
517 FALSE
, -1, -1, (wxObject
*) NULL
,
518 _("Show/hide navigation panel"));
520 toolBar
->AddSeparator();
521 toolBar
->AddTool(wxID_HTML_BACK
, wbackBitmap
, wxNullBitmap
,
522 FALSE
, -1, -1, (wxObject
*) NULL
,
524 toolBar
->AddTool(wxID_HTML_FORWARD
, wforwardBitmap
, wxNullBitmap
,
525 FALSE
, -1, -1, (wxObject
*) NULL
,
527 toolBar
->AddSeparator();
529 toolBar
->AddTool(wxID_HTML_UPNODE
, wupnodeBitmap
, wxNullBitmap
,
530 FALSE
, -1, -1, (wxObject
*) NULL
,
531 _("Go one level up in document hierarchy"));
532 toolBar
->AddTool(wxID_HTML_UP
, wupBitmap
, wxNullBitmap
,
533 FALSE
, -1, -1, (wxObject
*) NULL
,
535 toolBar
->AddTool(wxID_HTML_DOWN
, wdownBitmap
, wxNullBitmap
,
536 FALSE
, -1, -1, (wxObject
*) NULL
,
539 if ((style
& wxHF_PRINT
) || (style
& wxHF_OPEN_FILES
))
540 toolBar
->AddSeparator();
542 if (style
& wxHF_OPEN_FILES
)
543 toolBar
->AddTool(wxID_HTML_OPENFILE
, wopenBitmap
, wxNullBitmap
,
544 FALSE
, -1, -1, (wxObject
*) NULL
,
545 _("Open HTML document"));
547 #if wxUSE_PRINTING_ARCHITECTURE
548 if (style
& wxHF_PRINT
)
549 toolBar
->AddTool(wxID_HTML_PRINT
, wprintBitmap
, wxNullBitmap
,
550 FALSE
, -1, -1, (wxObject
*) NULL
,
551 _("Print this page"));
554 toolBar
->AddSeparator();
555 toolBar
->AddTool(wxID_HTML_OPTIONS
, woptionsBitmap
, wxNullBitmap
,
556 FALSE
, -1, -1, (wxObject
*) NULL
,
557 _("Display options dialog"));
561 void wxHtmlHelpFrame::SetTitleFormat(const wxString
& format
)
564 m_HtmlWin
->SetRelatedFrame(this, format
);
565 m_TitleFormat
= format
;
569 bool wxHtmlHelpFrame::Display(const wxString
& x
)
571 wxString url
= m_Data
->FindPageByName(x
);
574 m_HtmlWin
->LoadPage(url
);
581 bool wxHtmlHelpFrame::Display(const int id
)
583 wxString url
= m_Data
->FindPageById(id
);
586 m_HtmlWin
->LoadPage(url
);
595 bool wxHtmlHelpFrame::DisplayContents()
599 if (!m_Splitter
->IsSplit())
601 m_NavigPan
->Show(TRUE
);
602 m_HtmlWin
->Show(TRUE
);
603 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
604 m_Cfg
.navig_on
= TRUE
;
606 m_NavigNotebook
->SetSelection(0);
607 if (m_Data
->GetBookRecArray().GetCount() > 0)
609 wxHtmlBookRecord
& book
= m_Data
->GetBookRecArray()[0];
610 if (!book
.GetStart().IsEmpty())
611 m_HtmlWin
->LoadPage(book
.GetFullPath(book
.GetStart()));
618 bool wxHtmlHelpFrame::DisplayIndex()
622 if (!m_Splitter
->IsSplit())
624 m_NavigPan
->Show(TRUE
);
625 m_HtmlWin
->Show(TRUE
);
626 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
628 m_NavigNotebook
->SetSelection(1);
629 if (m_Data
->GetBookRecArray().GetCount() > 0)
631 wxHtmlBookRecord
& book
= m_Data
->GetBookRecArray()[0];
632 if (!book
.GetStart().IsEmpty())
633 m_HtmlWin
->LoadPage(book
.GetFullPath(book
.GetStart()));
640 bool wxHtmlHelpFrame::KeywordSearch(const wxString
& keyword
)
642 if (! (m_SearchList
&& m_SearchButton
&& m_SearchText
&& m_SearchChoice
))
645 int foundcnt
= 0, curi
;
647 wxString book
= wxEmptyString
;
649 if (!m_Splitter
->IsSplit())
651 m_NavigPan
->Show(TRUE
);
652 m_HtmlWin
->Show(TRUE
);
653 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
655 m_NavigNotebook
->SetSelection(m_SearchPage
);
656 m_SearchList
->Clear();
657 m_SearchText
->SetValue(keyword
);
658 m_SearchButton
->Enable(FALSE
);
660 if (m_SearchChoice
->GetSelection() != 0)
661 book
= m_SearchChoice
->GetStringSelection();
663 wxHtmlSearchStatus
status(m_Data
, keyword
,
664 m_SearchCaseSensitive
->GetValue(), m_SearchWholeWords
->GetValue(),
667 wxProgressDialog
progress(_("Searching..."), _("No matching page found yet"),
668 status
.GetMaxIndex(), this,
669 wxPD_APP_MODAL
| wxPD_CAN_ABORT
| wxPD_AUTO_HIDE
);
671 while (status
.IsActive())
673 curi
= status
.GetCurIndex();
674 if (curi
% 32 == 0 && progress
.Update(curi
) == FALSE
)
678 foundstr
.Printf(_("Found %i matches"), ++foundcnt
);
679 progress
.Update(status
.GetCurIndex(), foundstr
);
680 m_SearchList
->Append(status
.GetName(), status
.GetContentsItem());
684 m_SearchButton
->Enable(TRUE
);
685 m_SearchText
->SetSelection(0, keyword
.Length());
686 m_SearchText
->SetFocus();
689 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_SearchList
->GetClientData(0);
692 m_HtmlWin
->LoadPage(it
->GetFullPath());
696 return (foundcnt
> 0);
699 void wxHtmlHelpFrame::CreateContents()
704 m_ContentsBox
->Clear();
706 if (m_PagesHash
) delete m_PagesHash
;
707 m_PagesHash
= new wxHashTable(wxKEY_STRING
, 2 * m_Data
->GetContentsCnt());
708 m_PagesHash
->DeleteContents(TRUE
);
710 int cnt
= m_Data
->GetContentsCnt();
713 wxHtmlContentsItem
*it
;
715 const int MAX_ROOTS
= 64;
716 wxTreeItemId roots
[MAX_ROOTS
];
717 // VS: this array holds information about whether we've set item icon at
718 // given level. This is neccessary because m_Data has flat structure
719 // and there's no way of recognizing if some item has subitems or not.
720 // We set the icon later: when we find an item with level=n, we know
721 // that the last item with level=n-1 was folder with subitems, so we
722 // set its icon accordingly
723 bool imaged
[MAX_ROOTS
];
724 m_ContentsBox
->DeleteAllItems();
726 roots
[0] = m_ContentsBox
->AddRoot(_("(Help)"));
727 m_ContentsBox
->SetItemImage(roots
[0], IMG_RootFolder
);
728 m_ContentsBox
->SetItemSelectedImage(roots
[0], IMG_RootFolder
);
731 for (it
= m_Data
->GetContents(), i
= 0; i
< cnt
; i
++, it
++)
734 if (it
->m_Level
== 0)
736 if (m_hfStyle
& wxHF_MERGE_BOOKS
)
737 // VS: we don't want book nodes, books' content should
738 // appear under tree's root. This line will create "fake"
739 // record about book node so that the rest of this look
740 // will believe there really _is_ book node and will
745 roots
[1] = m_ContentsBox
->AppendItem(roots
[0],
746 it
->m_Name
, IMG_Book
, -1,
747 new wxHtmlHelpTreeItemData(i
));
748 m_ContentsBox
->SetItemBold(roots
[1], TRUE
);
752 // ...and their contents:
755 roots
[it
->m_Level
+ 1] = m_ContentsBox
->AppendItem(
756 roots
[it
->m_Level
], it
->m_Name
, IMG_Page
,
757 -1, new wxHtmlHelpTreeItemData(i
));
758 imaged
[it
->m_Level
+ 1] = FALSE
;
761 m_PagesHash
->Put(it
->GetFullPath(),
762 new wxHtmlHelpHashData(i
, roots
[it
->m_Level
+ 1]));
764 // Set the icon for the node one level up in the hiearachy,
765 // unless already done (see comment above imaged[] declaration)
766 if (!imaged
[it
->m_Level
])
768 int image
= IMG_Folder
;
769 if (m_hfStyle
& wxHF_ICONS_BOOK
)
771 else if (m_hfStyle
& wxHF_ICONS_BOOK_CHAPTER
)
772 image
= (it
->m_Level
== 1) ? IMG_Book
: IMG_Folder
;
773 m_ContentsBox
->SetItemImage(roots
[it
->m_Level
], image
);
774 m_ContentsBox
->SetItemSelectedImage(roots
[it
->m_Level
], image
);
775 imaged
[it
->m_Level
] = TRUE
;
779 m_ContentsBox
->Expand(roots
[0]);
783 void wxHtmlHelpFrame::CreateIndex()
788 m_IndexList
->Clear();
790 int cnt
= m_Data
->GetIndexCnt();
793 if (cnt
> INDEX_IS_SMALL
) cnttext
.Printf(_("%i of %i"), 0, cnt
);
794 else cnttext
.Printf(_("%i of %i"), cnt
, cnt
);
795 m_IndexCountInfo
->SetLabel(cnttext
);
796 if (cnt
> INDEX_IS_SMALL
) return;
798 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
800 for (int i
= 0; i
< cnt
; i
++)
801 m_IndexList
->Append(index
[i
].m_Name
, (char*)(index
+ i
));
804 void wxHtmlHelpFrame::CreateSearch()
806 if (! (m_SearchList
&& m_SearchChoice
))
808 m_SearchList
->Clear();
809 m_SearchChoice
->Clear();
810 m_SearchChoice
->Append(_("Search in all books"));
811 const wxHtmlBookRecArray
& bookrec
= m_Data
->GetBookRecArray();
812 int i
, cnt
= bookrec
.GetCount();
813 for (i
= 0; i
< cnt
; i
++)
814 m_SearchChoice
->Append(bookrec
[i
].GetTitle());
815 m_SearchChoice
->SetSelection(0);
819 void wxHtmlHelpFrame::RefreshLists()
826 void wxHtmlHelpFrame::ReadCustomization(wxConfigBase
*cfg
, const wxString
& path
)
831 if (path
!= wxEmptyString
)
833 oldpath
= cfg
->GetPath();
834 cfg
->SetPath(_T("/") + path
);
837 m_Cfg
.navig_on
= cfg
->Read(wxT("hcNavigPanel"), m_Cfg
.navig_on
) != 0;
838 m_Cfg
.sashpos
= cfg
->Read(wxT("hcSashPos"), m_Cfg
.sashpos
);
839 m_Cfg
.x
= cfg
->Read(wxT("hcX"), m_Cfg
.x
);
840 m_Cfg
.y
= cfg
->Read(wxT("hcY"), m_Cfg
.y
);
841 m_Cfg
.w
= cfg
->Read(wxT("hcW"), m_Cfg
.w
);
842 m_Cfg
.h
= cfg
->Read(wxT("hcH"), m_Cfg
.h
);
844 m_FixedFace
= cfg
->Read(wxT("hcFixedFace"), m_FixedFace
);
845 m_NormalFace
= cfg
->Read(wxT("hcNormalFace"), m_NormalFace
);
846 m_FontSize
= cfg
->Read(wxT("hcFontSize"), m_FontSize
);
853 cnt
= cfg
->Read(wxT("hcBookmarksCnt"), 0L);
856 m_BookmarksNames
.Clear();
857 m_BookmarksPages
.Clear();
860 m_Bookmarks
->Clear();
861 m_Bookmarks
->Append(_("(bookmarks)"));
864 for (i
= 0; i
< cnt
; i
++)
866 val
.Printf(wxT("hcBookmark_%i"), i
);
868 m_BookmarksNames
.Add(s
);
869 if (m_Bookmarks
) m_Bookmarks
->Append(s
);
870 val
.Printf(wxT("hcBookmark_%i_url"), i
);
872 m_BookmarksPages
.Add(s
);
878 m_HtmlWin
->ReadCustomization(cfg
);
880 if (path
!= wxEmptyString
)
881 cfg
->SetPath(oldpath
);
884 void wxHtmlHelpFrame::WriteCustomization(wxConfigBase
*cfg
, const wxString
& path
)
889 if (path
!= wxEmptyString
)
891 oldpath
= cfg
->GetPath();
892 cfg
->SetPath(_T("/") + path
);
895 cfg
->Write(wxT("hcNavigPanel"), m_Cfg
.navig_on
);
896 cfg
->Write(wxT("hcSashPos"), (long)m_Cfg
.sashpos
);
897 cfg
->Write(wxT("hcX"), (long)m_Cfg
.x
);
898 cfg
->Write(wxT("hcY"), (long)m_Cfg
.y
);
899 cfg
->Write(wxT("hcW"), (long)m_Cfg
.w
);
900 cfg
->Write(wxT("hcH"), (long)m_Cfg
.h
);
901 cfg
->Write(wxT("hcFixedFace"), m_FixedFace
);
902 cfg
->Write(wxT("hcNormalFace"), m_NormalFace
);
903 cfg
->Write(wxT("hcFontSize"), (long)m_FontSize
);
908 int cnt
= m_BookmarksNames
.GetCount();
911 cfg
->Write(wxT("hcBookmarksCnt"), (long)cnt
);
912 for (i
= 0; i
< cnt
; i
++)
914 val
.Printf(wxT("hcBookmark_%i"), i
);
915 cfg
->Write(val
, m_BookmarksNames
[i
]);
916 val
.Printf(wxT("hcBookmark_%i_url"), i
);
917 cfg
->Write(val
, m_BookmarksPages
[i
]);
922 m_HtmlWin
->WriteCustomization(cfg
);
924 if (path
!= wxEmptyString
)
925 cfg
->SetPath(oldpath
);
932 static void SetFontsToHtmlWin(wxHtmlWindow
*win
, wxString scalf
, wxString fixf
, int size
)
934 static int f_sizes
[5][7] =
936 { 6, 7, 9, 12, 14, 16, 19},
937 { 8, 9, 12, 14, 16, 19, 22},
938 {10, 12, 14, 16, 19, 24, 32},
939 {14, 16, 18, 24, 32, 38, 45},
940 {16, 20, 24, 32, 38, 45, 50}
943 win
->SetFonts(scalf
, fixf
, f_sizes
[size
]);
947 class wxHtmlHelpFrameOptionsDialog
: public wxDialog
950 wxComboBox
*NormalFont
, *FixedFont
;
951 wxRadioBox
*RadioBox
;
952 wxHtmlWindow
*TestWin
;
954 wxHtmlHelpFrameOptionsDialog(wxWindow
*parent
) : wxDialog(parent
, -1, wxString(_("Help Browser Options")))
956 wxString choices
[5] = {_("very small"), _("small"), _("medium"), _("large"), _("very large")};
957 wxBoxSizer
*topsizer
, *sizer
, *sizer2
;
959 topsizer
= new wxBoxSizer(wxVERTICAL
);
961 sizer
= new wxBoxSizer(wxHORIZONTAL
);
963 sizer2
= new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Normal font:")), wxVERTICAL
);
964 sizer2
->Add(NormalFont
= new wxComboBox(this, -1, wxEmptyString
, wxDefaultPosition
,
966 0, NULL
, wxCB_DROPDOWN
| wxCB_READONLY
),
967 1, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
969 sizer
->Add(sizer2
, 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10);
971 sizer2
= new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Fixed font:")), wxVERTICAL
);
972 sizer2
->Add(FixedFont
= new wxComboBox(this, -1, wxEmptyString
, wxDefaultPosition
,
974 0, NULL
, wxCB_DROPDOWN
| wxCB_READONLY
),
975 1, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
977 sizer
->Add(sizer2
, 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10);
979 topsizer
->Add(sizer
);
981 topsizer
->Add(RadioBox
= new wxRadioBox(this, -1, _("Font size:"),
982 wxDefaultPosition
, wxDefaultSize
, 5, choices
, 5),
983 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10);
985 topsizer
->Add(new wxStaticText(this, -1, _("Preview:")),
986 0, wxLEFT
| wxTOP
, 10);
987 topsizer
->Add(TestWin
= new wxHtmlWindow(this, -1, wxDefaultPosition
, wxSize(-1, 150),
988 wxHW_SCROLLBAR_AUTO
| wxSUNKEN_BORDER
),
989 1, wxEXPAND
| wxLEFT
|wxTOP
|wxRIGHT
, 10);
991 sizer
= new wxBoxSizer(wxHORIZONTAL
);
992 sizer
->Add(new wxButton(this, wxID_OK
, _("OK")), 0, wxALL
, 10);
993 sizer
->Add(new wxButton(this, wxID_CANCEL
, _("Cancel")), 0, wxALL
, 10);
994 topsizer
->Add(sizer
, 0, wxALIGN_RIGHT
);
1003 void UpdateTestWin()
1006 SetFontsToHtmlWin(TestWin
,
1007 NormalFont
->GetStringSelection(),
1008 FixedFont
->GetStringSelection(),
1009 RadioBox
->GetSelection());
1012 Normal face<br>(and <u>underlined</u>. <i>Italic face.</i> \
1013 <b>Bold face.</b> <b><i>Bold italic face.</i></b><br>\
1014 <font size=-2>font size -2</font><br>\
1015 <font size=-1>font size -1</font><br>\
1016 <font size=+0>font size +0</font><br>\
1017 <font size=+1>font size +1</font><br>\
1018 <font size=+2>font size +2</font><br>\
1019 <font size=+3>font size +3</font><br>\
1020 <font size=+4>font size +4</font><br>\
1022 <p><tt>Fixed size face.<br> <b>bold</b> <i>italic</i> \
1023 <b><i>bold italic <u>underlined</u></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></tt>\
1035 void OnUpdate(wxCommandEvent
& WXUNUSED(event
))
1040 DECLARE_EVENT_TABLE()
1043 BEGIN_EVENT_TABLE(wxHtmlHelpFrameOptionsDialog
, wxDialog
)
1044 EVT_COMBOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate
)
1045 EVT_RADIOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate
)
1049 void wxHtmlHelpFrame::OptionsDialog()
1051 wxHtmlHelpFrameOptionsDialog
dlg(this);
1054 if (m_NormalFonts
== NULL
)
1056 wxFontEnumerator enu
;
1057 enu
.EnumerateFacenames();
1058 m_NormalFonts
= new wxArrayString
;
1059 *m_NormalFonts
= *enu
.GetFacenames();
1060 m_NormalFonts
->Sort();
1062 if (m_FixedFonts
== NULL
)
1064 wxFontEnumerator enu
;
1065 enu
.EnumerateFacenames(wxFONTENCODING_SYSTEM
, TRUE
);
1066 m_FixedFonts
= new wxArrayString
;
1067 *m_FixedFonts
= *enu
.GetFacenames();
1068 m_FixedFonts
->Sort();
1071 for (i
= 0; i
< m_NormalFonts
->GetCount(); i
++)
1072 dlg
.NormalFont
->Append((*m_NormalFonts
)[i
]);
1073 for (i
= 0; i
< m_FixedFonts
->GetCount(); i
++)
1074 dlg
.FixedFont
->Append((*m_FixedFonts
)[i
]);
1075 if (!m_NormalFace
.IsEmpty()) dlg
.NormalFont
->SetStringSelection(m_NormalFace
);
1076 else dlg
.NormalFont
->SetSelection(0);
1077 if (!m_FixedFace
.IsEmpty()) dlg
.FixedFont
->SetStringSelection(m_FixedFace
);
1078 else dlg
.FixedFont
->SetSelection(0);
1079 dlg
.RadioBox
->SetSelection(m_FontSize
);
1080 dlg
.UpdateTestWin();
1082 if (dlg
.ShowModal() == wxID_OK
)
1084 m_NormalFace
= dlg
.NormalFont
->GetStringSelection();
1085 m_FixedFace
= dlg
.FixedFont
->GetStringSelection();
1086 m_FontSize
= dlg
.RadioBox
->GetSelection();
1087 SetFontsToHtmlWin(m_HtmlWin
, m_NormalFace
, m_FixedFace
, m_FontSize
);
1093 void wxHtmlHelpFrame::NotifyPageChanged()
1095 if (m_UpdateContents
&& m_PagesHash
)
1097 wxString an
= m_HtmlWin
->GetOpenedAnchor();
1098 wxHtmlHelpHashData
*ha
;
1100 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage());
1102 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage() + wxT("#") + an
);
1105 bool olduc
= m_UpdateContents
;
1106 m_UpdateContents
= FALSE
;
1107 m_ContentsBox
->SelectItem(ha
->m_Id
);
1108 m_ContentsBox
->EnsureVisible(ha
->m_Id
);
1109 m_UpdateContents
= olduc
;
1121 void wxHtmlHelpFrame::OnToolbar(wxCommandEvent
& event
)
1123 switch (event
.GetId())
1125 case wxID_HTML_BACK
:
1126 m_HtmlWin
->HistoryBack();
1127 NotifyPageChanged();
1130 case wxID_HTML_FORWARD
:
1131 m_HtmlWin
->HistoryForward();
1132 NotifyPageChanged();
1138 wxString an
= m_HtmlWin
->GetOpenedAnchor();
1139 wxHtmlHelpHashData
*ha
;
1141 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage());
1143 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage() + wxT("#") + an
);
1144 if (ha
&& ha
->m_Index
> 0)
1146 wxHtmlContentsItem
*it
= m_Data
->GetContents() + (ha
->m_Index
- 1);
1147 if (it
->m_Page
[0] != 0)
1149 m_HtmlWin
->LoadPage(it
->GetFullPath());
1150 NotifyPageChanged();
1156 case wxID_HTML_UPNODE
:
1159 wxString an
= m_HtmlWin
->GetOpenedAnchor();
1160 wxHtmlHelpHashData
*ha
;
1162 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage());
1164 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage() + wxT("#") + an
);
1165 if (ha
&& ha
->m_Index
> 0)
1167 int level
= m_Data
->GetContents()[ha
->m_Index
].m_Level
- 1;
1168 wxHtmlContentsItem
*it
;
1169 int ind
= ha
->m_Index
- 1;
1171 it
= m_Data
->GetContents() + ind
;
1172 while (ind
>= 0 && it
->m_Level
!= level
) ind
--, it
--;
1175 if (it
->m_Page
[0] != 0)
1177 m_HtmlWin
->LoadPage(it
->GetFullPath());
1178 NotifyPageChanged();
1185 case wxID_HTML_DOWN
:
1188 wxString an
= m_HtmlWin
->GetOpenedAnchor();
1190 wxHtmlHelpHashData
*ha
;
1192 if (an
.IsEmpty()) adr
= m_HtmlWin
->GetOpenedPage();
1193 else adr
= m_HtmlWin
->GetOpenedPage() + wxT("#") + an
;
1195 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(adr
);
1197 if (ha
&& ha
->m_Index
< m_Data
->GetContentsCnt() - 1)
1199 wxHtmlContentsItem
*it
= m_Data
->GetContents() + (ha
->m_Index
+ 1);
1201 while (it
->GetFullPath() == adr
) it
++;
1203 if (it
->m_Page
[0] != 0)
1205 m_HtmlWin
->LoadPage(it
->GetFullPath());
1206 NotifyPageChanged();
1212 case wxID_HTML_PANEL
:
1214 if (! (m_Splitter
&& m_NavigPan
))
1216 if (m_Splitter
->IsSplit())
1218 m_Cfg
.sashpos
= m_Splitter
->GetSashPosition();
1219 m_Splitter
->Unsplit(m_NavigPan
);
1220 m_Cfg
.navig_on
= FALSE
;
1224 m_NavigPan
->Show(TRUE
);
1225 m_HtmlWin
->Show(TRUE
);
1226 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
1227 m_Cfg
.navig_on
= TRUE
;
1232 case wxID_HTML_OPTIONS
:
1236 case wxID_HTML_BOOKMARKSADD
:
1241 item
= m_HtmlWin
->GetOpenedPageTitle();
1242 url
= m_HtmlWin
->GetOpenedPage();
1243 if (item
== wxEmptyString
)
1244 item
= url
.AfterLast(wxT('/'));
1245 if (m_BookmarksPages
.Index(url
) == wxNOT_FOUND
)
1247 m_Bookmarks
->Append(item
);
1248 m_BookmarksNames
.Add(item
);
1249 m_BookmarksPages
.Add(url
);
1254 case wxID_HTML_BOOKMARKSREMOVE
:
1259 item
= m_Bookmarks
->GetStringSelection();
1260 pos
= m_BookmarksNames
.Index(item
);
1261 if (pos
!= wxNOT_FOUND
)
1263 m_BookmarksNames
.Remove(pos
);
1264 m_BookmarksPages
.Remove(pos
);
1265 m_Bookmarks
->Delete(m_Bookmarks
->GetSelection());
1270 #if wxUSE_PRINTING_ARCHITECTURE
1271 case wxID_HTML_PRINT
:
1273 if (m_Printer
== NULL
)
1274 m_Printer
= new wxHtmlEasyPrinting(_("Help Printing"), this);
1275 if (!m_HtmlWin
->GetOpenedPage())
1276 wxLogWarning(_("Cannot print empty page."));
1278 m_Printer
->PrintFile(m_HtmlWin
->GetOpenedPage());
1283 case wxID_HTML_OPENFILE
:
1285 wxString s
= wxFileSelector(_("Open HTML document"),
1290 "HTML files (*.htm)|*.htm|HTML files (*.html)|*.html|\
1291 Help books (*.htb)|*.htb|Help books (*.zip)|*.zip|\
1292 HTML Help Project (*.hhp)|*.hhp|\
1295 wxOPEN
| wxFILE_MUST_EXIST
,
1299 wxString ext
= s
.Right(4).Lower();
1300 if (ext
== _T(".zip") || ext
== _T(".htb") || ext
== _T(".hhp"))
1307 m_HtmlWin
->LoadPage(s
);
1316 void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent
& event
)
1318 wxHtmlHelpTreeItemData
*pg
;
1319 wxHtmlContentsItem
*it
;
1321 pg
= (wxHtmlHelpTreeItemData
*) m_ContentsBox
->GetItemData(event
.GetItem());
1323 if (pg
&& m_UpdateContents
)
1325 it
= m_Data
->GetContents() + (pg
->m_Id
);
1326 m_UpdateContents
= FALSE
;
1327 if (it
->m_Page
[0] != 0)
1328 m_HtmlWin
->LoadPage(it
->GetFullPath());
1329 m_UpdateContents
= TRUE
;
1335 void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent
& WXUNUSED(event
))
1337 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_IndexList
->GetClientData(m_IndexList
->GetSelection());
1338 if (it
->m_Page
[0] != 0)
1339 m_HtmlWin
->LoadPage(it
->GetFullPath());
1340 NotifyPageChanged();
1344 void wxHtmlHelpFrame::OnIndexFind(wxCommandEvent
& event
)
1346 wxString sr
= m_IndexText
->GetLineText(0);
1348 if (sr
== wxEmptyString
)
1355 const wxChar
*cstr
= sr
.c_str();
1360 m_IndexList
->Clear();
1361 int cnt
= m_Data
->GetIndexCnt();
1362 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
1365 for (int i
= 0; i
< cnt
; i
++)
1367 wxStrncpy(mybuff
, index
[i
].m_Name
, 512);
1368 mybuff
[511] = _T('\0');
1369 for (ptr
= mybuff
; *ptr
!= 0; ptr
++)
1370 if (*ptr
>= _T('A') && *ptr
<= _T('Z'))
1371 *ptr
-= (wxChar
)(_T('A') - _T('a'));
1372 if (wxStrstr(mybuff
, cstr
) != NULL
)
1374 m_IndexList
->Append(index
[i
].m_Name
, (char*)(index
+ i
));
1378 if (index
[i
].m_Page
[0] != 0)
1379 m_HtmlWin
->LoadPage(index
[i
].GetFullPath());
1380 NotifyPageChanged();
1387 cnttext
.Printf(_("%i of %i"), displ
, cnt
);
1388 m_IndexCountInfo
->SetLabel(cnttext
);
1390 m_IndexText
->SetSelection(0, sr
.Length());
1391 m_IndexText
->SetFocus();
1395 void wxHtmlHelpFrame::OnIndexAll(wxCommandEvent
& WXUNUSED(event
))
1399 m_IndexList
->Clear();
1400 int cnt
= m_Data
->GetIndexCnt();
1402 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
1404 for (int i
= 0; i
< cnt
; i
++)
1406 m_IndexList
->Append(index
[i
].m_Name
, (char*)(index
+ i
));
1409 if (index
[i
].m_Page
[0] != 0)
1410 m_HtmlWin
->LoadPage(index
[i
].GetFullPath());
1411 NotifyPageChanged();
1417 cnttext
.Printf(_("%i of %i"), cnt
, cnt
);
1418 m_IndexCountInfo
->SetLabel(cnttext
);
1422 void wxHtmlHelpFrame::OnSearchSel(wxCommandEvent
& WXUNUSED(event
))
1424 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_SearchList
->GetClientData(m_SearchList
->GetSelection());
1427 if (it
->m_Page
[0] != 0)
1428 m_HtmlWin
->LoadPage(it
->GetFullPath());
1429 NotifyPageChanged();
1433 void wxHtmlHelpFrame::OnSearch(wxCommandEvent
& WXUNUSED(event
))
1435 wxString sr
= m_SearchText
->GetLineText(0);
1437 if (sr
!= wxEmptyString
) KeywordSearch(sr
);
1440 void wxHtmlHelpFrame::OnBookmarksSel(wxCommandEvent
& WXUNUSED(event
))
1442 wxString sr
= m_Bookmarks
->GetStringSelection();
1444 if (sr
!= wxEmptyString
&& sr
!= _("(bookmarks)"))
1446 m_HtmlWin
->LoadPage(m_BookmarksPages
[m_BookmarksNames
.Index(sr
)]);
1447 NotifyPageChanged();
1451 void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent
& evt
)
1453 GetSize(&m_Cfg
.w
, &m_Cfg
.h
);
1454 GetPosition(&m_Cfg
.x
, &m_Cfg
.y
);
1456 if (m_Splitter
&& m_Cfg
.navig_on
) m_Cfg
.sashpos
= m_Splitter
->GetSashPosition();
1459 WriteCustomization(m_Config
, m_ConfigRoot
);
1461 if (m_helpController
&& m_helpController
->IsKindOf(CLASSINFO(wxHtmlHelpController
)))
1463 ((wxHtmlHelpController
*) m_helpController
)->OnCloseFrame(evt
);
1469 BEGIN_EVENT_TABLE(wxHtmlHelpFrame
, wxFrame
)
1470 EVT_TOOL_RANGE(wxID_HTML_PANEL
, wxID_HTML_OPTIONS
, wxHtmlHelpFrame::OnToolbar
)
1471 EVT_BUTTON(wxID_HTML_BOOKMARKSREMOVE
, wxHtmlHelpFrame::OnToolbar
)
1472 EVT_BUTTON(wxID_HTML_BOOKMARKSADD
, wxHtmlHelpFrame::OnToolbar
)
1473 EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL
, wxHtmlHelpFrame::OnContentsSel
)
1474 EVT_LISTBOX(wxID_HTML_INDEXLIST
, wxHtmlHelpFrame::OnIndexSel
)
1475 EVT_LISTBOX(wxID_HTML_SEARCHLIST
, wxHtmlHelpFrame::OnSearchSel
)
1476 EVT_BUTTON(wxID_HTML_SEARCHBUTTON
, wxHtmlHelpFrame::OnSearch
)
1477 EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT
, wxHtmlHelpFrame::OnSearch
)
1478 EVT_BUTTON(wxID_HTML_INDEXBUTTON
, wxHtmlHelpFrame::OnIndexFind
)
1479 EVT_TEXT_ENTER(wxID_HTML_INDEXTEXT
, wxHtmlHelpFrame::OnIndexFind
)
1480 EVT_BUTTON(wxID_HTML_INDEXBUTTONALL
, wxHtmlHelpFrame::OnIndexAll
)
1481 EVT_COMBOBOX(wxID_HTML_BOOKMARKSLIST
, wxHtmlHelpFrame::OnBookmarksSel
)
1482 EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow
)
1485 #endif // wxUSE_WXHTML_HELP