d9bf5d2b114a711d523d33cc8ba6011f8b70e8fd
2 // Purpose: Help controller
3 // Author: Vaclav Slavik
4 // Copyright: (c) 1999 Vaclav Slavik
5 // Licence: wxWindows Licence
6 /////////////////////////////////////////////////////////////////////////////
10 #pragma implementation "htmlhelp.h"
13 #include "wx/wxprec.h"
26 #include <wx/notebook.h>
27 #include <wx/imaglist.h>
28 #include <wx/treectrl.h>
29 #include <wx/tokenzr.h>
30 #include <wx/wfstream.h>
31 #include <wx/html/htmlwin.h>
32 #include <wx/html/htmlhelp.h>
33 #include <wx/busyinfo.h>
35 #if !((wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7)))
36 #include <wx/progdlg.h>
43 #include "bitmaps/panel.xpm"
44 #include "bitmaps/back.xpm"
45 #include "bitmaps/forward.xpm"
46 #include "bitmaps/book.xpm"
47 #include "bitmaps/folder.xpm"
48 #include "bitmaps/page.xpm"
55 //-----------------------------------------------------------------------------
57 //-----------------------------------------------------------------------------
63 wxID_HTML_PANEL
= wxID_HIGHEST
+ 1,
73 wxID_HTML_SEARCHBUTTON
90 class HtmlHelpTreeItemData
: public wxTreeItemData
96 HtmlHelpTreeItemData(HtmlContentsItem
*it
) : wxTreeItemData() {m_Page
= it
-> m_Book
-> GetBasePath() + it
-> m_Page
;}
97 const wxString
& GetPage() {return m_Page
;}
104 #include <wx/arrimpl.cpp>
105 WX_DEFINE_OBJARRAY(HtmlBookRecArray
)
115 //-----------------------------------------------------------------------------
116 // wxHtmlHelpController
117 //-----------------------------------------------------------------------------
120 IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpController
, wxEvtHandler
)
123 wxHtmlHelpController::wxHtmlHelpController() : wxEvtHandler()
127 m_ConfigRoot
= wxEmptyString
;
128 m_TitleFormat
= _("Help : %s");
129 m_TempPath
= wxEmptyString
;
131 m_Cfg
.x
= m_Cfg
.y
= 0;
132 m_Cfg
.w
= 700; m_Cfg
.h
= 480;
134 m_Cfg
.navig_on
= TRUE
;
136 m_ContentsImageList
= new wxImageList(12, 12);
137 m_ContentsImageList
-> Add(wxICON(book
));
138 m_ContentsImageList
-> Add(wxICON(folder
));
139 m_ContentsImageList
-> Add(wxICON(page
));
149 wxHtmlHelpController::~wxHtmlHelpController()
153 m_BookRecords
.Empty();
154 delete m_ContentsImageList
;
156 for (i
= 0; i
< m_ContentsCnt
; i
++) {
157 delete[] m_Contents
[i
].m_Page
;
158 delete[] m_Contents
[i
].m_Name
;
163 for (i
= 0; i
< m_IndexCnt
; i
++) {
164 delete[] m_Index
[i
].m_Page
;
165 delete[] m_Index
[i
].m_Name
;
173 void wxHtmlHelpController::SetTempDir(const wxString
& path
)
175 if (path
== wxEmptyString
) m_TempPath
= path
;
177 if (wxIsAbsolutePath(path
)) m_TempPath
= path
;
178 else m_TempPath
= wxGetCwd() + "/" + path
;
180 if (m_TempPath
[m_TempPath
.Length() - 1] != '/')
188 // Reads one line, stores it into buf and returns pointer to new line or NULL.
189 static char* ReadLine(char *line
, char *buf
)
191 char *writeptr
= buf
, *readptr
= line
;
193 while (*readptr
!= 0 && *readptr
!= '\r' && *readptr
!= '\n') *(writeptr
++) = *(readptr
++);
195 while (*readptr
== '\r' || *readptr
== '\n') readptr
++;
196 if (*readptr
== 0) return NULL
;
201 static wxString
SafeFileName(const wxString
& s
)
204 res
.Replace(":", "_", TRUE
);
205 res
.Replace(" ", "_", TRUE
);
206 res
.Replace("/", "_", TRUE
);
207 res
.Replace("\\", "_", TRUE
);
208 res
.Replace("#", "_", TRUE
);
209 res
.Replace(".", "_", TRUE
);
214 static int IndexCompareFunc(const void *a
, const void *b
)
216 return strcmp(((HtmlContentsItem
*)a
) -> m_Name
, ((HtmlContentsItem
*)b
) -> m_Name
);
221 bool wxHtmlHelpController::AddBook(const wxString
& book
, bool show_wait_msg
)
226 HtmlBookRecord
*bookr
;
230 char *buff
, *lineptr
;
233 wxString title
= _("noname"),
235 start
= wxEmptyString
,
236 contents
= wxEmptyString
, index
= wxEmptyString
;
238 if (wxIsAbsolutePath(book
)) bookFull
= book
;
239 else bookFull
= wxGetCwd() + "/" + book
;
241 fi
= fsys
.OpenFile(bookFull
);
242 if (fi
== NULL
) return FALSE
;
243 fsys
.ChangePathTo(bookFull
);
244 s
= fi
-> GetStream();
246 buff
= new char[sz
+1];
252 while ((lineptr
= ReadLine(lineptr
, linebuf
)) != NULL
) {
253 if (strstr(linebuf
, "Title=") == linebuf
)
254 title
= linebuf
+ strlen("Title=");
255 if (strstr(linebuf
, "Default topic=") == linebuf
)
256 start
= linebuf
+ strlen("Default topic=");
257 if (strstr(linebuf
, "Index file=") == linebuf
)
258 index
= linebuf
+ strlen("Index file=");
259 if (strstr(linebuf
, "Contents file=") == linebuf
)
260 contents
= linebuf
+ strlen("Contents file=");
264 bookr
= new HtmlBookRecord(fsys
.GetPath(), title
, start
);
266 if (m_ContentsCnt
% HTML_REALLOC_STEP
== 0)
267 m_Contents
= (HtmlContentsItem
*) realloc(m_Contents
, (m_ContentsCnt
+ HTML_REALLOC_STEP
) * sizeof(HtmlContentsItem
));
268 m_Contents
[m_ContentsCnt
].m_Level
= 0;
269 m_Contents
[m_ContentsCnt
].m_ID
= 0;
270 m_Contents
[m_ContentsCnt
].m_Page
= new char[start
.Length() + 1];
271 strcpy(m_Contents
[m_ContentsCnt
].m_Page
, start
.c_str());
272 m_Contents
[m_ContentsCnt
].m_Name
= new char [title
.Length() + 1];
273 strcpy(m_Contents
[m_ContentsCnt
].m_Name
, title
.c_str());
274 m_Contents
[m_ContentsCnt
].m_Book
= bookr
;
277 // Try to find cached binary versions:
278 safetitle
= SafeFileName(title
);
279 fi
= fsys
.OpenFile(safetitle
+ ".cached");
280 if (fi
== NULL
) fi
= fsys
.OpenFile(m_TempPath
+ safetitle
+ ".cached");
281 if ((fi
== NULL
) || (m_TempPath
== wxEmptyString
)) {
282 LoadMSProject(bookr
, fsys
, index
, contents
, show_wait_msg
);
283 if (m_TempPath
!= wxEmptyString
) {
284 wxFileOutputStream
*outs
= new wxFileOutputStream(m_TempPath
+ safetitle
+ ".cached");
285 SaveCachedBook(bookr
, outs
);
290 LoadCachedBook(bookr
, fi
-> GetStream());
294 m_BookRecords
.Add(bookr
);
296 qsort(m_Index
, m_IndexCnt
, sizeof(HtmlContentsItem
), IndexCompareFunc
);
304 void wxHtmlHelpController::Display(const wxString
& x
)
313 /* 1. try to open given file: */
315 cnt
= m_BookRecords
.GetCount();
316 for (i
= 0; i
< cnt
; i
++) {
317 f
= fsys
.OpenFile(m_BookRecords
[i
].GetBasePath() + x
);
319 m_HtmlWin
-> LoadPage(m_BookRecords
[i
].GetBasePath() + x
);
326 /* 2. try to find a book: */
328 for (i
= 0; i
< cnt
; i
++) {
329 if (m_BookRecords
[i
].GetTitle() == x
) {
330 m_HtmlWin
-> LoadPage(m_BookRecords
[i
].GetBasePath() + m_BookRecords
[i
].GetStart());
335 /* 3. try to find in contents: */
338 for (i
= 0; i
< cnt
; i
++) {
339 if (strcmp(m_Contents
[i
].m_Name
, x
) == 0) {
340 m_HtmlWin
-> LoadPage(m_Contents
[i
].m_Book
-> GetBasePath() + m_Contents
[i
].m_Page
);
346 /* 4. try to find in index: */
349 for (i
= 0; i
< cnt
; i
++) {
350 if (strcmp(m_Index
[i
].m_Name
, x
) == 0) {
351 m_HtmlWin
-> LoadPage(m_Index
[i
].m_Book
-> GetBasePath() + m_Index
[i
].m_Page
);
357 /* 5. if everything failed, search the documents: */
364 void wxHtmlHelpController::Display(const int id
)
368 for (int i
= 0; i
< m_ContentsCnt
; i
++) {
369 if (m_Contents
[i
].m_ID
== id
) {
370 m_HtmlWin
-> LoadPage(m_Contents
[i
].m_Book
-> GetBasePath() + m_Contents
[i
].m_Page
);
378 void wxHtmlHelpController::DisplayContents()
382 if (!m_Splitter
-> IsSplit()) {
383 m_NavigPan
-> Show(TRUE
);
384 m_HtmlWin
-> Show(TRUE
);
385 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
387 m_NavigPan
-> SetSelection(0);
392 void wxHtmlHelpController::DisplayIndex()
396 if (!m_Splitter
-> IsSplit()) {
397 m_NavigPan
-> Show(TRUE
);
398 m_HtmlWin
-> Show(TRUE
);
399 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
401 m_NavigPan
-> SetSelection(1);
407 #if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
409 class MyProgressDlg
: public wxDialog
414 MyProgressDlg(wxWindow
*parent
) : wxDialog(parent
, -1,
422 {m_Canceled
= FALSE
;}
423 void OnCancel(wxCommandEvent
& event
) {m_Canceled
= TRUE
;}
424 DECLARE_EVENT_TABLE()
426 BEGIN_EVENT_TABLE(MyProgressDlg
, wxDialog
)
427 EVT_BUTTON(wxID_CANCEL
, MyProgressDlg::OnCancel
)
433 bool wxHtmlHelpController::KeywordSearch(const wxString
& keyword
)
439 if (!m_Splitter
-> IsSplit()) {
440 m_NavigPan
-> Show(TRUE
);
441 m_HtmlWin
-> Show(TRUE
);
442 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
444 m_NavigPan
-> SetSelection(2);
445 m_SearchList
-> Clear();
446 m_SearchText
-> SetValue(keyword
);
447 m_SearchButton
-> Enable(FALSE
);
450 int cnt
= m_ContentsCnt
;
451 wxSearchEngine engine
;
454 wxString lastpage
= wxEmptyString
;
457 #if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
458 MyProgressDlg
progress(m_Frame
);
460 wxStaticText
*prompt
= new wxStaticText(&progress
, -1, "", wxPoint(20, 50), wxSize(260, 25), wxALIGN_CENTER
);
461 wxGauge
*gauge
= new wxGauge(&progress
, -1, cnt
, wxPoint(20, 20), wxSize(260, 25));
462 wxButton
*btn
= new wxButton(&progress
, wxID_CANCEL
, _("Cancel"), wxPoint(110, 70), wxSize(80, 25));
463 btn
= btn
; /* fool compiler :-) */
464 prompt
-> SetLabel(_("No matching page found yet"));
466 progress
.Centre(wxBOTH
);
469 wxProgressDialog
progress(_("Searching..."), _("No matching page found yet"), cnt
, m_Frame
, wxPD_APP_MODAL
| wxPD_CAN_ABORT
| wxPD_AUTO_HIDE
);
472 engine
.LookFor(keyword
);
474 for (int i
= 0; i
< cnt
; i
++) {
475 #if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
476 gauge
-> SetValue(i
);
477 if (progress
.m_Canceled
) break;
479 if (progress
.Update(i
) == FALSE
) break;
483 file
= fsys
.OpenFile(m_Contents
[i
].m_Book
-> GetBasePath() + m_Contents
[i
].m_Page
);
485 if (lastpage
!= file
-> GetLocation()) {
486 lastpage
= file
-> GetLocation();
487 if (engine
.Scan(file
-> GetStream())) {
488 foundstr
.Printf(_("Found %i matches"), ++foundcnt
);
489 #if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
490 prompt
-> SetLabel(foundstr
);
492 progress
.Update(i
, foundstr
);
495 m_SearchList
-> Append(m_Contents
[i
].m_Name
, (char*)(m_Contents
+ i
));
502 #if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
503 progress
.Close(TRUE
);
507 m_SearchButton
-> Enable(TRUE
);
508 m_SearchText
-> SetSelection(0, keyword
.Length());
509 m_SearchText
-> SetFocus();
511 HtmlContentsItem
*it
= (HtmlContentsItem
*) m_SearchList
-> GetClientData(0);
512 if (it
) m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
514 return (foundcnt
> 0);
522 void wxHtmlHelpController::CreateHelpWindow()
530 m_Frame
-> Show(TRUE
);
535 wxBusyInfo
busyinfo(_("Preparing help window..."));
538 if (m_Config
) ReadCustomization(m_Config
, m_ConfigRoot
);
540 m_Frame
= new wxFrame(NULL
, -1, "", wxPoint(m_Cfg
.x
, m_Cfg
.y
), wxSize(m_Cfg
.w
, m_Cfg
.h
));
541 m_Frame
-> PushEventHandler(this);
542 sbar
= m_Frame
-> CreateStatusBar();
546 toolBar
= m_Frame
-> CreateToolBar(wxNO_BORDER
| wxTB_HORIZONTAL
| wxTB_FLAT
| wxTB_DOCKABLE
);
547 toolBar
-> SetMargins(2, 2);
548 wxBitmap
* toolBarBitmaps
[3];
551 toolBarBitmaps
[0] = new wxBitmap("panel");
552 toolBarBitmaps
[1] = new wxBitmap("back");
553 toolBarBitmaps
[2] = new wxBitmap("forward");
556 toolBarBitmaps
[0] = new wxBitmap(panel_xpm
);
557 toolBarBitmaps
[1] = new wxBitmap(back_xpm
);
558 toolBarBitmaps
[2] = new wxBitmap(forward_xpm
);
564 toolBar
-> AddTool(wxID_HTML_PANEL
, *(toolBarBitmaps
[0]), wxNullBitmap
, FALSE
, currentX
, -1, (wxObject
*) NULL
, _("Show/hide navigation panel"));
565 currentX
+= width
+ 5;
566 toolBar
-> AddSeparator();
567 toolBar
-> AddTool(wxID_HTML_BACK
, *(toolBarBitmaps
[1]), wxNullBitmap
, FALSE
, currentX
, -1, (wxObject
*) NULL
, _("Go back to the previous HTML page"));
568 currentX
+= width
+ 5;
569 toolBar
-> AddTool(wxID_HTML_FORWARD
, *(toolBarBitmaps
[2]), wxNullBitmap
, FALSE
, currentX
, -1, (wxObject
*) NULL
, _("Go forward to the next HTML page"));
570 currentX
+= width
+ 5;
572 toolBar
-> Realize();
574 // Can delete the bitmaps since they're reference counted
575 for (int i
= 0; i
< 3; i
++) delete toolBarBitmaps
[i
];
580 m_Splitter
= new wxSplitterWindow(m_Frame
);
582 m_HtmlWin
= new wxHtmlWindow(m_Splitter
);
583 m_HtmlWin
-> SetRelatedFrame(m_Frame
, m_TitleFormat
);
584 m_HtmlWin
-> SetRelatedStatusBar(0);
585 if (m_Config
) m_HtmlWin
-> ReadCustomization(m_Config
, m_ConfigRoot
);
587 m_NavigPan
= new wxNotebook(m_Splitter
, wxID_HTML_NOTEBOOK
, wxDefaultPosition
, wxDefaultSize
);
589 m_ContentsBox
= new wxTreeCtrl(m_NavigPan
, wxID_HTML_TREECTRL
, wxDefaultPosition
, wxDefaultSize
, wxTR_HAS_BUTTONS
| wxSUNKEN_BORDER
);
590 m_ContentsBox
-> SetImageList(m_ContentsImageList
);
591 m_NavigPan
-> AddPage(m_ContentsBox
, _("Contents"));
595 wxWindow
*dummy
= new wxPanel(m_NavigPan
, wxID_HTML_INDEXPAGE
);
596 wxLayoutConstraints
*b1
= new wxLayoutConstraints
;
597 b1
-> top
.SameAs (dummy
, wxTop
, 0);
598 b1
-> left
.SameAs (dummy
, wxLeft
, 0);
599 b1
-> width
.PercentOf (dummy
, wxWidth
, 100);
600 b1
-> bottom
.SameAs (dummy
, wxBottom
, 0);
601 m_IndexBox
= new wxListBox(dummy
, wxID_HTML_INDEXLIST
, wxDefaultPosition
, wxDefaultSize
, 0);
602 m_IndexBox
-> SetConstraints(b1
);
603 dummy
-> SetAutoLayout(TRUE
);
604 m_NavigPan
-> AddPage(dummy
, _("Index"));
608 wxWindow
*dummy
= new wxPanel(m_NavigPan
, wxID_HTML_SEARCHPAGE
);
610 wxLayoutConstraints
*b1
= new wxLayoutConstraints
;
611 m_SearchText
= new wxTextCtrl(dummy
, wxID_HTML_SEARCHTEXT
);
612 b1
-> top
.SameAs (dummy
, wxTop
, 0);
613 b1
-> left
.SameAs (dummy
, wxLeft
, 0);
614 b1
-> right
.SameAs (dummy
, wxRight
, 0);
616 m_SearchText
-> SetConstraints(b1
);
618 wxLayoutConstraints
*b2
= new wxLayoutConstraints
;
619 m_SearchButton
= new wxButton(dummy
, wxID_HTML_SEARCHBUTTON
, _("Search!"));
620 b2
-> top
.Below (m_SearchText
, 10);
621 b2
-> right
.SameAs (dummy
, wxRight
, 10);
624 m_SearchButton
-> SetConstraints(b2
);
626 wxLayoutConstraints
*b3
= new wxLayoutConstraints
;
627 m_SearchList
= new wxListBox(dummy
, wxID_HTML_SEARCHLIST
, wxDefaultPosition
, wxDefaultSize
, 0);
628 b3
-> top
.Below (m_SearchButton
, 10);
629 b3
-> left
.SameAs (dummy
, wxLeft
, 0);
630 b3
-> right
.SameAs (dummy
, wxRight
, 0);
631 b3
-> bottom
.SameAs (dummy
, wxBottom
, 0);
632 m_SearchList
-> SetConstraints(b3
);
634 dummy
-> SetAutoLayout(TRUE
);
636 m_NavigPan
-> AddPage(dummy
, _("Search"));
640 m_NavigPan
-> Show(TRUE
);
641 m_HtmlWin
-> Show(TRUE
);
642 m_Splitter
-> SetMinimumPaneSize(20);
643 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
644 if (!m_Cfg
.navig_on
) m_Splitter
-> Unsplit(m_NavigPan
);
648 m_Frame
-> Show(TRUE
);
656 void wxHtmlHelpController::CreateContents()
658 HtmlContentsItem
*it
;
659 wxTreeItemId roots
[MAX_ROOTS
];
660 bool imaged
[MAX_ROOTS
];
661 int count
= m_ContentsCnt
;
663 m_ContentsBox
-> DeleteAllItems();
664 roots
[0] = m_ContentsBox
-> AddRoot(_("(Help)"));
667 for (int i
= 0; i
< count
; i
++) {
669 roots
[it
-> m_Level
+ 1] = m_ContentsBox
-> AppendItem(roots
[it
-> m_Level
], it
-> m_Name
, IMG_Page
, -1, new HtmlHelpTreeItemData(it
));
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
);
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
;
685 m_ContentsBox
-> Expand(roots
[0]);
691 void wxHtmlHelpController::CreateIndex()
693 m_IndexBox
-> Clear();
695 for (int i
= 0; i
< m_IndexCnt
; i
++)
696 m_IndexBox
-> Append(m_Index
[i
].m_Name
, (char*)(m_Index
+ i
));
701 void wxHtmlHelpController::RefreshLists()
706 m_SearchList
-> Clear();
716 void wxHtmlHelpController::ReadCustomization(wxConfigBase
*cfg
, wxString path
)
721 if (path
!= wxEmptyString
) {
722 oldpath
= cfg
-> GetPath();
723 cfg
-> SetPath(path
);
726 m_Cfg
.navig_on
= cfg
-> Read("hcNavigPanel", m_Cfg
.navig_on
) != 0;
727 m_Cfg
.sashpos
= cfg
-> Read("hcSashPos", m_Cfg
.sashpos
);
728 m_Cfg
.x
= cfg
-> Read("hcX", m_Cfg
.x
);
729 m_Cfg
.y
= cfg
-> Read("hcY", m_Cfg
.y
);
730 m_Cfg
.w
= cfg
-> Read("hcW", m_Cfg
.w
);
731 m_Cfg
.h
= cfg
-> Read("hcH", m_Cfg
.h
);
733 if (path
!= wxEmptyString
)
734 cfg
-> SetPath(oldpath
);
739 void wxHtmlHelpController::WriteCustomization(wxConfigBase
*cfg
, wxString path
)
744 if (path
!= wxEmptyString
) {
745 oldpath
= cfg
-> GetPath();
746 cfg
-> SetPath(path
);
749 cfg
-> Write("hcNavigPanel", m_Cfg
.navig_on
);
750 cfg
-> Write("hcSashPos", (long)m_Cfg
.sashpos
);
751 cfg
-> Write("hcX", (long)m_Cfg
.x
);
752 cfg
-> Write("hcY", (long)m_Cfg
.y
);
753 cfg
-> Write("hcW", (long)m_Cfg
.w
);
754 cfg
-> Write("hcH", (long)m_Cfg
.h
);
756 if (path
!= wxEmptyString
)
757 cfg
-> SetPath(oldpath
);
769 void wxHtmlHelpController::OnToolbar(wxCommandEvent
& event
)
771 switch (event
.GetId()) {
772 case wxID_HTML_BACK
:
773 m_HtmlWin
-> HistoryBack();
775 case wxID_HTML_FORWARD
:
776 m_HtmlWin
-> HistoryForward();
778 case wxID_HTML_PANEL
:
779 if (m_Splitter
-> IsSplit()) {
780 m_Cfg
.sashpos
= m_Splitter
-> GetSashPosition();
781 m_Splitter
-> Unsplit(m_NavigPan
);
784 m_NavigPan
-> Show(TRUE
);
785 m_HtmlWin
-> Show(TRUE
);
786 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
794 void wxHtmlHelpController::OnContentsSel(wxTreeEvent
& event
)
796 HtmlHelpTreeItemData
*pg
;
798 pg
= (HtmlHelpTreeItemData
*) m_ContentsBox
-> GetItemData(event
.GetItem());
799 if (pg
) m_HtmlWin
-> LoadPage(pg
-> GetPage());
804 void wxHtmlHelpController::OnIndexSel(wxCommandEvent
& event
)
806 HtmlContentsItem
*it
= (HtmlContentsItem
*) m_IndexBox
-> GetClientData(m_IndexBox
-> GetSelection());
807 if (it
) m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
812 void wxHtmlHelpController::OnSearchSel(wxCommandEvent
& event
)
814 HtmlContentsItem
*it
= (HtmlContentsItem
*) m_SearchList
-> GetClientData(m_SearchList
-> GetSelection());
815 if (it
) m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
820 void wxHtmlHelpController::OnCloseWindow(wxCloseEvent
& event
)
824 m_Cfg
.navig_on
= m_Splitter
-> IsSplit();
826 m_Cfg
.sashpos
= m_Splitter
-> GetSashPosition();
827 m_Frame
-> GetPosition(&a
, &b
);
828 m_Cfg
.x
= a
, m_Cfg
.y
= b
;
829 m_Frame
-> GetSize(&a
, &b
);
830 m_Cfg
.w
= a
, m_Cfg
.h
= b
;
833 WriteCustomization(m_Config
, m_ConfigRoot
);
834 m_HtmlWin
-> WriteCustomization(m_Config
, m_ConfigRoot
);
843 void wxHtmlHelpController::OnSearch(wxCommandEvent
& event
)
845 wxString sr
= m_SearchText
-> GetLineText(0);
847 if (sr
!= wxEmptyString
) KeywordSearch(sr
);
852 BEGIN_EVENT_TABLE(wxHtmlHelpController
, wxEvtHandler
)
853 EVT_TOOL_RANGE(wxID_HTML_PANEL
, wxID_HTML_FORWARD
, wxHtmlHelpController::OnToolbar
)
854 EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL
, wxHtmlHelpController::OnContentsSel
)
855 EVT_LISTBOX(wxID_HTML_INDEXLIST
, wxHtmlHelpController::OnIndexSel
)
856 EVT_LISTBOX(wxID_HTML_SEARCHLIST
, wxHtmlHelpController::OnSearchSel
)
857 EVT_CLOSE(wxHtmlHelpController::OnCloseWindow
)
858 EVT_BUTTON(wxID_HTML_SEARCHBUTTON
, wxHtmlHelpController::OnSearch
)
859 EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT
, wxHtmlHelpController::OnSearch
)