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 wxHtmlHelpFrameCfg
61 wxHtmlHelpFrameCfg() {};
65 int style
; // flags given to wxHtmlHelpFrame ctor
69 class WXDLLEXPORT wxHtmlHelpFrame
: public wxFrame
71 DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame
)
74 wxHtmlHelpFrame(wxHtmlHelpData
* data
= NULL
) { Init(data
); }
75 wxHtmlHelpFrame(wxWindow
* parent
, int wxWindowID
,
76 const wxString
& title
= wxEmptyString
,
77 int style
= wxHF_DEFAULTSTYLE
, wxHtmlHelpData
* data
= NULL
);
78 bool Create(wxWindow
* parent
, wxWindowID id
, const wxString
& title
= wxEmptyString
,
79 int style
= wxHF_DEFAULTSTYLE
);
82 wxHtmlHelpData
* GetData() { return m_Data
; }
84 void SetTitleFormat(const wxString
& format
) {
86 m_HtmlWin
->SetRelatedFrame(this, format
);
87 m_TitleFormat
= format
;
89 // Sets format of title of the frame. Must contain exactly one "%s"
90 // (for title of displayed HTML page)
92 bool Display(const wxString
& x
);
93 // Displays page x. If not found it will offect the user a choice of
95 // Looking for the page runs in these steps:
96 // 1. try to locate file named x (if x is for example "doc/howto.htm")
97 // 2. try to open starting page of book x
98 // 3. try to find x in contents (if x is for example "How To ...")
99 // 4. try to find x in index (if x is for example "How To ...")
100 bool Display(const int id
);
101 // Alternative version that works with numeric ID.
102 // (uses extension to MS format, <param name="ID" value=id>, see docs)
104 bool DisplayContents();
105 // Displays help window and focuses contents.
108 // Displays help window and focuses index.
110 bool KeywordSearch(const wxString
& keyword
);
111 // Searches for keyword. Returns TRUE and display page if found, return
113 // Syntax of keyword is Altavista-like:
114 // * words are separated by spaces
115 // (but "\"hello world\"" is only one world "hello world")
116 // * word may be pretended by + or -
117 // (+ : page must contain the word ; - : page can't contain the word)
118 // * if there is no + or - before the word, + is default
119 void RefreshLists(bool show_progress
= FALSE
);
120 // Refreshes Contents and Index tabs
121 void CreateContents(bool show_progress
= FALSE
);
122 // Adds items to m_Contents tree control
123 void CreateIndex(bool show_progress
= FALSE
);
124 // Adds items to m_IndexList
126 // Add books to search choice panel
127 void UseConfig(wxConfigBase
*config
, const wxString
& rootpath
= wxEmptyString
) {
128 m_Config
= config
; m_ConfigRoot
= rootpath
;
129 ReadCustomization(config
, rootpath
);
131 void ReadCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
132 // saves custom settings into cfg config. it will use the path 'path'
133 // if given, otherwise it will save info into currently selected path.
134 // saved values : things set by SetFonts, SetBorders.
135 void WriteCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
137 void OnToolbar(wxCommandEvent
& event
);
138 void OnContentsSel(wxTreeEvent
& event
);
139 void OnIndexSel(wxCommandEvent
& event
);
140 void OnSearchSel(wxCommandEvent
& event
);
141 void OnSearch(wxCommandEvent
& event
);
142 void OnCloseWindow(wxCloseEvent
& event
);
152 wxHtmlHelpData
* m_Data
;
153 bool m_DataCreated
; // m_Data created by frame, or supplied?
154 wxString m_TitleFormat
; // title of the help frame
155 // below are various pointers to GUI components
156 wxHtmlWindow
*m_HtmlWin
;
157 wxSplitterWindow
*m_Splitter
;
158 wxNotebook
*m_NavigPan
;
159 wxTreeCtrl
*m_ContentsBox
;
160 wxImageList
*m_ContentsImageList
;
161 wxListBox
*m_IndexBox
;
162 wxTextCtrl
*m_SearchText
;
163 wxButton
*m_SearchButton
;
164 wxListBox
*m_SearchList
;
165 wxChoice
*m_SearchChoice
;
167 wxHtmlHelpFrameCfg m_Cfg
;
168 wxConfigBase
*m_Config
;
169 wxString m_ConfigRoot
;
171 // pagenumbers of controls in notebook (usually 0,1,2)
177 void Init(wxHtmlHelpData
* data
= NULL
);
179 DECLARE_EVENT_TABLE()