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"
31 #include "wx/html/helpfrm.h"
32 #include "wx/html/helpctrl.h"
33 #include "wx/notebook.h"
34 #include "wx/imaglist.h"
35 #include "wx/treectrl.h"
36 #include "wx/tokenzr.h"
37 #include "wx/wfstream.h"
38 #include "wx/html/htmlwin.h"
39 #include "wx/busyinfo.h"
40 #include "wx/progdlg.h"
41 #include "wx/toolbar.h"
42 #include "wx/fontenum.h"
43 #include "wx/stream.h"
44 #include "wx/filedlg.h"
49 #include "bitmaps/wpanel.xpm"
50 #include "bitmaps/wback.xpm"
51 #include "bitmaps/wforward.xpm"
52 #include "bitmaps/wbook.xpm"
53 #include "bitmaps/woptions.xpm"
54 #include "bitmaps/wfolder.xpm"
55 #include "bitmaps/wpage.xpm"
56 #include "bitmaps/whelp.xpm"
57 #include "bitmaps/whlproot.xpm"
58 #include "bitmaps/wbkadd.xpm"
59 #include "bitmaps/wbkdel.xpm"
60 #include "bitmaps/wup.xpm"
61 #include "bitmaps/wupnode.xpm"
62 #include "bitmaps/wdown.xpm"
63 #include "bitmaps/wopen.xpm"
64 #include "bitmaps/wprint.xpm"
68 // what is considered "small index"?
69 #define INDEX_IS_SMALL 100
72 //--------------------------------------------------------------------------
73 // wxHtmlHelpTreeItemData (private)
74 //--------------------------------------------------------------------------
76 class wxHtmlHelpTreeItemData
: public wxTreeItemData
79 wxHtmlHelpTreeItemData(int id
) : wxTreeItemData()
86 //--------------------------------------------------------------------------
87 // wxHtmlHelpHashData (private)
88 //--------------------------------------------------------------------------
90 class wxHtmlHelpHashData
: public wxObject
93 wxHtmlHelpHashData(int index
, wxTreeItemId id
) : wxObject()
94 { m_Index
= index
; m_Id
= id
;}
95 ~wxHtmlHelpHashData() {}
102 //--------------------------------------------------------------------------
103 // wxHtmlHelpHtmlWindow (private)
104 //--------------------------------------------------------------------------
106 class wxHtmlHelpHtmlWindow
: public wxHtmlWindow
109 wxHtmlHelpHtmlWindow(wxHtmlHelpFrame
*fr
, wxWindow
*parent
) : wxHtmlWindow(parent
), m_Frame(fr
) {}
111 virtual void OnLinkClicked(const wxHtmlLinkInfo
& link
)
113 wxHtmlWindow::OnLinkClicked(link
);
114 m_Frame
-> NotifyPageChanged();
118 wxHtmlHelpFrame
*m_Frame
;
123 //---------------------------------------------------------------------------
125 //---------------------------------------------------------------------------
127 IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpFrame
, wxFrame
)
129 wxHtmlHelpFrame::wxHtmlHelpFrame(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
130 int style
, wxHtmlHelpData
* data
)
133 Create(parent
, id
, title
, style
);
136 void wxHtmlHelpFrame::Init(wxHtmlHelpData
* data
)
140 m_DataCreated
= FALSE
;
142 m_Data
= new wxHtmlHelpData();
143 m_DataCreated
= TRUE
;
146 m_ContentsImageList
= new wxImageList(16, 16);
147 m_ContentsImageList
-> Add(wxICON(wbook
));
148 m_ContentsImageList
-> Add(wxICON(wfolder
));
149 m_ContentsImageList
-> Add(wxICON(wpage
));
150 m_ContentsImageList
-> Add(wxICON(whlproot
));
152 m_ContentsBox
= NULL
;
154 m_IndexButton
= NULL
;
155 m_IndexButtonAll
= NULL
;
158 m_SearchButton
= NULL
;
160 m_SearchChoice
= NULL
;
161 m_IndexCountInfo
= NULL
;
166 m_SearchCaseSensitive
= NULL
;
167 m_SearchWholeWords
= NULL
;
170 m_ConfigRoot
= wxEmptyString
;
172 m_Cfg
.x
= m_Cfg
.y
= 0;
176 m_Cfg
.navig_on
= TRUE
;
178 m_NormalFonts
= m_FixedFonts
= NULL
;
179 m_NormalFace
= m_FixedFace
= wxEmptyString
;
182 #if wxUSE_PRINTING_ARCHITECTURE
187 m_UpdateContents
= TRUE
;
188 m_helpController
= (wxHelpControllerBase
*) NULL
;
191 // Create: builds the GUI components.
192 // with the style flag it's possible to toggle the toolbar, contents, index and search
194 // m_HtmlWin will *always* be created, but it's important to realize that
195 // m_ContentsBox, m_IndexList, m_SearchList, m_SearchButton, m_SearchText and
196 // m_SearchButton may be NULL.
197 // moreover, if no contents, index or searchpage is needed, m_Splitter and
198 // m_NavigPan will be NULL too (with m_HtmlWin directly connected to the frame)
200 bool wxHtmlHelpFrame::Create(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
203 // Do the config in two steps. We read the HtmlWindow customization after we
204 // create the window.
206 ReadCustomization(m_Config
, m_ConfigRoot
);
208 wxFrame::Create(parent
, id
, _("Help"), wxPoint(m_Cfg
.x
, m_Cfg
.y
), wxSize(m_Cfg
.w
, m_Cfg
.h
), wxDEFAULT_FRAME_STYLE
, "wxHtmlHelp");
210 GetPosition(&m_Cfg
.x
, &m_Cfg
.y
);
212 SetIcon(wxICON(whelp
));
214 int notebook_page
= 0;
219 if (style
& wxHF_TOOLBAR
) {
220 wxToolBar
*toolBar
= CreateToolBar(wxNO_BORDER
| wxTB_HORIZONTAL
| wxTB_DOCKABLE
);
221 toolBar
->SetMargins( 2, 2 );
222 AddToolbarButtons(toolBar
, style
);
223 toolBar
-> Realize();
226 if (style
& (wxHF_CONTENTS
| wxHF_INDEX
| wxHF_SEARCH
)) {
227 // traditional help controller; splitter window with html page on the
228 // right and a notebook containing various pages on the left
229 m_Splitter
= new wxSplitterWindow(this);
231 m_HtmlWin
= new wxHtmlHelpHtmlWindow(this, m_Splitter
);
232 m_NavigPan
= new wxNotebook(m_Splitter
, wxID_HTML_NOTEBOOK
,
233 wxDefaultPosition
, wxDefaultSize
);
234 } else { // only html window, no notebook with index,contents etc
235 m_HtmlWin
= new wxHtmlWindow(this);
238 m_HtmlWin
-> SetRelatedFrame(this, m_TitleFormat
);
239 m_HtmlWin
-> SetRelatedStatusBar(0);
241 m_HtmlWin
-> ReadCustomization(m_Config
, m_ConfigRoot
);
243 // contents tree panel?
244 if (style
& wxHF_CONTENTS
) {
245 wxWindow
*dummy
= new wxPanel(m_NavigPan
, wxID_HTML_INDEXPAGE
);
247 if (style
& wxHF_BOOKMARKS
) {
248 wxLayoutConstraints
*b1
= new wxLayoutConstraints
;
249 wxBitmapButton
*bmpbt
= new wxBitmapButton(dummy
, wxID_HTML_BOOKMARKSREMOVE
, wxBITMAP(wbkdel
), wxDefaultPosition
, wxSize(20,20));
251 b1
-> top
.SameAs (dummy
, wxTop
, 10);
252 b1
-> right
.SameAs (dummy
, wxRight
, 10);
255 bmpbt
-> SetConstraints(b1
);
257 wxLayoutConstraints
*b2
= new wxLayoutConstraints
;
258 wxBitmapButton
*bmpbt2
= new wxBitmapButton(dummy
, wxID_HTML_BOOKMARKSADD
, wxBITMAP(wbkadd
), wxDefaultPosition
, wxSize(20,20));
260 b2
-> top
.SameAs (dummy
, wxTop
, 10);
261 b2
-> right
.LeftOf (bmpbt
, 2);
264 bmpbt2
-> SetConstraints(b2
);
267 bmpbt
-> SetToolTip(_("Remove current page from bookmarks"));
268 bmpbt2
-> SetToolTip(_("Add current page to bookmarks"));
269 #endif //wxUSE_TOOLTIPS
271 wxLayoutConstraints
*b3
= new wxLayoutConstraints
;
272 m_Bookmarks
= new wxComboBox(dummy
, wxID_HTML_BOOKMARKSLIST
, wxEmptyString
,
273 wxDefaultPosition
, wxDefaultSize
, 0, NULL
, wxCB_READONLY
| wxCB_SORT
);
274 m_Bookmarks
-> Append(_("(bookmarks)"));
275 for (unsigned i
= 0; i
< m_BookmarksNames
.GetCount(); i
++)
276 m_Bookmarks
-> Append(m_BookmarksNames
[i
]);
277 m_Bookmarks
-> SetSelection(0);
279 b3
-> centreY
.SameAs (bmpbt2
, wxCentreY
);
280 b3
-> left
.SameAs (dummy
, wxLeft
, 10);
281 b3
-> right
.LeftOf (bmpbt2
, 5);
283 m_Bookmarks
-> SetConstraints(b3
);
286 wxLayoutConstraints
*b4
= new wxLayoutConstraints
;
287 m_ContentsBox
= new wxTreeCtrl(dummy
, wxID_HTML_TREECTRL
,
288 wxDefaultPosition
, wxDefaultSize
,
289 wxTR_HAS_BUTTONS
| wxSUNKEN_BORDER
);
290 m_ContentsBox
-> SetImageList(m_ContentsImageList
);
292 b4
-> top
.Below (m_Bookmarks
, 10);
293 b4
-> left
.SameAs (dummy
, wxLeft
, 0);
294 b4
-> right
.SameAs (dummy
, wxRight
, 0);
295 b4
-> bottom
.SameAs (dummy
, wxBottom
, 0);
296 m_ContentsBox
-> SetConstraints(b4
);
298 dummy
-> SetAutoLayout(TRUE
);
301 m_NavigPan
-> AddPage(dummy
, _("Contents"));
306 m_ContentsBox
= new wxTreeCtrl(m_NavigPan
, wxID_HTML_TREECTRL
,
307 wxDefaultPosition
, wxDefaultSize
,
308 wxTR_HAS_BUTTONS
| wxSUNKEN_BORDER
);
309 m_ContentsBox
-> SetImageList(m_ContentsImageList
);
310 m_NavigPan
-> AddPage(m_ContentsBox
, _("Contents"));
313 m_ContentsPage
= notebook_page
++;
316 // index listbox panel?
317 if (style
& wxHF_INDEX
) {
318 wxWindow
*dummy
= new wxPanel(m_NavigPan
, wxID_HTML_INDEXPAGE
);
320 wxLayoutConstraints
*b1
= new wxLayoutConstraints
;
321 m_IndexText
= new wxTextCtrl(dummy
, wxID_HTML_INDEXTEXT
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, wxTE_PROCESS_ENTER
);
322 b1
-> top
.SameAs (dummy
, wxTop
, 10);
323 b1
-> left
.SameAs (dummy
, wxLeft
, 10);
324 b1
-> right
.SameAs (dummy
, wxRight
, 10);
326 m_IndexText
-> SetConstraints(b1
);
328 wxLayoutConstraints
*b4
= new wxLayoutConstraints
;
329 m_IndexButtonAll
= new wxButton(dummy
, wxID_HTML_INDEXBUTTONALL
, _("Show all"));
331 b4
-> top
.Below (m_IndexText
, 10);
332 b4
-> right
.SameAs (dummy
, wxRight
, 10);
335 m_IndexButtonAll
-> SetConstraints(b4
);
337 wxLayoutConstraints
*b2
= new wxLayoutConstraints
;
338 m_IndexButton
= new wxButton(dummy
, wxID_HTML_INDEXBUTTON
, _("Find"));
339 b2
-> top
.Below (m_IndexText
, 10);
340 b2
-> right
.LeftOf (m_IndexButtonAll
, 10);
343 m_IndexButton
-> SetConstraints(b2
);
345 wxLayoutConstraints
*b5
= new wxLayoutConstraints
;
346 m_IndexCountInfo
= new wxStaticText(dummy
, wxID_HTML_COUNTINFO
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, wxALIGN_RIGHT
| wxST_NO_AUTORESIZE
);
348 b5
-> top
.Below (m_IndexButton
, 5);
349 b5
-> right
.SameAs (dummy
, wxRight
, 10);
350 b5
-> left
.SameAs (dummy
, wxLeft
, 10);
352 m_IndexCountInfo
-> SetConstraints(b5
);
354 wxLayoutConstraints
*b3
= new wxLayoutConstraints
;
355 m_IndexList
= new wxListBox(dummy
, wxID_HTML_INDEXLIST
, wxDefaultPosition
, wxDefaultSize
, 0, NULL
, wxLB_SINGLE
);
356 b3
-> top
.Below (m_IndexCountInfo
, 5);
357 b3
-> left
.SameAs (dummy
, wxLeft
, 0);
358 b3
-> right
.SameAs (dummy
, wxRight
, 0);
359 b3
-> bottom
.SameAs (dummy
, wxBottom
, 0);
360 m_IndexList
-> SetConstraints(b3
);
363 m_IndexButtonAll
-> SetToolTip(_("Show all items in index"));
364 m_IndexButton
-> SetToolTip(_("Display all index items that contain given substring. Search is case insensitive."));
365 #endif //wxUSE_TOOLTIPS
367 dummy
-> SetAutoLayout(TRUE
);
370 m_NavigPan
-> AddPage(dummy
, _("Index"));
371 m_IndexPage
= notebook_page
++;
374 // search list panel?
375 if (style
& wxHF_SEARCH
) {
376 wxWindow
*dummy
= new wxPanel(m_NavigPan
, wxID_HTML_SEARCHPAGE
);
378 wxLayoutConstraints
*b1
= new wxLayoutConstraints
;
379 m_SearchText
= new wxTextCtrl(dummy
, wxID_HTML_SEARCHTEXT
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, wxTE_PROCESS_ENTER
);
380 b1
-> top
.SameAs (dummy
, wxTop
, 10);
381 b1
-> left
.SameAs (dummy
, wxLeft
, 10);
382 b1
-> right
.SameAs (dummy
, wxRight
, 10);
384 m_SearchText
-> SetConstraints(b1
);
386 wxLayoutConstraints
*b4
= new wxLayoutConstraints
;
387 m_SearchChoice
= new wxChoice(dummy
, wxID_HTML_SEARCHCHOICE
, wxDefaultPosition
,
389 b4
-> top
.Below (m_SearchText
, 10);
390 b4
-> left
.SameAs (dummy
, wxLeft
, 10);
391 b4
-> right
.SameAs (dummy
, wxRight
, 10);
393 m_SearchChoice
-> SetConstraints(b4
);
395 wxLayoutConstraints
*b5
= new wxLayoutConstraints
;
396 m_SearchCaseSensitive
= new wxCheckBox(dummy
, -1, _("Case sensitive"));
397 b5
-> top
.Below (m_SearchChoice
, 10);
398 b5
-> left
.SameAs (dummy
, wxLeft
, 10);
400 b5
-> height
.AsIs ();
401 m_SearchCaseSensitive
-> SetConstraints(b5
);
403 wxLayoutConstraints
*b6
= new wxLayoutConstraints
;
404 m_SearchWholeWords
= new wxCheckBox(dummy
, -1, _("Whole words only"));
405 b6
-> top
.Below (m_SearchCaseSensitive
, 0);
406 b6
-> left
.SameAs (dummy
, wxLeft
, 10);
408 b6
-> height
.AsIs ();
409 m_SearchWholeWords
-> SetConstraints(b6
);
411 wxLayoutConstraints
*b2
= new wxLayoutConstraints
;
412 m_SearchButton
= new wxButton(dummy
, wxID_HTML_SEARCHBUTTON
, _("Search"));
414 m_SearchButton
-> SetToolTip(_("Search contents of help book(s) for all occurences of the text you typed above"));
415 #endif //wxUSE_TOOLTIPS
416 b2
-> top
.Below (m_SearchWholeWords
, 0);
417 b2
-> right
.SameAs (dummy
, wxRight
, 10);
420 m_SearchButton
-> SetConstraints(b2
);
422 wxLayoutConstraints
*b3
= new wxLayoutConstraints
;
423 m_SearchList
= new wxListBox(dummy
, wxID_HTML_SEARCHLIST
, wxDefaultPosition
, wxDefaultSize
, 0, NULL
, wxLB_SINGLE
);
424 b3
-> top
.Below (m_SearchButton
, 10);
425 b3
-> left
.SameAs (dummy
, wxLeft
, 0);
426 b3
-> right
.SameAs (dummy
, wxRight
, 0);
427 b3
-> bottom
.SameAs (dummy
, wxBottom
, 0);
428 m_SearchList
-> SetConstraints(b3
);
430 dummy
-> SetAutoLayout(TRUE
);
432 m_NavigPan
-> AddPage(dummy
, _("Search"));
433 m_SearchPage
= notebook_page
++;
435 m_HtmlWin
-> Show(TRUE
);
440 if (m_NavigPan
&& m_Splitter
) {
441 m_Splitter
-> SetMinimumPaneSize(20);
443 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
445 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
446 m_Splitter
-> Unsplit();
448 if (m_Cfg
.navig_on
) {
449 m_NavigPan
-> Show(TRUE
);
450 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
453 m_NavigPan
-> Show(FALSE
);
454 m_Splitter
-> Initialize(m_HtmlWin
);
460 wxHtmlHelpFrame::~wxHtmlHelpFrame()
462 // PopEventHandler(); // wxhtmlhelpcontroller (not any more!)
463 delete m_ContentsImageList
;
466 if (m_NormalFonts
) delete m_NormalFonts
;
467 if (m_FixedFonts
) delete m_FixedFonts
;
468 if (m_PagesHash
) delete m_PagesHash
;
472 void wxHtmlHelpFrame::AddToolbarButtons(wxToolBar
*toolBar
, int style
)
474 toolBar
-> AddTool(wxID_HTML_PANEL
, wxBITMAP(wpanel
), wxNullBitmap
,
475 FALSE
, -1, -1, (wxObject
*) NULL
,
476 _("Show/hide navigation panel"));
478 toolBar
-> AddSeparator();
479 toolBar
-> AddTool(wxID_HTML_BACK
, wxBITMAP(wback
), wxNullBitmap
,
480 FALSE
, -1, -1, (wxObject
*) NULL
,
482 toolBar
-> AddTool(wxID_HTML_FORWARD
, wxBITMAP(wforward
), wxNullBitmap
,
483 FALSE
, -1, -1, (wxObject
*) NULL
,
485 toolBar
-> AddSeparator();
487 toolBar
-> AddTool(wxID_HTML_UPNODE
, wxBITMAP(wupnode
), wxNullBitmap
,
488 FALSE
, -1, -1, (wxObject
*) NULL
,
489 _("Go one level up in document hierarchy"));
490 toolBar
-> AddTool(wxID_HTML_UP
, wxBITMAP(wup
), wxNullBitmap
,
491 FALSE
, -1, -1, (wxObject
*) NULL
,
493 toolBar
-> AddTool(wxID_HTML_DOWN
, wxBITMAP(wdown
), wxNullBitmap
,
494 FALSE
, -1, -1, (wxObject
*) NULL
,
497 if ((style
& wxHF_PRINT
) || (style
& wxHF_OPENFILES
))
498 toolBar
-> AddSeparator();
500 if (style
& wxHF_OPENFILES
)
501 toolBar
-> AddTool(wxID_HTML_OPENFILE
, wxBITMAP(wopen
), wxNullBitmap
,
502 FALSE
, -1, -1, (wxObject
*) NULL
,
503 _("Open HTML document"));
505 #if wxUSE_PRINTING_ARCHITECTURE
506 if (style
& wxHF_PRINT
)
507 toolBar
-> AddTool(wxID_HTML_PRINT
, wxBITMAP(wprint
), wxNullBitmap
,
508 FALSE
, -1, -1, (wxObject
*) NULL
,
509 _("Print this page"));
512 toolBar
-> AddSeparator();
513 toolBar
-> AddTool(wxID_HTML_OPTIONS
, wxBITMAP(woptions
), wxNullBitmap
,
514 FALSE
, -1, -1, (wxObject
*) NULL
,
515 _("Display options dialog"));
519 void wxHtmlHelpFrame::SetTitleFormat(const wxString
& format
)
522 m_HtmlWin
->SetRelatedFrame(this, format
);
523 m_TitleFormat
= format
;
527 bool wxHtmlHelpFrame::Display(const wxString
& x
)
529 wxString url
= m_Data
->FindPageByName(x
);
530 if (! url
.IsEmpty()) {
531 m_HtmlWin
->LoadPage(url
);
538 bool wxHtmlHelpFrame::Display(const int id
)
540 wxString url
= m_Data
->FindPageById(id
);
541 if (! url
.IsEmpty()) {
542 m_HtmlWin
->LoadPage(url
);
551 bool wxHtmlHelpFrame::DisplayContents()
555 if (!m_Splitter
-> IsSplit()) {
556 m_NavigPan
-> Show(TRUE
);
557 m_HtmlWin
-> Show(TRUE
);
558 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
559 m_Cfg
.navig_on
= TRUE
;
561 m_NavigPan
-> SetSelection(0);
567 bool wxHtmlHelpFrame::DisplayIndex()
571 if (!m_Splitter
-> IsSplit()) {
572 m_NavigPan
-> Show(TRUE
);
573 m_HtmlWin
-> Show(TRUE
);
574 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
576 m_NavigPan
-> SetSelection(1);
582 bool wxHtmlHelpFrame::KeywordSearch(const wxString
& keyword
)
584 if (! (m_SearchList
&& m_SearchButton
&& m_SearchText
&& m_SearchChoice
))
587 int foundcnt
= 0, curi
;
589 wxString book
= wxEmptyString
;
591 if (!m_Splitter
-> IsSplit()) {
592 m_NavigPan
-> Show(TRUE
);
593 m_HtmlWin
-> Show(TRUE
);
594 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
596 m_NavigPan
-> SetSelection(m_SearchPage
);
597 m_SearchList
-> Clear();
598 m_SearchText
-> SetValue(keyword
);
599 m_SearchButton
-> Enable(FALSE
);
601 if (m_SearchChoice
->GetSelection() != 0)
602 book
= m_SearchChoice
->GetStringSelection();
604 wxHtmlSearchStatus
status(m_Data
, keyword
,
605 m_SearchCaseSensitive
-> GetValue(), m_SearchWholeWords
-> GetValue(),
608 wxProgressDialog
progress(_("Searching..."), _("No matching page found yet"),
609 status
.GetMaxIndex(), this,
610 wxPD_APP_MODAL
| wxPD_CAN_ABORT
| wxPD_AUTO_HIDE
);
612 while (status
.IsActive()) {
613 curi
= status
.GetCurIndex();
614 if (curi
% 32 == 0 && progress
.Update(curi
) == FALSE
)
616 if (status
.Search()) {
617 foundstr
.Printf(_("Found %i matches"), ++foundcnt
);
618 progress
.Update(status
.GetCurIndex(), foundstr
);
619 m_SearchList
-> Append(status
.GetName(), status
.GetContentsItem());
623 m_SearchButton
-> Enable(TRUE
);
624 m_SearchText
-> SetSelection(0, keyword
.Length());
625 m_SearchText
-> SetFocus();
627 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_SearchList
-> GetClientData(0);
630 m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
634 return (foundcnt
> 0);
639 void wxHtmlHelpFrame::CreateContents()
644 m_ContentsBox
->Clear();
646 if (m_PagesHash
) delete m_PagesHash
;
647 m_PagesHash
= new wxHashTable(wxKEY_STRING
, 2 * m_Data
-> GetContentsCnt());
648 m_PagesHash
-> DeleteContents(TRUE
);
650 int cnt
= m_Data
->GetContentsCnt();
653 wxHtmlContentsItem
*it
;
655 wxTreeItemId roots
[MAX_ROOTS
];
656 bool imaged
[MAX_ROOTS
];
658 m_ContentsBox
-> DeleteAllItems();
659 roots
[0] = m_ContentsBox
-> AddRoot(_("(Help)"));
660 m_ContentsBox
-> SetItemImage(roots
[0], IMG_RootFolder
);
661 m_ContentsBox
-> SetItemSelectedImage(roots
[0], IMG_RootFolder
);
664 for (it
= m_Data
->GetContents(), i
= 0; i
< cnt
; i
++, it
++) {
665 roots
[it
-> m_Level
+ 1] = m_ContentsBox
-> AppendItem(
666 roots
[it
-> m_Level
], it
-> m_Name
, IMG_Page
, -1,
667 new wxHtmlHelpTreeItemData(i
));
668 m_PagesHash
-> Put(it
-> m_Book
-> GetBasePath() + it
-> m_Page
,
669 new wxHtmlHelpHashData(i
, roots
[it
-> m_Level
+ 1]));
671 if (it
-> m_Level
== 0) {
672 m_ContentsBox
-> SetItemBold(roots
[1], TRUE
);
673 m_ContentsBox
-> SetItemImage(roots
[1], IMG_Book
);
674 m_ContentsBox
-> SetItemSelectedImage(roots
[1], IMG_Book
);
676 } else imaged
[it
-> m_Level
+ 1] = FALSE
;
678 if (!imaged
[it
-> m_Level
]) {
679 m_ContentsBox
-> SetItemImage(roots
[it
-> m_Level
], IMG_Folder
);
680 m_ContentsBox
-> SetItemSelectedImage(roots
[it
-> m_Level
], IMG_Folder
);
681 imaged
[it
-> m_Level
] = TRUE
;
684 m_ContentsBox
-> Expand(roots
[0]);
688 void wxHtmlHelpFrame::CreateIndex()
693 m_IndexList
->Clear();
695 int cnt
= m_Data
->GetIndexCnt();
698 if (cnt
> INDEX_IS_SMALL
) cnttext
.Printf(_("%i of %i"), 0, cnt
);
699 else cnttext
.Printf(_("%i of %i"), cnt
, cnt
);
700 m_IndexCountInfo
-> SetLabel(cnttext
);
701 if (cnt
> INDEX_IS_SMALL
) return;
703 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
705 for (int i
= 0; i
< cnt
; i
++)
706 m_IndexList
-> Append(index
[i
].m_Name
, (char*)(index
+ i
));
709 void wxHtmlHelpFrame::CreateSearch()
711 if (! (m_SearchList
&& m_SearchChoice
))
713 m_SearchList
-> Clear();
714 m_SearchChoice
-> Clear();
715 m_SearchChoice
-> Append(_("Search in all books"));
716 const wxHtmlBookRecArray
& bookrec
= m_Data
->GetBookRecArray();
717 int i
, cnt
= bookrec
.GetCount();
718 for (i
= 0; i
< cnt
; i
++)
719 m_SearchChoice
->Append(bookrec
[i
].GetTitle());
720 m_SearchChoice
->SetSelection(0);
724 void wxHtmlHelpFrame::RefreshLists()
731 void wxHtmlHelpFrame::ReadCustomization(wxConfigBase
*cfg
, const wxString
& path
)
736 if (path
!= wxEmptyString
) {
737 oldpath
= cfg
-> GetPath();
738 cfg
-> SetPath(_T("/") + path
);
741 m_Cfg
.navig_on
= cfg
-> Read(wxT("hcNavigPanel"), m_Cfg
.navig_on
) != 0;
742 m_Cfg
.sashpos
= cfg
-> Read(wxT("hcSashPos"), m_Cfg
.sashpos
);
743 m_Cfg
.x
= cfg
-> Read(wxT("hcX"), m_Cfg
.x
);
744 m_Cfg
.y
= cfg
-> Read(wxT("hcY"), m_Cfg
.y
);
745 m_Cfg
.w
= cfg
-> Read(wxT("hcW"), m_Cfg
.w
);
746 m_Cfg
.h
= cfg
-> Read(wxT("hcH"), m_Cfg
.h
);
748 m_FixedFace
= cfg
-> Read(wxT("hcFixedFace"), m_FixedFace
);
749 m_NormalFace
= cfg
-> Read(wxT("hcNormalFace"), m_NormalFace
);
750 m_FontSize
= cfg
-> Read(wxT("hcFontSize"), m_FontSize
);
757 cnt
= cfg
-> Read(wxT("hcBookmarksCnt"), 0L);
759 m_BookmarksNames
.Clear();
760 m_BookmarksPages
.Clear();
762 m_Bookmarks
-> Clear();
763 m_Bookmarks
-> Append(_("(bookmarks)"));
766 for (i
= 0; i
< cnt
; i
++) {
767 val
.Printf(wxT("hcBookmark_%i"), i
);
768 s
= cfg
-> Read(val
);
769 m_BookmarksNames
.Add(s
);
770 if (m_Bookmarks
) m_Bookmarks
-> Append(s
);
771 val
.Printf(wxT("hcBookmark_%i_url"), i
);
772 s
= cfg
-> Read(val
);
773 m_BookmarksPages
.Add(s
);
779 m_HtmlWin
->ReadCustomization(cfg
);
781 if (path
!= wxEmptyString
)
782 cfg
-> SetPath(oldpath
);
785 void wxHtmlHelpFrame::WriteCustomization(wxConfigBase
*cfg
, const wxString
& path
)
790 if (path
!= wxEmptyString
) {
791 oldpath
= cfg
-> GetPath();
792 cfg
-> SetPath(_T("/") + path
);
795 cfg
-> Write(wxT("hcNavigPanel"), m_Cfg
.navig_on
);
796 cfg
-> Write(wxT("hcSashPos"), (long)m_Cfg
.sashpos
);
797 cfg
-> Write(wxT("hcX"), (long)m_Cfg
.x
);
798 cfg
-> Write(wxT("hcY"), (long)m_Cfg
.y
);
799 cfg
-> Write(wxT("hcW"), (long)m_Cfg
.w
);
800 cfg
-> Write(wxT("hcH"), (long)m_Cfg
.h
);
801 cfg
-> Write(wxT("hcFixedFace"), m_FixedFace
);
802 cfg
-> Write(wxT("hcNormalFace"), m_NormalFace
);
803 cfg
-> Write(wxT("hcFontSize"), (long)m_FontSize
);
807 int cnt
= m_BookmarksNames
.GetCount();
810 cfg
-> Write(wxT("hcBookmarksCnt"), (long)cnt
);
811 for (i
= 0; i
< cnt
; i
++) {
812 val
.Printf(wxT("hcBookmark_%i"), i
);
813 cfg
-> Write(val
, m_BookmarksNames
[i
]);
814 val
.Printf(wxT("hcBookmark_%i_url"), i
);
815 cfg
-> Write(val
, m_BookmarksPages
[i
]);
820 m_HtmlWin
->WriteCustomization(cfg
);
822 if (path
!= wxEmptyString
)
823 cfg
-> SetPath(oldpath
);
830 static void SetFontsToHtmlWin(wxHtmlWindow
*win
, wxString scalf
, wxString fixf
, int size
)
832 static int f_sizes
[5][7] =
834 { 6, 7, 9, 12, 14, 16, 19},
835 { 8, 9, 12, 14, 16, 19, 22},
836 {10, 12, 14, 16, 19, 24, 32},
837 {14, 16, 18, 24, 32, 38, 45},
838 {16, 20, 24, 32, 38, 45, 50}
841 win
-> SetFonts(scalf
, fixf
, f_sizes
[size
]);
845 class wxHtmlHelpFrameOptionsDialog
: public wxDialog
848 wxComboBox
*NormalFont
, *FixedFont
;
849 wxRadioBox
*RadioBox
;
850 wxHtmlWindow
*TestWin
;
852 wxHtmlHelpFrameOptionsDialog(wxWindow
*parent
) : wxDialog(parent
, -1, wxString(_("Help Browser Options")))
854 wxString choices
[5] = {_("very small"), _("small"), _("medium"), _("large"), _("very large")};
855 wxBoxSizer
*topsizer
, *sizer
, *sizer2
;
857 topsizer
= new wxBoxSizer(wxVERTICAL
);
859 sizer
= new wxBoxSizer(wxHORIZONTAL
);
861 sizer2
= new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Normal font:")), wxVERTICAL
);
862 sizer2
-> Add(NormalFont
= new wxComboBox(this, -1, wxEmptyString
, wxDefaultPosition
,
864 0, NULL
, wxCB_DROPDOWN
| wxCB_READONLY
),
865 1, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
867 sizer
-> Add(sizer2
, 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10);
869 sizer2
= new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Fixed font:")), wxVERTICAL
);
870 sizer2
-> Add(FixedFont
= new wxComboBox(this, -1, wxEmptyString
, wxDefaultPosition
,
872 0, NULL
, wxCB_DROPDOWN
| wxCB_READONLY
),
873 1, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
875 sizer
-> Add(sizer2
, 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10);
877 topsizer
-> Add(sizer
);
879 topsizer
-> Add(RadioBox
= new wxRadioBox(this, -1, _("Font size:"),
880 wxDefaultPosition
, wxDefaultSize
, 5, choices
, 5),
881 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10);
883 topsizer
-> Add(new wxStaticText(this, -1, _("Preview:")),
884 0, wxLEFT
| wxTOP
, 10);
885 topsizer
-> Add(TestWin
= new wxHtmlWindow(this, -1, wxDefaultPosition
, wxSize(-1, 150)),
886 1, wxEXPAND
| wxLEFT
|wxTOP
|wxRIGHT
, 10);
888 sizer
= new wxBoxSizer(wxHORIZONTAL
);
889 sizer
-> Add(new wxButton(this, wxID_OK
, _("OK")), 0, wxALL
, 10);
890 sizer
-> Add(new wxButton(this, wxID_CANCEL
, _("Cancel")), 0, wxALL
, 10);
891 topsizer
-> Add(sizer
, 0, wxALIGN_RIGHT
);
895 topsizer
-> Fit(this);
903 SetFontsToHtmlWin(TestWin
,
904 NormalFont
-> GetStringSelection(),
905 FixedFont
-> GetStringSelection(),
906 RadioBox
-> GetSelection());
907 TestWin
-> SetPage(_("<html><body>"
908 "Normal face<br>(and <u>underlined</u>. <i>Italic face.</i> "
909 "<b>Bold face.</b> <b><i>Bold italic face.</i></b><br>"
910 "<font size=-2>font size -2</font><br>"
911 "<font size=-1>font size -1</font><br>"
912 "<font size=+0>font size +0</font><br>"
913 "<font size=+1>font size +1</font><br>"
914 "<font size=+2>font size +2</font><br>"
915 "<font size=+3>font size +3</font><br>"
916 "<font size=+4>font size +4</font><br>"
918 "<p><tt>Fixed size face.<br> <b>bold</b> <i>italic</i> "
919 "<b><i>bold italic <u>underlined</u></i></b><br>"
920 "<font size=-2>font size -2</font><br>"
921 "<font size=-1>font size -1</font><br>"
922 "<font size=+0>font size +0</font><br>"
923 "<font size=+1>font size +1</font><br>"
924 "<font size=+2>font size +2</font><br>"
925 "<font size=+3>font size +3</font><br>"
926 "<font size=+4>font size +4</font></tt>"
930 void OnUpdate(wxCommandEvent
& event
)
935 DECLARE_EVENT_TABLE()
938 BEGIN_EVENT_TABLE(wxHtmlHelpFrameOptionsDialog
, wxDialog
)
939 EVT_COMBOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate
)
940 EVT_RADIOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate
)
944 void wxHtmlHelpFrame::OptionsDialog()
946 wxHtmlHelpFrameOptionsDialog
dlg(this);
949 if (m_NormalFonts
== NULL
) {
950 wxFontEnumerator enu
;
951 enu
.EnumerateFacenames();
952 m_NormalFonts
= new wxArrayString
;
953 *m_NormalFonts
= *enu
.GetFacenames();
954 m_NormalFonts
-> Sort();
956 if (m_FixedFonts
== NULL
) {
957 wxFontEnumerator enu
;
958 enu
.EnumerateFacenames(wxFONTENCODING_SYSTEM
, TRUE
);
959 m_FixedFonts
= new wxArrayString
;
960 *m_FixedFonts
= *enu
.GetFacenames();
961 m_FixedFonts
-> Sort();
964 for (i
= 0; i
< m_NormalFonts
-> GetCount(); i
++)
965 dlg
.NormalFont
-> Append((*m_NormalFonts
)[i
]);
966 for (i
= 0; i
< m_FixedFonts
-> GetCount(); i
++)
967 dlg
.FixedFont
-> Append((*m_FixedFonts
)[i
]);
968 if (!m_NormalFace
.IsEmpty()) dlg
.NormalFont
-> SetStringSelection(m_NormalFace
);
969 else dlg
.NormalFont
-> SetSelection(0);
970 if (!m_FixedFace
.IsEmpty()) dlg
.FixedFont
-> SetStringSelection(m_FixedFace
);
971 else dlg
.FixedFont
-> SetSelection(0);
972 dlg
.RadioBox
-> SetSelection(m_FontSize
);
975 if (dlg
.ShowModal() == wxID_OK
) {
976 m_NormalFace
= dlg
.NormalFont
-> GetStringSelection();
977 m_FixedFace
= dlg
.FixedFont
-> GetStringSelection();
978 m_FontSize
= dlg
.RadioBox
-> GetSelection();
979 SetFontsToHtmlWin(m_HtmlWin
, m_NormalFace
, m_FixedFace
, m_FontSize
);
985 void wxHtmlHelpFrame::NotifyPageChanged()
987 if (m_UpdateContents
&& m_PagesHash
)
989 wxString an
= m_HtmlWin
-> GetOpenedAnchor();
990 wxHtmlHelpHashData
*ha
;
992 ha
= (wxHtmlHelpHashData
*) m_PagesHash
-> Get(m_HtmlWin
-> GetOpenedPage());
994 ha
= (wxHtmlHelpHashData
*) m_PagesHash
-> Get(m_HtmlWin
-> GetOpenedPage() + wxT("#") + an
);
997 bool olduc
= m_UpdateContents
;
998 m_UpdateContents
= FALSE
;
999 m_ContentsBox
-> SelectItem(ha
-> m_Id
);
1000 m_ContentsBox
-> EnsureVisible(ha
-> m_Id
);
1001 m_UpdateContents
= olduc
;
1013 void wxHtmlHelpFrame::OnToolbar(wxCommandEvent
& event
)
1015 switch (event
.GetId()) {
1017 case wxID_HTML_BACK
:
1018 m_HtmlWin
-> HistoryBack();
1019 NotifyPageChanged();
1022 case wxID_HTML_FORWARD
:
1023 m_HtmlWin
-> HistoryForward();
1024 NotifyPageChanged();
1030 wxString an
= m_HtmlWin
-> GetOpenedAnchor();
1031 wxHtmlHelpHashData
*ha
;
1033 ha
= (wxHtmlHelpHashData
*) m_PagesHash
-> Get(m_HtmlWin
-> GetOpenedPage());
1035 ha
= (wxHtmlHelpHashData
*) m_PagesHash
-> Get(m_HtmlWin
-> GetOpenedPage() + wxT("#") + an
);
1036 if (ha
&& ha
-> m_Index
> 0)
1038 wxHtmlContentsItem
*it
= m_Data
-> GetContents() + (ha
-> m_Index
- 1);
1039 m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
1040 NotifyPageChanged();
1045 case wxID_HTML_UPNODE
:
1048 wxString an
= m_HtmlWin
-> GetOpenedAnchor();
1049 wxHtmlHelpHashData
*ha
;
1051 ha
= (wxHtmlHelpHashData
*) m_PagesHash
-> Get(m_HtmlWin
-> GetOpenedPage());
1053 ha
= (wxHtmlHelpHashData
*) m_PagesHash
-> Get(m_HtmlWin
-> GetOpenedPage() + wxT("#") + an
);
1054 if (ha
&& ha
-> m_Index
> 0)
1056 int level
= m_Data
-> GetContents()[ha
-> m_Index
].m_Level
- 1;
1057 wxHtmlContentsItem
*it
;
1058 int ind
= ha
-> m_Index
- 1;
1060 it
= m_Data
-> GetContents() + ind
;
1061 while (ind
>= 0 && it
-> m_Level
!= level
) ind
--, it
--;
1064 m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
1065 NotifyPageChanged();
1071 case wxID_HTML_DOWN
:
1074 wxString an
= m_HtmlWin
-> GetOpenedAnchor();
1076 wxHtmlHelpHashData
*ha
;
1078 if (an
.IsEmpty()) adr
= m_HtmlWin
-> GetOpenedPage();
1079 else adr
= m_HtmlWin
-> GetOpenedPage() + wxT("#") + an
;
1081 ha
= (wxHtmlHelpHashData
*) m_PagesHash
-> Get(adr
);
1083 if (ha
&& ha
-> m_Index
< m_Data
-> GetContentsCnt() - 1)
1085 wxHtmlContentsItem
*it
= m_Data
-> GetContents() + (ha
-> m_Index
+ 1);
1087 while (it
-> m_Book
-> GetBasePath() + it
-> m_Page
== adr
) it
++;
1088 m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
1089 NotifyPageChanged();
1094 case wxID_HTML_PANEL
:
1096 if (! (m_Splitter
&& m_NavigPan
))
1098 if (m_Splitter
-> IsSplit()) {
1099 m_Cfg
.sashpos
= m_Splitter
-> GetSashPosition();
1100 m_Splitter
-> Unsplit(m_NavigPan
);
1101 m_Cfg
.navig_on
= FALSE
;
1103 m_NavigPan
-> Show(TRUE
);
1104 m_HtmlWin
-> Show(TRUE
);
1105 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
1106 m_Cfg
.navig_on
= TRUE
;
1111 case wxID_HTML_OPTIONS
:
1115 case wxID_HTML_BOOKMARKSADD
:
1120 item
= m_HtmlWin
-> GetOpenedPageTitle();
1121 url
= m_HtmlWin
-> GetOpenedPage();
1122 if (item
== wxEmptyString
) item
= url
.AfterLast(wxT('/'));
1123 if (m_BookmarksPages
.Index(url
) == wxNOT_FOUND
) {
1124 m_Bookmarks
-> Append(item
);
1125 m_BookmarksNames
.Add(item
);
1126 m_BookmarksPages
.Add(url
);
1131 case wxID_HTML_BOOKMARKSREMOVE
:
1136 item
= m_Bookmarks
-> GetStringSelection();
1137 pos
= m_BookmarksNames
.Index(item
);
1138 if (pos
!= wxNOT_FOUND
) {
1139 m_BookmarksNames
.Remove(pos
);
1140 m_BookmarksPages
.Remove(pos
);
1141 m_Bookmarks
-> Delete(m_Bookmarks
-> GetSelection());
1146 #if wxUSE_PRINTING_ARCHITECTURE
1147 case wxID_HTML_PRINT
:
1149 if (m_Printer
== NULL
)
1150 m_Printer
= new wxHtmlEasyPrinting(_("Help Printing"), this);
1151 if (!m_HtmlWin
-> GetOpenedPage())
1152 wxLogWarning(_("Cannot print empty page."));
1154 m_Printer
-> PrintFile(m_HtmlWin
-> GetOpenedPage());
1159 case wxID_HTML_OPENFILE
:
1161 wxString s
= wxFileSelector(_("Open HTML document"), wxEmptyString
, wxEmptyString
, wxEmptyString
,
1162 wxT("HTML files (*.htm)|*.htm|HTML files (*.html)|*.html|"
1163 "Help books (*.htb)|*.htb|Help books (*.zip)|*.zip|"
1164 "HTML Help Project (*.hhp)|*.hhp|"
1165 "All files (*.*)|*"),
1166 wxOPEN
| wxFILE_MUST_EXIST
, this);
1169 wxString ext
= s
.Right(4).Lower();
1170 if (ext
== _T(".zip") || ext
== _T(".htb") || ext
== _T(".hhp"))
1173 m_Data
-> AddBook(s
);
1177 m_HtmlWin
-> LoadPage(s
);
1186 void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent
& event
)
1188 wxHtmlHelpTreeItemData
*pg
;
1189 wxHtmlContentsItem
*it
;
1191 pg
= (wxHtmlHelpTreeItemData
*) m_ContentsBox
-> GetItemData(event
.GetItem());
1193 if (pg
&& m_UpdateContents
)
1195 it
= m_Data
-> GetContents() + (pg
-> m_Id
);
1196 m_UpdateContents
= FALSE
;
1197 m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
1198 m_UpdateContents
= TRUE
;
1204 void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent
& WXUNUSED(event
))
1206 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_IndexList
-> GetClientData(m_IndexList
-> GetSelection());
1207 m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
1208 NotifyPageChanged();
1212 void wxHtmlHelpFrame::OnIndexFind(wxCommandEvent
& event
)
1214 wxString sr
= m_IndexText
-> GetLineText(0);
1216 if (sr
== wxEmptyString
)
1221 const wxChar
*cstr
= sr
.c_str();
1222 wxChar mybuff
[512], *ptr
;
1225 m_IndexList
->Clear();
1226 int cnt
= m_Data
->GetIndexCnt();
1227 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
1230 for (int i
= 0; i
< cnt
; i
++)
1232 wxStrncpy(mybuff
, index
[i
].m_Name
, 512);
1234 for (ptr
= mybuff
; *ptr
!= 0; ptr
++)
1235 if (*ptr
>= 'A' && *ptr
<= 'Z') *ptr
-= 'A' - 'a';
1236 if (wxStrstr(mybuff
, cstr
) != NULL
) {
1237 m_IndexList
-> Append(index
[i
].m_Name
, (char*)(index
+ i
));
1240 m_HtmlWin
-> LoadPage(index
[i
].m_Book
-> GetBasePath() + index
[i
].m_Page
);
1241 NotifyPageChanged();
1248 cnttext
.Printf(_("%i of %i"), displ
, cnt
);
1249 m_IndexCountInfo
-> SetLabel(cnttext
);
1251 m_IndexText
-> SetSelection(0, sr
.Length());
1252 m_IndexText
-> SetFocus();
1256 void wxHtmlHelpFrame::OnIndexAll(wxCommandEvent
& WXUNUSED(event
))
1260 m_IndexList
->Clear();
1261 int cnt
= m_Data
->GetIndexCnt();
1263 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
1265 for (int i
= 0; i
< cnt
; i
++) {
1266 m_IndexList
-> Append(index
[i
].m_Name
, (char*)(index
+ i
));
1268 m_HtmlWin
-> LoadPage(index
[i
].m_Book
-> GetBasePath() + index
[i
].m_Page
);
1269 NotifyPageChanged();
1275 cnttext
.Printf(_("%i of %i"), cnt
, cnt
);
1276 m_IndexCountInfo
-> SetLabel(cnttext
);
1280 void wxHtmlHelpFrame::OnSearchSel(wxCommandEvent
& WXUNUSED(event
))
1282 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_SearchList
-> GetClientData(m_SearchList
-> GetSelection());
1285 m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
1286 NotifyPageChanged();
1290 void wxHtmlHelpFrame::OnSearch(wxCommandEvent
& WXUNUSED(event
))
1292 wxString sr
= m_SearchText
-> GetLineText(0);
1294 if (sr
!= wxEmptyString
) KeywordSearch(sr
);
1297 void wxHtmlHelpFrame::OnBookmarksSel(wxCommandEvent
& WXUNUSED(event
))
1299 wxString sr
= m_Bookmarks
-> GetStringSelection();
1301 if (sr
!= wxEmptyString
&& sr
!= _("(bookmarks)"))
1303 m_HtmlWin
-> LoadPage(m_BookmarksPages
[m_BookmarksNames
.Index(sr
)]);
1304 NotifyPageChanged();
1308 void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent
& evt
)
1310 GetSize(&m_Cfg
.w
, &m_Cfg
.h
);
1311 GetPosition(&m_Cfg
.x
, &m_Cfg
.y
);
1313 if (m_Splitter
&& m_Cfg
.navig_on
) m_Cfg
.sashpos
= m_Splitter
-> GetSashPosition();
1316 WriteCustomization(m_Config
, m_ConfigRoot
);
1318 if (m_helpController
&& m_helpController
->IsKindOf(CLASSINFO(wxHtmlHelpController
)))
1320 ((wxHtmlHelpController
*) m_helpController
)->OnCloseFrame(evt
);
1326 BEGIN_EVENT_TABLE(wxHtmlHelpFrame
, wxFrame
)
1327 EVT_TOOL_RANGE(wxID_HTML_PANEL
, wxID_HTML_OPTIONS
, wxHtmlHelpFrame::OnToolbar
)
1328 EVT_BUTTON(wxID_HTML_BOOKMARKSREMOVE
, wxHtmlHelpFrame::OnToolbar
)
1329 EVT_BUTTON(wxID_HTML_BOOKMARKSADD
, wxHtmlHelpFrame::OnToolbar
)
1330 EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL
, wxHtmlHelpFrame::OnContentsSel
)
1331 EVT_LISTBOX(wxID_HTML_INDEXLIST
, wxHtmlHelpFrame::OnIndexSel
)
1332 EVT_LISTBOX(wxID_HTML_SEARCHLIST
, wxHtmlHelpFrame::OnSearchSel
)
1333 EVT_BUTTON(wxID_HTML_SEARCHBUTTON
, wxHtmlHelpFrame::OnSearch
)
1334 EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT
, wxHtmlHelpFrame::OnSearch
)
1335 EVT_BUTTON(wxID_HTML_INDEXBUTTON
, wxHtmlHelpFrame::OnIndexFind
)
1336 EVT_TEXT_ENTER(wxID_HTML_INDEXTEXT
, wxHtmlHelpFrame::OnIndexFind
)
1337 EVT_BUTTON(wxID_HTML_INDEXBUTTONALL
, wxHtmlHelpFrame::OnIndexAll
)
1338 EVT_COMBOBOX(wxID_HTML_BOOKMARKSLIST
, wxHtmlHelpFrame::OnBookmarksSel
)
1339 EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow
)