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