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
8 // Copyright: (c) Harm van der Heijden and Vaclav Slavik
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_HELPFRM_H_
13 #define _WX_HELPFRM_H_
16 #pragma interface "helpfrm.h"
23 #include "wx/html/helpdata.h"
24 #include "wx/window.h"
26 #include "wx/config.h"
27 #include "wx/splitter.h"
28 #include "wx/notebook.h"
29 #include "wx/listbox.h"
30 #include "wx/choice.h"
31 #include "wx/combobox.h"
32 #include "wx/checkbox.h"
33 #include "wx/stattext.h"
34 #include "wx/html/htmlwin.h"
35 #include "wx/html/htmprint.h"
38 // style flags for the Help Frame
39 #define wxHF_TOOLBAR 0x0001
40 #define wxHF_CONTENTS 0x0002
41 #define wxHF_INDEX 0x0004
42 #define wxHF_SEARCH 0x0008
43 #define wxHF_BOOKMARKS 0x0010
44 #define wxHF_OPEN_FILES 0x0020
45 #define wxHF_PRINT 0x0040
46 #define wxHF_FLAT_TOOLBAR 0x0080
47 #define wxHF_MERGE_BOOKS 0x0100
48 #define wxHF_ICONS_BOOK 0x0200
49 #define wxHF_ICONS_BOOK_CHAPTER 0x0400
50 #define wxHF_ICONS_FOLDER 0x0000 // this is 0 since it is default
51 #define wxHF_DEFAULT_STYLE (wxHF_TOOLBAR | wxHF_CONTENTS | \
52 wxHF_INDEX | wxHF_SEARCH | \
53 wxHF_BOOKMARKS | wxHF_PRINT)
55 #define wxHF_OPENFILES wxHF_OPEN_FILES
56 #define wxHF_FLATTOOLBAR wxHF_FLAT_TOOLBAR
57 #define wxHF_DEFAULTSTYLE wxHF_DEFAULT_STYLE
60 struct wxHtmlHelpFrameCfg
68 class WXDLLEXPORT wxHelpControllerBase
;
70 class WXDLLEXPORT wxHtmlHelpFrame
: public wxFrame
72 DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame
)
75 wxHtmlHelpFrame(wxHtmlHelpData
* data
= NULL
) { Init(data
); }
76 wxHtmlHelpFrame(wxWindow
* parent
, wxWindowID wxWindowID
,
77 const wxString
& title
= wxEmptyString
,
78 int style
= wxHF_DEFAULT_STYLE
, wxHtmlHelpData
* data
= NULL
);
79 bool Create(wxWindow
* parent
, wxWindowID id
, const wxString
& title
= wxEmptyString
,
80 int style
= wxHF_DEFAULT_STYLE
);
83 wxHtmlHelpData
* GetData() { return m_Data
; }
84 wxHelpControllerBase
* GetController() const { return m_helpController
; }
85 void SetController(wxHelpControllerBase
* controller
) { m_helpController
= controller
; }
87 // Sets format of title of the frame. Must contain exactly one "%s"
88 // (for title of displayed HTML page)
89 void SetTitleFormat(const wxString
& format
);
91 // Displays page x. If not found it will offect the user a choice of
93 // Looking for the page runs in these steps:
94 // 1. try to locate file named x (if x is for example "doc/howto.htm")
95 // 2. try to open starting page of book x
96 // 3. try to find x in contents (if x is for example "How To ...")
97 // 4. try to find x in index (if x is for example "How To ...")
98 bool Display(const wxString
& x
);
100 // Alternative version that works with numeric ID.
101 // (uses extension to MS format, <param name="ID" value=id>, see docs)
102 bool Display(const int id
);
104 // Displays help window and focuses contents.
105 bool DisplayContents();
107 // Displays help window and focuses index.
110 // Searches for keyword. Returns TRUE and display page if found, return
112 // Syntax of keyword is Altavista-like:
113 // * words are separated by spaces
114 // (but "\"hello world\"" is only one world "hello world")
115 // * word may be pretended by + or -
116 // (+ : page must contain the word ; - : page can't contain the word)
117 // * if there is no + or - before the word, + is default
118 bool KeywordSearch(const wxString
& keyword
);
120 void UseConfig(wxConfigBase
*config
, const wxString
& rootpath
= wxEmptyString
)
123 m_ConfigRoot
= rootpath
;
124 ReadCustomization(config
, rootpath
);
127 // Saves custom settings into cfg config. it will use the path 'path'
128 // if given, otherwise it will save info into currently selected path.
129 // saved values : things set by SetFonts, SetBorders.
130 void ReadCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
131 void WriteCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
133 // call this to let wxHtmlHelpFrame know page changed
134 void NotifyPageChanged();
137 void Init(wxHtmlHelpData
* data
= NULL
);
139 // Refreshes Contents and Index tabs
142 // Adds items to m_Contents tree control
143 void CreateContents();
145 // Adds items to m_IndexList
148 // Add books to search choice panel
151 // Add custom buttons to toolbar
152 virtual void AddToolbarButtons(wxToolBar
*toolBar
, int style
);
154 // Displays options dialog (fonts etc.)
155 virtual void OptionsDialog();
157 void OnToolbar(wxCommandEvent
& event
);
158 void OnContentsSel(wxTreeEvent
& event
);
159 void OnIndexSel(wxCommandEvent
& event
);
160 void OnIndexFind(wxCommandEvent
& event
);
161 void OnIndexAll(wxCommandEvent
& event
);
162 void OnSearchSel(wxCommandEvent
& event
);
163 void OnSearch(wxCommandEvent
& event
);
164 void OnBookmarksSel(wxCommandEvent
& event
);
165 void OnCloseWindow(wxCloseEvent
& event
);
176 wxHtmlHelpData
* m_Data
;
177 bool m_DataCreated
; // m_Data created by frame, or supplied?
178 wxString m_TitleFormat
; // title of the help frame
179 // below are various pointers to GUI components
180 wxHtmlWindow
*m_HtmlWin
;
181 wxSplitterWindow
*m_Splitter
;
182 wxNotebook
*m_NavigPan
;
183 wxTreeCtrl
*m_ContentsBox
;
184 wxTextCtrl
*m_IndexText
;
185 wxButton
*m_IndexButton
;
186 wxButton
*m_IndexButtonAll
;
187 wxListBox
*m_IndexList
;
188 wxTextCtrl
*m_SearchText
;
189 wxButton
*m_SearchButton
;
190 wxListBox
*m_SearchList
;
191 wxChoice
*m_SearchChoice
;
192 wxStaticText
*m_IndexCountInfo
;
193 wxCheckBox
*m_SearchCaseSensitive
;
194 wxCheckBox
*m_SearchWholeWords
;
196 wxComboBox
*m_Bookmarks
;
197 wxArrayString m_BookmarksNames
, m_BookmarksPages
;
199 wxHtmlHelpFrameCfg m_Cfg
;
201 wxConfigBase
*m_Config
;
202 wxString m_ConfigRoot
;
204 // pagenumbers of controls in notebook (usually 0,1,2)
209 // lists of available fonts (used in options dialog)
210 wxArrayString
*m_NormalFonts
, *m_FixedFonts
;
211 int m_FontSize
; // 0,1,2 = small,medium,big
212 wxString m_NormalFace
, m_FixedFace
;
214 bool m_UpdateContents
;
216 #if wxUSE_PRINTING_ARCHITECTURE
217 wxHtmlEasyPrinting
*m_Printer
;
219 wxHashTable
*m_PagesHash
;
220 wxHelpControllerBase
* m_helpController
;
224 DECLARE_EVENT_TABLE()