]>
git.saurik.com Git - wxWidgets.git/blob - src/html/htmlhelp.cpp
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"
28 #include <wx/notebook.h>
29 #include <wx/imaglist.h>
30 #include <wx/treectrl.h>
31 #include <wx/tokenzr.h>
32 #include <wx/wfstream.h>
33 #include <wx/html/htmlwin.h>
34 #include <wx/html/htmlhelp.h>
35 #include <wx/busyinfo.h>
37 #if !((wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7)))
38 #include <wx/progdlg.h>
45 #include "bitmaps/panel.xpm"
46 #include "bitmaps/back.xpm"
47 #include "bitmaps/forward.xpm"
48 #include "bitmaps/book.xpm"
49 #include "bitmaps/folder.xpm"
50 #include "bitmaps/page.xpm"
58 #include <wx/arrimpl.cpp>
59 WX_DEFINE_OBJARRAY ( HtmlBookRecArray
)
69 //-----------------------------------------------------------------------------
70 // wxHtmlHelpController
71 //-----------------------------------------------------------------------------
74 IMPLEMENT_DYNAMIC_CLASS ( wxHtmlHelpController
, wxEvtHandler
)
77 wxHtmlHelpController :: wxHtmlHelpController () : wxEvtHandler ()
81 m_ConfigRoot
= wxEmptyString
;
82 m_TitleFormat
= _ ( "Help : %s " );
83 m_TempPath
= wxEmptyString
;
85 m_Cfg
. x
= m_Cfg
. y
= 0 ;
86 m_Cfg
. w
= 700 ; m_Cfg
. h
= 480 ;
88 m_Cfg
. navig_on
= TRUE
;
90 m_ContentsImageList
= new wxImageList ( 12 , 12 );
91 m_ContentsImageList
-> Add ( wxICON ( book
));
92 m_ContentsImageList
-> Add ( wxICON ( folder
));
93 m_ContentsImageList
-> Add ( wxICON ( page
));
101 m_ContentsBox
= NULL
;
104 m_SearchButton
= NULL
;
112 wxHtmlHelpController ::~ wxHtmlHelpController ()
116 m_BookRecords
. Empty ();
117 delete m_ContentsImageList
;
119 for ( i
= 0 ; i
< m_ContentsCnt
; i
++) {
120 delete [] m_Contents
[ i
]. m_Page
;
121 delete [] m_Contents
[ i
]. m_Name
;
126 for ( i
= 0 ; i
< m_IndexCnt
; i
++) {
127 delete [] m_Index
[ i
]. m_Page
;
128 delete [] m_Index
[ i
]. m_Name
;
136 void wxHtmlHelpController :: SetTempDir ( const wxString
& path
)
138 if ( path
== wxEmptyString
) m_TempPath
= path
;
140 if ( wxIsAbsolutePath ( path
)) m_TempPath
= path
;
141 else m_TempPath
= wxGetCwd () + "/" + path
;
143 if ( m_TempPath
[ m_TempPath
. Length () - 1 ] != '/' )
151 // Reads one line, stores it into buf and returns pointer to new line or NULL.
152 static char * ReadLine ( char * line
, char * buf
)
154 char * writeptr
= buf
, * readptr
= line
;
156 while (* readptr
!= 0 && * readptr
!= ' \r ' && * readptr
!= ' \n ' ) *( writeptr
++) = *( readptr
++);
158 while (* readptr
== ' \r ' || * readptr
== ' \n ' ) readptr
++;
159 if (* readptr
== 0 ) return NULL
;
164 static wxString
SafeFileName ( const wxString
& s
)
167 res
. Replace ( _T ( ":" ), _T ( "_" ), TRUE
);
168 res
. Replace ( _T ( " " ), _T ( "_" ), TRUE
);
169 res
. Replace ( _T ( "/" ), _T ( "_" ), TRUE
);
170 res
. Replace ( _T ( " \\ " ), _T ( "_" ), TRUE
);
171 res
. Replace ( _T ( "#" ), _T ( "_" ), TRUE
);
172 res
. Replace ( _T ( "." ), _T ( "_" ), TRUE
);
177 static int IndexCompareFunc ( const void * a
, const void * b
)
179 return strcmp ((( HtmlContentsItem
*) a
) -> m_Name
, (( HtmlContentsItem
*) b
) -> m_Name
);
184 bool wxHtmlHelpController :: AddBook ( const wxString
& book
, bool show_wait_msg
)
189 HtmlBookRecord
* bookr
;
193 char * buff
, * lineptr
;
196 wxString title
= _ ( "noname" ),
198 start
= wxEmptyString
,
199 contents
= wxEmptyString
, index
= wxEmptyString
;
201 if ( wxIsAbsolutePath ( book
)) bookFull
= book
;
202 else bookFull
= wxGetCwd () + "/" + book
;
204 fi
= fsys
. OpenFile ( bookFull
);
205 if ( fi
== NULL
) return FALSE
;
206 fsys
. ChangePathTo ( bookFull
);
207 s
= fi
-> GetStream ();
209 buff
= new char [ sz
+ 1 ];
215 while (( lineptr
= ReadLine ( lineptr
, linebuf
)) != NULL
) {
216 if ( strstr ( linebuf
, "Title=" ) == linebuf
)
217 title
= linebuf
+ strlen ( "Title=" );
218 if ( strstr ( linebuf
, "Default topic=" ) == linebuf
)
219 start
= linebuf
+ strlen ( "Default topic=" );
220 if ( strstr ( linebuf
, "Index file=" ) == linebuf
)
221 index
= linebuf
+ strlen ( "Index file=" );
222 if ( strstr ( linebuf
, "Contents file=" ) == linebuf
)
223 contents
= linebuf
+ strlen ( "Contents file=" );
227 bookr
= new HtmlBookRecord ( fsys
. GetPath (), title
, start
);
229 if ( m_ContentsCnt
% HTML_REALLOC_STEP
== 0 )
230 m_Contents
= ( HtmlContentsItem
*) realloc ( m_Contents
, ( m_ContentsCnt
+ HTML_REALLOC_STEP
) * sizeof ( HtmlContentsItem
));
231 m_Contents
[ m_ContentsCnt
]. m_Level
= 0 ;
232 m_Contents
[ m_ContentsCnt
]. m_ID
= 0 ;
233 m_Contents
[ m_ContentsCnt
]. m_Page
= new char [ start
. Length () + 1 ];
234 strcpy ( m_Contents
[ m_ContentsCnt
]. m_Page
, start
. c_str ());
235 m_Contents
[ m_ContentsCnt
]. m_Name
= new char [ title
. Length () + 1 ];
236 strcpy ( m_Contents
[ m_ContentsCnt
]. m_Name
, title
. c_str ());
237 m_Contents
[ m_ContentsCnt
]. m_Book
= bookr
;
240 // Try to find cached binary versions:
241 safetitle
= SafeFileName ( title
);
242 fi
= fsys
. OpenFile ( safetitle
+ ".cached" );
243 if ( fi
== NULL
) fi
= fsys
. OpenFile ( m_TempPath
+ safetitle
+ ".cached" );
244 if (( fi
== NULL
) || ( m_TempPath
== wxEmptyString
)) {
245 LoadMSProject ( bookr
, fsys
, index
, contents
, show_wait_msg
);
246 if ( m_TempPath
!= wxEmptyString
) {
247 wxFileOutputStream
* outs
= new wxFileOutputStream ( m_TempPath
+ safetitle
+ ".cached" );
248 SaveCachedBook ( bookr
, outs
);
253 LoadCachedBook ( bookr
, fi
-> GetStream ());
257 m_BookRecords
. Add ( bookr
);
259 qsort ( m_Index
, m_IndexCnt
, sizeof ( HtmlContentsItem
), IndexCompareFunc
);
267 void wxHtmlHelpController :: Display ( const wxString
& x
)
276 /* 1. try to open given file: */
278 cnt
= m_BookRecords
. GetCount ();
279 for ( i
= 0 ; i
< cnt
; i
++) {
280 f
= fsys
. OpenFile ( m_BookRecords
[ i
]. GetBasePath () + x
);
282 m_HtmlWin
-> LoadPage ( m_BookRecords
[ i
]. GetBasePath () + x
);
289 /* 2. try to find a book: */
291 for ( i
= 0 ; i
< cnt
; i
++) {
292 if ( m_BookRecords
[ i
]. GetTitle () == x
) {
293 m_HtmlWin
-> LoadPage ( m_BookRecords
[ i
]. GetBasePath () + m_BookRecords
[ i
]. GetStart ());
298 /* 3. try to find in contents: */
301 for ( i
= 0 ; i
< cnt
; i
++) {
302 if ( strcmp ( m_Contents
[ i
]. m_Name
, x
) == 0 ) {
303 m_HtmlWin
-> LoadPage ( m_Contents
[ i
]. m_Book
-> GetBasePath () + m_Contents
[ i
]. m_Page
);
309 /* 4. try to find in index: */
312 for ( i
= 0 ; i
< cnt
; i
++) {
313 if ( strcmp ( m_Index
[ i
]. m_Name
, x
) == 0 ) {
314 m_HtmlWin
-> LoadPage ( m_Index
[ i
]. m_Book
-> GetBasePath () + m_Index
[ i
]. m_Page
);
320 /* 5. if everything failed, search the documents: */
327 void wxHtmlHelpController :: Display ( const int id
)
331 for ( int i
= 0 ; i
< m_ContentsCnt
; i
++) {
332 if ( m_Contents
[ i
]. m_ID
== id
) {
333 m_HtmlWin
-> LoadPage ( m_Contents
[ i
]. m_Book
-> GetBasePath () + m_Contents
[ i
]. m_Page
);
341 void wxHtmlHelpController :: DisplayContents ()
345 if (! m_Splitter
-> IsSplit ()) {
346 m_NavigPan
-> Show ( TRUE
);
347 m_HtmlWin
-> Show ( TRUE
);
348 m_Splitter
-> SplitVertically ( m_NavigPan
, m_HtmlWin
, m_Cfg
. sashpos
);
350 m_NavigPan
-> SetSelection ( 0 );
355 void wxHtmlHelpController :: DisplayIndex ()
359 if (! m_Splitter
-> IsSplit ()) {
360 m_NavigPan
-> Show ( TRUE
);
361 m_HtmlWin
-> Show ( TRUE
);
362 m_Splitter
-> SplitVertically ( m_NavigPan
, m_HtmlWin
, m_Cfg
. sashpos
);
364 m_NavigPan
-> SetSelection ( 1 );
370 #if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
372 class MyProgressDlg
: public wxDialog
377 MyProgressDlg ( wxWindow
* parent
) : wxDialog ( parent
, - 1 ,
385 { m_Canceled
= FALSE
;}
386 void OnCancel ( wxCommandEvent
& event
) { m_Canceled
= TRUE
;}
387 DECLARE_EVENT_TABLE ()
389 BEGIN_EVENT_TABLE ( MyProgressDlg
, wxDialog
)
390 EVT_BUTTON ( wxID_CANCEL
, MyProgressDlg :: OnCancel
)
396 bool wxHtmlHelpController :: KeywordSearch ( const wxString
& keyword
)
400 // if these are not set, we can't continue
401 if (! ( m_SearchList
&& m_HtmlWin
))
404 if ( m_Splitter
&& m_NavigPan
&& m_SearchButton
) {
405 if (! m_Splitter
-> IsSplit ()) {
406 m_NavigPan
-> Show ( TRUE
);
407 m_HtmlWin
-> Show ( TRUE
);
408 m_Splitter
-> SplitVertically ( m_NavigPan
, m_HtmlWin
, m_Cfg
. sashpos
);
410 m_NavigPan
-> SetSelection ( 2 );
411 m_SearchList
-> Clear ();
412 m_SearchText
-> SetValue ( keyword
);
413 m_SearchButton
-> Enable ( FALSE
);
416 int cnt
= m_ContentsCnt
;
417 wxSearchEngine engine
;
420 wxString lastpage
= wxEmptyString
;
423 #if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
424 MyProgressDlg
progress ( m_Frame
);
426 wxStaticText
* prompt
= new wxStaticText (& progress
, - 1 , "" , wxPoint ( 20 , 50 ), wxSize ( 260 , 25 ), wxALIGN_CENTER
);
427 wxGauge
* gauge
= new wxGauge (& progress
, - 1 , cnt
, wxPoint ( 20 , 20 ), wxSize ( 260 , 25 ));
428 wxButton
* btn
= new wxButton (& progress
, wxID_CANCEL
, _ ( "Cancel" ), wxPoint ( 110 , 70 ), wxSize ( 80 , 25 ));
429 btn
= btn
; /* fool compiler :-) */
430 prompt
-> SetLabel ( _ ( "No matching page found yet" ));
432 progress
. Centre ( wxBOTH
);
435 wxProgressDialog
progress ( _ ( "Searching..." ), _ ( "No matching page found yet" ), cnt
, m_Frame
, wxPD_APP_MODAL
| wxPD_CAN_ABORT
| wxPD_AUTO_HIDE
);
438 engine
. LookFor ( keyword
);
440 for ( int i
= 0 ; i
< cnt
; i
++) {
441 #if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
442 gauge
-> SetValue ( i
);
443 if ( progress
. m_Canceled
) break ;
445 if ( progress
. Update ( i
) == FALSE
) break ;
449 file
= fsys
. OpenFile ( m_Contents
[ i
]. m_Book
-> GetBasePath () + m_Contents
[ i
]. m_Page
);
451 if ( lastpage
!= file
-> GetLocation ()) {
452 lastpage
= file
-> GetLocation ();
453 if ( engine
. Scan ( file
-> GetStream ())) {
454 foundstr
. Printf ( _ ( "Found %i matches" ), ++ foundcnt
);
455 #if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
456 prompt
-> SetLabel ( foundstr
);
458 progress
. Update ( i
, foundstr
);
461 m_SearchList
-> Append ( m_Contents
[ i
]. m_Name
, ( char *)( m_Contents
+ i
));
468 #if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
469 progress
. Close ( TRUE
);
473 m_SearchButton
-> Enable ( TRUE
);
475 m_SearchText
-> SetSelection ( 0 , keyword
. Length ());
476 m_SearchText
-> SetFocus ();
479 HtmlContentsItem
* it
= ( HtmlContentsItem
*) m_SearchList
-> GetClientData ( 0 );
480 if ( it
) m_HtmlWin
-> LoadPage ( it
-> m_Book
-> GetBasePath () + it
-> m_Page
);
482 return ( foundcnt
> 0 );
490 void wxHtmlHelpController :: CreateHelpWindow ()
498 m_Frame
-> Show ( TRUE
);
503 wxBusyInfo
busyinfo ( _ ( "Preparing help window..." ));
506 if ( m_Config
) ReadCustomization ( m_Config
, m_ConfigRoot
);
508 m_Frame
= new wxFrame ( NULL
, - 1 , "" , wxPoint ( m_Cfg
. x
, m_Cfg
. y
), wxSize ( m_Cfg
. w
, m_Cfg
. h
));
509 m_Frame
-> PushEventHandler ( this );
510 sbar
= m_Frame
-> CreateStatusBar ();
514 toolBar
= m_Frame
-> CreateToolBar ( wxNO_BORDER
| wxTB_HORIZONTAL
| wxTB_FLAT
| wxTB_DOCKABLE
);
515 toolBar
-> SetMargins ( 2 , 2 );
516 wxBitmap
* toolBarBitmaps
[ 3 ];
519 toolBarBitmaps
[ 0 ] = new wxBitmap ( "panel" );
520 toolBarBitmaps
[ 1 ] = new wxBitmap ( "back" );
521 toolBarBitmaps
[ 2 ] = new wxBitmap ( "forward" );
524 toolBarBitmaps
[ 0 ] = new wxBitmap ( panel_xpm
);
525 toolBarBitmaps
[ 1 ] = new wxBitmap ( back_xpm
);
526 toolBarBitmaps
[ 2 ] = new wxBitmap ( forward_xpm
);
532 toolBar
-> AddTool ( wxID_HTML_PANEL
, *( toolBarBitmaps
[ 0 ]), wxNullBitmap
, FALSE
, currentX
, - 1 , ( wxObject
*) NULL
, _ ( "Show/hide navigation panel" ));
533 currentX
+= width
+ 5 ;
534 toolBar
-> AddSeparator ();
535 toolBar
-> AddTool ( wxID_HTML_BACK
, *( toolBarBitmaps
[ 1 ]), wxNullBitmap
, FALSE
, currentX
, - 1 , ( wxObject
*) NULL
, _ ( "Go back to the previous HTML page" ));
536 currentX
+= width
+ 5 ;
537 toolBar
-> AddTool ( wxID_HTML_FORWARD
, *( toolBarBitmaps
[ 2 ]), wxNullBitmap
, FALSE
, currentX
, - 1 , ( wxObject
*) NULL
, _ ( "Go forward to the next HTML page" ));
538 currentX
+= width
+ 5 ;
540 toolBar
-> Realize ();
542 // Can delete the bitmaps since they're reference counted
543 for ( int i
= 0 ; i
< 3 ; i
++) delete toolBarBitmaps
[ i
];
548 m_Splitter
= new wxSplitterWindow ( m_Frame
);
550 m_HtmlWin
= new wxHtmlWindow ( m_Splitter
);
551 m_HtmlWin
-> SetRelatedFrame ( m_Frame
, m_TitleFormat
);
552 m_HtmlWin
-> SetRelatedStatusBar ( 0 );
553 if ( m_Config
) m_HtmlWin
-> ReadCustomization ( m_Config
, m_ConfigRoot
);
555 m_NavigPan
= new wxNotebook ( m_Splitter
, wxID_HTML_NOTEBOOK
, wxDefaultPosition
, wxDefaultSize
);
557 m_ContentsBox
= new wxTreeCtrl ( m_NavigPan
, wxID_HTML_TREECTRL
, wxDefaultPosition
, wxDefaultSize
, wxTR_HAS_BUTTONS
| wxSUNKEN_BORDER
);
558 m_ContentsBox
-> SetImageList ( m_ContentsImageList
);
559 m_NavigPan
-> AddPage ( m_ContentsBox
, _ ( "Contents" ));
563 wxWindow
* dummy
= new wxPanel ( m_NavigPan
, wxID_HTML_INDEXPAGE
);
564 wxLayoutConstraints
* b1
= new wxLayoutConstraints
;
565 b1
-> top
. SameAs ( dummy
, wxTop
, 0 );
566 b1
-> left
. SameAs ( dummy
, wxLeft
, 0 );
567 b1
-> width
. PercentOf ( dummy
, wxWidth
, 100 );
568 b1
-> bottom
. SameAs ( dummy
, wxBottom
, 0 );
569 m_IndexBox
= new wxListBox ( dummy
, wxID_HTML_INDEXLIST
, wxDefaultPosition
, wxDefaultSize
, 0 );
570 m_IndexBox
-> SetConstraints ( b1
);
571 dummy
-> SetAutoLayout ( TRUE
);
572 m_NavigPan
-> AddPage ( dummy
, _ ( "Index" ));
576 wxWindow
* dummy
= new wxPanel ( m_NavigPan
, wxID_HTML_SEARCHPAGE
);
578 wxLayoutConstraints
* b1
= new wxLayoutConstraints
;
579 m_SearchText
= new wxTextCtrl ( dummy
, wxID_HTML_SEARCHTEXT
);
580 b1
-> top
. SameAs ( dummy
, wxTop
, 0 );
581 b1
-> left
. SameAs ( dummy
, wxLeft
, 0 );
582 b1
-> right
. SameAs ( dummy
, wxRight
, 0 );
584 m_SearchText
-> SetConstraints ( b1
);
586 wxLayoutConstraints
* b2
= new wxLayoutConstraints
;
587 m_SearchButton
= new wxButton ( dummy
, wxID_HTML_SEARCHBUTTON
, _ ( "Search!" ));
588 b2
-> top
. Below ( m_SearchText
, 10 );
589 b2
-> right
. SameAs ( dummy
, wxRight
, 10 );
592 m_SearchButton
-> SetConstraints ( b2
);
594 wxLayoutConstraints
* b3
= new wxLayoutConstraints
;
595 m_SearchList
= new wxListBox ( dummy
, wxID_HTML_SEARCHLIST
, wxDefaultPosition
, wxDefaultSize
, 0 );
596 b3
-> top
. Below ( m_SearchButton
, 10 );
597 b3
-> left
. SameAs ( dummy
, wxLeft
, 0 );
598 b3
-> right
. SameAs ( dummy
, wxRight
, 0 );
599 b3
-> bottom
. SameAs ( dummy
, wxBottom
, 0 );
600 m_SearchList
-> SetConstraints ( b3
);
602 dummy
-> SetAutoLayout ( TRUE
);
604 m_NavigPan
-> AddPage ( dummy
, _ ( "Search" ));
608 m_NavigPan
-> Show ( TRUE
);
609 m_HtmlWin
-> Show ( TRUE
);
610 m_Splitter
-> SetMinimumPaneSize ( 20 );
611 m_Splitter
-> SplitVertically ( m_NavigPan
, m_HtmlWin
, m_Cfg
. sashpos
);
612 if (! m_Cfg
. navig_on
) m_Splitter
-> Unsplit ( m_NavigPan
);
616 m_Frame
-> Show ( TRUE
);
624 void wxHtmlHelpController :: CreateContents ()
626 HtmlContentsItem
* it
;
627 wxTreeItemId roots
[ MAX_ROOTS
];
628 bool imaged
[ MAX_ROOTS
];
629 int count
= m_ContentsCnt
;
631 m_ContentsBox
-> DeleteAllItems ();
632 roots
[ 0 ] = m_ContentsBox
-> AddRoot ( _ ( "(Help)" ));
635 for ( int i
= 0 ; i
< count
; i
++) {
637 roots
[ it
-> m_Level
+ 1 ] = m_ContentsBox
-> AppendItem ( roots
[ it
-> m_Level
], it
-> m_Name
, IMG_Page
, - 1 , new wxHtmlHelpTreeItemData ( it
));
638 if ( it
-> m_Level
== 0 ) {
639 m_ContentsBox
-> SetItemBold ( roots
[ 1 ], TRUE
);
640 m_ContentsBox
-> SetItemImage ( roots
[ 1 ], IMG_Book
);
641 m_ContentsBox
-> SetItemSelectedImage ( roots
[ 1 ], IMG_Book
);
644 else imaged
[ it
-> m_Level
+ 1 ] = FALSE
;
646 if (! imaged
[ it
-> m_Level
]) {
647 m_ContentsBox
-> SetItemImage ( roots
[ it
-> m_Level
], IMG_Folder
);
648 m_ContentsBox
-> SetItemSelectedImage ( roots
[ it
-> m_Level
], IMG_Folder
);
649 imaged
[ it
-> m_Level
] = TRUE
;
653 m_ContentsBox
-> Expand ( roots
[ 0 ]);
659 void wxHtmlHelpController :: CreateIndex ()
661 m_IndexBox
-> Clear ();
663 for ( int i
= 0 ; i
< m_IndexCnt
; i
++)
664 m_IndexBox
-> Append ( m_Index
[ i
]. m_Name
, ( char *)( m_Index
+ i
));
669 void wxHtmlHelpController :: RefreshLists ()
674 m_SearchList
-> Clear ();
684 void wxHtmlHelpController :: ReadCustomization ( wxConfigBase
* cfg
, wxString path
)
689 if ( path
!= wxEmptyString
) {
690 oldpath
= cfg
-> GetPath ();
691 cfg
-> SetPath ( path
);
694 m_Cfg
. navig_on
= cfg
-> Read ( "hcNavigPanel" , m_Cfg
. navig_on
) != 0 ;
695 m_Cfg
. sashpos
= cfg
-> Read ( "hcSashPos" , m_Cfg
. sashpos
);
696 m_Cfg
. x
= cfg
-> Read ( "hcX" , m_Cfg
. x
);
697 m_Cfg
. y
= cfg
-> Read ( "hcY" , m_Cfg
. y
);
698 m_Cfg
. w
= cfg
-> Read ( "hcW" , m_Cfg
. w
);
699 m_Cfg
. h
= cfg
-> Read ( "hcH" , m_Cfg
. h
);
701 if ( path
!= wxEmptyString
)
702 cfg
-> SetPath ( oldpath
);
707 void wxHtmlHelpController :: WriteCustomization ( wxConfigBase
* cfg
, wxString path
)
712 if ( path
!= wxEmptyString
) {
713 oldpath
= cfg
-> GetPath ();
714 cfg
-> SetPath ( path
);
717 cfg
-> Write ( "hcNavigPanel" , m_Cfg
. navig_on
);
718 cfg
-> Write ( "hcSashPos" , ( long ) m_Cfg
. sashpos
);
719 cfg
-> Write ( "hcX" , ( long ) m_Cfg
. x
);
720 cfg
-> Write ( "hcY" , ( long ) m_Cfg
. y
);
721 cfg
-> Write ( "hcW" , ( long ) m_Cfg
. w
);
722 cfg
-> Write ( "hcH" , ( long ) m_Cfg
. h
);
724 if ( path
!= wxEmptyString
)
725 cfg
-> SetPath ( oldpath
);
737 void wxHtmlHelpController :: OnToolbar ( wxCommandEvent
& event
)
739 switch ( event
. GetId ()) {
740 case wxID_HTML_BACK
:
741 m_HtmlWin
-> HistoryBack ();
743 case wxID_HTML_FORWARD
:
744 m_HtmlWin
-> HistoryForward ();
746 case wxID_HTML_PANEL
:
747 if ( m_Splitter
-> IsSplit ()) {
748 m_Cfg
. sashpos
= m_Splitter
-> GetSashPosition ();
749 m_Splitter
-> Unsplit ( m_NavigPan
);
752 m_NavigPan
-> Show ( TRUE
);
753 m_HtmlWin
-> Show ( TRUE
);
754 m_Splitter
-> SplitVertically ( m_NavigPan
, m_HtmlWin
, m_Cfg
. sashpos
);
762 void wxHtmlHelpController :: OnContentsSel ( wxTreeEvent
& event
)
764 wxHtmlHelpTreeItemData
* pg
;
766 pg
= ( wxHtmlHelpTreeItemData
*) m_ContentsBox
-> GetItemData ( event
. GetItem ());
767 if ( pg
) m_HtmlWin
-> LoadPage ( pg
-> GetPage ());
772 void wxHtmlHelpController :: OnIndexSel ( wxCommandEvent
& event
)
774 HtmlContentsItem
* it
= ( HtmlContentsItem
*) m_IndexBox
-> GetClientData ( m_IndexBox
-> GetSelection ());
775 if ( it
) m_HtmlWin
-> LoadPage ( it
-> m_Book
-> GetBasePath () + it
-> m_Page
);
780 void wxHtmlHelpController :: OnSearchSel ( wxCommandEvent
& event
)
782 HtmlContentsItem
* it
= ( HtmlContentsItem
*) m_SearchList
-> GetClientData ( m_SearchList
-> GetSelection ());
783 if ( it
) m_HtmlWin
-> LoadPage ( it
-> m_Book
-> GetBasePath () + it
-> m_Page
);
788 void wxHtmlHelpController :: OnCloseWindow ( wxCloseEvent
& event
)
792 m_Cfg
. navig_on
= m_Splitter
-> IsSplit ();
794 m_Cfg
. sashpos
= m_Splitter
-> GetSashPosition ();
795 m_Frame
-> GetPosition (& a
, & b
);
796 m_Cfg
. x
= a
, m_Cfg
. y
= b
;
797 m_Frame
-> GetSize (& a
, & b
);
798 m_Cfg
. w
= a
, m_Cfg
. h
= b
;
801 WriteCustomization ( m_Config
, m_ConfigRoot
);
802 m_HtmlWin
-> WriteCustomization ( m_Config
, m_ConfigRoot
);
811 void wxHtmlHelpController :: OnSearch ( wxCommandEvent
& event
)
813 wxString sr
= m_SearchText
-> GetLineText ( 0 );
815 if ( sr
!= wxEmptyString
) KeywordSearch ( sr
);
820 BEGIN_EVENT_TABLE ( wxHtmlHelpController
, wxEvtHandler
)
821 EVT_TOOL_RANGE ( wxID_HTML_PANEL
, wxID_HTML_FORWARD
, wxHtmlHelpController :: OnToolbar
)
822 EVT_TREE_SEL_CHANGED ( wxID_HTML_TREECTRL
, wxHtmlHelpController :: OnContentsSel
)
823 EVT_LISTBOX ( wxID_HTML_INDEXLIST
, wxHtmlHelpController :: OnIndexSel
)
824 EVT_LISTBOX ( wxID_HTML_SEARCHLIST
, wxHtmlHelpController :: OnSearchSel
)
825 EVT_CLOSE ( wxHtmlHelpController :: OnCloseWindow
)
826 EVT_BUTTON ( wxID_HTML_SEARCHBUTTON
, wxHtmlHelpController :: OnSearch
)
827 EVT_TEXT_ENTER ( wxID_HTML_SEARCHTEXT
, wxHtmlHelpController :: OnSearch
)