]>
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 | ||
af49c4b8 | 15 | #if defined(__GNUG__) && !defined(__APPLE__) |
97494971 | 16 | #pragma interface "helpfrm.h" |
8ec2b484 HH |
17 | #endif |
18 | ||
19 | #include "wx/defs.h" | |
20 | ||
3379ed37 | 21 | #if wxUSE_WXHTML_HELP |
8ec2b484 | 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 | 34 | #include "wx/html/htmlwin.h" |
0646614d | 35 | #include "wx/html/htmprint.h" |
2b5f62a0 | 36 | |
6acba9a7 VS |
37 | class WXDLLIMPEXP_CORE wxButton; |
38 | class WXDLLIMPEXP_CORE wxTextCtrl; | |
46674ada VZ |
39 | class WXDLLIMPEXP_CORE wxTreeEvent; |
40 | class WXDLLIMPEXP_CORE wxTreeCtrl; | |
8ec2b484 | 41 | |
d5bb85a0 | 42 | |
8ec2b484 | 43 | // style flags for the Help Frame |
576507e2 VS |
44 | #define wxHF_TOOLBAR 0x0001 |
45 | #define wxHF_CONTENTS 0x0002 | |
46 | #define wxHF_INDEX 0x0004 | |
47 | #define wxHF_SEARCH 0x0008 | |
48 | #define wxHF_BOOKMARKS 0x0010 | |
49 | #define wxHF_OPEN_FILES 0x0020 | |
50 | #define wxHF_PRINT 0x0040 | |
51 | #define wxHF_FLAT_TOOLBAR 0x0080 | |
52 | #define wxHF_MERGE_BOOKS 0x0100 | |
53 | #define wxHF_ICONS_BOOK 0x0200 | |
54 | #define wxHF_ICONS_BOOK_CHAPTER 0x0400 | |
55 | #define wxHF_ICONS_FOLDER 0x0000 // this is 0 since it is default | |
56 | #define wxHF_DEFAULT_STYLE (wxHF_TOOLBAR | wxHF_CONTENTS | \ | |
57 | wxHF_INDEX | wxHF_SEARCH | \ | |
58 | wxHF_BOOKMARKS | wxHF_PRINT) | |
59 | //compatibility: | |
60 | #define wxHF_OPENFILES wxHF_OPEN_FILES | |
61 | #define wxHF_FLATTOOLBAR wxHF_FLAT_TOOLBAR | |
62 | #define wxHF_DEFAULTSTYLE wxHF_DEFAULT_STYLE | |
8ec2b484 | 63 | |
d5bb85a0 | 64 | |
97494971 | 65 | struct wxHtmlHelpFrameCfg |
b31ba288 | 66 | { |
68364659 | 67 | int x, y, w, h; |
d5bb85a0 VS |
68 | long sashpos; |
69 | bool navig_on; | |
97494971 | 70 | }; |
d5bb85a0 VS |
71 | |
72 | ||
6acba9a7 | 73 | class WXDLLIMPEXP_CORE wxHelpControllerBase; |
b31ba288 | 74 | |
6acba9a7 | 75 | class WXDLLIMPEXP_HTML wxHtmlHelpFrame : public wxFrame |
8ec2b484 | 76 | { |
97494971 VS |
77 | DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame) |
78 | ||
79 | public: | |
80 | wxHtmlHelpFrame(wxHtmlHelpData* data = NULL) { Init(data); } | |
81 | wxHtmlHelpFrame(wxWindow* parent, wxWindowID wxWindowID, | |
82 | const wxString& title = wxEmptyString, | |
576507e2 | 83 | int style = wxHF_DEFAULT_STYLE, wxHtmlHelpData* data = NULL); |
97494971 | 84 | bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxEmptyString, |
576507e2 | 85 | int style = wxHF_DEFAULT_STYLE); |
97494971 VS |
86 | ~wxHtmlHelpFrame(); |
87 | ||
88 | wxHtmlHelpData* GetData() { return m_Data; } | |
89 | wxHelpControllerBase* GetController() const { return m_helpController; } | |
90 | void SetController(wxHelpControllerBase* controller) { m_helpController = controller; } | |
91 | ||
92 | // Sets format of title of the frame. Must contain exactly one "%s" | |
93 | // (for title of displayed HTML page) | |
94 | void SetTitleFormat(const wxString& format); | |
95 | ||
96 | // Displays page x. If not found it will offect the user a choice of | |
97 | // searching books. | |
98 | // Looking for the page runs in these steps: | |
99 | // 1. try to locate file named x (if x is for example "doc/howto.htm") | |
100 | // 2. try to open starting page of book x | |
101 | // 3. try to find x in contents (if x is for example "How To ...") | |
102 | // 4. try to find x in index (if x is for example "How To ...") | |
103 | bool Display(const wxString& x); | |
104 | ||
105 | // Alternative version that works with numeric ID. | |
106 | // (uses extension to MS format, <param name="ID" value=id>, see docs) | |
107 | bool Display(const int id); | |
108 | ||
109 | // Displays help window and focuses contents. | |
110 | bool DisplayContents(); | |
111 | ||
112 | // Displays help window and focuses index. | |
113 | bool DisplayIndex(); | |
114 | ||
115 | // Searches for keyword. Returns TRUE and display page if found, return | |
116 | // FALSE otherwise | |
117 | // Syntax of keyword is Altavista-like: | |
118 | // * words are separated by spaces | |
119 | // (but "\"hello world\"" is only one world "hello world") | |
120 | // * word may be pretended by + or - | |
121 | // (+ : page must contain the word ; - : page can't contain the word) | |
122 | // * if there is no + or - before the word, + is default | |
123 | bool KeywordSearch(const wxString& keyword); | |
124 | ||
125 | void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString) | |
126 | { | |
127 | m_Config = config; | |
128 | m_ConfigRoot = rootpath; | |
129 | ReadCustomization(config, rootpath); | |
130 | } | |
131 | ||
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 ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString); | |
136 | void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString); | |
137 | ||
138 | // call this to let wxHtmlHelpFrame know page changed | |
139 | void NotifyPageChanged(); | |
fc799548 | 140 | |
97494971 VS |
141 | // Refreshes Contents and Index tabs |
142 | void RefreshLists(); | |
fc799548 JS |
143 | |
144 | protected: | |
145 | void Init(wxHtmlHelpData* data = NULL); | |
97494971 VS |
146 | |
147 | // Adds items to m_Contents tree control | |
148 | void CreateContents(); | |
149 | ||
150 | // Adds items to m_IndexList | |
151 | void CreateIndex(); | |
152 | ||
153 | // Add books to search choice panel | |
154 | void CreateSearch(); | |
155 | ||
156 | // Add custom buttons to toolbar | |
157 | virtual void AddToolbarButtons(wxToolBar *toolBar, int style); | |
158 | ||
159 | // Displays options dialog (fonts etc.) | |
160 | virtual void OptionsDialog(); | |
161 | ||
162 | void OnToolbar(wxCommandEvent& event); | |
163 | void OnContentsSel(wxTreeEvent& event); | |
164 | void OnIndexSel(wxCommandEvent& event); | |
165 | void OnIndexFind(wxCommandEvent& event); | |
166 | void OnIndexAll(wxCommandEvent& event); | |
167 | void OnSearchSel(wxCommandEvent& event); | |
168 | void OnSearch(wxCommandEvent& event); | |
169 | void OnBookmarksSel(wxCommandEvent& event); | |
170 | void OnCloseWindow(wxCloseEvent& event); | |
d45bc436 | 171 | void OnActivate(wxActivateEvent& event); |
97494971 | 172 | |
d9b21c9f | 173 | #ifdef __WXMAC__ |
4aa31786 | 174 | void OnClose(wxCommandEvent& event); |
d9b21c9f JS |
175 | void OnAbout(wxCommandEvent& event); |
176 | #endif | |
177 | ||
97494971 VS |
178 | // Images: |
179 | enum { | |
180 | IMG_Book = 0, | |
181 | IMG_Folder, | |
07e252a5 | 182 | IMG_Page |
97494971 VS |
183 | }; |
184 | ||
185 | protected: | |
186 | wxHtmlHelpData* m_Data; | |
187 | bool m_DataCreated; // m_Data created by frame, or supplied? | |
188 | wxString m_TitleFormat; // title of the help frame | |
189 | // below are various pointers to GUI components | |
190 | wxHtmlWindow *m_HtmlWin; | |
191 | wxSplitterWindow *m_Splitter; | |
5229b11d VS |
192 | wxPanel *m_NavigPan; |
193 | wxNotebook *m_NavigNotebook; | |
97494971 VS |
194 | wxTreeCtrl *m_ContentsBox; |
195 | wxTextCtrl *m_IndexText; | |
196 | wxButton *m_IndexButton; | |
197 | wxButton *m_IndexButtonAll; | |
198 | wxListBox *m_IndexList; | |
199 | wxTextCtrl *m_SearchText; | |
200 | wxButton *m_SearchButton; | |
201 | wxListBox *m_SearchList; | |
202 | wxChoice *m_SearchChoice; | |
203 | wxStaticText *m_IndexCountInfo; | |
204 | wxCheckBox *m_SearchCaseSensitive; | |
205 | wxCheckBox *m_SearchWholeWords; | |
206 | ||
207 | wxComboBox *m_Bookmarks; | |
208 | wxArrayString m_BookmarksNames, m_BookmarksPages; | |
209 | ||
210 | wxHtmlHelpFrameCfg m_Cfg; | |
211 | ||
212 | wxConfigBase *m_Config; | |
213 | wxString m_ConfigRoot; | |
214 | ||
215 | // pagenumbers of controls in notebook (usually 0,1,2) | |
216 | int m_ContentsPage; | |
217 | int m_IndexPage; | |
218 | int m_SearchPage; | |
219 | ||
220 | // lists of available fonts (used in options dialog) | |
221 | wxArrayString *m_NormalFonts, *m_FixedFonts; | |
222 | int m_FontSize; // 0,1,2 = small,medium,big | |
223 | wxString m_NormalFace, m_FixedFace; | |
224 | ||
225 | bool m_UpdateContents; | |
0646614d VS |
226 | |
227 | #if wxUSE_PRINTING_ARCHITECTURE | |
97494971 | 228 | wxHtmlEasyPrinting *m_Printer; |
0646614d | 229 | #endif |
97494971 VS |
230 | wxHashTable *m_PagesHash; |
231 | wxHelpControllerBase* m_helpController; | |
3379ed37 | 232 | |
576507e2 | 233 | int m_hfStyle; |
d5bb85a0 | 234 | |
97494971 | 235 | DECLARE_EVENT_TABLE() |
22f3361e | 236 | DECLARE_NO_COPY_CLASS(wxHtmlHelpFrame) |
8ec2b484 HH |
237 | }; |
238 | ||
3379ed37 | 239 | #endif // wxUSE_WXHTML_HELP |
8ec2b484 HH |
240 | |
241 | #endif |