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
9 // Copyright: (c) Harm van der Heijden and Vaclav Slavik
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_HELPFRM_H_
14 #define _WX_HELPFRM_H_
17 #pragma interface "helpfrm.h"
25 #include "wx/window.h"
27 #include "wx/config.h"
28 #include "wx/splitter.h"
29 #include "wx/notebook.h"
30 #include "wx/listbox.h"
31 #include "wx/choice.h"
32 #include "wx/html/htmlwin.h"
34 // style flags for the Help Frame
35 const int wxHF_TOOLBAR
= 1;
36 const int wxHF_CONTENTS
= 2;
37 const int wxHF_INDEX
= 4;
38 const int wxHF_SEARCH
= 8;
39 const int wxHF_DEFAULTSTYLE
= -1;
43 wxID_HTML_PANEL
= wxID_HIGHEST
+ 1,
53 wxID_HTML_SEARCHBUTTON
,
54 wxID_HTML_SEARCHCHOICE
,
55 wxID_HTML_HELPFRAME
// the id of wxHtmlHelpController's helpframe
58 class WXDLLEXPORT wxHtmlHelpFrame
: public wxFrame
60 DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame
)
63 wxHtmlHelpFrame(wxHtmlHelpData
* data
= NULL
) { Init(data
); }
64 wxHtmlHelpFrame(wxWindow
* parent
, int wxWindowID
,
65 const wxString
& title
= wxEmptyString
,
66 int style
= wxHF_DEFAULTSTYLE
, wxHtmlHelpData
* data
= NULL
);
67 bool Create(wxWindow
* parent
, wxWindowID id
, const wxString
& title
= wxEmptyString
,
68 int style
= wxHF_DEFAULTSTYLE
);
71 wxHtmlHelpData
* GetData() { return m_Data
; }
73 void SetTitleFormat(const wxString
& format
) {
75 m_HtmlWin
->SetRelatedFrame(this, format
);
76 m_TitleFormat
= format
;
78 // Sets format of title of the frame. Must contain exactly one "%s"
79 // (for title of displayed HTML page)
81 bool Display(const wxString
& x
);
82 // Displays page x. If not found it will offect the user a choice of
84 // Looking for the page runs in these steps:
85 // 1. try to locate file named x (if x is for example "doc/howto.htm")
86 // 2. try to open starting page of book x
87 // 3. try to find x in contents (if x is for example "How To ...")
88 // 4. try to find x in index (if x is for example "How To ...")
89 bool Display(const int id
);
90 // Alternative version that works with numeric ID.
91 // (uses extension to MS format, <param name="ID" value=id>, see docs)
93 bool DisplayContents();
94 // Displays help window and focuses contents.
97 // Displays help window and focuses index.
99 bool KeywordSearch(const wxString
& keyword
);
100 // Searches for keyword. Returns TRUE and display page if found, return
102 // Syntax of keyword is Altavista-like:
103 // * words are separated by spaces
104 // (but "\"hello world\"" is only one world "hello world")
105 // * word may be pretended by + or -
106 // (+ : page must contain the word ; - : page can't contain the word)
107 // * if there is no + or - before the word, + is default
108 void RefreshLists(bool show_progress
= FALSE
);
109 // Refreshes Contents and Index tabs
110 void CreateContents(bool show_progress
= FALSE
);
111 // Adds items to m_Contents tree control
112 void CreateIndex(bool show_progress
= FALSE
);
113 // Adds items to m_IndexList
115 // Add books to search choice panel
116 void UseConfig(wxConfigBase
*config
, const wxString
& rootpath
= wxEmptyString
) {
117 m_Config
= config
; m_ConfigRoot
= rootpath
;
118 ReadCustomization(config
, rootpath
);
120 void ReadCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
121 // saves custom settings into cfg config. it will use the path 'path'
122 // if given, otherwise it will save info into currently selected path.
123 // saved values : things set by SetFonts, SetBorders.
124 void WriteCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
126 void OnToolbar(wxCommandEvent
& event
);
127 void OnContentsSel(wxTreeEvent
& event
);
128 void OnIndexSel(wxCommandEvent
& event
);
129 void OnSearchSel(wxCommandEvent
& event
);
130 void OnSearch(wxCommandEvent
& event
);
131 void OnCloseWindow(wxCloseEvent
& event
);
141 wxHtmlHelpData
* m_Data
;
142 bool m_DataCreated
; // m_Data created by frame, or supplied?
143 wxString m_TitleFormat
; // title of the help frame
144 // below are various pointers to GUI components
145 wxHtmlWindow
*m_HtmlWin
;
146 wxSplitterWindow
*m_Splitter
;
147 wxNotebook
*m_NavigPan
;
148 wxTreeCtrl
*m_ContentsBox
;
149 wxImageList
*m_ContentsImageList
;
150 wxListBox
*m_IndexBox
;
151 wxTextCtrl
*m_SearchText
;
152 wxButton
*m_SearchButton
;
153 wxListBox
*m_SearchList
;
154 wxChoice
*m_SearchChoice
;
160 int style
; // flags given to wxHtmlHelpFrame ctor
161 wxString titleformat
;
163 // settings (window size, position, sash pos etc..)
164 wxConfigBase
*m_Config
;
165 wxString m_ConfigRoot
;
167 // pagenumbers of controls in notebook (usually 0,1,2)
173 void Init(wxHtmlHelpData
* data
= NULL
);
175 DECLARE_EVENT_TABLE()