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
;}
101 //--------------------------------------------------------------------------
102 // wxHtmlHelpHtmlWindow (private)
103 //--------------------------------------------------------------------------
105 class wxHtmlHelpHtmlWindow
: public wxHtmlWindow
108 wxHtmlHelpHtmlWindow(wxHtmlHelpFrame
*fr
, wxWindow
*parent
) : wxHtmlWindow(parent
), m_Frame(fr
) {}
110 virtual void OnLinkClicked(const wxHtmlLinkInfo
& link
)
112 wxHtmlWindow::OnLinkClicked(link
);
113 m_Frame
-> NotifyPageChanged();
117 wxHtmlHelpFrame
*m_Frame
;
122 //---------------------------------------------------------------------------
124 //---------------------------------------------------------------------------
126 IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpFrame
, wxFrame
)
128 wxHtmlHelpFrame::wxHtmlHelpFrame(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
129 int style
, wxHtmlHelpData
* data
)
132 Create(parent
, id
, title
, style
);
135 void wxHtmlHelpFrame::Init(wxHtmlHelpData
* data
)
139 m_DataCreated
= FALSE
;
141 m_Data
= new wxHtmlHelpData();
142 m_DataCreated
= TRUE
;
145 m_ContentsImageList
= new wxImageList(16, 16);
146 m_ContentsImageList
-> Add(wxICON(wbook
));
147 m_ContentsImageList
-> Add(wxICON(wfolder
));
148 m_ContentsImageList
-> Add(wxICON(wpage
));
149 m_ContentsImageList
-> Add(wxICON(whlproot
));
151 m_ContentsBox
= NULL
;
153 m_IndexButton
= NULL
;
154 m_IndexButtonAll
= NULL
;
157 m_SearchButton
= NULL
;
159 m_SearchChoice
= NULL
;
160 m_IndexCountInfo
= NULL
;
165 m_SearchCaseSensitive
= NULL
;
166 m_SearchWholeWords
= NULL
;
169 m_ConfigRoot
= wxEmptyString
;
171 m_Cfg
.x
= m_Cfg
.y
= 0;
175 m_Cfg
.navig_on
= TRUE
;
177 m_NormalFonts
= m_FixedFonts
= NULL
;
178 m_NormalFace
= m_FixedFace
= wxEmptyString
;
181 #if wxUSE_PRINTING_ARCHITECTURE
186 m_UpdateContents
= TRUE
;
187 m_helpController
= (wxHelpControllerBase
*) NULL
;
190 // Create: builds the GUI components.
191 // with the style flag it's possible to toggle the toolbar, contents, index and search
193 // m_HtmlWin will *always* be created, but it's important to realize that
194 // m_ContentsBox, m_IndexList, m_SearchList, m_SearchButton, m_SearchText and
195 // m_SearchButton may be NULL.
196 // moreover, if no contents, index or searchpage is needed, m_Splitter and
197 // m_NavigPan will be NULL too (with m_HtmlWin directly connected to the frame)
199 bool wxHtmlHelpFrame::Create(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
202 // Do the config in two steps. We read the HtmlWindow customization after we
203 // create the window.
205 ReadCustomization(m_Config
, m_ConfigRoot
);
207 wxFrame::Create(parent
, id
, _("Help"), wxPoint(m_Cfg
.x
, m_Cfg
.y
), wxSize(m_Cfg
.w
, m_Cfg
.h
), wxDEFAULT_FRAME_STYLE
, "wxHtmlHelp");
209 GetPosition(&m_Cfg
.x
, &m_Cfg
.y
);
211 SetIcon(wxICON(whelp
));
213 int notebook_page
= 0;
218 if (style
& wxHF_TOOLBAR
) {
219 wxToolBar
*toolBar
= CreateToolBar(wxNO_BORDER
| wxTB_HORIZONTAL
| wxTB_DOCKABLE
);
220 toolBar
->SetMargins( 2, 2 );
221 AddToolbarButtons(toolBar
, style
);
222 toolBar
-> Realize();
225 if (style
& (wxHF_CONTENTS
| wxHF_INDEX
| wxHF_SEARCH
)) {
226 // traditional help controller; splitter window with html page on the
227 // right and a notebook containing various pages on the left
228 m_Splitter
= new wxSplitterWindow(this);
230 m_HtmlWin
= new wxHtmlHelpHtmlWindow(this, m_Splitter
);
231 m_NavigPan
= new wxNotebook(m_Splitter
, wxID_HTML_NOTEBOOK
,
232 wxDefaultPosition
, wxDefaultSize
);
233 } else { // only html window, no notebook with index,contents etc
234 m_HtmlWin
= new wxHtmlWindow(this);
237 m_HtmlWin
-> SetRelatedFrame(this, m_TitleFormat
);
238 m_HtmlWin
-> SetRelatedStatusBar(0);
240 m_HtmlWin
-> ReadCustomization(m_Config
, m_ConfigRoot
);
242 // contents tree panel?
243 if (style
& wxHF_CONTENTS
) {
244 wxWindow
*dummy
= new wxPanel(m_NavigPan
, wxID_HTML_INDEXPAGE
);
246 if (style
& wxHF_BOOKMARKS
) {
247 wxLayoutConstraints
*b1
= new wxLayoutConstraints
;
248 wxBitmapButton
*bmpbt
= new wxBitmapButton(dummy
, wxID_HTML_BOOKMARKSREMOVE
, wxBITMAP(wbkdel
), wxDefaultPosition
, wxSize(20,20));
250 b1
-> top
.SameAs (dummy
, wxTop
, 10);
251 b1
-> right
.SameAs (dummy
, wxRight
, 10);
254 bmpbt
-> SetConstraints(b1
);
256 wxLayoutConstraints
*b2
= new wxLayoutConstraints
;
257 wxBitmapButton
*bmpbt2
= new wxBitmapButton(dummy
, wxID_HTML_BOOKMARKSADD
, wxBITMAP(wbkadd
), wxDefaultPosition
, wxSize(20,20));
259 b2
-> top
.SameAs (dummy
, wxTop
, 10);
260 b2
-> right
.LeftOf (bmpbt
, 2);
263 bmpbt2
-> SetConstraints(b2
);
266 bmpbt
-> SetToolTip(_("Remove current page from bookmarks"));
267 bmpbt2
-> SetToolTip(_("Add current page to bookmarks"));
268 #endif //wxUSE_TOOLTIPS
270 wxLayoutConstraints
*b3
= new wxLayoutConstraints
;
271 m_Bookmarks
= new wxComboBox(dummy
, wxID_HTML_BOOKMARKSLIST
, wxEmptyString
,
272 wxDefaultPosition
, wxDefaultSize
, 0, NULL
, wxCB_READONLY
| wxCB_SORT
);
273 m_Bookmarks
-> Append(_("(bookmarks)"));
274 for (unsigned i
= 0; i
< m_BookmarksNames
.GetCount(); i
++)
275 m_Bookmarks
-> Append(m_BookmarksNames
[i
]);
276 m_Bookmarks
-> SetSelection(0);
278 b3
-> centreY
.SameAs (bmpbt2
, wxCentreY
);
279 b3
-> left
.SameAs (dummy
, wxLeft
, 10);
280 b3
-> right
.LeftOf (bmpbt2
, 5);
282 m_Bookmarks
-> SetConstraints(b3
);
285 wxLayoutConstraints
*b4
= new wxLayoutConstraints
;
286 m_ContentsBox
= new wxTreeCtrl(dummy
, wxID_HTML_TREECTRL
,
287 wxDefaultPosition
, wxDefaultSize
,
288 wxTR_HAS_BUTTONS
| wxSUNKEN_BORDER
);
289 m_ContentsBox
-> SetImageList(m_ContentsImageList
);
291 b4
-> top
.Below (m_Bookmarks
, 10);
292 b4
-> left
.SameAs (dummy
, wxLeft
, 0);
293 b4
-> right
.SameAs (dummy
, wxRight
, 0);
294 b4
-> bottom
.SameAs (dummy
, wxBottom
, 0);
295 m_ContentsBox
-> SetConstraints(b4
);
297 dummy
-> SetAutoLayout(TRUE
);
300 m_NavigPan
-> AddPage(dummy
, _("Contents"));
305 m_ContentsBox
= new wxTreeCtrl(m_NavigPan
, wxID_HTML_TREECTRL
,
306 wxDefaultPosition
, wxDefaultSize
,
307 wxTR_HAS_BUTTONS
| wxSUNKEN_BORDER
);
308 m_ContentsBox
-> SetImageList(m_ContentsImageList
);
309 m_NavigPan
-> AddPage(m_ContentsBox
, _("Contents"));
312 m_ContentsPage
= notebook_page
++;
315 // index listbox panel?
316 if (style
& wxHF_INDEX
) {
317 wxWindow
*dummy
= new wxPanel(m_NavigPan
, wxID_HTML_INDEXPAGE
);
319 wxLayoutConstraints
*b1
= new wxLayoutConstraints
;
320 m_IndexText
= new wxTextCtrl(dummy
, wxID_HTML_INDEXTEXT
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, wxTE_PROCESS_ENTER
);
321 b1
-> top
.SameAs (dummy
, wxTop
, 10);
322 b1
-> left
.SameAs (dummy
, wxLeft
, 10);
323 b1
-> right
.SameAs (dummy
, wxRight
, 10);
325 m_IndexText
-> SetConstraints(b1
);
327 wxLayoutConstraints
*b4
= new wxLayoutConstraints
;
328 m_IndexButtonAll
= new wxButton(dummy
, wxID_HTML_INDEXBUTTONALL
, _("Show all"));
330 b4
-> top
.Below (m_IndexText
, 10);
331 b4
-> right
.SameAs (dummy
, wxRight
, 10);
334 m_IndexButtonAll
-> SetConstraints(b4
);
336 wxLayoutConstraints
*b2
= new wxLayoutConstraints
;
337 m_IndexButton
= new wxButton(dummy
, wxID_HTML_INDEXBUTTON
, _("Find"));
338 b2
-> top
.Below (m_IndexText
, 10);
339 b2
-> right
.LeftOf (m_IndexButtonAll
, 10);
342 m_IndexButton
-> SetConstraints(b2
);
344 wxLayoutConstraints
*b5
= new wxLayoutConstraints
;
345 m_IndexCountInfo
= new wxStaticText(dummy
, wxID_HTML_COUNTINFO
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, wxALIGN_RIGHT
| wxST_NO_AUTORESIZE
);
347 b5
-> top
.Below (m_IndexButton
, 5);
348 b5
-> right
.SameAs (dummy
, wxRight
, 10);
349 b5
-> left
.SameAs (dummy
, wxLeft
, 10);
351 m_IndexCountInfo
-> SetConstraints(b5
);
353 wxLayoutConstraints
*b3
= new wxLayoutConstraints
;
354 m_IndexList
= new wxListBox(dummy
, wxID_HTML_INDEXLIST
, wxDefaultPosition
, wxDefaultSize
, 0, NULL
, wxLB_SINGLE
);
355 b3
-> top
.Below (m_IndexCountInfo
, 5);
356 b3
-> left
.SameAs (dummy
, wxLeft
, 0);
357 b3
-> right
.SameAs (dummy
, wxRight
, 0);
358 b3
-> bottom
.SameAs (dummy
, wxBottom
, 0);
359 m_IndexList
-> SetConstraints(b3
);
362 m_IndexButtonAll
-> SetToolTip(_("Show all items in index"));
363 m_IndexButton
-> SetToolTip(_("Display all index items that contain given substring. Search is case insensitive."));
364 #endif //wxUSE_TOOLTIPS
366 dummy
-> SetAutoLayout(TRUE
);
369 m_NavigPan
-> AddPage(dummy
, _("Index"));
370 m_IndexPage
= notebook_page
++;
373 // search list panel?
374 if (style
& wxHF_SEARCH
) {
375 wxWindow
*dummy
= new wxPanel(m_NavigPan
, wxID_HTML_SEARCHPAGE
);
377 wxLayoutConstraints
*b1
= new wxLayoutConstraints
;
378 m_SearchText
= new wxTextCtrl(dummy
, wxID_HTML_SEARCHTEXT
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, wxTE_PROCESS_ENTER
);
379 b1
-> top
.SameAs (dummy
, wxTop
, 10);
380 b1
-> left
.SameAs (dummy
, wxLeft
, 10);
381 b1
-> right
.SameAs (dummy
, wxRight
, 10);
383 m_SearchText
-> SetConstraints(b1
);
385 wxLayoutConstraints
*b4
= new wxLayoutConstraints
;
386 m_SearchChoice
= new wxChoice(dummy
, wxID_HTML_SEARCHCHOICE
, wxDefaultPosition
,
388 b4
-> top
.Below (m_SearchText
, 10);
389 b4
-> left
.SameAs (dummy
, wxLeft
, 10);
390 b4
-> right
.SameAs (dummy
, wxRight
, 10);
392 m_SearchChoice
-> SetConstraints(b4
);
394 wxLayoutConstraints
*b5
= new wxLayoutConstraints
;
395 m_SearchCaseSensitive
= new wxCheckBox(dummy
, -1, _("Case sensitive"));
396 b5
-> top
.Below (m_SearchChoice
, 10);
397 b5
-> left
.SameAs (dummy
, wxLeft
, 10);
399 b5
-> height
.AsIs ();
400 m_SearchCaseSensitive
-> SetConstraints(b5
);
402 wxLayoutConstraints
*b6
= new wxLayoutConstraints
;
403 m_SearchWholeWords
= new wxCheckBox(dummy
, -1, _("Whole words only"));
404 b6
-> top
.Below (m_SearchCaseSensitive
, 0);
405 b6
-> left
.SameAs (dummy
, wxLeft
, 10);
407 b6
-> height
.AsIs ();
408 m_SearchWholeWords
-> SetConstraints(b6
);
410 wxLayoutConstraints
*b2
= new wxLayoutConstraints
;
411 m_SearchButton
= new wxButton(dummy
, wxID_HTML_SEARCHBUTTON
, _("Search"));
413 m_SearchButton
-> SetToolTip(_("Search contents of help book(s) for all occurences of the text you typed above"));
414 #endif //wxUSE_TOOLTIPS
415 b2
-> top
.Below (m_SearchWholeWords
, 0);
416 b2
-> right
.SameAs (dummy
, wxRight
, 10);
419 m_SearchButton
-> SetConstraints(b2
);
421 wxLayoutConstraints
*b3
= new wxLayoutConstraints
;
422 m_SearchList
= new wxListBox(dummy
, wxID_HTML_SEARCHLIST
, wxDefaultPosition
, wxDefaultSize
, 0, NULL
, wxLB_SINGLE
);
423 b3
-> top
.Below (m_SearchButton
, 10);
424 b3
-> left
.SameAs (dummy
, wxLeft
, 0);
425 b3
-> right
.SameAs (dummy
, wxRight
, 0);
426 b3
-> bottom
.SameAs (dummy
, wxBottom
, 0);
427 m_SearchList
-> SetConstraints(b3
);
429 dummy
-> SetAutoLayout(TRUE
);
431 m_NavigPan
-> AddPage(dummy
, _("Search"));
432 m_SearchPage
= notebook_page
++;
434 m_HtmlWin
-> Show(TRUE
);
439 if (m_NavigPan
&& m_Splitter
) {
440 m_Splitter
-> SetMinimumPaneSize(20);
442 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
444 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
445 m_Splitter
-> Unsplit();
447 if (m_Cfg
.navig_on
) {
448 m_NavigPan
-> Show(TRUE
);
449 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
452 m_NavigPan
-> Show(FALSE
);
453 m_Splitter
-> Initialize(m_HtmlWin
);
459 wxHtmlHelpFrame::~wxHtmlHelpFrame()
461 // PopEventHandler(); // wxhtmlhelpcontroller (not any more!)
462 delete m_ContentsImageList
;
465 if (m_NormalFonts
) delete m_NormalFonts
;
466 if (m_FixedFonts
) delete m_FixedFonts
;
467 if (m_PagesHash
) delete m_PagesHash
;
471 void wxHtmlHelpFrame::AddToolbarButtons(wxToolBar
*toolBar
, int style
)
473 toolBar
-> AddTool(wxID_HTML_PANEL
, wxBITMAP(wpanel
), wxNullBitmap
,
474 FALSE
, -1, -1, (wxObject
*) NULL
,
475 _("Show/hide navigation panel"));
477 toolBar
-> AddSeparator();
478 toolBar
-> AddTool(wxID_HTML_BACK
, wxBITMAP(wback
), wxNullBitmap
,
479 FALSE
, -1, -1, (wxObject
*) NULL
,
481 toolBar
-> AddTool(wxID_HTML_FORWARD
, wxBITMAP(wforward
), wxNullBitmap
,
482 FALSE
, -1, -1, (wxObject
*) NULL
,
484 toolBar
-> AddSeparator();
486 toolBar
-> AddTool(wxID_HTML_UPNODE
, wxBITMAP(wupnode
), wxNullBitmap
,
487 FALSE
, -1, -1, (wxObject
*) NULL
,
488 _("Go one level up in document hierarchy"));
489 toolBar
-> AddTool(wxID_HTML_UP
, wxBITMAP(wup
), wxNullBitmap
,
490 FALSE
, -1, -1, (wxObject
*) NULL
,
492 toolBar
-> AddTool(wxID_HTML_DOWN
, wxBITMAP(wdown
), wxNullBitmap
,
493 FALSE
, -1, -1, (wxObject
*) NULL
,
496 if ((style
& wxHF_PRINT
) || (style
& wxHF_OPENFILES
))
497 toolBar
-> AddSeparator();
499 if (style
& wxHF_OPENFILES
)
500 toolBar
-> AddTool(wxID_HTML_OPENFILE
, wxBITMAP(wopen
), wxNullBitmap
,
501 FALSE
, -1, -1, (wxObject
*) NULL
,
502 _("Open HTML document"));
504 #if wxUSE_PRINTING_ARCHITECTURE
505 if (style
& wxHF_PRINT
)
506 toolBar
-> AddTool(wxID_HTML_PRINT
, wxBITMAP(wprint
), wxNullBitmap
,
507 FALSE
, -1, -1, (wxObject
*) NULL
,
508 _("Print this page"));
511 toolBar
-> AddSeparator();
512 toolBar
-> AddTool(wxID_HTML_OPTIONS
, wxBITMAP(woptions
), wxNullBitmap
,
513 FALSE
, -1, -1, (wxObject
*) NULL
,
514 _("Display options dialog"));
518 void wxHtmlHelpFrame::SetTitleFormat(const wxString
& format
)
521 m_HtmlWin
->SetRelatedFrame(this, format
);
522 m_TitleFormat
= format
;
526 bool wxHtmlHelpFrame::Display(const wxString
& x
)
528 wxString url
= m_Data
->FindPageByName(x
);
529 if (! url
.IsEmpty()) {
530 m_HtmlWin
->LoadPage(url
);
537 bool wxHtmlHelpFrame::Display(const int id
)
539 wxString url
= m_Data
->FindPageById(id
);
540 if (! url
.IsEmpty()) {
541 m_HtmlWin
->LoadPage(url
);
550 bool wxHtmlHelpFrame::DisplayContents()
554 if (!m_Splitter
-> IsSplit()) {
555 m_NavigPan
-> Show(TRUE
);
556 m_HtmlWin
-> Show(TRUE
);
557 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
558 m_Cfg
.navig_on
= TRUE
;
560 m_NavigPan
-> SetSelection(0);
566 bool wxHtmlHelpFrame::DisplayIndex()
570 if (!m_Splitter
-> IsSplit()) {
571 m_NavigPan
-> Show(TRUE
);
572 m_HtmlWin
-> Show(TRUE
);
573 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
575 m_NavigPan
-> SetSelection(1);
581 bool wxHtmlHelpFrame::KeywordSearch(const wxString
& keyword
)
583 if (! (m_SearchList
&& m_SearchButton
&& m_SearchText
&& m_SearchChoice
))
586 int foundcnt
= 0, curi
;
588 wxString book
= wxEmptyString
;
590 if (!m_Splitter
-> IsSplit()) {
591 m_NavigPan
-> Show(TRUE
);
592 m_HtmlWin
-> Show(TRUE
);
593 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
595 m_NavigPan
-> SetSelection(m_SearchPage
);
596 m_SearchList
-> Clear();
597 m_SearchText
-> SetValue(keyword
);
598 m_SearchButton
-> Enable(FALSE
);
600 if (m_SearchChoice
->GetSelection() != 0)
601 book
= m_SearchChoice
->GetStringSelection();
603 wxHtmlSearchStatus
status(m_Data
, keyword
,
604 m_SearchCaseSensitive
-> GetValue(), m_SearchWholeWords
-> GetValue(),
607 wxProgressDialog
progress(_("Searching..."), _("No matching page found yet"),
608 status
.GetMaxIndex(), this,
609 wxPD_APP_MODAL
| wxPD_CAN_ABORT
| wxPD_AUTO_HIDE
);
611 while (status
.IsActive()) {
612 curi
= status
.GetCurIndex();
613 if (curi
% 32 == 0 && progress
.Update(curi
) == FALSE
)
615 if (status
.Search()) {
616 foundstr
.Printf(_("Found %i matches"), ++foundcnt
);
617 progress
.Update(status
.GetCurIndex(), foundstr
);
618 m_SearchList
-> Append(status
.GetName(), status
.GetContentsItem());
622 m_SearchButton
-> Enable(TRUE
);
623 m_SearchText
-> SetSelection(0, keyword
.Length());
624 m_SearchText
-> SetFocus();
626 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_SearchList
-> GetClientData(0);
629 m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
633 return (foundcnt
> 0);
638 void wxHtmlHelpFrame::CreateContents()
643 m_ContentsBox
->Clear();
645 if (m_PagesHash
) delete m_PagesHash
;
646 m_PagesHash
= new wxHashTable(wxKEY_STRING
, 2 * m_Data
-> GetContentsCnt());
647 m_PagesHash
-> DeleteContents(TRUE
);
649 int cnt
= m_Data
->GetContentsCnt();
652 wxHtmlContentsItem
*it
;
654 wxTreeItemId roots
[MAX_ROOTS
];
655 bool imaged
[MAX_ROOTS
];
657 m_ContentsBox
-> DeleteAllItems();
658 roots
[0] = m_ContentsBox
-> AddRoot(_("(Help)"));
659 m_ContentsBox
-> SetItemImage(roots
[0], IMG_RootFolder
);
660 m_ContentsBox
-> SetItemSelectedImage(roots
[0], IMG_RootFolder
);
663 for (it
= m_Data
->GetContents(), i
= 0; i
< cnt
; i
++, it
++) {
664 roots
[it
-> m_Level
+ 1] = m_ContentsBox
-> AppendItem(
665 roots
[it
-> m_Level
], it
-> m_Name
, IMG_Page
, -1,
666 new wxHtmlHelpTreeItemData(i
));
667 m_PagesHash
-> Put(it
-> m_Book
-> GetBasePath() + it
-> m_Page
,
668 new wxHtmlHelpHashData(i
, roots
[it
-> m_Level
+ 1]));
670 if (it
-> m_Level
== 0) {
671 m_ContentsBox
-> SetItemBold(roots
[1], TRUE
);
672 m_ContentsBox
-> SetItemImage(roots
[1], IMG_Book
);
673 m_ContentsBox
-> SetItemSelectedImage(roots
[1], IMG_Book
);
675 } else imaged
[it
-> m_Level
+ 1] = FALSE
;
677 if (!imaged
[it
-> m_Level
]) {
678 m_ContentsBox
-> SetItemImage(roots
[it
-> m_Level
], IMG_Folder
);
679 m_ContentsBox
-> SetItemSelectedImage(roots
[it
-> m_Level
], IMG_Folder
);
680 imaged
[it
-> m_Level
] = TRUE
;
683 m_ContentsBox
-> Expand(roots
[0]);
687 void wxHtmlHelpFrame::CreateIndex()
692 m_IndexList
->Clear();
694 int cnt
= m_Data
->GetIndexCnt();
697 if (cnt
> INDEX_IS_SMALL
) cnttext
.Printf(_("%i of %i"), 0, cnt
);
698 else cnttext
.Printf(_("%i of %i"), cnt
, cnt
);
699 m_IndexCountInfo
-> SetLabel(cnttext
);
700 if (cnt
> INDEX_IS_SMALL
) return;
702 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
704 for (int i
= 0; i
< cnt
; i
++)
705 m_IndexList
-> Append(index
[i
].m_Name
, (char*)(index
+ i
));
708 void wxHtmlHelpFrame::CreateSearch()
710 if (! (m_SearchList
&& m_SearchChoice
))
712 m_SearchList
-> Clear();
713 m_SearchChoice
-> Clear();
714 m_SearchChoice
-> Append(_("Search in all books"));
715 const wxHtmlBookRecArray
& bookrec
= m_Data
->GetBookRecArray();
716 int i
, cnt
= bookrec
.GetCount();
717 for (i
= 0; i
< cnt
; i
++)
718 m_SearchChoice
->Append(bookrec
[i
].GetTitle());
719 m_SearchChoice
->SetSelection(0);
723 void wxHtmlHelpFrame::RefreshLists()
730 void wxHtmlHelpFrame::ReadCustomization(wxConfigBase
*cfg
, const wxString
& path
)
735 if (path
!= wxEmptyString
) {
736 oldpath
= cfg
-> GetPath();
737 cfg
-> SetPath(_T("/") + path
);
740 m_Cfg
.navig_on
= cfg
-> Read(wxT("hcNavigPanel"), m_Cfg
.navig_on
) != 0;
741 m_Cfg
.sashpos
= cfg
-> Read(wxT("hcSashPos"), m_Cfg
.sashpos
);
742 m_Cfg
.x
= cfg
-> Read(wxT("hcX"), m_Cfg
.x
);
743 m_Cfg
.y
= cfg
-> Read(wxT("hcY"), m_Cfg
.y
);
744 m_Cfg
.w
= cfg
-> Read(wxT("hcW"), m_Cfg
.w
);
745 m_Cfg
.h
= cfg
-> Read(wxT("hcH"), m_Cfg
.h
);
747 m_FixedFace
= cfg
-> Read(wxT("hcFixedFace"), m_FixedFace
);
748 m_NormalFace
= cfg
-> Read(wxT("hcNormalFace"), m_NormalFace
);
749 m_FontSize
= cfg
-> Read(wxT("hcFontSize"), m_FontSize
);
756 cnt
= cfg
-> Read(wxT("hcBookmarksCnt"), 0L);
758 m_BookmarksNames
.Clear();
759 m_BookmarksPages
.Clear();
761 m_Bookmarks
-> Clear();
762 m_Bookmarks
-> Append(_("(bookmarks)"));
765 for (i
= 0; i
< cnt
; i
++) {
766 val
.Printf(wxT("hcBookmark_%i"), i
);
767 s
= cfg
-> Read(val
);
768 m_BookmarksNames
.Add(s
);
769 if (m_Bookmarks
) m_Bookmarks
-> Append(s
);
770 val
.Printf(wxT("hcBookmark_%i_url"), i
);
771 s
= cfg
-> Read(val
);
772 m_BookmarksPages
.Add(s
);
778 m_HtmlWin
->ReadCustomization(cfg
);
780 if (path
!= wxEmptyString
)
781 cfg
-> SetPath(oldpath
);
784 void wxHtmlHelpFrame::WriteCustomization(wxConfigBase
*cfg
, const wxString
& path
)
789 if (path
!= wxEmptyString
) {
790 oldpath
= cfg
-> GetPath();
791 cfg
-> SetPath(_T("/") + path
);
794 cfg
-> Write(wxT("hcNavigPanel"), m_Cfg
.navig_on
);
795 cfg
-> Write(wxT("hcSashPos"), (long)m_Cfg
.sashpos
);
796 cfg
-> Write(wxT("hcX"), (long)m_Cfg
.x
);
797 cfg
-> Write(wxT("hcY"), (long)m_Cfg
.y
);
798 cfg
-> Write(wxT("hcW"), (long)m_Cfg
.w
);
799 cfg
-> Write(wxT("hcH"), (long)m_Cfg
.h
);
800 cfg
-> Write(wxT("hcFixedFace"), m_FixedFace
);
801 cfg
-> Write(wxT("hcNormalFace"), m_NormalFace
);
802 cfg
-> Write(wxT("hcFontSize"), (long)m_FontSize
);
806 int cnt
= m_BookmarksNames
.GetCount();
809 cfg
-> Write(wxT("hcBookmarksCnt"), (long)cnt
);
810 for (i
= 0; i
< cnt
; i
++) {
811 val
.Printf(wxT("hcBookmark_%i"), i
);
812 cfg
-> Write(val
, m_BookmarksNames
[i
]);
813 val
.Printf(wxT("hcBookmark_%i_url"), i
);
814 cfg
-> Write(val
, m_BookmarksPages
[i
]);
819 m_HtmlWin
->WriteCustomization(cfg
);
821 if (path
!= wxEmptyString
)
822 cfg
-> SetPath(oldpath
);
829 static void SetFontsToHtmlWin(wxHtmlWindow
*win
, wxString scalf
, wxString fixf
, int size
)
831 static int f_sizes
[5][7] =
833 { 6, 7, 9, 12, 14, 16, 19},
834 { 8, 9, 12, 14, 16, 19, 22},
835 {10, 12, 14, 16, 19, 24, 32},
836 {14, 16, 18, 24, 32, 38, 45},
837 {16, 20, 24, 32, 38, 45, 50}
840 win
-> SetFonts(scalf
, fixf
, f_sizes
[size
]);
844 class wxHtmlHelpFrameOptionsDialog
: public wxDialog
847 wxComboBox
*NormalFont
, *FixedFont
;
848 wxRadioBox
*RadioBox
;
849 wxHtmlWindow
*TestWin
;
851 wxHtmlHelpFrameOptionsDialog(wxWindow
*parent
) : wxDialog(parent
, -1, wxString(_("Help Browser Options")))
853 wxString choices
[5] = {_("very small"), _("small"), _("medium"), _("large"), _("very large")};
854 wxBoxSizer
*topsizer
, *sizer
, *sizer2
;
856 topsizer
= new wxBoxSizer(wxVERTICAL
);
858 sizer
= new wxBoxSizer(wxHORIZONTAL
);
860 sizer2
= new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Normal font:")), wxVERTICAL
);
861 sizer2
-> Add(NormalFont
= new wxComboBox(this, -1, wxEmptyString
, wxDefaultPosition
,
863 0, NULL
, wxCB_DROPDOWN
| wxCB_READONLY
),
864 1, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
866 sizer
-> Add(sizer2
, 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10);
868 sizer2
= new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Fixed font:")), wxVERTICAL
);
869 sizer2
-> Add(FixedFont
= new wxComboBox(this, -1, wxEmptyString
, wxDefaultPosition
,
871 0, NULL
, wxCB_DROPDOWN
| wxCB_READONLY
),
872 1, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
874 sizer
-> Add(sizer2
, 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10);
876 topsizer
-> Add(sizer
);
878 topsizer
-> Add(RadioBox
= new wxRadioBox(this, -1, _("Font size:"),
879 wxDefaultPosition
, wxDefaultSize
, 5, choices
, 5),
880 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxTOP
, 10);
882 topsizer
-> Add(new wxStaticText(this, -1, _("Preview:")),
883 0, wxLEFT
| wxTOP
, 10);
884 topsizer
-> Add(TestWin
= new wxHtmlWindow(this, -1, wxDefaultPosition
, wxSize(-1, 150)),
885 1, wxEXPAND
| wxLEFT
|wxTOP
|wxRIGHT
, 10);
887 sizer
= new wxBoxSizer(wxHORIZONTAL
);
888 sizer
-> Add(new wxButton(this, wxID_OK
, _("OK")), 0, wxALL
, 10);
889 sizer
-> Add(new wxButton(this, wxID_CANCEL
, _("Cancel")), 0, wxALL
, 10);
890 topsizer
-> Add(sizer
, 0, wxALIGN_RIGHT
);
894 topsizer
-> Fit(this);
902 SetFontsToHtmlWin(TestWin
,
903 NormalFont
-> GetStringSelection(),
904 FixedFont
-> GetStringSelection(),
905 RadioBox
-> GetSelection());
906 TestWin
-> SetPage(_("<html><body>"
907 "Normal face<br>(and <u>underlined</u>. <i>Italic face.</i> "
908 "<b>Bold face.</b> <b><i>Bold italic face.</i></b><br>"
909 "<font size=-2>font size -2</font><br>"
910 "<font size=-1>font size -1</font><br>"
911 "<font size=+0>font size +0</font><br>"
912 "<font size=+1>font size +1</font><br>"
913 "<font size=+2>font size +2</font><br>"
914 "<font size=+3>font size +3</font><br>"
915 "<font size=+4>font size +4</font><br>"
917 "<p><tt>Fixed size face.<br> <b>bold</b> <i>italic</i> "
918 "<b><i>bold italic <u>underlined</u></i></b><br>"
919 "<font size=-2>font size -2</font><br>"
920 "<font size=-1>font size -1</font><br>"
921 "<font size=+0>font size +0</font><br>"
922 "<font size=+1>font size +1</font><br>"
923 "<font size=+2>font size +2</font><br>"
924 "<font size=+3>font size +3</font><br>"
925 "<font size=+4>font size +4</font></tt>"
929 void OnUpdate(wxCommandEvent
& event
)
934 DECLARE_EVENT_TABLE()
937 BEGIN_EVENT_TABLE(wxHtmlHelpFrameOptionsDialog
, wxDialog
)
938 EVT_COMBOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate
)
939 EVT_RADIOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate
)
943 void wxHtmlHelpFrame::OptionsDialog()
945 wxHtmlHelpFrameOptionsDialog
dlg(this);
948 if (m_NormalFonts
== NULL
) {
949 wxFontEnumerator enu
;
950 enu
.EnumerateFacenames();
951 m_NormalFonts
= new wxArrayString
;
952 *m_NormalFonts
= *enu
.GetFacenames();
953 m_NormalFonts
-> Sort();
955 if (m_FixedFonts
== NULL
) {
956 wxFontEnumerator enu
;
957 enu
.EnumerateFacenames(wxFONTENCODING_SYSTEM
, TRUE
);
958 m_FixedFonts
= new wxArrayString
;
959 *m_FixedFonts
= *enu
.GetFacenames();
960 m_FixedFonts
-> Sort();
963 for (i
= 0; i
< m_NormalFonts
-> GetCount(); i
++)
964 dlg
.NormalFont
-> Append((*m_NormalFonts
)[i
]);
965 for (i
= 0; i
< m_FixedFonts
-> GetCount(); i
++)
966 dlg
.FixedFont
-> Append((*m_FixedFonts
)[i
]);
967 if (!m_NormalFace
.IsEmpty()) dlg
.NormalFont
-> SetStringSelection(m_NormalFace
);
968 else dlg
.NormalFont
-> SetSelection(0);
969 if (!m_FixedFace
.IsEmpty()) dlg
.FixedFont
-> SetStringSelection(m_FixedFace
);
970 else dlg
.FixedFont
-> SetSelection(0);
971 dlg
.RadioBox
-> SetSelection(m_FontSize
);
974 if (dlg
.ShowModal() == wxID_OK
) {
975 m_NormalFace
= dlg
.NormalFont
-> GetStringSelection();
976 m_FixedFace
= dlg
.FixedFont
-> GetStringSelection();
977 m_FontSize
= dlg
.RadioBox
-> GetSelection();
978 SetFontsToHtmlWin(m_HtmlWin
, m_NormalFace
, m_FixedFace
, m_FontSize
);
984 void wxHtmlHelpFrame::NotifyPageChanged()
986 if (m_UpdateContents
&& m_PagesHash
)
988 wxString an
= m_HtmlWin
-> GetOpenedAnchor();
989 wxHtmlHelpHashData
*ha
;
991 ha
= (wxHtmlHelpHashData
*) m_PagesHash
-> Get(m_HtmlWin
-> GetOpenedPage());
993 ha
= (wxHtmlHelpHashData
*) m_PagesHash
-> Get(m_HtmlWin
-> GetOpenedPage() + wxT("#") + an
);
996 bool olduc
= m_UpdateContents
;
997 m_UpdateContents
= FALSE
;
998 m_ContentsBox
-> SelectItem(ha
-> m_Id
);
999 m_ContentsBox
-> EnsureVisible(ha
-> m_Id
);
1000 m_UpdateContents
= olduc
;
1012 void wxHtmlHelpFrame::OnToolbar(wxCommandEvent
& event
)
1014 switch (event
.GetId()) {
1016 case wxID_HTML_BACK
:
1017 m_HtmlWin
-> HistoryBack();
1018 NotifyPageChanged();
1021 case wxID_HTML_FORWARD
:
1022 m_HtmlWin
-> HistoryForward();
1023 NotifyPageChanged();
1029 wxString an
= m_HtmlWin
-> GetOpenedAnchor();
1030 wxHtmlHelpHashData
*ha
;
1032 ha
= (wxHtmlHelpHashData
*) m_PagesHash
-> Get(m_HtmlWin
-> GetOpenedPage());
1034 ha
= (wxHtmlHelpHashData
*) m_PagesHash
-> Get(m_HtmlWin
-> GetOpenedPage() + wxT("#") + an
);
1035 if (ha
&& ha
-> m_Index
> 0)
1037 wxHtmlContentsItem
*it
= m_Data
-> GetContents() + (ha
-> m_Index
- 1);
1038 m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
1039 NotifyPageChanged();
1044 case wxID_HTML_UPNODE
:
1047 wxString an
= m_HtmlWin
-> GetOpenedAnchor();
1048 wxHtmlHelpHashData
*ha
;
1050 ha
= (wxHtmlHelpHashData
*) m_PagesHash
-> Get(m_HtmlWin
-> GetOpenedPage());
1052 ha
= (wxHtmlHelpHashData
*) m_PagesHash
-> Get(m_HtmlWin
-> GetOpenedPage() + wxT("#") + an
);
1053 if (ha
&& ha
-> m_Index
> 0)
1055 int level
= m_Data
-> GetContents()[ha
-> m_Index
].m_Level
- 1;
1056 wxHtmlContentsItem
*it
;
1057 int ind
= ha
-> m_Index
- 1;
1059 it
= m_Data
-> GetContents() + ind
;
1060 while (ind
>= 0 && it
-> m_Level
!= level
) ind
--, it
--;
1063 m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
1064 NotifyPageChanged();
1070 case wxID_HTML_DOWN
:
1073 wxString an
= m_HtmlWin
-> GetOpenedAnchor();
1075 wxHtmlHelpHashData
*ha
;
1077 if (an
.IsEmpty()) adr
= m_HtmlWin
-> GetOpenedPage();
1078 else adr
= m_HtmlWin
-> GetOpenedPage() + wxT("#") + an
;
1080 ha
= (wxHtmlHelpHashData
*) m_PagesHash
-> Get(adr
);
1082 if (ha
&& ha
-> m_Index
< m_Data
-> GetContentsCnt() - 1)
1084 wxHtmlContentsItem
*it
= m_Data
-> GetContents() + (ha
-> m_Index
+ 1);
1086 while (it
-> m_Book
-> GetBasePath() + it
-> m_Page
== adr
) it
++;
1087 m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
1088 NotifyPageChanged();
1093 case wxID_HTML_PANEL
:
1095 if (! (m_Splitter
&& m_NavigPan
))
1097 if (m_Splitter
-> IsSplit()) {
1098 m_Cfg
.sashpos
= m_Splitter
-> GetSashPosition();
1099 m_Splitter
-> Unsplit(m_NavigPan
);
1100 m_Cfg
.navig_on
= FALSE
;
1102 m_NavigPan
-> Show(TRUE
);
1103 m_HtmlWin
-> Show(TRUE
);
1104 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
1105 m_Cfg
.navig_on
= TRUE
;
1110 case wxID_HTML_OPTIONS
:
1114 case wxID_HTML_BOOKMARKSADD
:
1119 item
= m_HtmlWin
-> GetOpenedPageTitle();
1120 url
= m_HtmlWin
-> GetOpenedPage();
1121 if (item
== wxEmptyString
) item
= url
.AfterLast(wxT('/'));
1122 if (m_BookmarksPages
.Index(url
) == wxNOT_FOUND
) {
1123 m_Bookmarks
-> Append(item
);
1124 m_BookmarksNames
.Add(item
);
1125 m_BookmarksPages
.Add(url
);
1130 case wxID_HTML_BOOKMARKSREMOVE
:
1135 item
= m_Bookmarks
-> GetStringSelection();
1136 pos
= m_BookmarksNames
.Index(item
);
1137 if (pos
!= wxNOT_FOUND
) {
1138 m_BookmarksNames
.Remove(pos
);
1139 m_BookmarksPages
.Remove(pos
);
1140 m_Bookmarks
-> Delete(m_Bookmarks
-> GetSelection());
1145 #if wxUSE_PRINTING_ARCHITECTURE
1146 case wxID_HTML_PRINT
:
1148 if (m_Printer
== NULL
)
1149 m_Printer
= new wxHtmlEasyPrinting(_("Help Printing"), this);
1150 m_Printer
-> PrintFile(m_HtmlWin
-> GetOpenedPage());
1155 case wxID_HTML_OPENFILE
:
1157 wxString s
= wxFileSelector(_("Open HTML document"), wxEmptyString
, wxEmptyString
, wxEmptyString
,
1158 wxT("HTML files (*.htm)|*.htm|HTML files (*.html)|*.html|"
1159 "Help books (*.htb)|*.htb|Help books (*.zip)|*.zip|"
1160 "HTML Help Project (*.hhp)|*.hhp|"
1161 "All files (*.*)|*"),
1162 wxOPEN
| wxFILE_MUST_EXIST
, this);
1165 wxString ext
= s
.Right(4).Lower();
1166 if (ext
== _T(".zip") || ext
== _T(".htb") || ext
== _T(".hhp"))
1169 m_Data
-> AddBook(s
);
1173 m_HtmlWin
-> LoadPage(s
);
1182 void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent
& event
)
1184 wxHtmlHelpTreeItemData
*pg
;
1185 wxHtmlContentsItem
*it
;
1187 pg
= (wxHtmlHelpTreeItemData
*) m_ContentsBox
-> GetItemData(event
.GetItem());
1189 if (pg
&& m_UpdateContents
)
1191 it
= m_Data
-> GetContents() + (pg
-> m_Id
);
1192 m_UpdateContents
= FALSE
;
1193 m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
1194 m_UpdateContents
= TRUE
;
1200 void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent
& WXUNUSED(event
))
1202 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_IndexList
-> GetClientData(m_IndexList
-> GetSelection());
1203 m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
1204 NotifyPageChanged();
1208 void wxHtmlHelpFrame::OnIndexFind(wxCommandEvent
& event
)
1210 wxString sr
= m_IndexText
-> GetLineText(0);
1212 if (sr
== wxEmptyString
)
1217 const wxChar
*cstr
= sr
.c_str();
1218 wxChar mybuff
[512], *ptr
;
1221 m_IndexList
->Clear();
1222 int cnt
= m_Data
->GetIndexCnt();
1223 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
1226 for (int i
= 0; i
< cnt
; i
++)
1228 wxStrncpy(mybuff
, index
[i
].m_Name
, 512);
1230 for (ptr
= mybuff
; *ptr
!= 0; ptr
++)
1231 if (*ptr
>= 'A' && *ptr
<= 'Z') *ptr
-= 'A' - 'a';
1232 if (wxStrstr(mybuff
, cstr
) != NULL
) {
1233 m_IndexList
-> Append(index
[i
].m_Name
, (char*)(index
+ i
));
1236 m_HtmlWin
-> LoadPage(index
[i
].m_Book
-> GetBasePath() + index
[i
].m_Page
);
1237 NotifyPageChanged();
1244 cnttext
.Printf(_("%i of %i"), displ
, cnt
);
1245 m_IndexCountInfo
-> SetLabel(cnttext
);
1247 m_IndexText
-> SetSelection(0, sr
.Length());
1248 m_IndexText
-> SetFocus();
1252 void wxHtmlHelpFrame::OnIndexAll(wxCommandEvent
& WXUNUSED(event
))
1256 m_IndexList
->Clear();
1257 int cnt
= m_Data
->GetIndexCnt();
1259 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
1261 for (int i
= 0; i
< cnt
; i
++) {
1262 m_IndexList
-> Append(index
[i
].m_Name
, (char*)(index
+ i
));
1264 m_HtmlWin
-> LoadPage(index
[i
].m_Book
-> GetBasePath() + index
[i
].m_Page
);
1265 NotifyPageChanged();
1271 cnttext
.Printf(_("%i of %i"), cnt
, cnt
);
1272 m_IndexCountInfo
-> SetLabel(cnttext
);
1276 void wxHtmlHelpFrame::OnSearchSel(wxCommandEvent
& WXUNUSED(event
))
1278 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_SearchList
-> GetClientData(m_SearchList
-> GetSelection());
1281 m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
1282 NotifyPageChanged();
1286 void wxHtmlHelpFrame::OnSearch(wxCommandEvent
& WXUNUSED(event
))
1288 wxString sr
= m_SearchText
-> GetLineText(0);
1290 if (sr
!= wxEmptyString
) KeywordSearch(sr
);
1293 void wxHtmlHelpFrame::OnBookmarksSel(wxCommandEvent
& WXUNUSED(event
))
1295 wxString sr
= m_Bookmarks
-> GetStringSelection();
1297 if (sr
!= wxEmptyString
&& sr
!= _("(bookmarks)"))
1299 m_HtmlWin
-> LoadPage(m_BookmarksPages
[m_BookmarksNames
.Index(sr
)]);
1300 NotifyPageChanged();
1304 void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent
& evt
)
1306 GetSize(&m_Cfg
.w
, &m_Cfg
.h
);
1307 GetPosition(&m_Cfg
.x
, &m_Cfg
.y
);
1309 if (m_Splitter
&& m_Cfg
.navig_on
) m_Cfg
.sashpos
= m_Splitter
-> GetSashPosition();
1312 WriteCustomization(m_Config
, m_ConfigRoot
);
1314 if (m_helpController
&& m_helpController
->IsKindOf(CLASSINFO(wxHtmlHelpController
)))
1316 ((wxHtmlHelpController
*) m_helpController
)->OnCloseFrame(evt
);
1322 BEGIN_EVENT_TABLE(wxHtmlHelpFrame
, wxFrame
)
1323 EVT_TOOL_RANGE(wxID_HTML_PANEL
, wxID_HTML_OPTIONS
, wxHtmlHelpFrame::OnToolbar
)
1324 EVT_BUTTON(wxID_HTML_BOOKMARKSREMOVE
, wxHtmlHelpFrame::OnToolbar
)
1325 EVT_BUTTON(wxID_HTML_BOOKMARKSADD
, wxHtmlHelpFrame::OnToolbar
)
1326 EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL
, wxHtmlHelpFrame::OnContentsSel
)
1327 EVT_LISTBOX(wxID_HTML_INDEXLIST
, wxHtmlHelpFrame::OnIndexSel
)
1328 EVT_LISTBOX(wxID_HTML_SEARCHLIST
, wxHtmlHelpFrame::OnSearchSel
)
1329 EVT_BUTTON(wxID_HTML_SEARCHBUTTON
, wxHtmlHelpFrame::OnSearch
)
1330 EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT
, wxHtmlHelpFrame::OnSearch
)
1331 EVT_BUTTON(wxID_HTML_INDEXBUTTON
, wxHtmlHelpFrame::OnIndexFind
)
1332 EVT_TEXT_ENTER(wxID_HTML_INDEXTEXT
, wxHtmlHelpFrame::OnIndexFind
)
1333 EVT_BUTTON(wxID_HTML_INDEXBUTTONALL
, wxHtmlHelpFrame::OnIndexAll
)
1334 EVT_COMBOBOX(wxID_HTML_BOOKMARKSLIST
, wxHtmlHelpFrame::OnBookmarksSel
)
1335 EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow
)