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