]>
Commit | Line | Data |
---|---|---|
8ec2b484 HH |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: helpfrm.h | |
3 | // Purpose: wxHtmlHelpFrame | |
f42b1601 | 4 | // Notes: Based on htmlhelp.cpp, implementing a monolithic |
8ec2b484 HH |
5 | // HTML Help controller class, by Vaclav Slavik |
6 | // Author: Harm van der Heijden and Vaclav Slavik | |
69941f05 | 7 | // RCS-ID: $Id$ |
8ec2b484 HH |
8 | // Copyright: (c) Harm van der Heijden and Vaclav Slavik |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_HELPFRM_H_ | |
13 | #define _WX_HELPFRM_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
69941f05 | 16 | #pragma interface |
8ec2b484 HH |
17 | #endif |
18 | ||
19 | #include "wx/defs.h" | |
20 | ||
21 | #if wxUSE_HTML | |
22 | ||
16a12a3d | 23 | #include "wx/html/helpdata.h" |
8ec2b484 HH |
24 | #include "wx/window.h" |
25 | #include "wx/frame.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" | |
382e6efe | 31 | #include "wx/combobox.h" |
c4971147 | 32 | #include "wx/checkbox.h" |
240c2873 | 33 | #include "wx/stattext.h" |
8ec2b484 HH |
34 | #include "wx/html/htmlwin.h" |
35 | ||
d5bb85a0 | 36 | |
8ec2b484 | 37 | // style flags for the Help Frame |
d5bb85a0 VS |
38 | #define wxHF_TOOLBAR 0x0001 |
39 | #define wxHF_CONTENTS 0x0002 | |
40 | #define wxHF_INDEX 0x0004 | |
41 | #define wxHF_SEARCH 0x0008 | |
382e6efe VS |
42 | #define wxHF_BOOKMARKS 0x0010 |
43 | #define wxHF_DEFAULTSTYLE (wxHF_TOOLBAR | wxHF_CONTENTS | wxHF_INDEX | wxHF_SEARCH | wxHF_BOOKMARKS) | |
d5bb85a0 | 44 | |
8ec2b484 HH |
45 | |
46 | // Command IDs : | |
d5bb85a0 VS |
47 | enum |
48 | { | |
8ec2b484 HH |
49 | wxID_HTML_PANEL = wxID_HIGHEST + 1, |
50 | wxID_HTML_BACK, | |
51 | wxID_HTML_FORWARD, | |
83efdf33 | 52 | wxID_HTML_OPTIONS, |
382e6efe VS |
53 | wxID_HTML_BOOKMARKSLIST, |
54 | wxID_HTML_BOOKMARKSADD, | |
55 | wxID_HTML_BOOKMARKSREMOVE, | |
8ec2b484 HH |
56 | wxID_HTML_TREECTRL, |
57 | wxID_HTML_INDEXPAGE, | |
58 | wxID_HTML_INDEXLIST, | |
f0b6a33f VS |
59 | wxID_HTML_INDEXTEXT, |
60 | wxID_HTML_INDEXBUTTON, | |
61 | wxID_HTML_INDEXBUTTONALL, | |
8ec2b484 HH |
62 | wxID_HTML_NOTEBOOK, |
63 | wxID_HTML_SEARCHPAGE, | |
64 | wxID_HTML_SEARCHTEXT, | |
65 | wxID_HTML_SEARCHLIST, | |
66 | wxID_HTML_SEARCHBUTTON, | |
67 | wxID_HTML_SEARCHCHOICE, | |
240c2873 | 68 | wxID_HTML_COUNTINFO, |
8ec2b484 | 69 | wxID_HTML_HELPFRAME // the id of wxHtmlHelpController's helpframe |
d5bb85a0 VS |
70 | } |
71 | ; | |
8ec2b484 | 72 | |
d5bb85a0 VS |
73 | |
74 | typedef struct | |
b31ba288 | 75 | { |
68364659 | 76 | int x, y, w, h; |
d5bb85a0 VS |
77 | long sashpos; |
78 | bool navig_on; | |
79 | } | |
80 | wxHtmlHelpFrameCfg; | |
81 | ||
82 | ||
b31ba288 | 83 | |
8ec2b484 HH |
84 | class WXDLLEXPORT wxHtmlHelpFrame : public wxFrame |
85 | { | |
d5bb85a0 VS |
86 | DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame) |
87 | ||
88 | public: | |
89 | wxHtmlHelpFrame(wxHtmlHelpData* data = NULL) { Init(data); } | |
90 | wxHtmlHelpFrame(wxWindow* parent, int wxWindowID, | |
91 | const wxString& title = wxEmptyString, | |
92 | int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL); | |
93 | bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxEmptyString, | |
94 | int style = wxHF_DEFAULTSTYLE); | |
95 | ~wxHtmlHelpFrame(); | |
96 | ||
97 | wxHtmlHelpData* GetData() { return m_Data; } | |
98 | ||
99 | void SetTitleFormat(const wxString& format) | |
100 | { | |
101 | if (m_HtmlWin) | |
102 | m_HtmlWin->SetRelatedFrame(this, format); | |
103 | m_TitleFormat = format; | |
104 | } | |
105 | // Sets format of title of the frame. Must contain exactly one "%s" | |
106 | // (for title of displayed HTML page) | |
107 | ||
108 | bool Display(const wxString& x); | |
109 | // Displays page x. If not found it will offect the user a choice of | |
110 | // searching books. | |
111 | // Looking for the page runs in these steps: | |
112 | // 1. try to locate file named x (if x is for example "doc/howto.htm") | |
113 | // 2. try to open starting page of book x | |
114 | // 3. try to find x in contents (if x is for example "How To ...") | |
115 | // 4. try to find x in index (if x is for example "How To ...") | |
116 | bool Display(const int id); | |
117 | // Alternative version that works with numeric ID. | |
118 | // (uses extension to MS format, <param name="ID" value=id>, see docs) | |
119 | ||
120 | bool DisplayContents(); | |
121 | // Displays help window and focuses contents. | |
122 | ||
123 | bool DisplayIndex(); | |
124 | // Displays help window and focuses index. | |
125 | ||
126 | bool KeywordSearch(const wxString& keyword); | |
127 | // Searches for keyword. Returns TRUE and display page if found, return | |
128 | // FALSE otherwise | |
129 | // Syntax of keyword is Altavista-like: | |
130 | // * words are separated by spaces | |
131 | // (but "\"hello world\"" is only one world "hello world") | |
132 | // * word may be pretended by + or - | |
133 | // (+ : page must contain the word ; - : page can't contain the word) | |
134 | // * if there is no + or - before the word, + is default | |
83efdf33 | 135 | |
d5bb85a0 | 136 | void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString) |
83efdf33 VS |
137 | { |
138 | m_Config = config; | |
139 | m_ConfigRoot = rootpath; | |
140 | ReadCustomization(config, rootpath); | |
141 | } | |
142 | ||
d5bb85a0 VS |
143 | void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString); |
144 | // saves custom settings into cfg config. it will use the path 'path' | |
145 | // if given, otherwise it will save info into currently selected path. | |
146 | // saved values : things set by SetFonts, SetBorders. | |
147 | void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString); | |
148 | // ... | |
83efdf33 | 149 | |
052e12db VS |
150 | protected: |
151 | void Init(wxHtmlHelpData* data = NULL); | |
152 | ||
153 | void RefreshLists(); | |
154 | // Refreshes Contents and Index tabs | |
155 | ||
156 | void CreateContents(); | |
157 | // Adds items to m_Contents tree control | |
158 | ||
159 | void CreateIndex(); | |
160 | // Adds items to m_IndexList | |
161 | ||
162 | void CreateSearch(); | |
163 | // Add books to search choice panel | |
164 | ||
b854b7b8 VS |
165 | virtual void AddToolbarButtons(wxToolBar *toolBar, int style); |
166 | // Add custom buttons to toolbar | |
052e12db | 167 | |
83efdf33 VS |
168 | virtual void OptionsDialog(); |
169 | // Displays options dialog (fonts etc.) | |
170 | ||
d5bb85a0 VS |
171 | void OnToolbar(wxCommandEvent& event); |
172 | void OnContentsSel(wxTreeEvent& event); | |
173 | void OnIndexSel(wxCommandEvent& event); | |
f0b6a33f VS |
174 | void OnIndexFind(wxCommandEvent& event); |
175 | void OnIndexAll(wxCommandEvent& event); | |
d5bb85a0 VS |
176 | void OnSearchSel(wxCommandEvent& event); |
177 | void OnSearch(wxCommandEvent& event); | |
382e6efe | 178 | void OnBookmarksSel(wxCommandEvent& event); |
d5bb85a0 VS |
179 | void OnCloseWindow(wxCloseEvent& event); |
180 | ||
181 | // Images: | |
182 | enum { | |
183 | IMG_Book = 0, | |
184 | IMG_Folder, | |
5c172c17 VS |
185 | IMG_Page, |
186 | IMG_RootFolder | |
d5bb85a0 VS |
187 | }; |
188 | ||
189 | protected: | |
190 | wxHtmlHelpData* m_Data; | |
191 | bool m_DataCreated; // m_Data created by frame, or supplied? | |
192 | wxString m_TitleFormat; // title of the help frame | |
193 | // below are various pointers to GUI components | |
194 | wxHtmlWindow *m_HtmlWin; | |
195 | wxSplitterWindow *m_Splitter; | |
196 | wxNotebook *m_NavigPan; | |
197 | wxTreeCtrl *m_ContentsBox; | |
198 | wxImageList *m_ContentsImageList; | |
f0b6a33f VS |
199 | wxTextCtrl *m_IndexText; |
200 | wxButton *m_IndexButton; | |
201 | wxButton *m_IndexButtonAll; | |
202 | wxListBox *m_IndexList; | |
d5bb85a0 VS |
203 | wxTextCtrl *m_SearchText; |
204 | wxButton *m_SearchButton; | |
205 | wxListBox *m_SearchList; | |
206 | wxChoice *m_SearchChoice; | |
240c2873 | 207 | wxStaticText *m_IndexCountInfo; |
c4971147 VS |
208 | wxCheckBox *m_SearchCaseSensitive; |
209 | wxCheckBox *m_SearchWholeWords; | |
d5bb85a0 | 210 | |
382e6efe VS |
211 | wxComboBox *m_Bookmarks; |
212 | wxArrayString m_BookmarksNames, m_BookmarksPages; | |
213 | ||
d5bb85a0 VS |
214 | wxHtmlHelpFrameCfg m_Cfg; |
215 | ||
216 | wxConfigBase *m_Config; | |
217 | wxString m_ConfigRoot; | |
218 | ||
219 | // pagenumbers of controls in notebook (usually 0,1,2) | |
220 | int m_ContentsPage; | |
221 | int m_IndexPage; | |
222 | int m_SearchPage; | |
83efdf33 VS |
223 | |
224 | // lists of available fonts (used in options dialog) | |
225 | wxArrayString *m_NormalFonts, *m_FixedFonts; | |
226 | int m_FontSize; // 0,1,2 = small,medium,big | |
227 | wxString m_NormalFace, m_FixedFace; | |
d5bb85a0 | 228 | |
d5bb85a0 | 229 | DECLARE_EVENT_TABLE() |
8ec2b484 HH |
230 | }; |
231 | ||
052e12db | 232 | #endif // wxUSE_HTML |
8ec2b484 HH |
233 | |
234 | #endif |