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"
53 #include "wx/artprov.h"
55 // what is considered "small index"?
56 #define INDEX_IS_SMALL 100
58 /* Motif defines this as a macro */
63 //--------------------------------------------------------------------------
64 // wxHtmlHelpTreeItemData (private)
65 //--------------------------------------------------------------------------
67 class wxHtmlHelpTreeItemData
: public wxTreeItemData
70 #if defined(__VISAGECPP__)
71 // VA needs a default ctor for some reason....
72 wxHtmlHelpTreeItemData() : wxTreeItemData()
75 wxHtmlHelpTreeItemData(int id
) : wxTreeItemData()
82 //--------------------------------------------------------------------------
83 // wxHtmlHelpHashData (private)
84 //--------------------------------------------------------------------------
86 class wxHtmlHelpHashData
: public wxObject
89 wxHtmlHelpHashData(int index
, wxTreeItemId id
) : wxObject()
90 { m_Index
= index
; m_Id
= id
;}
91 ~wxHtmlHelpHashData() {}
98 //--------------------------------------------------------------------------
99 // wxHtmlHelpHtmlWindow (private)
100 //--------------------------------------------------------------------------
102 class wxHtmlHelpHtmlWindow
: public wxHtmlWindow
105 wxHtmlHelpHtmlWindow(wxHtmlHelpFrame
*fr
, wxWindow
*parent
) : wxHtmlWindow(parent
), m_Frame(fr
) {}
107 virtual void OnLinkClicked(const wxHtmlLinkInfo
& link
)
109 wxHtmlWindow::OnLinkClicked(link
);
110 m_Frame
->NotifyPageChanged();
114 wxHtmlHelpFrame
*m_Frame
;
119 //---------------------------------------------------------------------------
121 //---------------------------------------------------------------------------
126 //wxID_HTML_HELPFRAME = wxID_HIGHEST + 1,
127 wxID_HTML_PANEL
= wxID_HIGHEST
+ 2,
136 wxID_HTML_BOOKMARKSLIST
,
137 wxID_HTML_BOOKMARKSADD
,
138 wxID_HTML_BOOKMARKSREMOVE
,
143 wxID_HTML_INDEXBUTTON
,
144 wxID_HTML_INDEXBUTTONALL
,
146 wxID_HTML_SEARCHPAGE
,
147 wxID_HTML_SEARCHTEXT
,
148 wxID_HTML_SEARCHLIST
,
149 wxID_HTML_SEARCHBUTTON
,
150 wxID_HTML_SEARCHCHOICE
,
155 IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpFrame
, wxFrame
)
157 wxHtmlHelpFrame::wxHtmlHelpFrame(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
158 int style
, wxHtmlHelpData
* data
)
161 Create(parent
, id
, title
, style
);
164 void wxHtmlHelpFrame::Init(wxHtmlHelpData
* data
)
169 m_DataCreated
= FALSE
;
172 m_Data
= new wxHtmlHelpData();
173 m_DataCreated
= TRUE
;
176 m_ContentsBox
= NULL
;
178 m_IndexButton
= NULL
;
179 m_IndexButtonAll
= NULL
;
182 m_SearchButton
= NULL
;
184 m_SearchChoice
= NULL
;
185 m_IndexCountInfo
= NULL
;
188 m_NavigNotebook
= NULL
;
191 m_SearchCaseSensitive
= NULL
;
192 m_SearchWholeWords
= NULL
;
195 m_ConfigRoot
= wxEmptyString
;
197 m_Cfg
.x
= m_Cfg
.y
= 0;
201 m_Cfg
.navig_on
= TRUE
;
203 m_NormalFonts
= m_FixedFonts
= NULL
;
204 m_NormalFace
= m_FixedFace
= wxEmptyString
;
207 #if wxUSE_PRINTING_ARCHITECTURE
212 m_UpdateContents
= TRUE
;
213 m_helpController
= (wxHelpControllerBase
*) NULL
;
216 // Create: builds the GUI components.
217 // with the style flag it's possible to toggle the toolbar, contents, index and search
219 // m_HtmlWin will *always* be created, but it's important to realize that
220 // m_ContentsBox, m_IndexList, m_SearchList, m_SearchButton, m_SearchText and
221 // m_SearchButton may be NULL.
222 // moreover, if no contents, index or searchpage is needed, m_Splitter and
223 // m_NavigPan will be NULL too (with m_HtmlWin directly connected to the frame)
225 bool wxHtmlHelpFrame::Create(wxWindow
* parent
, wxWindowID id
,
226 const wxString
& WXUNUSED(title
), int style
)
230 wxImageList
*ContentsImageList
= new wxImageList(16, 16);
231 ContentsImageList
->Add(wxArtProvider::GetIcon(wxART_HELP_BOOK
, wxART_HELP_BROWSER
));
232 ContentsImageList
->Add(wxArtProvider::GetIcon(wxART_HELP_FOLDER
, wxART_HELP_BROWSER
));
233 ContentsImageList
->Add(wxArtProvider::GetIcon(wxART_HELP_PAGE
, wxART_HELP_BROWSER
));
235 // Do the config in two steps. We read the HtmlWindow customization after we
236 // create the window.
238 ReadCustomization(m_Config
, m_ConfigRoot
);
240 wxFrame::Create(parent
, id
, _("Help"),
241 wxPoint(m_Cfg
.x
, m_Cfg
.y
), wxSize(m_Cfg
.w
, m_Cfg
.h
),
242 wxDEFAULT_FRAME_STYLE
, wxT("wxHtmlHelp"));
244 GetPosition(&m_Cfg
.x
, &m_Cfg
.y
);
246 SetIcon(wxArtProvider::GetIcon(wxART_FRAME_ICON
, wxART_HELP_BROWSER
));
248 int notebook_page
= 0;
253 if (style
& (wxHF_TOOLBAR
| wxHF_FLAT_TOOLBAR
))
255 wxToolBar
*toolBar
= CreateToolBar(wxNO_BORDER
| wxTB_HORIZONTAL
|
257 (style
& wxHF_FLAT_TOOLBAR
? wxTB_FLAT
: 0));
258 toolBar
->SetMargins( 2, 2 );
259 AddToolbarButtons(toolBar
, style
);
263 wxSizer
*navigSizer
= NULL
;
265 if (style
& (wxHF_CONTENTS
| wxHF_INDEX
| wxHF_SEARCH
))
267 // traditional help controller; splitter window with html page on the
268 // right and a notebook containing various pages on the left
269 m_Splitter
= new wxSplitterWindow(this);
271 m_HtmlWin
= new wxHtmlHelpHtmlWindow(this, m_Splitter
);
272 m_NavigPan
= new wxPanel(m_Splitter
, -1);
273 m_NavigNotebook
= new wxNotebook(m_NavigPan
, wxID_HTML_NOTEBOOK
,
274 wxDefaultPosition
, wxDefaultSize
);
275 wxNotebookSizer
*nbs
= new wxNotebookSizer(m_NavigNotebook
);
277 navigSizer
= new wxBoxSizer(wxVERTICAL
);
278 navigSizer
->Add(nbs
, 1, wxEXPAND
);
280 m_NavigPan
->SetAutoLayout(TRUE
);
281 m_NavigPan
->SetSizer(navigSizer
);
284 { // only html window, no notebook with index,contents etc
285 m_HtmlWin
= new wxHtmlWindow(this);
288 m_HtmlWin
->SetRelatedFrame(this, m_TitleFormat
);
289 m_HtmlWin
->SetRelatedStatusBar(0);
291 m_HtmlWin
->ReadCustomization(m_Config
, m_ConfigRoot
);
293 // contents tree panel?
294 if ( style
& wxHF_CONTENTS
)
296 wxWindow
*dummy
= new wxPanel(m_NavigNotebook
, wxID_HTML_INDEXPAGE
);
297 wxSizer
*topsizer
= new wxBoxSizer(wxVERTICAL
);
299 topsizer
->Add(0, 10);
301 dummy
->SetAutoLayout(TRUE
);
302 dummy
->SetSizer(topsizer
);
304 if ( style
& wxHF_BOOKMARKS
)
306 m_Bookmarks
= new wxComboBox(dummy
, wxID_HTML_BOOKMARKSLIST
,
308 wxDefaultPosition
, wxDefaultSize
,
309 0, NULL
, wxCB_READONLY
| wxCB_SORT
);
310 m_Bookmarks
->Append(_("(bookmarks)"));
311 for (unsigned i
= 0; i
< m_BookmarksNames
.GetCount(); i
++)
312 m_Bookmarks
->Append(m_BookmarksNames
[i
]);
313 m_Bookmarks
->SetSelection(0);
315 wxBitmapButton
*bmpbt1
, *bmpbt2
;
316 bmpbt1
= new wxBitmapButton(dummy
, wxID_HTML_BOOKMARKSADD
,
317 wxArtProvider::GetBitmap(wxART_ADD_BOOKMARK
,
318 wxART_HELP_BROWSER
));
319 bmpbt2
= new wxBitmapButton(dummy
, wxID_HTML_BOOKMARKSREMOVE
,
320 wxArtProvider::GetBitmap(wxART_DEL_BOOKMARK
,
321 wxART_HELP_BROWSER
));
323 bmpbt1
->SetToolTip(_("Add current page to bookmarks"));
324 bmpbt2
->SetToolTip(_("Remove current page from bookmarks"));
325 #endif // wxUSE_TOOLTIPS
327 wxSizer
*sizer
= new wxBoxSizer(wxHORIZONTAL
);
329 sizer
->Add(m_Bookmarks
, 1, wxALIGN_CENTRE_VERTICAL
| wxRIGHT
, 5);
330 sizer
->Add(bmpbt1
, 0, wxALIGN_CENTRE_VERTICAL
| wxRIGHT
, 2);
331 sizer
->Add(bmpbt2
, 0, wxALIGN_CENTRE_VERTICAL
, 0);
333 topsizer
->Add(sizer
, 0, wxEXPAND
| wxLEFT
| wxBOTTOM
| wxRIGHT
, 10);
336 m_ContentsBox
= new wxTreeCtrl(dummy
, wxID_HTML_TREECTRL
,
337 wxDefaultPosition
, wxDefaultSize
,
339 wxTR_HAS_BUTTONS
| wxTR_HIDE_ROOT
|
342 m_ContentsBox
->AssignImageList(ContentsImageList
);
344 topsizer
->Add(m_ContentsBox
, 1, wxEXPAND
| wxLEFT
| wxBOTTOM
| wxRIGHT
, 2);
346 m_NavigNotebook
->AddPage(dummy
, _("Contents"));
347 m_ContentsPage
= notebook_page
++;
350 // index listbox panel?
351 if ( style
& wxHF_INDEX
)
353 wxWindow
*dummy
= new wxPanel(m_NavigNotebook
, wxID_HTML_INDEXPAGE
);
354 wxSizer
*topsizer
= new wxBoxSizer(wxVERTICAL
);
356 dummy
->SetAutoLayout(TRUE
);
357 dummy
->SetSizer(topsizer
);
359 m_IndexText
= new wxTextCtrl(dummy
, wxID_HTML_INDEXTEXT
, wxEmptyString
,
360 wxDefaultPosition
, wxDefaultSize
,
362 m_IndexButton
= new wxButton(dummy
, wxID_HTML_INDEXBUTTON
, _("Find"));
363 m_IndexButtonAll
= new wxButton(dummy
, wxID_HTML_INDEXBUTTONALL
,
365 m_IndexCountInfo
= new wxStaticText(dummy
, wxID_HTML_COUNTINFO
,
366 wxEmptyString
, wxDefaultPosition
,
368 wxALIGN_RIGHT
| wxST_NO_AUTORESIZE
);
369 m_IndexList
= new wxListBox(dummy
, wxID_HTML_INDEXLIST
,
370 wxDefaultPosition
, wxDefaultSize
,
371 0, NULL
, wxLB_SINGLE
);
374 m_IndexButton
->SetToolTip(_("Display all index items that contain given substring. Search is case insensitive."));
375 m_IndexButtonAll
->SetToolTip(_("Show all items in index"));
376 #endif //wxUSE_TOOLTIPS
378 topsizer
->Add(m_IndexText
, 0, wxEXPAND
| wxALL
, 10);
379 wxSizer
*btsizer
= new wxBoxSizer(wxHORIZONTAL
);
380 btsizer
->Add(m_IndexButton
, 0, wxRIGHT
, 2);
381 btsizer
->Add(m_IndexButtonAll
);
382 topsizer
->Add(btsizer
, 0,
383 wxALIGN_RIGHT
| wxLEFT
| wxRIGHT
| wxBOTTOM
, 10);
384 topsizer
->Add(m_IndexCountInfo
, 0, wxEXPAND
| wxLEFT
| wxRIGHT
, 2);
385 topsizer
->Add(m_IndexList
, 1, wxEXPAND
| wxALL
, 2);
387 m_NavigNotebook
->AddPage(dummy
, _("Index"));
388 m_IndexPage
= notebook_page
++;
391 // search list panel?
392 if ( style
& wxHF_SEARCH
)
394 wxWindow
*dummy
= new wxPanel(m_NavigNotebook
, wxID_HTML_INDEXPAGE
);
395 wxSizer
*sizer
= new wxBoxSizer(wxVERTICAL
);
397 dummy
->SetAutoLayout(TRUE
);
398 dummy
->SetSizer(sizer
);
400 m_SearchText
= new wxTextCtrl(dummy
, wxID_HTML_SEARCHTEXT
,
402 wxDefaultPosition
, wxDefaultSize
,
404 m_SearchChoice
= new wxChoice(dummy
, wxID_HTML_SEARCHCHOICE
,
405 wxDefaultPosition
, wxDefaultSize
);
406 m_SearchCaseSensitive
= new wxCheckBox(dummy
, -1, _("Case sensitive"));
407 m_SearchWholeWords
= new wxCheckBox(dummy
, -1, _("Whole words only"));
408 m_SearchButton
= new wxButton(dummy
, wxID_HTML_SEARCHBUTTON
, _("Search"));
410 m_SearchButton
->SetToolTip(_("Search contents of help book(s) for all occurences of the text you typed above"));
411 #endif //wxUSE_TOOLTIPS
412 m_SearchList
= new wxListBox(dummy
, wxID_HTML_SEARCHLIST
,
413 wxDefaultPosition
, wxDefaultSize
,
414 0, NULL
, wxLB_SINGLE
);
416 sizer
->Add(m_SearchText
, 0, wxEXPAND
| wxALL
, 10);
417 sizer
->Add(m_SearchChoice
, 0, wxEXPAND
| wxLEFT
| wxRIGHT
| wxBOTTOM
, 10);
418 sizer
->Add(m_SearchCaseSensitive
, 0, wxLEFT
| wxRIGHT
, 10);
419 sizer
->Add(m_SearchWholeWords
, 0, wxLEFT
| wxRIGHT
, 10);
420 sizer
->Add(m_SearchButton
, 0, wxALL
| wxALIGN_RIGHT
, 8);
421 sizer
->Add(m_SearchList
, 1, wxALL
| wxEXPAND
, 2);
423 m_NavigNotebook
->AddPage(dummy
, _("Search"));
424 m_SearchPage
= notebook_page
++;
427 m_HtmlWin
->Show(TRUE
);
433 navigSizer
->SetSizeHints(m_NavigPan
);
434 m_NavigPan
->Layout();
438 if ( m_NavigPan
&& m_Splitter
)
440 m_Splitter
->SetMinimumPaneSize(20);
441 if ( m_Cfg
.navig_on
)
442 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
444 if ( m_Cfg
.navig_on
)
446 m_NavigPan
->Show(TRUE
);
447 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
451 m_NavigPan
->Show(FALSE
);
452 m_Splitter
->Initialize(m_HtmlWin
);
459 wxHtmlHelpFrame::~wxHtmlHelpFrame()
461 // PopEventHandler(); // wxhtmlhelpcontroller (not any more!)
464 if (m_NormalFonts
) delete m_NormalFonts
;
465 if (m_FixedFonts
) delete m_FixedFonts
;
466 if (m_PagesHash
) delete m_PagesHash
;
470 void wxHtmlHelpFrame::AddToolbarButtons(wxToolBar
*toolBar
, int style
)
472 wxBitmap wpanelBitmap
=
473 wxArtProvider::GetBitmap(wxART_HELP_SIDE_PANEL
, wxART_HELP_BROWSER
);
474 wxBitmap wbackBitmap
=
475 wxArtProvider::GetBitmap(wxART_GO_BACK
, wxART_HELP_BROWSER
);
476 wxBitmap wforwardBitmap
=
477 wxArtProvider::GetBitmap(wxART_GO_FORWARD
, wxART_HELP_BROWSER
);
478 wxBitmap wupnodeBitmap
=
479 wxArtProvider::GetBitmap(wxART_GO_TO_PARENT
, wxART_HELP_BROWSER
);
481 wxArtProvider::GetBitmap(wxART_GO_UP
, wxART_HELP_BROWSER
);
482 wxBitmap wdownBitmap
=
483 wxArtProvider::GetBitmap(wxART_GO_DOWN
, wxART_HELP_BROWSER
);
484 wxBitmap wopenBitmap
=
485 wxArtProvider::GetBitmap(wxART_FILE_OPEN
, wxART_HELP_BROWSER
);
486 wxBitmap wprintBitmap
=
487 wxArtProvider::GetBitmap(wxART_PRINT
, wxART_HELP_BROWSER
);
488 wxBitmap woptionsBitmap
=
489 wxArtProvider::GetBitmap(wxART_HELP_SETTINGS
, wxART_HELP_BROWSER
);
491 wxASSERT_MSG( (wpanelBitmap
.Ok() && wbackBitmap
.Ok() &&
492 wforwardBitmap
.Ok() && wupnodeBitmap
.Ok() &&
493 wupBitmap
.Ok() && wdownBitmap
.Ok() &&
494 wopenBitmap
.Ok() && wprintBitmap
.Ok() &&
495 woptionsBitmap
.Ok()),
496 wxT("One or more HTML help frame toolbar bitmap could not be loaded.")) ;
499 toolBar
->AddTool(wxID_HTML_PANEL
, wpanelBitmap
, wxNullBitmap
,
500 FALSE
, -1, -1, (wxObject
*) NULL
,
501 _("Show/hide navigation panel"));
503 toolBar
->AddSeparator();
504 toolBar
->AddTool(wxID_HTML_BACK
, wbackBitmap
, wxNullBitmap
,
505 FALSE
, -1, -1, (wxObject
*) NULL
,
507 toolBar
->AddTool(wxID_HTML_FORWARD
, wforwardBitmap
, wxNullBitmap
,
508 FALSE
, -1, -1, (wxObject
*) NULL
,
510 toolBar
->AddSeparator();
512 toolBar
->AddTool(wxID_HTML_UPNODE
, wupnodeBitmap
, wxNullBitmap
,
513 FALSE
, -1, -1, (wxObject
*) NULL
,
514 _("Go one level up in document hierarchy"));
515 toolBar
->AddTool(wxID_HTML_UP
, wupBitmap
, wxNullBitmap
,
516 FALSE
, -1, -1, (wxObject
*) NULL
,
518 toolBar
->AddTool(wxID_HTML_DOWN
, wdownBitmap
, wxNullBitmap
,
519 FALSE
, -1, -1, (wxObject
*) NULL
,
522 if ((style
& wxHF_PRINT
) || (style
& wxHF_OPEN_FILES
))
523 toolBar
->AddSeparator();
525 if (style
& wxHF_OPEN_FILES
)
526 toolBar
->AddTool(wxID_HTML_OPENFILE
, wopenBitmap
, wxNullBitmap
,
527 FALSE
, -1, -1, (wxObject
*) NULL
,
528 _("Open HTML document"));
530 #if wxUSE_PRINTING_ARCHITECTURE
531 if (style
& wxHF_PRINT
)
532 toolBar
->AddTool(wxID_HTML_PRINT
, wprintBitmap
, wxNullBitmap
,
533 FALSE
, -1, -1, (wxObject
*) NULL
,
534 _("Print this page"));
537 toolBar
->AddSeparator();
538 toolBar
->AddTool(wxID_HTML_OPTIONS
, woptionsBitmap
, wxNullBitmap
,
539 FALSE
, -1, -1, (wxObject
*) NULL
,
540 _("Display options dialog"));
544 void wxHtmlHelpFrame::SetTitleFormat(const wxString
& format
)
547 m_HtmlWin
->SetRelatedFrame(this, format
);
548 m_TitleFormat
= format
;
552 bool wxHtmlHelpFrame::Display(const wxString
& x
)
554 wxString url
= m_Data
->FindPageByName(x
);
557 m_HtmlWin
->LoadPage(url
);
564 bool wxHtmlHelpFrame::Display(const int id
)
566 wxString url
= m_Data
->FindPageById(id
);
569 m_HtmlWin
->LoadPage(url
);
578 bool wxHtmlHelpFrame::DisplayContents()
582 if (!m_Splitter
->IsSplit())
584 m_NavigPan
->Show(TRUE
);
585 m_HtmlWin
->Show(TRUE
);
586 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
587 m_Cfg
.navig_on
= TRUE
;
589 m_NavigNotebook
->SetSelection(0);
590 if (m_Data
->GetBookRecArray().GetCount() > 0)
592 wxHtmlBookRecord
& book
= m_Data
->GetBookRecArray()[0];
593 if (!book
.GetStart().IsEmpty())
594 m_HtmlWin
->LoadPage(book
.GetFullPath(book
.GetStart()));
601 bool wxHtmlHelpFrame::DisplayIndex()
605 if (!m_Splitter
->IsSplit())
607 m_NavigPan
->Show(TRUE
);
608 m_HtmlWin
->Show(TRUE
);
609 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
611 m_NavigNotebook
->SetSelection(1);
612 if (m_Data
->GetBookRecArray().GetCount() > 0)
614 wxHtmlBookRecord
& book
= m_Data
->GetBookRecArray()[0];
615 if (!book
.GetStart().IsEmpty())
616 m_HtmlWin
->LoadPage(book
.GetFullPath(book
.GetStart()));
623 bool wxHtmlHelpFrame::KeywordSearch(const wxString
& keyword
)
625 if (! (m_SearchList
&& m_SearchButton
&& m_SearchText
&& m_SearchChoice
))
628 int foundcnt
= 0, curi
;
630 wxString book
= wxEmptyString
;
632 if (!m_Splitter
->IsSplit())
634 m_NavigPan
->Show(TRUE
);
635 m_HtmlWin
->Show(TRUE
);
636 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
638 m_NavigNotebook
->SetSelection(m_SearchPage
);
639 m_SearchList
->Clear();
640 m_SearchText
->SetValue(keyword
);
641 m_SearchButton
->Enable(FALSE
);
643 if (m_SearchChoice
->GetSelection() != 0)
644 book
= m_SearchChoice
->GetStringSelection();
646 wxHtmlSearchStatus
status(m_Data
, keyword
,
647 m_SearchCaseSensitive
->GetValue(), m_SearchWholeWords
->GetValue(),
650 wxProgressDialog
progress(_("Searching..."), _("No matching page found yet"),
651 status
.GetMaxIndex(), this,
652 wxPD_APP_MODAL
| wxPD_CAN_ABORT
| wxPD_AUTO_HIDE
);
654 while (status
.IsActive())
656 curi
= status
.GetCurIndex();
657 if (curi
% 32 == 0 && progress
.Update(curi
) == FALSE
)
661 foundstr
.Printf(_("Found %i matches"), ++foundcnt
);
662 progress
.Update(status
.GetCurIndex(), foundstr
);
663 m_SearchList
->Append(status
.GetName(), status
.GetContentsItem());
667 m_SearchButton
->Enable(TRUE
);
668 m_SearchText
->SetSelection(0, keyword
.Length());
669 m_SearchText
->SetFocus();
672 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_SearchList
->GetClientData(0);
675 m_HtmlWin
->LoadPage(it
->GetFullPath());
679 return (foundcnt
> 0);
682 void wxHtmlHelpFrame::CreateContents()
687 m_ContentsBox
->Clear();
689 if (m_PagesHash
) delete m_PagesHash
;
690 m_PagesHash
= new wxHashTable(wxKEY_STRING
, 2 * m_Data
->GetContentsCnt());
691 m_PagesHash
->DeleteContents(TRUE
);
693 int cnt
= m_Data
->GetContentsCnt();
696 wxHtmlContentsItem
*it
;
698 const int MAX_ROOTS
= 64;
699 wxTreeItemId roots
[MAX_ROOTS
];
700 // VS: this array holds information about whether we've set item icon at
701 // given level. This is neccessary because m_Data has flat structure
702 // and there's no way of recognizing if some item has subitems or not.
703 // We set the icon later: when we find an item with level=n, we know
704 // that the last item with level=n-1 was folder with subitems, so we
705 // set its icon accordingly
706 bool imaged
[MAX_ROOTS
];
707 m_ContentsBox
->DeleteAllItems();
709 roots
[0] = m_ContentsBox
->AddRoot(_("(Help)"));
712 for (it
= m_Data
->GetContents(), i
= 0; i
< cnt
; i
++, it
++)
715 if (it
->m_Level
== 0)
717 if (m_hfStyle
& wxHF_MERGE_BOOKS
)
718 // VS: we don't want book nodes, books' content should
719 // appear under tree's root. This line will create "fake"
720 // record about book node so that the rest of this look
721 // will believe there really _is_ book node and will
726 roots
[1] = m_ContentsBox
->AppendItem(roots
[0],
727 it
->m_Name
, IMG_Book
, -1,
728 new wxHtmlHelpTreeItemData(i
));
729 m_ContentsBox
->SetItemBold(roots
[1], TRUE
);
733 // ...and their contents:
736 roots
[it
->m_Level
+ 1] = m_ContentsBox
->AppendItem(
737 roots
[it
->m_Level
], it
->m_Name
, IMG_Page
,
738 -1, new wxHtmlHelpTreeItemData(i
));
739 imaged
[it
->m_Level
+ 1] = FALSE
;
742 m_PagesHash
->Put(it
->GetFullPath(),
743 new wxHtmlHelpHashData(i
, roots
[it
->m_Level
+ 1]));
745 // Set the icon for the node one level up in the hiearachy,
746 // unless already done (see comment above imaged[] declaration)
747 if (!imaged
[it
->m_Level
])
749 int image
= IMG_Folder
;
750 if (m_hfStyle
& wxHF_ICONS_BOOK
)
752 else if (m_hfStyle
& wxHF_ICONS_BOOK_CHAPTER
)
753 image
= (it
->m_Level
== 1) ? IMG_Book
: IMG_Folder
;
754 m_ContentsBox
->SetItemImage(roots
[it
->m_Level
], image
);
755 m_ContentsBox
->SetItemSelectedImage(roots
[it
->m_Level
], image
);
756 imaged
[it
->m_Level
] = TRUE
;
762 void wxHtmlHelpFrame::CreateIndex()
767 m_IndexList
->Clear();
769 int cnt
= m_Data
->GetIndexCnt();
772 if (cnt
> INDEX_IS_SMALL
) cnttext
.Printf(_("%i of %i"), 0, cnt
);
773 else cnttext
.Printf(_("%i of %i"), cnt
, cnt
);
774 m_IndexCountInfo
->SetLabel(cnttext
);
775 if (cnt
> INDEX_IS_SMALL
) return;
777 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
779 for (int i
= 0; i
< cnt
; i
++)
780 m_IndexList
->Append(index
[i
].m_Name
, (char*)(index
+ i
));
783 void wxHtmlHelpFrame::CreateSearch()
785 if (! (m_SearchList
&& m_SearchChoice
))
787 m_SearchList
->Clear();
788 m_SearchChoice
->Clear();
789 m_SearchChoice
->Append(_("Search in all books"));
790 const wxHtmlBookRecArray
& bookrec
= m_Data
->GetBookRecArray();
791 int i
, cnt
= bookrec
.GetCount();
792 for (i
= 0; i
< cnt
; i
++)
793 m_SearchChoice
->Append(bookrec
[i
].GetTitle());
794 m_SearchChoice
->SetSelection(0);
798 void wxHtmlHelpFrame::RefreshLists()
805 void wxHtmlHelpFrame::ReadCustomization(wxConfigBase
*cfg
, const wxString
& path
)
810 if (path
!= wxEmptyString
)
812 oldpath
= cfg
->GetPath();
813 cfg
->SetPath(_T("/") + path
);
816 m_Cfg
.navig_on
= cfg
->Read(wxT("hcNavigPanel"), m_Cfg
.navig_on
) != 0;
817 m_Cfg
.sashpos
= cfg
->Read(wxT("hcSashPos"), m_Cfg
.sashpos
);
818 m_Cfg
.x
= cfg
->Read(wxT("hcX"), m_Cfg
.x
);
819 m_Cfg
.y
= cfg
->Read(wxT("hcY"), m_Cfg
.y
);
820 m_Cfg
.w
= cfg
->Read(wxT("hcW"), m_Cfg
.w
);
821 m_Cfg
.h
= cfg
->Read(wxT("hcH"), m_Cfg
.h
);
823 m_FixedFace
= cfg
->Read(wxT("hcFixedFace"), m_FixedFace
);
824 m_NormalFace
= cfg
->Read(wxT("hcNormalFace"), m_NormalFace
);
825 m_FontSize
= cfg
->Read(wxT("hcFontSize"), m_FontSize
);
832 cnt
= cfg
->Read(wxT("hcBookmarksCnt"), 0L);
835 m_BookmarksNames
.Clear();
836 m_BookmarksPages
.Clear();
839 m_Bookmarks
->Clear();
840 m_Bookmarks
->Append(_("(bookmarks)"));
843 for (i
= 0; i
< cnt
; i
++)
845 val
.Printf(wxT("hcBookmark_%i"), i
);
847 m_BookmarksNames
.Add(s
);
848 if (m_Bookmarks
) m_Bookmarks
->Append(s
);
849 val
.Printf(wxT("hcBookmark_%i_url"), i
);
851 m_BookmarksPages
.Add(s
);
857 m_HtmlWin
->ReadCustomization(cfg
);
859 if (path
!= wxEmptyString
)
860 cfg
->SetPath(oldpath
);
863 void wxHtmlHelpFrame::WriteCustomization(wxConfigBase
*cfg
, const wxString
& path
)
868 if (path
!= wxEmptyString
)
870 oldpath
= cfg
->GetPath();
871 cfg
->SetPath(_T("/") + path
);
874 cfg
->Write(wxT("hcNavigPanel"), m_Cfg
.navig_on
);
875 cfg
->Write(wxT("hcSashPos"), (long)m_Cfg
.sashpos
);
876 cfg
->Write(wxT("hcX"), (long)m_Cfg
.x
);
877 cfg
->Write(wxT("hcY"), (long)m_Cfg
.y
);
878 cfg
->Write(wxT("hcW"), (long)m_Cfg
.w
);
879 cfg
->Write(wxT("hcH"), (long)m_Cfg
.h
);
880 cfg
->Write(wxT("hcFixedFace"), m_FixedFace
);
881 cfg
->Write(wxT("hcNormalFace"), m_NormalFace
);
882 cfg
->Write(wxT("hcFontSize"), (long)m_FontSize
);
887 int cnt
= m_BookmarksNames
.GetCount();
890 cfg
->Write(wxT("hcBookmarksCnt"), (long)cnt
);
891 for (i
= 0; i
< cnt
; i
++)
893 val
.Printf(wxT("hcBookmark_%i"), i
);
894 cfg
->Write(val
, m_BookmarksNames
[i
]);
895 val
.Printf(wxT("hcBookmark_%i_url"), i
);
896 cfg
->Write(val
, m_BookmarksPages
[i
]);
901 m_HtmlWin
->WriteCustomization(cfg
);
903 if (path
!= wxEmptyString
)
904 cfg
->SetPath(oldpath
);
911 static void SetFontsToHtmlWin(wxHtmlWindow
*win
, wxString scalf
, wxString fixf
, int size
)
913 static int f_sizes
[5][7] =
915 { 6, 7, 9, 12, 14, 16, 19},
916 { 8, 9, 12, 14, 16, 19, 22},
917 {10, 12, 14, 16, 19, 24, 32},
918 {14, 16, 18, 24, 32, 38, 45},
919 {16, 20, 24, 32, 38, 45, 50}
922 win
->SetFonts(scalf
, fixf
, f_sizes
[size
]);
926 class wxHtmlHelpFrameOptionsDialog
: public wxDialog
929 wxComboBox
*NormalFont
, *FixedFont
;
930 wxRadioBox
*RadioBox
;
931 wxHtmlWindow
*TestWin
;
933 wxHtmlHelpFrameOptionsDialog(wxWindow
*parent
) : wxDialog(parent
, -1, wxString(_("Help Browser Options")))
935 wxString choices
[5] = {_("very small"), _("small"), _("medium"), _("large"), _("very large")};
936 wxBoxSizer
*topsizer
, *sizer
, *sizer2
;
938 topsizer
= new wxBoxSizer(wxVERTICAL
);
940 sizer
= new wxBoxSizer(wxHORIZONTAL
);
942 sizer2
= new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Normal font:")), wxVERTICAL
);
943 sizer2
->Add(NormalFont
= new wxComboBox(this, -1, wxEmptyString
, wxDefaultPosition
,
945 0, NULL
, wxCB_DROPDOWN
| wxCB_READONLY
),
946 1, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
948 sizer
->Add(sizer2
, 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10);
950 sizer2
= new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Fixed font:")), wxVERTICAL
);
951 sizer2
->Add(FixedFont
= new wxComboBox(this, -1, wxEmptyString
, wxDefaultPosition
,
953 0, NULL
, wxCB_DROPDOWN
| wxCB_READONLY
),
954 1, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
956 sizer
->Add(sizer2
, 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10);
958 topsizer
->Add(sizer
);
960 topsizer
->Add(RadioBox
= new wxRadioBox(this, -1, _("Font size:"),
961 wxDefaultPosition
, wxDefaultSize
, 5, choices
, 5),
962 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10);
964 topsizer
->Add(new wxStaticText(this, -1, _("Preview:")),
965 0, wxLEFT
| wxTOP
, 10);
966 topsizer
->Add(TestWin
= new wxHtmlWindow(this, -1, wxDefaultPosition
, wxSize(20, 150),
967 wxHW_SCROLLBAR_AUTO
| wxSUNKEN_BORDER
),
968 1, wxEXPAND
| wxLEFT
|wxTOP
|wxRIGHT
, 10);
970 sizer
= new wxBoxSizer(wxHORIZONTAL
);
972 sizer
->Add(ok
= new wxButton(this, wxID_OK
, _("OK")), 0, wxALL
, 10);
974 sizer
->Add(new wxButton(this, wxID_CANCEL
, _("Cancel")), 0, wxALL
, 10);
975 topsizer
->Add(sizer
, 0, wxALIGN_RIGHT
);
987 SetFontsToHtmlWin(TestWin
,
988 NormalFont
->GetStringSelection(),
989 FixedFont
->GetStringSelection(),
990 RadioBox
->GetSelection());
993 Normal face<br>(and <u>underlined</u>. <i>Italic face.</i> \
994 <b>Bold face.</b> <b><i>Bold italic face.</i></b><br>\
995 <font size=-2>font size -2</font><br>\
996 <font size=-1>font size -1</font><br>\
997 <font size=+0>font size +0</font><br>\
998 <font size=+1>font size +1</font><br>\
999 <font size=+2>font size +2</font><br>\
1000 <font size=+3>font size +3</font><br>\
1001 <font size=+4>font size +4</font><br>\
1003 <p><tt>Fixed size face.<br> <b>bold</b> <i>italic</i> \
1004 <b><i>bold italic <u>underlined</u></i></b><br>\
1005 <font size=-2>font size -2</font><br>\
1006 <font size=-1>font size -1</font><br>\
1007 <font size=+0>font size +0</font><br>\
1008 <font size=+1>font size +1</font><br>\
1009 <font size=+2>font size +2</font><br>\
1010 <font size=+3>font size +3</font><br>\
1011 <font size=+4>font size +4</font></tt>\
1016 void OnUpdate(wxCommandEvent
& WXUNUSED(event
))
1021 DECLARE_EVENT_TABLE()
1024 BEGIN_EVENT_TABLE(wxHtmlHelpFrameOptionsDialog
, wxDialog
)
1025 EVT_COMBOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate
)
1026 EVT_RADIOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate
)
1030 void wxHtmlHelpFrame::OptionsDialog()
1032 wxHtmlHelpFrameOptionsDialog
dlg(this);
1035 if (m_NormalFonts
== NULL
)
1037 wxFontEnumerator enu
;
1038 enu
.EnumerateFacenames();
1039 m_NormalFonts
= new wxArrayString
;
1040 *m_NormalFonts
= *enu
.GetFacenames();
1041 m_NormalFonts
->Sort();
1043 if (m_FixedFonts
== NULL
)
1045 wxFontEnumerator enu
;
1046 enu
.EnumerateFacenames(wxFONTENCODING_SYSTEM
, TRUE
);
1047 m_FixedFonts
= new wxArrayString
;
1048 *m_FixedFonts
= *enu
.GetFacenames();
1049 m_FixedFonts
->Sort();
1052 for (i
= 0; i
< m_NormalFonts
->GetCount(); i
++)
1053 dlg
.NormalFont
->Append((*m_NormalFonts
)[i
]);
1054 for (i
= 0; i
< m_FixedFonts
->GetCount(); i
++)
1055 dlg
.FixedFont
->Append((*m_FixedFonts
)[i
]);
1056 if (!m_NormalFace
.IsEmpty()) dlg
.NormalFont
->SetStringSelection(m_NormalFace
);
1057 else dlg
.NormalFont
->SetSelection(0);
1058 if (!m_FixedFace
.IsEmpty()) dlg
.FixedFont
->SetStringSelection(m_FixedFace
);
1059 else dlg
.FixedFont
->SetSelection(0);
1060 dlg
.RadioBox
->SetSelection(m_FontSize
);
1061 dlg
.UpdateTestWin();
1063 if (dlg
.ShowModal() == wxID_OK
)
1065 m_NormalFace
= dlg
.NormalFont
->GetStringSelection();
1066 m_FixedFace
= dlg
.FixedFont
->GetStringSelection();
1067 m_FontSize
= dlg
.RadioBox
->GetSelection();
1068 SetFontsToHtmlWin(m_HtmlWin
, m_NormalFace
, m_FixedFace
, m_FontSize
);
1074 void wxHtmlHelpFrame::NotifyPageChanged()
1076 if (m_UpdateContents
&& m_PagesHash
)
1078 wxString an
= m_HtmlWin
->GetOpenedAnchor();
1079 wxHtmlHelpHashData
*ha
;
1081 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage());
1083 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage() + wxT("#") + an
);
1086 bool olduc
= m_UpdateContents
;
1087 m_UpdateContents
= FALSE
;
1088 m_ContentsBox
->SelectItem(ha
->m_Id
);
1089 m_ContentsBox
->EnsureVisible(ha
->m_Id
);
1090 m_UpdateContents
= olduc
;
1102 void wxHtmlHelpFrame::OnToolbar(wxCommandEvent
& event
)
1104 switch (event
.GetId())
1106 case wxID_HTML_BACK
:
1107 m_HtmlWin
->HistoryBack();
1108 NotifyPageChanged();
1111 case wxID_HTML_FORWARD
:
1112 m_HtmlWin
->HistoryForward();
1113 NotifyPageChanged();
1119 wxString an
= m_HtmlWin
->GetOpenedAnchor();
1120 wxHtmlHelpHashData
*ha
;
1122 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage());
1124 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage() + wxT("#") + an
);
1125 if (ha
&& ha
->m_Index
> 0)
1127 wxHtmlContentsItem
*it
= m_Data
->GetContents() + (ha
->m_Index
- 1);
1128 if (it
->m_Page
[0] != 0)
1130 m_HtmlWin
->LoadPage(it
->GetFullPath());
1131 NotifyPageChanged();
1137 case wxID_HTML_UPNODE
:
1140 wxString an
= m_HtmlWin
->GetOpenedAnchor();
1141 wxHtmlHelpHashData
*ha
;
1143 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage());
1145 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(m_HtmlWin
->GetOpenedPage() + wxT("#") + an
);
1146 if (ha
&& ha
->m_Index
> 0)
1148 int level
= m_Data
->GetContents()[ha
->m_Index
].m_Level
- 1;
1149 wxHtmlContentsItem
*it
;
1150 int ind
= ha
->m_Index
- 1;
1152 it
= m_Data
->GetContents() + ind
;
1153 while (ind
>= 0 && it
->m_Level
!= level
) ind
--, it
--;
1156 if (it
->m_Page
[0] != 0)
1158 m_HtmlWin
->LoadPage(it
->GetFullPath());
1159 NotifyPageChanged();
1166 case wxID_HTML_DOWN
:
1169 wxString an
= m_HtmlWin
->GetOpenedAnchor();
1171 wxHtmlHelpHashData
*ha
;
1173 if (an
.IsEmpty()) adr
= m_HtmlWin
->GetOpenedPage();
1174 else adr
= m_HtmlWin
->GetOpenedPage() + wxT("#") + an
;
1176 ha
= (wxHtmlHelpHashData
*) m_PagesHash
->Get(adr
);
1178 if (ha
&& ha
->m_Index
< m_Data
->GetContentsCnt() - 1)
1180 wxHtmlContentsItem
*it
= m_Data
->GetContents() + (ha
->m_Index
+ 1);
1182 while (it
->GetFullPath() == adr
) it
++;
1184 if (it
->m_Page
[0] != 0)
1186 m_HtmlWin
->LoadPage(it
->GetFullPath());
1187 NotifyPageChanged();
1193 case wxID_HTML_PANEL
:
1195 if (! (m_Splitter
&& m_NavigPan
))
1197 if (m_Splitter
->IsSplit())
1199 m_Cfg
.sashpos
= m_Splitter
->GetSashPosition();
1200 m_Splitter
->Unsplit(m_NavigPan
);
1201 m_Cfg
.navig_on
= FALSE
;
1205 m_NavigPan
->Show(TRUE
);
1206 m_HtmlWin
->Show(TRUE
);
1207 m_Splitter
->SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
1208 m_Cfg
.navig_on
= TRUE
;
1213 case wxID_HTML_OPTIONS
:
1217 case wxID_HTML_BOOKMARKSADD
:
1222 item
= m_HtmlWin
->GetOpenedPageTitle();
1223 url
= m_HtmlWin
->GetOpenedPage();
1224 if (item
== wxEmptyString
)
1225 item
= url
.AfterLast(wxT('/'));
1226 if (m_BookmarksPages
.Index(url
) == wxNOT_FOUND
)
1228 m_Bookmarks
->Append(item
);
1229 m_BookmarksNames
.Add(item
);
1230 m_BookmarksPages
.Add(url
);
1235 case wxID_HTML_BOOKMARKSREMOVE
:
1240 item
= m_Bookmarks
->GetStringSelection();
1241 pos
= m_BookmarksNames
.Index(item
);
1242 if (pos
!= wxNOT_FOUND
)
1244 m_BookmarksNames
.Remove(pos
);
1245 m_BookmarksPages
.Remove(pos
);
1246 m_Bookmarks
->Delete(m_Bookmarks
->GetSelection());
1251 #if wxUSE_PRINTING_ARCHITECTURE
1252 case wxID_HTML_PRINT
:
1254 if (m_Printer
== NULL
)
1255 m_Printer
= new wxHtmlEasyPrinting(_("Help Printing"), this);
1256 if (!m_HtmlWin
->GetOpenedPage())
1257 wxLogWarning(_("Cannot print empty page."));
1259 m_Printer
->PrintFile(m_HtmlWin
->GetOpenedPage());
1264 case wxID_HTML_OPENFILE
:
1266 wxString s
= wxFileSelector(_("Open HTML document"),
1271 "HTML files (*.htm)|*.htm|HTML files (*.html)|*.html|\
1272 Help books (*.htb)|*.htb|Help books (*.zip)|*.zip|\
1273 HTML Help Project (*.hhp)|*.hhp|\
1276 wxOPEN
| wxFILE_MUST_EXIST
,
1280 wxString ext
= s
.Right(4).Lower();
1281 if (ext
== _T(".zip") || ext
== _T(".htb") || ext
== _T(".hhp"))
1288 m_HtmlWin
->LoadPage(s
);
1297 void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent
& event
)
1299 wxHtmlHelpTreeItemData
*pg
;
1300 wxHtmlContentsItem
*it
;
1302 pg
= (wxHtmlHelpTreeItemData
*) m_ContentsBox
->GetItemData(event
.GetItem());
1304 if (pg
&& m_UpdateContents
)
1306 it
= m_Data
->GetContents() + (pg
->m_Id
);
1307 m_UpdateContents
= FALSE
;
1308 if (it
->m_Page
[0] != 0)
1309 m_HtmlWin
->LoadPage(it
->GetFullPath());
1310 m_UpdateContents
= TRUE
;
1316 void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent
& WXUNUSED(event
))
1318 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_IndexList
->GetClientData(m_IndexList
->GetSelection());
1319 if (it
->m_Page
[0] != 0)
1320 m_HtmlWin
->LoadPage(it
->GetFullPath());
1321 NotifyPageChanged();
1325 void wxHtmlHelpFrame::OnIndexFind(wxCommandEvent
& event
)
1327 wxString sr
= m_IndexText
->GetLineText(0);
1329 if (sr
== wxEmptyString
)
1336 const wxChar
*cstr
= sr
.c_str();
1341 m_IndexList
->Clear();
1342 int cnt
= m_Data
->GetIndexCnt();
1343 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
1346 for (int i
= 0; i
< cnt
; i
++)
1348 wxStrncpy(mybuff
, index
[i
].m_Name
, 512);
1349 mybuff
[511] = _T('\0');
1350 for (ptr
= mybuff
; *ptr
!= 0; ptr
++)
1351 if (*ptr
>= _T('A') && *ptr
<= _T('Z'))
1352 *ptr
-= (wxChar
)(_T('A') - _T('a'));
1353 if (wxStrstr(mybuff
, cstr
) != NULL
)
1355 m_IndexList
->Append(index
[i
].m_Name
, (char*)(index
+ i
));
1359 if (index
[i
].m_Page
[0] != 0)
1360 m_HtmlWin
->LoadPage(index
[i
].GetFullPath());
1361 NotifyPageChanged();
1368 cnttext
.Printf(_("%i of %i"), displ
, cnt
);
1369 m_IndexCountInfo
->SetLabel(cnttext
);
1371 m_IndexText
->SetSelection(0, sr
.Length());
1372 m_IndexText
->SetFocus();
1376 void wxHtmlHelpFrame::OnIndexAll(wxCommandEvent
& WXUNUSED(event
))
1380 m_IndexList
->Clear();
1381 int cnt
= m_Data
->GetIndexCnt();
1383 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
1385 for (int i
= 0; i
< cnt
; i
++)
1387 m_IndexList
->Append(index
[i
].m_Name
, (char*)(index
+ i
));
1390 if (index
[i
].m_Page
[0] != 0)
1391 m_HtmlWin
->LoadPage(index
[i
].GetFullPath());
1392 NotifyPageChanged();
1398 cnttext
.Printf(_("%i of %i"), cnt
, cnt
);
1399 m_IndexCountInfo
->SetLabel(cnttext
);
1403 void wxHtmlHelpFrame::OnSearchSel(wxCommandEvent
& WXUNUSED(event
))
1405 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_SearchList
->GetClientData(m_SearchList
->GetSelection());
1408 if (it
->m_Page
[0] != 0)
1409 m_HtmlWin
->LoadPage(it
->GetFullPath());
1410 NotifyPageChanged();
1414 void wxHtmlHelpFrame::OnSearch(wxCommandEvent
& WXUNUSED(event
))
1416 wxString sr
= m_SearchText
->GetLineText(0);
1418 if (sr
!= wxEmptyString
) KeywordSearch(sr
);
1421 void wxHtmlHelpFrame::OnBookmarksSel(wxCommandEvent
& WXUNUSED(event
))
1423 wxString sr
= m_Bookmarks
->GetStringSelection();
1425 if (sr
!= wxEmptyString
&& sr
!= _("(bookmarks)"))
1427 m_HtmlWin
->LoadPage(m_BookmarksPages
[m_BookmarksNames
.Index(sr
)]);
1428 NotifyPageChanged();
1432 void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent
& evt
)
1434 GetSize(&m_Cfg
.w
, &m_Cfg
.h
);
1435 GetPosition(&m_Cfg
.x
, &m_Cfg
.y
);
1437 if (m_Splitter
&& m_Cfg
.navig_on
) m_Cfg
.sashpos
= m_Splitter
->GetSashPosition();
1440 WriteCustomization(m_Config
, m_ConfigRoot
);
1442 if (m_helpController
&& m_helpController
->IsKindOf(CLASSINFO(wxHtmlHelpController
)))
1444 ((wxHtmlHelpController
*) m_helpController
)->OnCloseFrame(evt
);
1450 BEGIN_EVENT_TABLE(wxHtmlHelpFrame
, wxFrame
)
1451 EVT_TOOL_RANGE(wxID_HTML_PANEL
, wxID_HTML_OPTIONS
, wxHtmlHelpFrame::OnToolbar
)
1452 EVT_BUTTON(wxID_HTML_BOOKMARKSREMOVE
, wxHtmlHelpFrame::OnToolbar
)
1453 EVT_BUTTON(wxID_HTML_BOOKMARKSADD
, wxHtmlHelpFrame::OnToolbar
)
1454 EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL
, wxHtmlHelpFrame::OnContentsSel
)
1455 EVT_LISTBOX(wxID_HTML_INDEXLIST
, wxHtmlHelpFrame::OnIndexSel
)
1456 EVT_LISTBOX(wxID_HTML_SEARCHLIST
, wxHtmlHelpFrame::OnSearchSel
)
1457 EVT_BUTTON(wxID_HTML_SEARCHBUTTON
, wxHtmlHelpFrame::OnSearch
)
1458 EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT
, wxHtmlHelpFrame::OnSearch
)
1459 EVT_BUTTON(wxID_HTML_INDEXBUTTON
, wxHtmlHelpFrame::OnIndexFind
)
1460 EVT_TEXT_ENTER(wxID_HTML_INDEXTEXT
, wxHtmlHelpFrame::OnIndexFind
)
1461 EVT_BUTTON(wxID_HTML_INDEXBUTTONALL
, wxHtmlHelpFrame::OnIndexAll
)
1462 EVT_COMBOBOX(wxID_HTML_BOOKMARKSLIST
, wxHtmlHelpFrame::OnBookmarksSel
)
1463 EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow
)
1466 #endif // wxUSE_WXHTML_HELP