2 // Purpose: Help controller
3 // Author: Vaclav Slavik
4 // Copyright: (c) 1999 Vaclav Slavik
5 // Licence: wxWindows Licence
6 /////////////////////////////////////////////////////////////////////////////
8 #error This file should not be compiled! Update your build system! \
9 (configure users, rerun configure to get a new Makefile) \
10 Instead of htmlhelp[_io], use helpdata, helpfrm and helpctrl. This \
11 file is only left to point out the problem and will be removed r.s.n.
14 #pragma implementation "htmlhelp.h"
17 #include "wx/wxprec.h"
30 #include <wx/notebook.h>
31 #include <wx/imaglist.h>
32 #include <wx/treectrl.h>
33 #include <wx/tokenzr.h>
34 #include <wx/wfstream.h>
35 #include <wx/html/htmlwin.h>
36 #include <wx/html/htmlhelp.h>
37 #include <wx/busyinfo.h>
39 #if !((wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7)))
40 #include <wx/progdlg.h>
47 #include "bitmaps/panel.xpm"
48 #include "bitmaps/back.xpm"
49 #include "bitmaps/forward.xpm"
50 #include "bitmaps/book.xpm"
51 #include "bitmaps/folder.xpm"
52 #include "bitmaps/page.xpm"
60 #include <wx/arrimpl.cpp>
61 WX_DEFINE_OBJARRAY(HtmlBookRecArray
)
71 //-----------------------------------------------------------------------------
72 // wxHtmlHelpController
73 //-----------------------------------------------------------------------------
76 IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpController
, wxEvtHandler
)
79 wxHtmlHelpController::wxHtmlHelpController() : wxEvtHandler()
83 m_ConfigRoot
= wxEmptyString
;
84 m_TitleFormat
= _("Help : %s");
85 m_TempPath
= wxEmptyString
;
87 m_Cfg
.x
= m_Cfg
.y
= 0;
88 m_Cfg
.w
= 700; m_Cfg
.h
= 480;
90 m_Cfg
.navig_on
= TRUE
;
92 m_ContentsImageList
= new wxImageList(12, 12);
93 m_ContentsImageList
-> Add(wxICON(book
));
94 m_ContentsImageList
-> Add(wxICON(folder
));
95 m_ContentsImageList
-> Add(wxICON(page
));
103 m_ContentsBox
= NULL
;
106 m_SearchButton
= NULL
;
114 wxHtmlHelpController::~wxHtmlHelpController()
118 m_BookRecords
.Empty();
119 delete m_ContentsImageList
;
121 for (i
= 0; i
< m_ContentsCnt
; i
++) {
122 delete[] m_Contents
[i
].m_Page
;
123 delete[] m_Contents
[i
].m_Name
;
128 for (i
= 0; i
< m_IndexCnt
; i
++) {
129 delete[] m_Index
[i
].m_Page
;
130 delete[] m_Index
[i
].m_Name
;
138 void wxHtmlHelpController::SetTempDir(const wxString
& path
)
140 if (path
== wxEmptyString
) m_TempPath
= path
;
142 if (wxIsAbsolutePath(path
)) m_TempPath
= path
;
143 else m_TempPath
= wxGetCwd() + "/" + path
;
145 if (m_TempPath
[m_TempPath
.Length() - 1] != '/')
153 // Reads one line, stores it into buf and returns pointer to new line or NULL.
154 static char* ReadLine(char *line
, char *buf
)
156 char *writeptr
= buf
, *readptr
= line
;
158 while (*readptr
!= 0 && *readptr
!= '\r' && *readptr
!= '\n') *(writeptr
++) = *(readptr
++);
160 while (*readptr
== '\r' || *readptr
== '\n') readptr
++;
161 if (*readptr
== 0) return NULL
;
166 static wxString
SafeFileName(const wxString
& s
)
169 res
.Replace(_T(":"), _T("_"), TRUE
);
170 res
.Replace(_T(" "), _T("_"), TRUE
);
171 res
.Replace(_T("/"), _T("_"), TRUE
);
172 res
.Replace(_T("\\"), _T("_"), TRUE
);
173 res
.Replace(_T("#"), _T("_"), TRUE
);
174 res
.Replace(_T("."), _T("_"), TRUE
);
179 static int IndexCompareFunc(const void *a
, const void *b
)
181 return strcmp(((HtmlContentsItem
*)a
) -> m_Name
, ((HtmlContentsItem
*)b
) -> m_Name
);
186 bool wxHtmlHelpController::AddBook(const wxString
& book
, bool show_wait_msg
)
191 HtmlBookRecord
*bookr
;
195 char *buff
, *lineptr
;
198 wxString title
= _("noname"),
200 start
= wxEmptyString
,
201 contents
= wxEmptyString
, index
= wxEmptyString
;
203 if (wxIsAbsolutePath(book
)) bookFull
= book
;
204 else bookFull
= wxGetCwd() + "/" + book
;
206 fi
= fsys
.OpenFile(bookFull
);
207 if (fi
== NULL
) return FALSE
;
208 fsys
.ChangePathTo(bookFull
);
209 s
= fi
-> GetStream();
211 buff
= new char[sz
+1];
217 while ((lineptr
= ReadLine(lineptr
, linebuf
)) != NULL
) {
218 if (strstr(linebuf
, "Title=") == linebuf
)
219 title
= linebuf
+ strlen("Title=");
220 if (strstr(linebuf
, "Default topic=") == linebuf
)
221 start
= linebuf
+ strlen("Default topic=");
222 if (strstr(linebuf
, "Index file=") == linebuf
)
223 index
= linebuf
+ strlen("Index file=");
224 if (strstr(linebuf
, "Contents file=") == linebuf
)
225 contents
= linebuf
+ strlen("Contents file=");
229 bookr
= new HtmlBookRecord(fsys
.GetPath(), title
, start
);
231 if (m_ContentsCnt
% HTML_REALLOC_STEP
== 0)
232 m_Contents
= (HtmlContentsItem
*) realloc(m_Contents
, (m_ContentsCnt
+ HTML_REALLOC_STEP
) * sizeof(HtmlContentsItem
));
233 m_Contents
[m_ContentsCnt
].m_Level
= 0;
234 m_Contents
[m_ContentsCnt
].m_ID
= 0;
235 m_Contents
[m_ContentsCnt
].m_Page
= new char[start
.Length() + 1];
236 strcpy(m_Contents
[m_ContentsCnt
].m_Page
, start
.c_str());
237 m_Contents
[m_ContentsCnt
].m_Name
= new char [title
.Length() + 1];
238 strcpy(m_Contents
[m_ContentsCnt
].m_Name
, title
.c_str());
239 m_Contents
[m_ContentsCnt
].m_Book
= bookr
;
242 // Try to find cached binary versions:
243 safetitle
= SafeFileName(title
);
244 fi
= fsys
.OpenFile(safetitle
+ ".cached");
245 if (fi
== NULL
) fi
= fsys
.OpenFile(m_TempPath
+ safetitle
+ ".cached");
246 if ((fi
== NULL
) || (m_TempPath
== wxEmptyString
)) {
247 LoadMSProject(bookr
, fsys
, index
, contents
, show_wait_msg
);
248 if (m_TempPath
!= wxEmptyString
) {
249 wxFileOutputStream
*outs
= new wxFileOutputStream(m_TempPath
+ safetitle
+ ".cached");
250 SaveCachedBook(bookr
, outs
);
255 LoadCachedBook(bookr
, fi
-> GetStream());
259 m_BookRecords
.Add(bookr
);
261 qsort(m_Index
, m_IndexCnt
, sizeof(HtmlContentsItem
), IndexCompareFunc
);
269 void wxHtmlHelpController::Display(const wxString
& x
)
278 /* 1. try to open given file: */
280 cnt
= m_BookRecords
.GetCount();
281 for (i
= 0; i
< cnt
; i
++) {
282 f
= fsys
.OpenFile(m_BookRecords
[i
].GetBasePath() + x
);
284 m_HtmlWin
-> LoadPage(m_BookRecords
[i
].GetBasePath() + x
);
291 /* 2. try to find a book: */
293 for (i
= 0; i
< cnt
; i
++) {
294 if (m_BookRecords
[i
].GetTitle() == x
) {
295 m_HtmlWin
-> LoadPage(m_BookRecords
[i
].GetBasePath() + m_BookRecords
[i
].GetStart());
300 /* 3. try to find in contents: */
303 for (i
= 0; i
< cnt
; i
++) {
304 if (strcmp(m_Contents
[i
].m_Name
, x
) == 0) {
305 m_HtmlWin
-> LoadPage(m_Contents
[i
].m_Book
-> GetBasePath() + m_Contents
[i
].m_Page
);
311 /* 4. try to find in index: */
314 for (i
= 0; i
< cnt
; i
++) {
315 if (strcmp(m_Index
[i
].m_Name
, x
) == 0) {
316 m_HtmlWin
-> LoadPage(m_Index
[i
].m_Book
-> GetBasePath() + m_Index
[i
].m_Page
);
322 /* 5. if everything failed, search the documents: */
329 void wxHtmlHelpController::Display(const int id
)
333 for (int i
= 0; i
< m_ContentsCnt
; i
++) {
334 if (m_Contents
[i
].m_ID
== id
) {
335 m_HtmlWin
-> LoadPage(m_Contents
[i
].m_Book
-> GetBasePath() + m_Contents
[i
].m_Page
);
343 void wxHtmlHelpController::DisplayContents()
347 if (!m_Splitter
-> IsSplit()) {
348 m_NavigPan
-> Show(TRUE
);
349 m_HtmlWin
-> Show(TRUE
);
350 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
352 m_NavigPan
-> SetSelection(0);
357 void wxHtmlHelpController::DisplayIndex()
361 if (!m_Splitter
-> IsSplit()) {
362 m_NavigPan
-> Show(TRUE
);
363 m_HtmlWin
-> Show(TRUE
);
364 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
366 m_NavigPan
-> SetSelection(1);
372 #if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
374 class MyProgressDlg
: public wxDialog
379 MyProgressDlg(wxWindow
*parent
) : wxDialog(parent
, -1,
387 {m_Canceled
= FALSE
;}
388 void OnCancel(wxCommandEvent
& event
) {m_Canceled
= TRUE
;}
389 DECLARE_EVENT_TABLE()
391 BEGIN_EVENT_TABLE(MyProgressDlg
, wxDialog
)
392 EVT_BUTTON(wxID_CANCEL
, MyProgressDlg::OnCancel
)
398 bool wxHtmlHelpController::KeywordSearch(const wxString
& keyword
)
402 // if these are not set, we can't continue
403 if (! (m_SearchList
&& m_HtmlWin
))
406 if (m_Splitter
&& m_NavigPan
&& m_SearchButton
) {
407 if (!m_Splitter
-> IsSplit()) {
408 m_NavigPan
-> Show(TRUE
);
409 m_HtmlWin
-> Show(TRUE
);
410 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
412 m_NavigPan
-> SetSelection(2);
413 m_SearchList
-> Clear();
414 m_SearchText
-> SetValue(keyword
);
415 m_SearchButton
-> Enable(FALSE
);
418 int cnt
= m_ContentsCnt
;
419 wxSearchEngine engine
;
422 wxString lastpage
= wxEmptyString
;
425 #if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
426 MyProgressDlg
progress(m_Frame
);
428 wxStaticText
*prompt
= new wxStaticText(&progress
, -1, "", wxPoint(20, 50), wxSize(260, 25), wxALIGN_CENTER
);
429 wxGauge
*gauge
= new wxGauge(&progress
, -1, cnt
, wxPoint(20, 20), wxSize(260, 25));
430 wxButton
*btn
= new wxButton(&progress
, wxID_CANCEL
, _("Cancel"), wxPoint(110, 70), wxSize(80, 25));
431 btn
= btn
; /* fool compiler :-) */
432 prompt
-> SetLabel(_("No matching page found yet"));
434 progress
.Centre(wxBOTH
);
437 wxProgressDialog
progress(_("Searching..."), _("No matching page found yet"), cnt
, m_Frame
, wxPD_APP_MODAL
| wxPD_CAN_ABORT
| wxPD_AUTO_HIDE
);
440 engine
.LookFor(keyword
);
442 for (int i
= 0; i
< cnt
; i
++) {
443 #if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
444 gauge
-> SetValue(i
);
445 if (progress
.m_Canceled
) break;
447 if (progress
.Update(i
) == FALSE
) break;
451 file
= fsys
.OpenFile(m_Contents
[i
].m_Book
-> GetBasePath() + m_Contents
[i
].m_Page
);
453 if (lastpage
!= file
-> GetLocation()) {
454 lastpage
= file
-> GetLocation();
455 if (engine
.Scan(file
-> GetStream())) {
456 foundstr
.Printf(_("Found %i matches"), ++foundcnt
);
457 #if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
458 prompt
-> SetLabel(foundstr
);
460 progress
.Update(i
, foundstr
);
463 m_SearchList
-> Append(m_Contents
[i
].m_Name
, (char*)(m_Contents
+ i
));
470 #if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
471 progress
.Close(TRUE
);
475 m_SearchButton
-> Enable(TRUE
);
477 m_SearchText
-> SetSelection(0, keyword
.Length());
478 m_SearchText
-> SetFocus();
481 HtmlContentsItem
*it
= (HtmlContentsItem
*) m_SearchList
-> GetClientData(0);
482 if (it
) m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
484 return (foundcnt
> 0);
492 void wxHtmlHelpController::CreateHelpWindow()
500 m_Frame
-> Show(TRUE
);
505 wxBusyInfo
busyinfo(_("Preparing help window..."));
508 if (m_Config
) ReadCustomization(m_Config
, m_ConfigRoot
);
510 m_Frame
= new wxFrame(NULL
, -1, "", wxPoint(m_Cfg
.x
, m_Cfg
.y
), wxSize(m_Cfg
.w
, m_Cfg
.h
));
511 m_Frame
-> PushEventHandler(this);
512 sbar
= m_Frame
-> CreateStatusBar();
516 toolBar
= m_Frame
-> CreateToolBar(wxNO_BORDER
| wxTB_HORIZONTAL
| wxTB_FLAT
| wxTB_DOCKABLE
);
517 toolBar
-> SetMargins(2, 2);
518 wxBitmap
* toolBarBitmaps
[3];
521 toolBarBitmaps
[0] = new wxBitmap("panel");
522 toolBarBitmaps
[1] = new wxBitmap("back");
523 toolBarBitmaps
[2] = new wxBitmap("forward");
526 toolBarBitmaps
[0] = new wxBitmap(panel_xpm
);
527 toolBarBitmaps
[1] = new wxBitmap(back_xpm
);
528 toolBarBitmaps
[2] = new wxBitmap(forward_xpm
);
534 toolBar
-> AddTool(wxID_HTML_PANEL
, *(toolBarBitmaps
[0]), wxNullBitmap
, FALSE
, currentX
, -1, (wxObject
*) NULL
, _("Show/hide navigation panel"));
535 currentX
+= width
+ 5;
536 toolBar
-> AddSeparator();
537 toolBar
-> AddTool(wxID_HTML_BACK
, *(toolBarBitmaps
[1]), wxNullBitmap
, FALSE
, currentX
, -1, (wxObject
*) NULL
, _("Go back to the previous HTML page"));
538 currentX
+= width
+ 5;
539 toolBar
-> AddTool(wxID_HTML_FORWARD
, *(toolBarBitmaps
[2]), wxNullBitmap
, FALSE
, currentX
, -1, (wxObject
*) NULL
, _("Go forward to the next HTML page"));
540 currentX
+= width
+ 5;
542 toolBar
-> Realize();
544 // Can delete the bitmaps since they're reference counted
545 for (int i
= 0; i
< 3; i
++) delete toolBarBitmaps
[i
];
550 m_Splitter
= new wxSplitterWindow(m_Frame
);
552 m_HtmlWin
= new wxHtmlWindow(m_Splitter
);
553 m_HtmlWin
-> SetRelatedFrame(m_Frame
, m_TitleFormat
);
554 m_HtmlWin
-> SetRelatedStatusBar(0);
555 if (m_Config
) m_HtmlWin
-> ReadCustomization(m_Config
, m_ConfigRoot
);
557 m_NavigPan
= new wxNotebook(m_Splitter
, wxID_HTML_NOTEBOOK
, wxDefaultPosition
, wxDefaultSize
);
559 m_ContentsBox
= new wxTreeCtrl(m_NavigPan
, wxID_HTML_TREECTRL
, wxDefaultPosition
, wxDefaultSize
, wxTR_HAS_BUTTONS
| wxSUNKEN_BORDER
);
560 m_ContentsBox
-> SetImageList(m_ContentsImageList
);
561 m_NavigPan
-> AddPage(m_ContentsBox
, _("Contents"));
565 wxWindow
*dummy
= new wxPanel(m_NavigPan
, wxID_HTML_INDEXPAGE
);
566 wxLayoutConstraints
*b1
= new wxLayoutConstraints
;
567 b1
-> top
.SameAs (dummy
, wxTop
, 0);
568 b1
-> left
.SameAs (dummy
, wxLeft
, 0);
569 b1
-> width
.PercentOf (dummy
, wxWidth
, 100);
570 b1
-> bottom
.SameAs (dummy
, wxBottom
, 0);
571 m_IndexBox
= new wxListBox(dummy
, wxID_HTML_INDEXLIST
, wxDefaultPosition
, wxDefaultSize
, 0);
572 m_IndexBox
-> SetConstraints(b1
);
573 dummy
-> SetAutoLayout(TRUE
);
574 m_NavigPan
-> AddPage(dummy
, _("Index"));
578 wxWindow
*dummy
= new wxPanel(m_NavigPan
, wxID_HTML_SEARCHPAGE
);
580 wxLayoutConstraints
*b1
= new wxLayoutConstraints
;
581 m_SearchText
= new wxTextCtrl(dummy
, wxID_HTML_SEARCHTEXT
);
582 b1
-> top
.SameAs (dummy
, wxTop
, 0);
583 b1
-> left
.SameAs (dummy
, wxLeft
, 0);
584 b1
-> right
.SameAs (dummy
, wxRight
, 0);
586 m_SearchText
-> SetConstraints(b1
);
588 wxLayoutConstraints
*b2
= new wxLayoutConstraints
;
589 m_SearchButton
= new wxButton(dummy
, wxID_HTML_SEARCHBUTTON
, _("Search!"));
590 b2
-> top
.Below (m_SearchText
, 10);
591 b2
-> right
.SameAs (dummy
, wxRight
, 10);
594 m_SearchButton
-> SetConstraints(b2
);
596 wxLayoutConstraints
*b3
= new wxLayoutConstraints
;
597 m_SearchList
= new wxListBox(dummy
, wxID_HTML_SEARCHLIST
, wxDefaultPosition
, wxDefaultSize
, 0);
598 b3
-> top
.Below (m_SearchButton
, 10);
599 b3
-> left
.SameAs (dummy
, wxLeft
, 0);
600 b3
-> right
.SameAs (dummy
, wxRight
, 0);
601 b3
-> bottom
.SameAs (dummy
, wxBottom
, 0);
602 m_SearchList
-> SetConstraints(b3
);
604 dummy
-> SetAutoLayout(TRUE
);
606 m_NavigPan
-> AddPage(dummy
, _("Search"));
610 m_NavigPan
-> Show(TRUE
);
611 m_HtmlWin
-> Show(TRUE
);
612 m_Splitter
-> SetMinimumPaneSize(20);
613 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
614 if (!m_Cfg
.navig_on
) m_Splitter
-> Unsplit(m_NavigPan
);
618 m_Frame
-> Show(TRUE
);
626 void wxHtmlHelpController::CreateContents()
628 HtmlContentsItem
*it
;
629 wxTreeItemId roots
[MAX_ROOTS
];
630 bool imaged
[MAX_ROOTS
];
631 int count
= m_ContentsCnt
;
633 m_ContentsBox
-> DeleteAllItems();
634 roots
[0] = m_ContentsBox
-> AddRoot(_("(Help)"));
637 for (int i
= 0; i
< count
; i
++) {
639 roots
[it
-> m_Level
+ 1] = m_ContentsBox
-> AppendItem(roots
[it
-> m_Level
], it
-> m_Name
, IMG_Page
, -1, new wxHtmlHelpTreeItemData(it
));
640 if (it
-> m_Level
== 0) {
641 m_ContentsBox
-> SetItemBold(roots
[1], TRUE
);
642 m_ContentsBox
-> SetItemImage(roots
[1], IMG_Book
);
643 m_ContentsBox
-> SetItemSelectedImage(roots
[1], IMG_Book
);
646 else imaged
[it
-> m_Level
+ 1] = FALSE
;
648 if (!imaged
[it
-> m_Level
]) {
649 m_ContentsBox
-> SetItemImage(roots
[it
-> m_Level
], IMG_Folder
);
650 m_ContentsBox
-> SetItemSelectedImage(roots
[it
-> m_Level
], IMG_Folder
);
651 imaged
[it
-> m_Level
] = TRUE
;
655 m_ContentsBox
-> Expand(roots
[0]);
661 void wxHtmlHelpController::CreateIndex()
663 m_IndexBox
-> Clear();
665 for (int i
= 0; i
< m_IndexCnt
; i
++)
666 m_IndexBox
-> Append(m_Index
[i
].m_Name
, (char*)(m_Index
+ i
));
671 void wxHtmlHelpController::RefreshLists()
676 m_SearchList
-> Clear();
686 void wxHtmlHelpController::ReadCustomization(wxConfigBase
*cfg
, wxString path
)
691 if (path
!= wxEmptyString
) {
692 oldpath
= cfg
-> GetPath();
693 cfg
-> SetPath(path
);
696 m_Cfg
.navig_on
= cfg
-> Read("hcNavigPanel", m_Cfg
.navig_on
) != 0;
697 m_Cfg
.sashpos
= cfg
-> Read("hcSashPos", m_Cfg
.sashpos
);
698 m_Cfg
.x
= cfg
-> Read("hcX", m_Cfg
.x
);
699 m_Cfg
.y
= cfg
-> Read("hcY", m_Cfg
.y
);
700 m_Cfg
.w
= cfg
-> Read("hcW", m_Cfg
.w
);
701 m_Cfg
.h
= cfg
-> Read("hcH", m_Cfg
.h
);
703 if (path
!= wxEmptyString
)
704 cfg
-> SetPath(oldpath
);
709 void wxHtmlHelpController::WriteCustomization(wxConfigBase
*cfg
, wxString path
)
714 if (path
!= wxEmptyString
) {
715 oldpath
= cfg
-> GetPath();
716 cfg
-> SetPath(path
);
719 cfg
-> Write("hcNavigPanel", m_Cfg
.navig_on
);
720 cfg
-> Write("hcSashPos", (long)m_Cfg
.sashpos
);
721 cfg
-> Write("hcX", (long)m_Cfg
.x
);
722 cfg
-> Write("hcY", (long)m_Cfg
.y
);
723 cfg
-> Write("hcW", (long)m_Cfg
.w
);
724 cfg
-> Write("hcH", (long)m_Cfg
.h
);
726 if (path
!= wxEmptyString
)
727 cfg
-> SetPath(oldpath
);
739 void wxHtmlHelpController::OnToolbar(wxCommandEvent
& event
)
741 switch (event
.GetId()) {
742 case wxID_HTML_BACK
:
743 m_HtmlWin
-> HistoryBack();
745 case wxID_HTML_FORWARD
:
746 m_HtmlWin
-> HistoryForward();
748 case wxID_HTML_PANEL
:
749 if (m_Splitter
-> IsSplit()) {
750 m_Cfg
.sashpos
= m_Splitter
-> GetSashPosition();
751 m_Splitter
-> Unsplit(m_NavigPan
);
754 m_NavigPan
-> Show(TRUE
);
755 m_HtmlWin
-> Show(TRUE
);
756 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
764 void wxHtmlHelpController::OnContentsSel(wxTreeEvent
& event
)
766 wxHtmlHelpTreeItemData
*pg
;
768 pg
= (wxHtmlHelpTreeItemData
*) m_ContentsBox
-> GetItemData(event
.GetItem());
769 if (pg
) m_HtmlWin
-> LoadPage(pg
-> GetPage());
774 void wxHtmlHelpController::OnIndexSel(wxCommandEvent
& event
)
776 HtmlContentsItem
*it
= (HtmlContentsItem
*) m_IndexBox
-> GetClientData(m_IndexBox
-> GetSelection());
777 if (it
) m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
782 void wxHtmlHelpController::OnSearchSel(wxCommandEvent
& event
)
784 HtmlContentsItem
*it
= (HtmlContentsItem
*) m_SearchList
-> GetClientData(m_SearchList
-> GetSelection());
785 if (it
) m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
790 void wxHtmlHelpController::OnCloseWindow(wxCloseEvent
& event
)
794 m_Cfg
.navig_on
= m_Splitter
-> IsSplit();
796 m_Cfg
.sashpos
= m_Splitter
-> GetSashPosition();
797 m_Frame
-> GetPosition(&a
, &b
);
798 m_Cfg
.x
= a
, m_Cfg
.y
= b
;
799 m_Frame
-> GetSize(&a
, &b
);
800 m_Cfg
.w
= a
, m_Cfg
.h
= b
;
803 WriteCustomization(m_Config
, m_ConfigRoot
);
804 m_HtmlWin
-> WriteCustomization(m_Config
, m_ConfigRoot
);
813 void wxHtmlHelpController::OnSearch(wxCommandEvent
& event
)
815 wxString sr
= m_SearchText
-> GetLineText(0);
817 if (sr
!= wxEmptyString
) KeywordSearch(sr
);
822 BEGIN_EVENT_TABLE(wxHtmlHelpController
, wxEvtHandler
)
823 EVT_TOOL_RANGE(wxID_HTML_PANEL
, wxID_HTML_FORWARD
, wxHtmlHelpController::OnToolbar
)
824 EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL
, wxHtmlHelpController::OnContentsSel
)
825 EVT_LISTBOX(wxID_HTML_INDEXLIST
, wxHtmlHelpController::OnIndexSel
)
826 EVT_LISTBOX(wxID_HTML_SEARCHLIST
, wxHtmlHelpController::OnSearchSel
)
827 EVT_CLOSE(wxHtmlHelpController::OnCloseWindow
)
828 EVT_BUTTON(wxID_HTML_SEARCHBUTTON
, wxHtmlHelpController::OnSearch
)
829 EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT
, wxHtmlHelpController::OnSearch
)