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 long treeStyle
= wxSUNKEN_BORDER
| wxTR_HAS_BUTTONS
;
331 #ifndef __WXMSW__ // FIXME - temporary, till MSW supports wxTR_HIDE_ROOT
332 treeStyle
|= wxTR_HIDE_ROOT
;
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
,
349 wxDefaultPosition
, wxSize(20,20));
350 bmpbt2
= new wxBitmapButton(dummy
, wxID_HTML_BOOKMARKSREMOVE
,
352 wxDefaultPosition
, wxSize(20,20));
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, wxRIGHT
, 5);
361 sizer
->Add(bmpbt1
, 0, wxRIGHT
, 2);
362 sizer
->Add(bmpbt2
, 0, 0, 0);
364 topsizer
->Add(sizer
, 0, wxEXPAND
| wxLEFT
| wxBOTTOM
| wxRIGHT
, 10);
367 m_ContentsBox
= new wxTreeCtrl(dummy
, wxID_HTML_TREECTRL
,
368 wxDefaultPosition
, wxDefaultSize
,
370 m_ContentsBox
->AssignImageList(ContentsImageList
);
372 topsizer
->Add(m_ContentsBox
, 1, wxEXPAND
| wxLEFT
| wxBOTTOM
| wxRIGHT
, 2);
374 m_NavigNotebook
->AddPage(dummy
, _("Contents"));
375 m_ContentsPage
= notebook_page
++;
378 // index listbox panel?
379 if ( style
& wxHF_INDEX
)
381 wxWindow
*dummy
= new wxPanel(m_NavigNotebook
, wxID_HTML_INDEXPAGE
);
382 wxSizer
*topsizer
= new wxBoxSizer(wxVERTICAL
);
384 dummy
->SetAutoLayout(TRUE
);
385 dummy
->SetSizer(topsizer
);
387 m_IndexText
= new wxTextCtrl(dummy
, wxID_HTML_INDEXTEXT
, wxEmptyString
,
388 wxDefaultPosition
, wxDefaultSize
,
390 m_IndexButton
= new wxButton(dummy
, wxID_HTML_INDEXBUTTON
, _("Find"));
391 m_IndexButtonAll
= new wxButton(dummy
, wxID_HTML_INDEXBUTTONALL
,
393 m_IndexCountInfo
= new wxStaticText(dummy
, wxID_HTML_COUNTINFO
,
394 wxEmptyString
, wxDefaultPosition
,
396 wxALIGN_RIGHT
| wxST_NO_AUTORESIZE
);
397 m_IndexList
= new wxListBox(dummy
, wxID_HTML_INDEXLIST
,
398 wxDefaultPosition
, wxDefaultSize
,
399 0, NULL
, wxLB_SINGLE
);
402 m_IndexButton
->SetToolTip(_("Display all index items that contain given substring. Search is case insensitive."));
403 m_IndexButtonAll
->SetToolTip(_("Show all items in index"));
404 #endif //wxUSE_TOOLTIPS
406 topsizer
->Add(m_IndexText
, 0, wxEXPAND
| wxALL
, 10);
407 wxSizer
*btsizer
= new wxBoxSizer(wxHORIZONTAL
);
408 btsizer
->Add(m_IndexButton
, 0, wxRIGHT
, 2);
409 btsizer
->Add(m_IndexButtonAll
);
410 topsizer
->Add(btsizer
, 0,
411 wxALIGN_RIGHT
| wxLEFT
| wxRIGHT
| wxBOTTOM
, 10);
412 topsizer
->Add(m_IndexCountInfo
, 0, wxEXPAND
| wxLEFT
| wxRIGHT
, 2);
413 topsizer
->Add(m_IndexList
, 1, wxEXPAND
| wxALL
, 2);
415 m_NavigNotebook
->AddPage(dummy
, _("Index"));
416 m_IndexPage
= notebook_page
++;
419 // search list panel?
420 if ( style
& wxHF_SEARCH
)
422 wxWindow
*dummy
= new wxPanel(m_NavigNotebook
, wxID_HTML_INDEXPAGE
);
423 wxSizer
*sizer
= new wxBoxSizer(wxVERTICAL
);
425 dummy
->SetAutoLayout(TRUE
);
426 dummy
->SetSizer(sizer
);
428 m_SearchText
= new wxTextCtrl(dummy
, wxID_HTML_SEARCHTEXT
,
430 wxDefaultPosition
, wxDefaultSize
,
432 m_SearchChoice
= new wxChoice(dummy
, wxID_HTML_SEARCHCHOICE
,
433 wxDefaultPosition
, wxDefaultSize
);
434 m_SearchCaseSensitive
= new wxCheckBox(dummy
, -1, _("Case sensitive"));
435 m_SearchWholeWords
= new wxCheckBox(dummy
, -1, _("Whole words only"));
436 m_SearchButton
= new wxButton(dummy
, wxID_HTML_SEARCHBUTTON
, _("Search"));
438 m_SearchButton
->SetToolTip(_("Search contents of help book(s) for all occurences of the text you typed above"));
439 #endif //wxUSE_TOOLTIPS
440 m_SearchList
= new wxListBox(dummy
, wxID_HTML_SEARCHLIST
,
441 wxDefaultPosition
, wxDefaultSize
,
442 0, NULL
, wxLB_SINGLE
);
444 sizer
->Add(m_SearchText
, 0, wxEXPAND
| wxALL
, 10);
445 sizer
->Add(m_SearchChoice
, 0, wxEXPAND
| wxLEFT
| wxRIGHT
| wxBOTTOM
, 10);
446 sizer
->Add(m_SearchCaseSensitive
, 0, wxLEFT
| wxRIGHT
, 10);
447 sizer
->Add(m_SearchWholeWords
, 0, wxLEFT
| wxRIGHT
, 10);
448 sizer
->Add(m_SearchButton
, 0, wxALL
| wxALIGN_RIGHT
, 8);
449 sizer
->Add(m_SearchList
, 1, wxALL
| wxEXPAND
, 2);
451 m_NavigNotebook
->AddPage(dummy
, _("Search"));
452 m_SearchPage
= notebook_page
++;
455 m_HtmlWin
->Show(TRUE
);
461 navigSizer
->SetSizeHints(m_NavigPan
);
462 m_NavigPan
->Layout();
466 if ( m_NavigPan
&& m_Splitter
)
468 m_Splitter
->SetMinimumPaneSize(20);
469 if ( m_Cfg
.navig_on
)
470 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
472 if ( m_Cfg
.navig_on
)
474 m_NavigPan
->Show(TRUE
);
475 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
479 m_NavigPan
->Show(FALSE
);
480 m_Splitter
->Initialize(m_HtmlWin
);
487 wxHtmlHelpFrame::~wxHtmlHelpFrame()
489 // PopEventHandler(); // wxhtmlhelpcontroller (not any more!)
492 if (m_NormalFonts
) delete m_NormalFonts
;
493 if (m_FixedFonts
) delete m_FixedFonts
;
494 if (m_PagesHash
) delete m_PagesHash
;
498 void wxHtmlHelpFrame::AddToolbarButtons(wxToolBar
*toolBar
, int style
)
500 wxBitmap wpanelBitmap
= wxBITMAP(wpanel
);
501 wxBitmap wbackBitmap
= wxBITMAP(wback
);
502 wxBitmap wforwardBitmap
= wxBITMAP(wforward
);
503 wxBitmap wupnodeBitmap
= wxBITMAP(wupnode
);
504 wxBitmap wupBitmap
= wxBITMAP(wup
);
505 wxBitmap wdownBitmap
= wxBITMAP(wdown
);
506 wxBitmap wopenBitmap
= wxBITMAP(wopen
);
507 wxBitmap wprintBitmap
= wxBITMAP(wprint
);
508 wxBitmap woptionsBitmap
= wxBITMAP(woptions
);
510 wxASSERT_MSG( (wpanelBitmap
.Ok() && wbackBitmap
.Ok() &&
511 wforwardBitmap
.Ok() && wupnodeBitmap
.Ok() &&
512 wupBitmap
.Ok() && wdownBitmap
.Ok() &&
513 wopenBitmap
.Ok() && wprintBitmap
.Ok() &&
514 woptionsBitmap
.Ok()),
515 wxT("One or more HTML help frame toolbar bitmap could not be loaded.")) ;
518 toolBar
->AddTool(wxID_HTML_PANEL
, wpanelBitmap
, wxNullBitmap
,
519 FALSE
, -1, -1, (wxObject
*) NULL
,
520 _("Show/hide navigation panel"));
522 toolBar
->AddSeparator();
523 toolBar
->AddTool(wxID_HTML_BACK
, wbackBitmap
, wxNullBitmap
,
524 FALSE
, -1, -1, (wxObject
*) NULL
,
526 toolBar
->AddTool(wxID_HTML_FORWARD
, wforwardBitmap
, wxNullBitmap
,
527 FALSE
, -1, -1, (wxObject
*) NULL
,
529 toolBar
->AddSeparator();
531 toolBar
->AddTool(wxID_HTML_UPNODE
, wupnodeBitmap
, wxNullBitmap
,
532 FALSE
, -1, -1, (wxObject
*) NULL
,
533 _("Go one level up in document hierarchy"));
534 toolBar
->AddTool(wxID_HTML_UP
, wupBitmap
, wxNullBitmap
,
535 FALSE
, -1, -1, (wxObject
*) NULL
,
537 toolBar
->AddTool(wxID_HTML_DOWN
, wdownBitmap
, wxNullBitmap
,
538 FALSE
, -1, -1, (wxObject
*) NULL
,
541 if ((style
& wxHF_PRINT
) || (style
& wxHF_OPEN_FILES
))
542 toolBar
->AddSeparator();
544 if (style
& wxHF_OPEN_FILES
)
545 toolBar
->AddTool(wxID_HTML_OPENFILE
, wopenBitmap
, wxNullBitmap
,
546 FALSE
, -1, -1, (wxObject
*) NULL
,
547 _("Open HTML document"));
549 #if wxUSE_PRINTING_ARCHITECTURE
550 if (style
& wxHF_PRINT
)
551 toolBar
->AddTool(wxID_HTML_PRINT
, wprintBitmap
, wxNullBitmap
,
552 FALSE
, -1, -1, (wxObject
*) NULL
,
553 _("Print this page"));
556 toolBar
->AddSeparator();
557 toolBar
->AddTool(wxID_HTML_OPTIONS
, woptionsBitmap
, wxNullBitmap
,
558 FALSE
, -1, -1, (wxObject
*) NULL
,
559 _("Display options dialog"));
563 void wxHtmlHelpFrame::SetTitleFormat(const wxString
& format
)
566 m_HtmlWin
->SetRelatedFrame(this, format
);
567 m_TitleFormat
= format
;
571 bool wxHtmlHelpFrame::Display(const wxString
& x
)
573 wxString url
= m_Data
->FindPageByName(x
);
576 m_HtmlWin
->LoadPage(url
);
583 bool wxHtmlHelpFrame::Display(const int id
)
585 wxString url
= m_Data
->FindPageById(id
);
588 m_HtmlWin
->LoadPage(url
);
597 bool wxHtmlHelpFrame::DisplayContents()
601 if (!m_Splitter
->IsSplit())
603 m_NavigPan
->Show(TRUE
);
604 m_HtmlWin
->Show(TRUE
);
605 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
606 m_Cfg
.navig_on
= TRUE
;
608 m_NavigNotebook
->SetSelection(0);
609 if (m_Data
->GetBookRecArray().GetCount() > 0)
611 wxHtmlBookRecord
& book
= m_Data
->GetBookRecArray()[0];
612 if (!book
.GetStart().IsEmpty())
613 m_HtmlWin
->LoadPage(book
.GetFullPath(book
.GetStart()));
620 bool wxHtmlHelpFrame::DisplayIndex()
624 if (!m_Splitter
->IsSplit())
626 m_NavigPan
->Show(TRUE
);
627 m_HtmlWin
->Show(TRUE
);
628 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
630 m_NavigNotebook
->SetSelection(1);
631 if (m_Data
->GetBookRecArray().GetCount() > 0)
633 wxHtmlBookRecord
& book
= m_Data
->GetBookRecArray()[0];
634 if (!book
.GetStart().IsEmpty())
635 m_HtmlWin
->LoadPage(book
.GetFullPath(book
.GetStart()));
642 bool wxHtmlHelpFrame::KeywordSearch(const wxString
& keyword
)
644 if (! (m_SearchList
&& m_SearchButton
&& m_SearchText
&& m_SearchChoice
))
647 int foundcnt
= 0, curi
;
649 wxString book
= wxEmptyString
;
651 if (!m_Splitter
->IsSplit())
653 m_NavigPan
->Show(TRUE
);
654 m_HtmlWin
->Show(TRUE
);
655 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
657 m_NavigNotebook
->SetSelection(m_SearchPage
);
658 m_SearchList
->Clear();
659 m_SearchText
->SetValue(keyword
);
660 m_SearchButton
->Enable(FALSE
);
662 if (m_SearchChoice
->GetSelection() != 0)
663 book
= m_SearchChoice
->GetStringSelection();
665 wxHtmlSearchStatus
status(m_Data
, keyword
,
666 m_SearchCaseSensitive
->GetValue(), m_SearchWholeWords
->GetValue(),
669 wxProgressDialog
progress(_("Searching..."), _("No matching page found yet"),
670 status
.GetMaxIndex(), this,
671 wxPD_APP_MODAL
| wxPD_CAN_ABORT
| wxPD_AUTO_HIDE
);
673 while (status
.IsActive())
675 curi
= status
.GetCurIndex();
676 if (curi
% 32 == 0 && progress
.Update(curi
) == FALSE
)
680 foundstr
.Printf(_("Found %i matches"), ++foundcnt
);
681 progress
.Update(status
.GetCurIndex(), foundstr
);
682 m_SearchList
->Append(status
.GetName(), status
.GetContentsItem());
686 m_SearchButton
->Enable(TRUE
);
687 m_SearchText
->SetSelection(0, keyword
.Length());
688 m_SearchText
->SetFocus();
691 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_SearchList
->GetClientData(0);
694 m_HtmlWin
->LoadPage(it
->GetFullPath());
698 return (foundcnt
> 0);
701 void wxHtmlHelpFrame::CreateContents()
706 m_ContentsBox
->Clear();
708 if (m_PagesHash
) delete m_PagesHash
;
709 m_PagesHash
= new wxHashTable(wxKEY_STRING
, 2 * m_Data
->GetContentsCnt());
710 m_PagesHash
->DeleteContents(TRUE
);
712 int cnt
= m_Data
->GetContentsCnt();
714 size_t booksCnt
= m_Data
->GetBookRecArray().GetCount();
716 wxHtmlContentsItem
*it
;
718 const int MAX_ROOTS
= 64;
719 wxTreeItemId roots
[MAX_ROOTS
];
720 // VS: this array holds information about whether we've set item icon at
721 // given level. This is neccessary because m_Data has flat structure
722 // and there's no way of recognizing if some item has subitems or not.
723 // We set the icon later: when we find an item with level=n, we know
724 // that the last item with level=n-1 was folder with subitems, so we
725 // set its icon accordingly
726 bool imaged
[MAX_ROOTS
];
727 m_ContentsBox
->DeleteAllItems();
729 // FIXME - will go away when wxMSW's wxTreeCtrl supports wxTR_HIDE_ROOT!
730 bool hasSuperRoot
= (booksCnt
> 1) ||
731 (m_ContentsBox
->GetWindowStyle() & wxTR_HIDE_ROOT
);
733 // Don't show (Help) root if there's only one boook
736 roots
[0] = m_ContentsBox
->AddRoot(_("(Help)"));
737 m_ContentsBox
->SetItemImage(roots
[0], IMG_RootFolder
);
738 m_ContentsBox
->SetItemSelectedImage(roots
[0], IMG_RootFolder
);
742 for (it
= m_Data
->GetContents(), i
= 0; i
< cnt
; i
++, it
++)
745 if (it
->m_Level
== 0)
747 // special case, only one book, make it tree's root:
750 roots
[0] = roots
[1] = m_ContentsBox
->AddRoot(
751 it
->m_Name
, IMG_Book
, -1,
752 new wxHtmlHelpTreeItemData(i
));
753 imaged
[0] = imaged
[1] = TRUE
;
754 m_ContentsBox
->SetItemBold(roots
[1], TRUE
);
759 if (m_hfStyle
& wxHF_MERGE_BOOKS
)
760 // VS: we don't want book nodes, books' content should
761 // appear under tree's root. This line will create "fake"
762 // record about book node so that the rest of this look
763 // will believe there really _is_ book node and will
768 roots
[1] = m_ContentsBox
->AppendItem(roots
[0],
769 it
->m_Name
, IMG_Book
, -1,
770 new wxHtmlHelpTreeItemData(i
));
771 m_ContentsBox
->SetItemBold(roots
[1], TRUE
);
776 // ...and their contents:
779 roots
[it
->m_Level
+ 1] = m_ContentsBox
->AppendItem(
780 roots
[it
->m_Level
], it
->m_Name
, IMG_Page
,
781 -1, new wxHtmlHelpTreeItemData(i
));
782 imaged
[it
->m_Level
+ 1] = FALSE
;
785 m_PagesHash
->Put(it
->GetFullPath(),
786 new wxHtmlHelpHashData(i
, roots
[it
->m_Level
+ 1]));
788 // Set the icon for the node one level up in the hiearachy,
789 // unless already done (see comment above imaged[] declaration)
790 if (!imaged
[it
->m_Level
])
792 int image
= IMG_Folder
;
793 if (m_hfStyle
& wxHF_ICONS_BOOK
)
795 else if (m_hfStyle
& wxHF_ICONS_BOOK_CHAPTER
)
796 image
= (it
->m_Level
== 1) ? IMG_Book
: IMG_Folder
;
797 m_ContentsBox
->SetItemImage(roots
[it
->m_Level
], image
);
798 m_ContentsBox
->SetItemSelectedImage(roots
[it
->m_Level
], image
);
799 imaged
[it
->m_Level
] = TRUE
;
803 m_ContentsBox
->Expand(roots
[0]);
807 void wxHtmlHelpFrame::CreateIndex()
812 m_IndexList
->Clear();
814 int cnt
= m_Data
->GetIndexCnt();
817 if (cnt
> INDEX_IS_SMALL
) cnttext
.Printf(_("%i of %i"), 0, cnt
);
818 else cnttext
.Printf(_("%i of %i"), cnt
, cnt
);
819 m_IndexCountInfo
->SetLabel(cnttext
);
820 if (cnt
> INDEX_IS_SMALL
) return;
822 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
824 for (int i
= 0; i
< cnt
; i
++)
825 m_IndexList
->Append(index
[i
].m_Name
, (char*)(index
+ i
));
828 void wxHtmlHelpFrame::CreateSearch()
830 if (! (m_SearchList
&& m_SearchChoice
))
832 m_SearchList
->Clear();
833 m_SearchChoice
->Clear();
834 m_SearchChoice
->Append(_("Search in all books"));
835 const wxHtmlBookRecArray
& bookrec
= m_Data
->GetBookRecArray();
836 int i
, cnt
= bookrec
.GetCount();
837 for (i
= 0; i
< cnt
; i
++)
838 m_SearchChoice
->Append(bookrec
[i
].GetTitle());
839 m_SearchChoice
->SetSelection(0);
843 void wxHtmlHelpFrame::RefreshLists()
850 void wxHtmlHelpFrame::ReadCustomization(wxConfigBase
*cfg
, const wxString
& path
)
855 if (path
!= wxEmptyString
)
857 oldpath
= cfg
->GetPath();
858 cfg
->SetPath(_T("/") + path
);
861 m_Cfg
.navig_on
= cfg
->Read(wxT("hcNavigPanel"), m_Cfg
.navig_on
) != 0;
862 m_Cfg
.sashpos
= cfg
->Read(wxT("hcSashPos"), m_Cfg
.sashpos
);
863 m_Cfg
.x
= cfg
->Read(wxT("hcX"), m_Cfg
.x
);
864 m_Cfg
.y
= cfg
->Read(wxT("hcY"), m_Cfg
.y
);
865 m_Cfg
.w
= cfg
->Read(wxT("hcW"), m_Cfg
.w
);
866 m_Cfg
.h
= cfg
->Read(wxT("hcH"), m_Cfg
.h
);
868 m_FixedFace
= cfg
->Read(wxT("hcFixedFace"), m_FixedFace
);
869 m_NormalFace
= cfg
->Read(wxT("hcNormalFace"), m_NormalFace
);
870 m_FontSize
= cfg
->Read(wxT("hcFontSize"), m_FontSize
);
877 cnt
= cfg
->Read(wxT("hcBookmarksCnt"), 0L);
880 m_BookmarksNames
.Clear();
881 m_BookmarksPages
.Clear();
884 m_Bookmarks
->Clear();
885 m_Bookmarks
->Append(_("(bookmarks)"));
888 for (i
= 0; i
< cnt
; i
++)
890 val
.Printf(wxT("hcBookmark_%i"), i
);
892 m_BookmarksNames
.Add(s
);
893 if (m_Bookmarks
) m_Bookmarks
->Append(s
);
894 val
.Printf(wxT("hcBookmark_%i_url"), i
);
896 m_BookmarksPages
.Add(s
);
902 m_HtmlWin
->ReadCustomization(cfg
);
904 if (path
!= wxEmptyString
)
905 cfg
->SetPath(oldpath
);
908 void wxHtmlHelpFrame::WriteCustomization(wxConfigBase
*cfg
, const wxString
& path
)
913 if (path
!= wxEmptyString
)
915 oldpath
= cfg
->GetPath();
916 cfg
->SetPath(_T("/") + path
);
919 cfg
->Write(wxT("hcNavigPanel"), m_Cfg
.navig_on
);
920 cfg
->Write(wxT("hcSashPos"), (long)m_Cfg
.sashpos
);
921 cfg
->Write(wxT("hcX"), (long)m_Cfg
.x
);
922 cfg
->Write(wxT("hcY"), (long)m_Cfg
.y
);
923 cfg
->Write(wxT("hcW"), (long)m_Cfg
.w
);
924 cfg
->Write(wxT("hcH"), (long)m_Cfg
.h
);
925 cfg
->Write(wxT("hcFixedFace"), m_FixedFace
);
926 cfg
->Write(wxT("hcNormalFace"), m_NormalFace
);
927 cfg
->Write(wxT("hcFontSize"), (long)m_FontSize
);
932 int cnt
= m_BookmarksNames
.GetCount();
935 cfg
->Write(wxT("hcBookmarksCnt"), (long)cnt
);
936 for (i
= 0; i
< cnt
; i
++)
938 val
.Printf(wxT("hcBookmark_%i"), i
);
939 cfg
->Write(val
, m_BookmarksNames
[i
]);
940 val
.Printf(wxT("hcBookmark_%i_url"), i
);
941 cfg
->Write(val
, m_BookmarksPages
[i
]);
946 m_HtmlWin
->WriteCustomization(cfg
);
948 if (path
!= wxEmptyString
)
949 cfg
->SetPath(oldpath
);
956 static void SetFontsToHtmlWin(wxHtmlWindow
*win
, wxString scalf
, wxString fixf
, int size
)
958 static int f_sizes
[5][7] =
960 { 6, 7, 9, 12, 14, 16, 19},
961 { 8, 9, 12, 14, 16, 19, 22},
962 {10, 12, 14, 16, 19, 24, 32},
963 {14, 16, 18, 24, 32, 38, 45},
964 {16, 20, 24, 32, 38, 45, 50}
967 win
->SetFonts(scalf
, fixf
, f_sizes
[size
]);
971 class wxHtmlHelpFrameOptionsDialog
: public wxDialog
974 wxComboBox
*NormalFont
, *FixedFont
;
975 wxRadioBox
*RadioBox
;
976 wxHtmlWindow
*TestWin
;
978 wxHtmlHelpFrameOptionsDialog(wxWindow
*parent
) : wxDialog(parent
, -1, wxString(_("Help Browser Options")))
980 wxString choices
[5] = {_("very small"), _("small"), _("medium"), _("large"), _("very large")};
981 wxBoxSizer
*topsizer
, *sizer
, *sizer2
;
983 topsizer
= new wxBoxSizer(wxVERTICAL
);
985 sizer
= new wxBoxSizer(wxHORIZONTAL
);
987 sizer2
= new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Normal font:")), wxVERTICAL
);
988 sizer2
->Add(NormalFont
= new wxComboBox(this, -1, wxEmptyString
, wxDefaultPosition
,
990 0, NULL
, wxCB_DROPDOWN
| wxCB_READONLY
),
991 1, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
993 sizer
->Add(sizer2
, 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10);
995 sizer2
= new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Fixed font:")), wxVERTICAL
);
996 sizer2
->Add(FixedFont
= new wxComboBox(this, -1, wxEmptyString
, wxDefaultPosition
,
998 0, NULL
, wxCB_DROPDOWN
| wxCB_READONLY
),
999 1, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
1001 sizer
->Add(sizer2
, 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10);
1003 topsizer
->Add(sizer
);
1005 topsizer
->Add(RadioBox
= new wxRadioBox(this, -1, _("Font size:"),
1006 wxDefaultPosition
, wxDefaultSize
, 5, choices
, 5),
1007 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10);
1009 topsizer
->Add(new wxStaticText(this, -1, _("Preview:")),
1010 0, wxLEFT
| wxTOP
, 10);
1011 topsizer
->Add(TestWin
= new wxHtmlWindow(this, -1, wxDefaultPosition
, wxSize(-1, 150),
1012 wxHW_SCROLLBAR_AUTO
| wxSUNKEN_BORDER
),
1013 1, wxEXPAND
| wxLEFT
|wxTOP
|wxRIGHT
, 10);
1015 sizer
= new wxBoxSizer(wxHORIZONTAL
);
1016 sizer
->Add(new wxButton(this, wxID_OK
, _("OK")), 0, wxALL
, 10);
1017 sizer
->Add(new wxButton(this, wxID_CANCEL
, _("Cancel")), 0, wxALL
, 10);
1018 topsizer
->Add(sizer
, 0, wxALIGN_RIGHT
);
1020 SetAutoLayout(TRUE
);
1022 topsizer
->Fit(this);
1027 void UpdateTestWin()
1030 SetFontsToHtmlWin(TestWin
,
1031 NormalFont
->GetStringSelection(),
1032 FixedFont
->GetStringSelection(),
1033 RadioBox
->GetSelection());
1036 Normal face<br>(and <u>underlined</u>. <i>Italic face.</i> \
1037 <b>Bold face.</b> <b><i>Bold italic face.</i></b><br>\
1038 <font size=-2>font size -2</font><br>\
1039 <font size=-1>font size -1</font><br>\
1040 <font size=+0>font size +0</font><br>\
1041 <font size=+1>font size +1</font><br>\
1042 <font size=+2>font size +2</font><br>\
1043 <font size=+3>font size +3</font><br>\
1044 <font size=+4>font size +4</font><br>\
1046 <p><tt>Fixed size face.<br> <b>bold</b> <i>italic</i> \
1047 <b><i>bold italic <u>underlined</u></i></b><br>\
1048 <font size=-2>font size -2</font><br>\
1049 <font size=-1>font size -1</font><br>\
1050 <font size=+0>font size +0</font><br>\
1051 <font size=+1>font size +1</font><br>\
1052 <font size=+2>font size +2</font><br>\
1053 <font size=+3>font size +3</font><br>\
1054 <font size=+4>font size +4</font></tt>\
1059 void OnUpdate(wxCommandEvent
& WXUNUSED(event
))
1064 DECLARE_EVENT_TABLE()
1067 BEGIN_EVENT_TABLE(wxHtmlHelpFrameOptionsDialog
, wxDialog
)
1068 EVT_COMBOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate
)
1069 EVT_RADIOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate
)
1073 void wxHtmlHelpFrame::OptionsDialog()
1075 wxHtmlHelpFrameOptionsDialog
dlg(this);
1078 if (m_NormalFonts
== NULL
)
1080 wxFontEnumerator enu
;
1081 enu
.EnumerateFacenames();
1082 m_NormalFonts
= new wxArrayString
;
1083 *m_NormalFonts
= *enu
.GetFacenames();
1084 m_NormalFonts
->Sort();
1086 if (m_FixedFonts
== NULL
)
1088 wxFontEnumerator enu
;
1089 enu
.EnumerateFacenames(wxFONTENCODING_SYSTEM
, TRUE
);
1090 m_FixedFonts
= new wxArrayString
;
1091 *m_FixedFonts
= *enu
.GetFacenames();
1092 m_FixedFonts
->Sort();
1095 for (i
= 0; i
< m_NormalFonts
->GetCount(); i
++)
1096 dlg
.NormalFont
->Append((*m_NormalFonts
)[i
]);
1097 for (i
= 0; i
< m_FixedFonts
->GetCount(); i
++)
1098 dlg
.FixedFont
->Append((*m_FixedFonts
)[i
]);
1099 if (!m_NormalFace
.IsEmpty()) dlg
.NormalFont
->SetStringSelection(m_NormalFace
);
1100 else dlg
.NormalFont
->SetSelection(0);
1101 if (!m_FixedFace
.IsEmpty()) dlg
.FixedFont
->SetStringSelection(m_FixedFace
);
1102 else dlg
.FixedFont
->SetSelection(0);
1103 dlg
.RadioBox
->SetSelection(m_FontSize
);
1104 dlg
.UpdateTestWin();
1106 if (dlg
.ShowModal() == wxID_OK
)
1108 m_NormalFace
= dlg
.NormalFont
->GetStringSelection();
1109 m_FixedFace
= dlg
.FixedFont
->GetStringSelection();
1110 m_FontSize
= dlg
.RadioBox
->GetSelection();
1111 SetFontsToHtmlWin(m_HtmlWin
, m_NormalFace
, m_FixedFace
, m_FontSize
);
1117 void wxHtmlHelpFrame::NotifyPageChanged()
1119 if (m_UpdateContents
&& m_PagesHash
)
1121 wxString an
= m_HtmlWin
->GetOpenedAnchor();
1122 wxHtmlHelpHashData
*ha
;
1124 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage());
1126 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage() + wxT("#") + an
);
1129 bool olduc
= m_UpdateContents
;
1130 m_UpdateContents
= FALSE
;
1131 m_ContentsBox
->SelectItem(ha
->m_Id
);
1132 m_ContentsBox
->EnsureVisible(ha
->m_Id
);
1133 m_UpdateContents
= olduc
;
1145 void wxHtmlHelpFrame::OnToolbar(wxCommandEvent
& event
)
1147 switch (event
.GetId())
1149 case wxID_HTML_BACK
:
1150 m_HtmlWin
->HistoryBack();
1151 NotifyPageChanged();
1154 case wxID_HTML_FORWARD
:
1155 m_HtmlWin
->HistoryForward();
1156 NotifyPageChanged();
1162 wxString an
= m_HtmlWin
->GetOpenedAnchor();
1163 wxHtmlHelpHashData
*ha
;
1165 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage());
1167 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage() + wxT("#") + an
);
1168 if (ha
&& ha
->m_Index
> 0)
1170 wxHtmlContentsItem
*it
= m_Data
->GetContents() + (ha
->m_Index
- 1);
1171 if (it
->m_Page
[0] != 0)
1173 m_HtmlWin
->LoadPage(it
->GetFullPath());
1174 NotifyPageChanged();
1180 case wxID_HTML_UPNODE
:
1183 wxString an
= m_HtmlWin
->GetOpenedAnchor();
1184 wxHtmlHelpHashData
*ha
;
1186 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage());
1188 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage() + wxT("#") + an
);
1189 if (ha
&& ha
->m_Index
> 0)
1191 int level
= m_Data
->GetContents()[ha
->m_Index
].m_Level
- 1;
1192 wxHtmlContentsItem
*it
;
1193 int ind
= ha
->m_Index
- 1;
1195 it
= m_Data
->GetContents() + ind
;
1196 while (ind
>= 0 && it
->m_Level
!= level
) ind
--, it
--;
1199 if (it
->m_Page
[0] != 0)
1201 m_HtmlWin
->LoadPage(it
->GetFullPath());
1202 NotifyPageChanged();
1209 case wxID_HTML_DOWN
:
1212 wxString an
= m_HtmlWin
->GetOpenedAnchor();
1214 wxHtmlHelpHashData
*ha
;
1216 if (an
.IsEmpty()) adr
= m_HtmlWin
->GetOpenedPage();
1217 else adr
= m_HtmlWin
->GetOpenedPage() + wxT("#") + an
;
1219 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(adr
);
1221 if (ha
&& ha
->m_Index
< m_Data
->GetContentsCnt() - 1)
1223 wxHtmlContentsItem
*it
= m_Data
->GetContents() + (ha
->m_Index
+ 1);
1225 while (it
->GetFullPath() == adr
) it
++;
1227 if (it
->m_Page
[0] != 0)
1229 m_HtmlWin
->LoadPage(it
->GetFullPath());
1230 NotifyPageChanged();
1236 case wxID_HTML_PANEL
:
1238 if (! (m_Splitter
&& m_NavigPan
))
1240 if (m_Splitter
->IsSplit())
1242 m_Cfg
.sashpos
= m_Splitter
->GetSashPosition();
1243 m_Splitter
->Unsplit(m_NavigPan
);
1244 m_Cfg
.navig_on
= FALSE
;
1248 m_NavigPan
->Show(TRUE
);
1249 m_HtmlWin
->Show(TRUE
);
1250 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
1251 m_Cfg
.navig_on
= TRUE
;
1256 case wxID_HTML_OPTIONS
:
1260 case wxID_HTML_BOOKMARKSADD
:
1265 item
= m_HtmlWin
->GetOpenedPageTitle();
1266 url
= m_HtmlWin
->GetOpenedPage();
1267 if (item
== wxEmptyString
)
1268 item
= url
.AfterLast(wxT('/'));
1269 if (m_BookmarksPages
.Index(url
) == wxNOT_FOUND
)
1271 m_Bookmarks
->Append(item
);
1272 m_BookmarksNames
.Add(item
);
1273 m_BookmarksPages
.Add(url
);
1278 case wxID_HTML_BOOKMARKSREMOVE
:
1283 item
= m_Bookmarks
->GetStringSelection();
1284 pos
= m_BookmarksNames
.Index(item
);
1285 if (pos
!= wxNOT_FOUND
)
1287 m_BookmarksNames
.Remove(pos
);
1288 m_BookmarksPages
.Remove(pos
);
1289 m_Bookmarks
->Delete(m_Bookmarks
->GetSelection());
1294 #if wxUSE_PRINTING_ARCHITECTURE
1295 case wxID_HTML_PRINT
:
1297 if (m_Printer
== NULL
)
1298 m_Printer
= new wxHtmlEasyPrinting(_("Help Printing"), this);
1299 if (!m_HtmlWin
->GetOpenedPage())
1300 wxLogWarning(_("Cannot print empty page."));
1302 m_Printer
->PrintFile(m_HtmlWin
->GetOpenedPage());
1307 case wxID_HTML_OPENFILE
:
1309 wxString s
= wxFileSelector(_("Open HTML document"),
1314 "HTML files (*.htm)|*.htm|HTML files (*.html)|*.html|\
1315 Help books (*.htb)|*.htb|Help books (*.zip)|*.zip|\
1316 HTML Help Project (*.hhp)|*.hhp|\
1319 wxOPEN
| wxFILE_MUST_EXIST
,
1323 wxString ext
= s
.Right(4).Lower();
1324 if (ext
== _T(".zip") || ext
== _T(".htb") || ext
== _T(".hhp"))
1331 m_HtmlWin
->LoadPage(s
);
1340 void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent
& event
)
1342 wxHtmlHelpTreeItemData
*pg
;
1343 wxHtmlContentsItem
*it
;
1345 pg
= (wxHtmlHelpTreeItemData
*) m_ContentsBox
->GetItemData(event
.GetItem());
1347 if (pg
&& m_UpdateContents
)
1349 it
= m_Data
->GetContents() + (pg
->m_Id
);
1350 m_UpdateContents
= FALSE
;
1351 if (it
->m_Page
[0] != 0)
1352 m_HtmlWin
->LoadPage(it
->GetFullPath());
1353 m_UpdateContents
= TRUE
;
1359 void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent
& WXUNUSED(event
))
1361 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_IndexList
->GetClientData(m_IndexList
->GetSelection());
1362 if (it
->m_Page
[0] != 0)
1363 m_HtmlWin
->LoadPage(it
->GetFullPath());
1364 NotifyPageChanged();
1368 void wxHtmlHelpFrame::OnIndexFind(wxCommandEvent
& event
)
1370 wxString sr
= m_IndexText
->GetLineText(0);
1372 if (sr
== wxEmptyString
)
1379 const wxChar
*cstr
= sr
.c_str();
1384 m_IndexList
->Clear();
1385 int cnt
= m_Data
->GetIndexCnt();
1386 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
1389 for (int i
= 0; i
< cnt
; i
++)
1391 wxStrncpy(mybuff
, index
[i
].m_Name
, 512);
1392 mybuff
[511] = _T('\0');
1393 for (ptr
= mybuff
; *ptr
!= 0; ptr
++)
1394 if (*ptr
>= _T('A') && *ptr
<= _T('Z'))
1395 *ptr
-= (wxChar
)(_T('A') - _T('a'));
1396 if (wxStrstr(mybuff
, cstr
) != NULL
)
1398 m_IndexList
->Append(index
[i
].m_Name
, (char*)(index
+ i
));
1402 if (index
[i
].m_Page
[0] != 0)
1403 m_HtmlWin
->LoadPage(index
[i
].GetFullPath());
1404 NotifyPageChanged();
1411 cnttext
.Printf(_("%i of %i"), displ
, cnt
);
1412 m_IndexCountInfo
->SetLabel(cnttext
);
1414 m_IndexText
->SetSelection(0, sr
.Length());
1415 m_IndexText
->SetFocus();
1419 void wxHtmlHelpFrame::OnIndexAll(wxCommandEvent
& WXUNUSED(event
))
1423 m_IndexList
->Clear();
1424 int cnt
= m_Data
->GetIndexCnt();
1426 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
1428 for (int i
= 0; i
< cnt
; i
++)
1430 m_IndexList
->Append(index
[i
].m_Name
, (char*)(index
+ i
));
1433 if (index
[i
].m_Page
[0] != 0)
1434 m_HtmlWin
->LoadPage(index
[i
].GetFullPath());
1435 NotifyPageChanged();
1441 cnttext
.Printf(_("%i of %i"), cnt
, cnt
);
1442 m_IndexCountInfo
->SetLabel(cnttext
);
1446 void wxHtmlHelpFrame::OnSearchSel(wxCommandEvent
& WXUNUSED(event
))
1448 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_SearchList
->GetClientData(m_SearchList
->GetSelection());
1451 if (it
->m_Page
[0] != 0)
1452 m_HtmlWin
->LoadPage(it
->GetFullPath());
1453 NotifyPageChanged();
1457 void wxHtmlHelpFrame::OnSearch(wxCommandEvent
& WXUNUSED(event
))
1459 wxString sr
= m_SearchText
->GetLineText(0);
1461 if (sr
!= wxEmptyString
) KeywordSearch(sr
);
1464 void wxHtmlHelpFrame::OnBookmarksSel(wxCommandEvent
& WXUNUSED(event
))
1466 wxString sr
= m_Bookmarks
->GetStringSelection();
1468 if (sr
!= wxEmptyString
&& sr
!= _("(bookmarks)"))
1470 m_HtmlWin
->LoadPage(m_BookmarksPages
[m_BookmarksNames
.Index(sr
)]);
1471 NotifyPageChanged();
1475 void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent
& evt
)
1477 GetSize(&m_Cfg
.w
, &m_Cfg
.h
);
1478 GetPosition(&m_Cfg
.x
, &m_Cfg
.y
);
1480 if (m_Splitter
&& m_Cfg
.navig_on
) m_Cfg
.sashpos
= m_Splitter
->GetSashPosition();
1483 WriteCustomization(m_Config
, m_ConfigRoot
);
1485 if (m_helpController
&& m_helpController
->IsKindOf(CLASSINFO(wxHtmlHelpController
)))
1487 ((wxHtmlHelpController
*) m_helpController
)->OnCloseFrame(evt
);
1493 BEGIN_EVENT_TABLE(wxHtmlHelpFrame
, wxFrame
)
1494 EVT_TOOL_RANGE(wxID_HTML_PANEL
, wxID_HTML_OPTIONS
, wxHtmlHelpFrame::OnToolbar
)
1495 EVT_BUTTON(wxID_HTML_BOOKMARKSREMOVE
, wxHtmlHelpFrame::OnToolbar
)
1496 EVT_BUTTON(wxID_HTML_BOOKMARKSADD
, wxHtmlHelpFrame::OnToolbar
)
1497 EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL
, wxHtmlHelpFrame::OnContentsSel
)
1498 EVT_LISTBOX(wxID_HTML_INDEXLIST
, wxHtmlHelpFrame::OnIndexSel
)
1499 EVT_LISTBOX(wxID_HTML_SEARCHLIST
, wxHtmlHelpFrame::OnSearchSel
)
1500 EVT_BUTTON(wxID_HTML_SEARCHBUTTON
, wxHtmlHelpFrame::OnSearch
)
1501 EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT
, wxHtmlHelpFrame::OnSearch
)
1502 EVT_BUTTON(wxID_HTML_INDEXBUTTON
, wxHtmlHelpFrame::OnIndexFind
)
1503 EVT_TEXT_ENTER(wxID_HTML_INDEXTEXT
, wxHtmlHelpFrame::OnIndexFind
)
1504 EVT_BUTTON(wxID_HTML_INDEXBUTTONALL
, wxHtmlHelpFrame::OnIndexAll
)
1505 EVT_COMBOBOX(wxID_HTML_BOOKMARKSLIST
, wxHtmlHelpFrame::OnBookmarksSel
)
1506 EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow
)
1509 #endif // wxUSE_WXHTML_HELP