]>
Commit | Line | Data |
---|---|---|
8ec2b484 HH |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: helpfrm.cpp | |
3 | // Purpose: wxHtmlHelpFrame | |
d5bb85a0 | 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 | 8 | // Copyright: (c) Harm van der Heijden and Vaclav Slavik |
65571936 | 9 | // Licence: wxWindows licence |
8ec2b484 HH |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
14f355c2 | 12 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
1aedb1dd | 13 | #pragma implementation "helpfrm.h" |
8ec2b484 HH |
14 | #endif |
15 | ||
c32bfc10 VS |
16 | // For compilers that support precompilation, includes "wx.h" |
17 | ||
8ec2b484 HH |
18 | #include "wx/wxprec.h" |
19 | ||
20 | #ifdef __BORLANDC__ | |
21 | #pragma hdrstop | |
22 | #endif | |
23 | ||
3379ed37 | 24 | #if wxUSE_WXHTML_HELP |
07b8d7ec | 25 | |
8ec2b484 | 26 | #ifndef WXPRECOMP |
07b8d7ec VZ |
27 | #include "wx/intl.h" |
28 | #include "wx/log.h" | |
29 | ||
30 | #include "wx/object.h" | |
07b8d7ec VZ |
31 | #include "wx/sizer.h" |
32 | ||
33 | #include "wx/bmpbuttn.h" | |
34 | #include "wx/statbox.h" | |
35 | #include "wx/radiobox.h" | |
36 | #endif // WXPRECOMP | |
8ec2b484 | 37 | |
c718e0b3 SC |
38 | #ifdef __WXMAC__ |
39 | #include "wx/menu.h" | |
40 | #include "wx/msgdlg.h" | |
41 | #endif | |
42 | ||
8ec2b484 | 43 | #include "wx/html/helpfrm.h" |
b4414c1f | 44 | #include "wx/html/helpctrl.h" |
618a5e38 | 45 | #include "wx/textctrl.h" |
8ec2b484 HH |
46 | #include "wx/notebook.h" |
47 | #include "wx/imaglist.h" | |
48 | #include "wx/treectrl.h" | |
49 | #include "wx/tokenzr.h" | |
50 | #include "wx/wfstream.h" | |
51 | #include "wx/html/htmlwin.h" | |
52 | #include "wx/busyinfo.h" | |
53 | #include "wx/progdlg.h" | |
2bd5bbc9 | 54 | #include "wx/toolbar.h" |
83efdf33 | 55 | #include "wx/fontenum.h" |
0646614d VS |
56 | #include "wx/stream.h" |
57 | #include "wx/filedlg.h" | |
f435c1f0 | 58 | #include "wx/artprov.h" |
c269cf62 | 59 | #include "wx/spinctrl.h" |
91fa114d VS |
60 | #include "wx/dynarray.h" |
61 | #include "wx/choicdlg.h" | |
8ec2b484 | 62 | |
f0b6a33f VS |
63 | // what is considered "small index"? |
64 | #define INDEX_IS_SMALL 100 | |
65 | ||
9806a47c JS |
66 | /* Motif defines this as a macro */ |
67 | #ifdef Below | |
68 | #undef Below | |
69 | #endif | |
f0b6a33f | 70 | |
8ec2b484 | 71 | //-------------------------------------------------------------------------- |
382e6efe | 72 | // wxHtmlHelpTreeItemData (private) |
8ec2b484 HH |
73 | //-------------------------------------------------------------------------- |
74 | ||
75 | class wxHtmlHelpTreeItemData : public wxTreeItemData | |
76 | { | |
0646614d | 77 | public: |
da4cc40c DW |
78 | #if defined(__VISAGECPP__) |
79 | // VA needs a default ctor for some reason.... | |
80 | wxHtmlHelpTreeItemData() : wxTreeItemData() | |
81 | { m_Id = 0; } | |
82 | #endif | |
0646614d VS |
83 | wxHtmlHelpTreeItemData(int id) : wxTreeItemData() |
84 | { m_Id = id;} | |
85 | ||
86 | int m_Id; | |
87 | }; | |
8ec2b484 | 88 | |
0646614d VS |
89 | |
90 | //-------------------------------------------------------------------------- | |
91 | // wxHtmlHelpHashData (private) | |
92 | //-------------------------------------------------------------------------- | |
93 | ||
94 | class wxHtmlHelpHashData : public wxObject | |
95 | { | |
8ec2b484 | 96 | public: |
0646614d VS |
97 | wxHtmlHelpHashData(int index, wxTreeItemId id) : wxObject() |
98 | { m_Index = index; m_Id = id;} | |
f5ba273e | 99 | ~wxHtmlHelpHashData() {} |
f6bcfd97 | 100 | |
0646614d VS |
101 | int m_Index; |
102 | wxTreeItemId m_Id; | |
8ec2b484 HH |
103 | }; |
104 | ||
382e6efe | 105 | |
0646614d VS |
106 | //-------------------------------------------------------------------------- |
107 | // wxHtmlHelpHtmlWindow (private) | |
108 | //-------------------------------------------------------------------------- | |
109 | ||
110 | class wxHtmlHelpHtmlWindow : public wxHtmlWindow | |
111 | { | |
112 | public: | |
113 | wxHtmlHelpHtmlWindow(wxHtmlHelpFrame *fr, wxWindow *parent) : wxHtmlWindow(parent), m_Frame(fr) {} | |
114 | ||
115 | virtual void OnLinkClicked(const wxHtmlLinkInfo& link) | |
116 | { | |
117 | wxHtmlWindow::OnLinkClicked(link); | |
adf2eb2d VS |
118 | const wxMouseEvent *e = link.GetEvent(); |
119 | if (e == NULL || e->LeftUp()) | |
120 | m_Frame->NotifyPageChanged(); | |
0646614d VS |
121 | } |
122 | ||
f6bcfd97 | 123 | private: |
0646614d | 124 | wxHtmlHelpFrame *m_Frame; |
22f3361e VZ |
125 | |
126 | DECLARE_NO_COPY_CLASS(wxHtmlHelpHtmlWindow) | |
0646614d VS |
127 | }; |
128 | ||
382e6efe | 129 | |
91fa114d VS |
130 | //--------------------------------------------------------------------------- |
131 | // wxHtmlHelpFrame::m_mergedIndex | |
132 | //--------------------------------------------------------------------------- | |
133 | ||
134 | WX_DEFINE_ARRAY(const wxHtmlHelpDataItem*, wxHtmlHelpDataItemPtrArray); | |
135 | ||
136 | struct wxHtmlHelpMergedIndexItem | |
137 | { | |
138 | wxHtmlHelpMergedIndexItem *parent; | |
139 | wxString name; | |
140 | wxHtmlHelpDataItemPtrArray items; | |
141 | }; | |
142 | ||
143 | WX_DECLARE_OBJARRAY(wxHtmlHelpMergedIndexItem, wxHtmlHelpMergedIndex); | |
144 | #include "wx/arrimpl.cpp" | |
145 | WX_DEFINE_OBJARRAY(wxHtmlHelpMergedIndex) | |
146 | ||
147 | void wxHtmlHelpFrame::UpdateMergedIndex() | |
148 | { | |
149 | delete m_mergedIndex; | |
150 | m_mergedIndex = new wxHtmlHelpMergedIndex; | |
151 | wxHtmlHelpMergedIndex& merged = *m_mergedIndex; | |
152 | ||
153 | const wxHtmlHelpDataItems& items = m_Data->GetIndexArray(); | |
154 | size_t len = items.size(); | |
155 | ||
156 | wxHtmlHelpMergedIndexItem *history[128] = {NULL}; | |
157 | ||
158 | for (size_t i = 0; i < len; i++) | |
159 | { | |
160 | const wxHtmlHelpDataItem& item = items[i]; | |
161 | wxASSERT_MSG( item.level < 128, _T("nested index entries too deep") ); | |
162 | ||
163 | if (history[item.level] && | |
164 | history[item.level]->items[0]->name == item.name) | |
165 | { | |
166 | // same index entry as previous one, update list of items | |
167 | history[item.level]->items.Add(&item); | |
168 | } | |
169 | else | |
170 | { | |
171 | // new index entry | |
172 | wxHtmlHelpMergedIndexItem *mi = new wxHtmlHelpMergedIndexItem(); | |
173 | mi->name = item.GetIndentedName(); | |
174 | mi->items.Add(&item); | |
175 | mi->parent = (item.level == 0) ? NULL : history[item.level - 1]; | |
176 | history[item.level] = mi; | |
177 | merged.Add(mi); | |
178 | } | |
179 | } | |
180 | } | |
181 | ||
382e6efe | 182 | |
8ec2b484 HH |
183 | //--------------------------------------------------------------------------- |
184 | // wxHtmlHelpFrame | |
185 | //--------------------------------------------------------------------------- | |
186 | ||
576507e2 VS |
187 | // Command IDs : |
188 | enum | |
189 | { | |
190 | //wxID_HTML_HELPFRAME = wxID_HIGHEST + 1, | |
191 | wxID_HTML_PANEL = wxID_HIGHEST + 2, | |
192 | wxID_HTML_BACK, | |
193 | wxID_HTML_FORWARD, | |
194 | wxID_HTML_UPNODE, | |
195 | wxID_HTML_UP, | |
196 | wxID_HTML_DOWN, | |
197 | wxID_HTML_PRINT, | |
198 | wxID_HTML_OPENFILE, | |
199 | wxID_HTML_OPTIONS, | |
200 | wxID_HTML_BOOKMARKSLIST, | |
201 | wxID_HTML_BOOKMARKSADD, | |
202 | wxID_HTML_BOOKMARKSREMOVE, | |
203 | wxID_HTML_TREECTRL, | |
204 | wxID_HTML_INDEXPAGE, | |
205 | wxID_HTML_INDEXLIST, | |
206 | wxID_HTML_INDEXTEXT, | |
207 | wxID_HTML_INDEXBUTTON, | |
208 | wxID_HTML_INDEXBUTTONALL, | |
209 | wxID_HTML_NOTEBOOK, | |
210 | wxID_HTML_SEARCHPAGE, | |
211 | wxID_HTML_SEARCHTEXT, | |
212 | wxID_HTML_SEARCHLIST, | |
213 | wxID_HTML_SEARCHBUTTON, | |
214 | wxID_HTML_SEARCHCHOICE, | |
215 | wxID_HTML_COUNTINFO | |
216 | }; | |
217 | ||
218 | ||
8ec2b484 HH |
219 | IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpFrame, wxFrame) |
220 | ||
221 | wxHtmlHelpFrame::wxHtmlHelpFrame(wxWindow* parent, wxWindowID id, const wxString& title, | |
d5bb85a0 | 222 | int style, wxHtmlHelpData* data) |
8ec2b484 HH |
223 | { |
224 | Init(data); | |
225 | Create(parent, id, title, style); | |
226 | } | |
d5bb85a0 | 227 | |
8ec2b484 HH |
228 | void wxHtmlHelpFrame::Init(wxHtmlHelpData* data) |
229 | { | |
da4cc40c | 230 | if (data) |
4f9297b0 | 231 | { |
d5bb85a0 | 232 | m_Data = data; |
dabbc6a5 | 233 | m_DataCreated = false; |
da4cc40c | 234 | } else |
4f9297b0 | 235 | { |
d5bb85a0 | 236 | m_Data = new wxHtmlHelpData(); |
dabbc6a5 | 237 | m_DataCreated = true; |
8ec2b484 HH |
238 | } |
239 | ||
8ec2b484 | 240 | m_ContentsBox = NULL; |
f0b6a33f VS |
241 | m_IndexList = NULL; |
242 | m_IndexButton = NULL; | |
243 | m_IndexButtonAll = NULL; | |
244 | m_IndexText = NULL; | |
8ec2b484 HH |
245 | m_SearchList = NULL; |
246 | m_SearchButton = NULL; | |
247 | m_SearchText = NULL; | |
248 | m_SearchChoice = NULL; | |
240c2873 | 249 | m_IndexCountInfo = NULL; |
8ec2b484 HH |
250 | m_Splitter = NULL; |
251 | m_NavigPan = NULL; | |
5229b11d | 252 | m_NavigNotebook = NULL; |
8ec2b484 | 253 | m_HtmlWin = NULL; |
382e6efe | 254 | m_Bookmarks = NULL; |
c4971147 VS |
255 | m_SearchCaseSensitive = NULL; |
256 | m_SearchWholeWords = NULL; | |
257 | ||
91fa114d VS |
258 | m_mergedIndex = NULL; |
259 | ||
8ec2b484 HH |
260 | m_Config = NULL; |
261 | m_ConfigRoot = wxEmptyString; | |
262 | ||
263 | m_Cfg.x = m_Cfg.y = 0; | |
d5bb85a0 VS |
264 | m_Cfg.w = 700; |
265 | m_Cfg.h = 480; | |
8ec2b484 | 266 | m_Cfg.sashpos = 240; |
dabbc6a5 | 267 | m_Cfg.navig_on = true; |
83efdf33 VS |
268 | |
269 | m_NormalFonts = m_FixedFonts = NULL; | |
83efdf33 | 270 | m_NormalFace = m_FixedFace = wxEmptyString; |
c269cf62 VS |
271 | #ifdef __WXMSW__ |
272 | m_FontSize = 10; | |
273 | #else | |
274 | m_FontSize = 14; | |
275 | #endif | |
f6bcfd97 | 276 | |
0646614d VS |
277 | #if wxUSE_PRINTING_ARCHITECTURE |
278 | m_Printer = NULL; | |
279 | #endif | |
280 | ||
281 | m_PagesHash = NULL; | |
dabbc6a5 | 282 | m_UpdateContents = true; |
b4414c1f | 283 | m_helpController = (wxHelpControllerBase*) NULL; |
8ec2b484 HH |
284 | } |
285 | ||
d5bb85a0 VS |
286 | // Create: builds the GUI components. |
287 | // with the style flag it's possible to toggle the toolbar, contents, index and search | |
288 | // controls. | |
289 | // m_HtmlWin will *always* be created, but it's important to realize that | |
f0b6a33f | 290 | // m_ContentsBox, m_IndexList, m_SearchList, m_SearchButton, m_SearchText and |
d5bb85a0 VS |
291 | // m_SearchButton may be NULL. |
292 | // moreover, if no contents, index or searchpage is needed, m_Splitter and | |
293 | // m_NavigPan will be NULL too (with m_HtmlWin directly connected to the frame) | |
294 | ||
3379ed37 | 295 | bool wxHtmlHelpFrame::Create(wxWindow* parent, wxWindowID id, |
576507e2 | 296 | const wxString& WXUNUSED(title), int style) |
8ec2b484 | 297 | { |
576507e2 VS |
298 | m_hfStyle = style; |
299 | ||
8fd2b35c | 300 | wxImageList *ContentsImageList = new wxImageList(16, 16); |
f435c1f0 VS |
301 | ContentsImageList->Add(wxArtProvider::GetIcon(wxART_HELP_BOOK, wxART_HELP_BROWSER)); |
302 | ContentsImageList->Add(wxArtProvider::GetIcon(wxART_HELP_FOLDER, wxART_HELP_BROWSER)); | |
303 | ContentsImageList->Add(wxArtProvider::GetIcon(wxART_HELP_PAGE, wxART_HELP_BROWSER)); | |
8fd2b35c | 304 | |
8ec2b484 HH |
305 | // Do the config in two steps. We read the HtmlWindow customization after we |
306 | // create the window. | |
d5bb85a0 VS |
307 | if (m_Config) |
308 | ReadCustomization(m_Config, m_ConfigRoot); | |
8ec2b484 | 309 | |
dabbc6a5 DS |
310 | wxFrame::Create(parent, id, _("Help"), |
311 | wxPoint(m_Cfg.x, m_Cfg.y), wxSize(m_Cfg.w, m_Cfg.h), | |
5229b11d | 312 | wxDEFAULT_FRAME_STYLE, wxT("wxHtmlHelp")); |
8ec2b484 | 313 | |
5c172c17 VS |
314 | GetPosition(&m_Cfg.x, &m_Cfg.y); |
315 | ||
79683a13 | 316 | SetIcon(wxArtProvider::GetIcon(wxART_HELP, wxART_HELP_BROWSER)); |
9ffdee80 | 317 | |
d9b21c9f JS |
318 | // On the Mac, each modeless frame must have a menubar. |
319 | // TODO: add more menu items, and perhaps add a style to show | |
320 | // the menubar: compulsory on the Mac, optional elsewhere. | |
321 | #ifdef __WXMAC__ | |
322 | wxMenuBar* menuBar = new wxMenuBar; | |
323 | ||
324 | wxMenu* fileMenu = new wxMenu; | |
325 | fileMenu->Append(wxID_HTML_OPENFILE, _("&Open...")); | |
d9b21c9f JS |
326 | fileMenu->AppendSeparator(); |
327 | fileMenu->Append(wxID_CLOSE, _("&Close")); | |
328 | ||
b05206c9 JS |
329 | wxMenu* helpMenu = new wxMenu; |
330 | helpMenu->Append(wxID_ABOUT, _("&About...")); | |
d9b21c9f | 331 | |
c3eeb758 RD |
332 | menuBar->Append(fileMenu,_("&File")); |
333 | menuBar->Append(helpMenu,_("&Help")); | |
d9b21c9f JS |
334 | SetMenuBar(menuBar); |
335 | #endif | |
336 | ||
8ec2b484 HH |
337 | int notebook_page = 0; |
338 | ||
339 | CreateStatusBar(); | |
340 | ||
ee2f6a93 | 341 | #if wxUSE_TOOLBAR |
8ec2b484 | 342 | // toolbar? |
576507e2 | 343 | if (style & (wxHF_TOOLBAR | wxHF_FLAT_TOOLBAR)) |
4f9297b0 | 344 | { |
f6bcfd97 BP |
345 | wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | |
346 | wxTB_DOCKABLE | | |
576507e2 | 347 | (style & wxHF_FLAT_TOOLBAR ? wxTB_FLAT : 0)); |
00655497 | 348 | toolBar->SetMargins( 2, 2 ); |
b854b7b8 | 349 | AddToolbarButtons(toolBar, style); |
4f9297b0 | 350 | toolBar->Realize(); |
8ec2b484 | 351 | } |
ee2f6a93 | 352 | #endif //wxUSE_TOOLBAR |
d5bb85a0 | 353 | |
5229b11d VS |
354 | wxSizer *navigSizer = NULL; |
355 | ||
da4cc40c | 356 | if (style & (wxHF_CONTENTS | wxHF_INDEX | wxHF_SEARCH)) |
4f9297b0 | 357 | { |
d5bb85a0 VS |
358 | // traditional help controller; splitter window with html page on the |
359 | // right and a notebook containing various pages on the left | |
360 | m_Splitter = new wxSplitterWindow(this); | |
361 | ||
0646614d | 362 | m_HtmlWin = new wxHtmlHelpHtmlWindow(this, m_Splitter); |
dabbc6a5 | 363 | m_NavigPan = new wxPanel(m_Splitter, wxID_ANY); |
5229b11d VS |
364 | m_NavigNotebook = new wxNotebook(m_NavigPan, wxID_HTML_NOTEBOOK, |
365 | wxDefaultPosition, wxDefaultSize); | |
dabbc6a5 | 366 | |
5229b11d | 367 | navigSizer = new wxBoxSizer(wxVERTICAL); |
adbf2d73 | 368 | navigSizer->Add(m_NavigNotebook, 1, wxEXPAND); |
5229b11d | 369 | |
5229b11d | 370 | m_NavigPan->SetSizer(navigSizer); |
da4cc40c DW |
371 | } |
372 | else | |
4f9297b0 | 373 | { // only html window, no notebook with index,contents etc |
d5bb85a0 | 374 | m_HtmlWin = new wxHtmlWindow(this); |
8ec2b484 HH |
375 | } |
376 | ||
4f9297b0 VS |
377 | m_HtmlWin->SetRelatedFrame(this, m_TitleFormat); |
378 | m_HtmlWin->SetRelatedStatusBar(0); | |
5229b11d | 379 | if ( m_Config ) |
4f9297b0 | 380 | m_HtmlWin->ReadCustomization(m_Config, m_ConfigRoot); |
8ec2b484 HH |
381 | |
382 | // contents tree panel? | |
5229b11d | 383 | if ( style & wxHF_CONTENTS ) |
4f9297b0 | 384 | { |
5229b11d VS |
385 | wxWindow *dummy = new wxPanel(m_NavigNotebook, wxID_HTML_INDEXPAGE); |
386 | wxSizer *topsizer = new wxBoxSizer(wxVERTICAL); | |
dabbc6a5 | 387 | |
5229b11d | 388 | topsizer->Add(0, 10); |
dabbc6a5 | 389 | |
5229b11d VS |
390 | dummy->SetSizer(topsizer); |
391 | ||
5229b11d | 392 | if ( style & wxHF_BOOKMARKS ) |
3379ed37 | 393 | { |
dabbc6a5 | 394 | m_Bookmarks = new wxComboBox(dummy, wxID_HTML_BOOKMARKSLIST, |
5229b11d | 395 | wxEmptyString, |
dabbc6a5 | 396 | wxDefaultPosition, wxDefaultSize, |
5229b11d | 397 | 0, NULL, wxCB_READONLY | wxCB_SORT); |
4f9297b0 | 398 | m_Bookmarks->Append(_("(bookmarks)")); |
ae80f837 | 399 | for (unsigned i = 0; i < m_BookmarksNames.GetCount(); i++) |
4f9297b0 VS |
400 | m_Bookmarks->Append(m_BookmarksNames[i]); |
401 | m_Bookmarks->SetSelection(0); | |
ae80f837 | 402 | |
5229b11d | 403 | wxBitmapButton *bmpbt1, *bmpbt2; |
dabbc6a5 DS |
404 | bmpbt1 = new wxBitmapButton(dummy, wxID_HTML_BOOKMARKSADD, |
405 | wxArtProvider::GetBitmap(wxART_ADD_BOOKMARK, | |
f435c1f0 | 406 | wxART_HELP_BROWSER)); |
dabbc6a5 DS |
407 | bmpbt2 = new wxBitmapButton(dummy, wxID_HTML_BOOKMARKSREMOVE, |
408 | wxArtProvider::GetBitmap(wxART_DEL_BOOKMARK, | |
f435c1f0 | 409 | wxART_HELP_BROWSER)); |
5229b11d VS |
410 | #if wxUSE_TOOLTIPS |
411 | bmpbt1->SetToolTip(_("Add current page to bookmarks")); | |
412 | bmpbt2->SetToolTip(_("Remove current page from bookmarks")); | |
413 | #endif // wxUSE_TOOLTIPS | |
414 | ||
415 | wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL); | |
dabbc6a5 | 416 | |
f435c1f0 VS |
417 | sizer->Add(m_Bookmarks, 1, wxALIGN_CENTRE_VERTICAL | wxRIGHT, 5); |
418 | sizer->Add(bmpbt1, 0, wxALIGN_CENTRE_VERTICAL | wxRIGHT, 2); | |
419 | sizer->Add(bmpbt2, 0, wxALIGN_CENTRE_VERTICAL, 0); | |
dabbc6a5 | 420 | |
5229b11d | 421 | topsizer->Add(sizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 10); |
ae80f837 VS |
422 | } |
423 | ||
5229b11d VS |
424 | m_ContentsBox = new wxTreeCtrl(dummy, wxID_HTML_TREECTRL, |
425 | wxDefaultPosition, wxDefaultSize, | |
dabbc6a5 | 426 | wxSUNKEN_BORDER | |
e0952648 VS |
427 | wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT | |
428 | wxTR_LINES_AT_ROOT); | |
429 | ||
5229b11d | 430 | m_ContentsBox->AssignImageList(ContentsImageList); |
dabbc6a5 | 431 | |
d49520c3 | 432 | topsizer->Add(m_ContentsBox, 1, |
395a82b1 | 433 | wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, |
d49520c3 | 434 | 2); |
ae80f837 | 435 | |
5229b11d | 436 | m_NavigNotebook->AddPage(dummy, _("Contents")); |
d5bb85a0 | 437 | m_ContentsPage = notebook_page++; |
8ec2b484 HH |
438 | } |
439 | ||
440 | // index listbox panel? | |
5229b11d | 441 | if ( style & wxHF_INDEX ) |
4f9297b0 | 442 | { |
dabbc6a5 | 443 | wxWindow *dummy = new wxPanel(m_NavigNotebook, wxID_HTML_INDEXPAGE); |
5229b11d VS |
444 | wxSizer *topsizer = new wxBoxSizer(wxVERTICAL); |
445 | ||
5229b11d VS |
446 | dummy->SetSizer(topsizer); |
447 | ||
dabbc6a5 DS |
448 | m_IndexText = new wxTextCtrl(dummy, wxID_HTML_INDEXTEXT, wxEmptyString, |
449 | wxDefaultPosition, wxDefaultSize, | |
5229b11d | 450 | wxTE_PROCESS_ENTER); |
f0b6a33f | 451 | m_IndexButton = new wxButton(dummy, wxID_HTML_INDEXBUTTON, _("Find")); |
dabbc6a5 | 452 | m_IndexButtonAll = new wxButton(dummy, wxID_HTML_INDEXBUTTONALL, |
5229b11d | 453 | _("Show all")); |
dabbc6a5 | 454 | m_IndexCountInfo = new wxStaticText(dummy, wxID_HTML_COUNTINFO, |
5229b11d | 455 | wxEmptyString, wxDefaultPosition, |
dabbc6a5 | 456 | wxDefaultSize, |
5229b11d | 457 | wxALIGN_RIGHT | wxST_NO_AUTORESIZE); |
dabbc6a5 DS |
458 | m_IndexList = new wxListBox(dummy, wxID_HTML_INDEXLIST, |
459 | wxDefaultPosition, wxDefaultSize, | |
5229b11d | 460 | 0, NULL, wxLB_SINGLE); |
f0b6a33f | 461 | |
7618e374 | 462 | #if wxUSE_TOOLTIPS |
4f9297b0 | 463 | m_IndexButton->SetToolTip(_("Display all index items that contain given substring. Search is case insensitive.")); |
5229b11d | 464 | m_IndexButtonAll->SetToolTip(_("Show all items in index")); |
7618e374 VS |
465 | #endif //wxUSE_TOOLTIPS |
466 | ||
5229b11d VS |
467 | topsizer->Add(m_IndexText, 0, wxEXPAND | wxALL, 10); |
468 | wxSizer *btsizer = new wxBoxSizer(wxHORIZONTAL); | |
469 | btsizer->Add(m_IndexButton, 0, wxRIGHT, 2); | |
470 | btsizer->Add(m_IndexButtonAll); | |
dabbc6a5 | 471 | topsizer->Add(btsizer, 0, |
5229b11d VS |
472 | wxALIGN_RIGHT | wxLEFT | wxRIGHT | wxBOTTOM, 10); |
473 | topsizer->Add(m_IndexCountInfo, 0, wxEXPAND | wxLEFT | wxRIGHT, 2); | |
395a82b1 | 474 | topsizer->Add(m_IndexList, 1, wxEXPAND | wxALL, 2); |
f0b6a33f | 475 | |
5229b11d | 476 | m_NavigNotebook->AddPage(dummy, _("Index")); |
d5bb85a0 | 477 | m_IndexPage = notebook_page++; |
8ec2b484 HH |
478 | } |
479 | ||
480 | // search list panel? | |
5229b11d | 481 | if ( style & wxHF_SEARCH ) |
4f9297b0 | 482 | { |
dabbc6a5 | 483 | wxWindow *dummy = new wxPanel(m_NavigNotebook, wxID_HTML_INDEXPAGE); |
5229b11d | 484 | wxSizer *sizer = new wxBoxSizer(wxVERTICAL); |
c4971147 | 485 | |
5229b11d VS |
486 | dummy->SetSizer(sizer); |
487 | ||
dabbc6a5 DS |
488 | m_SearchText = new wxTextCtrl(dummy, wxID_HTML_SEARCHTEXT, |
489 | wxEmptyString, | |
490 | wxDefaultPosition, wxDefaultSize, | |
5229b11d | 491 | wxTE_PROCESS_ENTER); |
dabbc6a5 | 492 | m_SearchChoice = new wxChoice(dummy, wxID_HTML_SEARCHCHOICE, |
5229b11d | 493 | wxDefaultPosition, wxDefaultSize); |
dabbc6a5 DS |
494 | m_SearchCaseSensitive = new wxCheckBox(dummy, wxID_ANY, _("Case sensitive")); |
495 | m_SearchWholeWords = new wxCheckBox(dummy, wxID_ANY, _("Whole words only")); | |
ae80f837 VS |
496 | m_SearchButton = new wxButton(dummy, wxID_HTML_SEARCHBUTTON, _("Search")); |
497 | #if wxUSE_TOOLTIPS | |
4f9297b0 | 498 | m_SearchButton->SetToolTip(_("Search contents of help book(s) for all occurences of the text you typed above")); |
ae80f837 | 499 | #endif //wxUSE_TOOLTIPS |
dabbc6a5 DS |
500 | m_SearchList = new wxListBox(dummy, wxID_HTML_SEARCHLIST, |
501 | wxDefaultPosition, wxDefaultSize, | |
5229b11d | 502 | 0, NULL, wxLB_SINGLE); |
dabbc6a5 | 503 | |
5229b11d VS |
504 | sizer->Add(m_SearchText, 0, wxEXPAND | wxALL, 10); |
505 | sizer->Add(m_SearchChoice, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 10); | |
506 | sizer->Add(m_SearchCaseSensitive, 0, wxLEFT | wxRIGHT, 10); | |
507 | sizer->Add(m_SearchWholeWords, 0, wxLEFT | wxRIGHT, 10); | |
508 | sizer->Add(m_SearchButton, 0, wxALL | wxALIGN_RIGHT, 8); | |
395a82b1 | 509 | sizer->Add(m_SearchList, 1, wxALL | wxEXPAND, 2); |
5229b11d VS |
510 | |
511 | m_NavigNotebook->AddPage(dummy, _("Search")); | |
999836aa | 512 | m_SearchPage = notebook_page; |
8ec2b484 | 513 | } |
5229b11d | 514 | |
dabbc6a5 | 515 | m_HtmlWin->Show(); |
f6bcfd97 | 516 | |
b5a7b000 | 517 | RefreshLists(); |
8ec2b484 | 518 | |
5229b11d VS |
519 | if ( navigSizer ) |
520 | { | |
d49520c3 | 521 | navigSizer->SetSizeHints(m_NavigPan); |
5229b11d VS |
522 | m_NavigPan->Layout(); |
523 | } | |
524 | ||
8ec2b484 | 525 | // showtime |
5229b11d | 526 | if ( m_NavigPan && m_Splitter ) |
4f9297b0 VS |
527 | { |
528 | m_Splitter->SetMinimumPaneSize(20); | |
5229b11d | 529 | if ( m_Cfg.navig_on ) |
4f9297b0 | 530 | m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); |
4f9297b0 | 531 | |
5229b11d | 532 | if ( m_Cfg.navig_on ) |
3379ed37 | 533 | { |
dabbc6a5 | 534 | m_NavigPan->Show(); |
4f9297b0 | 535 | m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); |
c32bfc10 | 536 | } |
da4cc40c | 537 | else |
3379ed37 | 538 | { |
dabbc6a5 | 539 | m_NavigPan->Show(false); |
4f9297b0 | 540 | m_Splitter->Initialize(m_HtmlWin); |
68364659 | 541 | } |
8ec2b484 | 542 | } |
dabbc6a5 | 543 | |
7e521b01 JS |
544 | // Reduce flicker by updating the splitter pane sizes before the |
545 | // frame is shown | |
546 | wxSizeEvent sizeEvent(GetSize(), GetId()); | |
547 | ProcessEvent(sizeEvent); | |
dabbc6a5 | 548 | |
7e521b01 | 549 | m_Splitter->UpdateSize(); |
dabbc6a5 DS |
550 | |
551 | return true; | |
8ec2b484 HH |
552 | } |
553 | ||
554 | wxHtmlHelpFrame::~wxHtmlHelpFrame() | |
555 | { | |
b4414c1f | 556 | // PopEventHandler(); // wxhtmlhelpcontroller (not any more!) |
8ec2b484 | 557 | if (m_DataCreated) |
d5bb85a0 | 558 | delete m_Data; |
83efdf33 VS |
559 | if (m_NormalFonts) delete m_NormalFonts; |
560 | if (m_FixedFonts) delete m_FixedFonts; | |
dabbc6a5 | 561 | if (m_PagesHash) |
ba8c1601 MB |
562 | { |
563 | WX_CLEAR_HASH_TABLE(*m_PagesHash); | |
564 | delete m_PagesHash; | |
565 | } | |
6c24d95c VS |
566 | #if wxUSE_PRINTING_ARCHITECTURE |
567 | if (m_Printer) delete m_Printer; | |
568 | #endif | |
8ec2b484 HH |
569 | } |
570 | ||
b854b7b8 | 571 | |
ee2f6a93 | 572 | #if wxUSE_TOOLBAR |
b854b7b8 VS |
573 | void wxHtmlHelpFrame::AddToolbarButtons(wxToolBar *toolBar, int style) |
574 | { | |
dabbc6a5 | 575 | wxBitmap wpanelBitmap = |
f435c1f0 | 576 | wxArtProvider::GetBitmap(wxART_HELP_SIDE_PANEL, wxART_HELP_BROWSER); |
dabbc6a5 | 577 | wxBitmap wbackBitmap = |
f435c1f0 | 578 | wxArtProvider::GetBitmap(wxART_GO_BACK, wxART_HELP_BROWSER); |
dabbc6a5 | 579 | wxBitmap wforwardBitmap = |
f435c1f0 | 580 | wxArtProvider::GetBitmap(wxART_GO_FORWARD, wxART_HELP_BROWSER); |
dabbc6a5 | 581 | wxBitmap wupnodeBitmap = |
f435c1f0 | 582 | wxArtProvider::GetBitmap(wxART_GO_TO_PARENT, wxART_HELP_BROWSER); |
dabbc6a5 | 583 | wxBitmap wupBitmap = |
f435c1f0 | 584 | wxArtProvider::GetBitmap(wxART_GO_UP, wxART_HELP_BROWSER); |
dabbc6a5 | 585 | wxBitmap wdownBitmap = |
f435c1f0 | 586 | wxArtProvider::GetBitmap(wxART_GO_DOWN, wxART_HELP_BROWSER); |
dabbc6a5 | 587 | wxBitmap wopenBitmap = |
f435c1f0 | 588 | wxArtProvider::GetBitmap(wxART_FILE_OPEN, wxART_HELP_BROWSER); |
dabbc6a5 | 589 | wxBitmap wprintBitmap = |
f435c1f0 | 590 | wxArtProvider::GetBitmap(wxART_PRINT, wxART_HELP_BROWSER); |
dabbc6a5 | 591 | wxBitmap woptionsBitmap = |
f435c1f0 | 592 | wxArtProvider::GetBitmap(wxART_HELP_SETTINGS, wxART_HELP_BROWSER); |
f6bcfd97 BP |
593 | |
594 | wxASSERT_MSG( (wpanelBitmap.Ok() && wbackBitmap.Ok() && | |
595 | wforwardBitmap.Ok() && wupnodeBitmap.Ok() && | |
596 | wupBitmap.Ok() && wdownBitmap.Ok() && | |
597 | wopenBitmap.Ok() && wprintBitmap.Ok() && | |
598 | woptionsBitmap.Ok()), | |
599 | wxT("One or more HTML help frame toolbar bitmap could not be loaded.")) ; | |
600 | ||
601 | ||
4f9297b0 | 602 | toolBar->AddTool(wxID_HTML_PANEL, wpanelBitmap, wxNullBitmap, |
dabbc6a5 | 603 | false, -1, -1, (wxObject *) NULL, |
b854b7b8 | 604 | _("Show/hide navigation panel")); |
0646614d | 605 | |
4f9297b0 VS |
606 | toolBar->AddSeparator(); |
607 | toolBar->AddTool(wxID_HTML_BACK, wbackBitmap, wxNullBitmap, | |
dabbc6a5 | 608 | false, -1, -1, (wxObject *) NULL, |
0646614d | 609 | _("Go back")); |
4f9297b0 | 610 | toolBar->AddTool(wxID_HTML_FORWARD, wforwardBitmap, wxNullBitmap, |
dabbc6a5 | 611 | false, -1, -1, (wxObject *) NULL, |
0646614d | 612 | _("Go forward")); |
4f9297b0 | 613 | toolBar->AddSeparator(); |
b854b7b8 | 614 | |
4f9297b0 | 615 | toolBar->AddTool(wxID_HTML_UPNODE, wupnodeBitmap, wxNullBitmap, |
dabbc6a5 | 616 | false, -1, -1, (wxObject *) NULL, |
0646614d | 617 | _("Go one level up in document hierarchy")); |
4f9297b0 | 618 | toolBar->AddTool(wxID_HTML_UP, wupBitmap, wxNullBitmap, |
dabbc6a5 | 619 | false, -1, -1, (wxObject *) NULL, |
0646614d | 620 | _("Previous page")); |
4f9297b0 | 621 | toolBar->AddTool(wxID_HTML_DOWN, wdownBitmap, wxNullBitmap, |
dabbc6a5 | 622 | false, -1, -1, (wxObject *) NULL, |
0646614d VS |
623 | _("Next page")); |
624 | ||
576507e2 | 625 | if ((style & wxHF_PRINT) || (style & wxHF_OPEN_FILES)) |
4f9297b0 | 626 | toolBar->AddSeparator(); |
f6bcfd97 | 627 | |
576507e2 | 628 | if (style & wxHF_OPEN_FILES) |
4f9297b0 | 629 | toolBar->AddTool(wxID_HTML_OPENFILE, wopenBitmap, wxNullBitmap, |
dabbc6a5 | 630 | false, -1, -1, (wxObject *) NULL, |
0646614d VS |
631 | _("Open HTML document")); |
632 | ||
633 | #if wxUSE_PRINTING_ARCHITECTURE | |
634 | if (style & wxHF_PRINT) | |
4f9297b0 | 635 | toolBar->AddTool(wxID_HTML_PRINT, wprintBitmap, wxNullBitmap, |
dabbc6a5 | 636 | false, -1, -1, (wxObject *) NULL, |
0646614d VS |
637 | _("Print this page")); |
638 | #endif | |
639 | ||
4f9297b0 VS |
640 | toolBar->AddSeparator(); |
641 | toolBar->AddTool(wxID_HTML_OPTIONS, woptionsBitmap, wxNullBitmap, | |
dabbc6a5 | 642 | false, -1, -1, (wxObject *) NULL, |
b854b7b8 VS |
643 | _("Display options dialog")); |
644 | } | |
ee2f6a93 | 645 | #endif //wxUSE_TOOLBAR |
b854b7b8 VS |
646 | |
647 | ||
721ab905 VS |
648 | void wxHtmlHelpFrame::SetTitleFormat(const wxString& format) |
649 | { | |
650 | if (m_HtmlWin) | |
651 | m_HtmlWin->SetRelatedFrame(this, format); | |
652 | m_TitleFormat = format; | |
653 | } | |
654 | ||
b854b7b8 | 655 | |
8ec2b484 HH |
656 | bool wxHtmlHelpFrame::Display(const wxString& x) |
657 | { | |
658 | wxString url = m_Data->FindPageByName(x); | |
da4cc40c | 659 | if (!url.IsEmpty()) |
4f9297b0 | 660 | { |
d5bb85a0 | 661 | m_HtmlWin->LoadPage(url); |
0646614d | 662 | NotifyPageChanged(); |
dabbc6a5 | 663 | return true; |
8ec2b484 | 664 | } |
dabbc6a5 DS |
665 | |
666 | return false; | |
8ec2b484 HH |
667 | } |
668 | ||
669 | bool wxHtmlHelpFrame::Display(const int id) | |
670 | { | |
671 | wxString url = m_Data->FindPageById(id); | |
da4cc40c | 672 | if (!url.IsEmpty()) |
4f9297b0 | 673 | { |
d5bb85a0 | 674 | m_HtmlWin->LoadPage(url); |
0646614d | 675 | NotifyPageChanged(); |
dabbc6a5 | 676 | return true; |
8ec2b484 | 677 | } |
dabbc6a5 DS |
678 | |
679 | return false; | |
8ec2b484 HH |
680 | } |
681 | ||
682 | ||
683 | ||
684 | bool wxHtmlHelpFrame::DisplayContents() | |
685 | { | |
686 | if (! m_ContentsBox) | |
dabbc6a5 DS |
687 | return false; |
688 | ||
da4cc40c | 689 | if (!m_Splitter->IsSplit()) |
4f9297b0 | 690 | { |
dabbc6a5 DS |
691 | m_NavigPan->Show(); |
692 | m_HtmlWin->Show(); | |
4f9297b0 | 693 | m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); |
dabbc6a5 | 694 | m_Cfg.navig_on = true; |
8ec2b484 | 695 | } |
dabbc6a5 | 696 | |
5229b11d | 697 | m_NavigNotebook->SetSelection(0); |
dabbc6a5 | 698 | |
71d04f7f JS |
699 | if (m_Data->GetBookRecArray().GetCount() > 0) |
700 | { | |
701 | wxHtmlBookRecord& book = m_Data->GetBookRecArray()[0]; | |
702 | if (!book.GetStart().IsEmpty()) | |
468ae730 | 703 | m_HtmlWin->LoadPage(book.GetFullPath(book.GetStart())); |
71d04f7f | 704 | } |
dabbc6a5 DS |
705 | |
706 | return true; | |
8ec2b484 HH |
707 | } |
708 | ||
709 | ||
710 | ||
711 | bool wxHtmlHelpFrame::DisplayIndex() | |
712 | { | |
f0b6a33f | 713 | if (! m_IndexList) |
dabbc6a5 DS |
714 | return false; |
715 | ||
da4cc40c | 716 | if (!m_Splitter->IsSplit()) |
4f9297b0 | 717 | { |
dabbc6a5 DS |
718 | m_NavigPan->Show(); |
719 | m_HtmlWin->Show(); | |
4f9297b0 | 720 | m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); |
8ec2b484 | 721 | } |
dabbc6a5 | 722 | |
5229b11d | 723 | m_NavigNotebook->SetSelection(1); |
dabbc6a5 | 724 | |
71d04f7f JS |
725 | if (m_Data->GetBookRecArray().GetCount() > 0) |
726 | { | |
727 | wxHtmlBookRecord& book = m_Data->GetBookRecArray()[0]; | |
728 | if (!book.GetStart().IsEmpty()) | |
468ae730 | 729 | m_HtmlWin->LoadPage(book.GetFullPath(book.GetStart())); |
71d04f7f | 730 | } |
dabbc6a5 DS |
731 | |
732 | return true; | |
8ec2b484 | 733 | } |
020707bb | 734 | |
91fa114d VS |
735 | void wxHtmlHelpFrame::DisplayIndexItem(const wxHtmlHelpMergedIndexItem *it) |
736 | { | |
737 | if (it->items.size() == 1) | |
738 | { | |
739 | if (!it->items[0]->page.empty()) | |
740 | { | |
741 | m_HtmlWin->LoadPage(it->items[0]->GetFullPath()); | |
742 | NotifyPageChanged(); | |
743 | } | |
744 | } | |
745 | else | |
746 | { | |
747 | wxBusyCursor busy_cursor; | |
8ec2b484 | 748 | |
91fa114d VS |
749 | // more pages associated with this index item -- let the user choose |
750 | // which one she/he wants from a list: | |
751 | wxArrayString arr; | |
752 | size_t len = it->items.size(); | |
753 | for (size_t i = 0; i < len; i++) | |
754 | { | |
755 | wxString page = it->items[i]->page; | |
756 | // try to find page's title in contents: | |
757 | const wxHtmlHelpDataItems& contents = m_Data->GetContentsArray(); | |
758 | size_t clen = contents.size(); | |
759 | for (size_t j = 0; j < clen; j++) | |
760 | { | |
761 | if (contents[j].page == page) | |
762 | { | |
763 | page = contents[j].name; | |
764 | break; | |
765 | } | |
766 | } | |
767 | arr.push_back(page); | |
768 | } | |
769 | ||
770 | wxSingleChoiceDialog dlg(this, | |
771 | _("Please choose the page to display:"), | |
772 | _("Help Topics"), | |
773 | arr, NULL, wxCHOICEDLG_STYLE & ~wxCENTRE); | |
774 | if (dlg.ShowModal() == wxID_OK) | |
775 | { | |
776 | m_HtmlWin->LoadPage(it->items[dlg.GetSelection()]->GetFullPath()); | |
777 | NotifyPageChanged(); | |
778 | } | |
779 | } | |
780 | } | |
b854b7b8 VS |
781 | |
782 | ||
69b5cec2 VS |
783 | bool wxHtmlHelpFrame::KeywordSearch(const wxString& keyword, |
784 | wxHelpSearchMode mode) | |
8ec2b484 | 785 | { |
69b5cec2 VS |
786 | if (mode == wxHELP_SEARCH_ALL) |
787 | { | |
788 | if ( !(m_SearchList && | |
789 | m_SearchButton && m_SearchText && m_SearchChoice) ) | |
790 | return false; | |
791 | } | |
792 | else if (mode == wxHELP_SEARCH_INDEX) | |
793 | { | |
794 | if ( !(m_IndexList && | |
795 | m_IndexButton && m_IndexButtonAll && m_IndexText) ) | |
796 | return false; | |
797 | } | |
8ec2b484 | 798 | |
69b5cec2 | 799 | int foundcnt = 0; |
8ec2b484 HH |
800 | wxString foundstr; |
801 | wxString book = wxEmptyString; | |
802 | ||
da4cc40c | 803 | if (!m_Splitter->IsSplit()) |
4f9297b0 | 804 | { |
dabbc6a5 DS |
805 | m_NavigPan->Show(); |
806 | m_HtmlWin->Show(); | |
4f9297b0 | 807 | m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); |
8ec2b484 | 808 | } |
8ec2b484 | 809 | |
69b5cec2 | 810 | if (mode == wxHELP_SEARCH_ALL) |
4f9297b0 | 811 | { |
69b5cec2 VS |
812 | m_NavigNotebook->SetSelection(m_SearchPage); |
813 | m_SearchList->Clear(); | |
814 | m_SearchText->SetValue(keyword); | |
dabbc6a5 | 815 | m_SearchButton->Disable(); |
69b5cec2 VS |
816 | |
817 | if (m_SearchChoice->GetSelection() != 0) | |
818 | book = m_SearchChoice->GetStringSelection(); | |
819 | ||
820 | wxHtmlSearchStatus status(m_Data, keyword, | |
821 | m_SearchCaseSensitive->GetValue(), | |
822 | m_SearchWholeWords->GetValue(), | |
823 | book); | |
824 | ||
3511e024 | 825 | #if wxUSE_PROGRESSDLG |
69b5cec2 VS |
826 | wxProgressDialog progress(_("Searching..."), |
827 | _("No matching page found yet"), | |
828 | status.GetMaxIndex(), this, | |
829 | wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_AUTO_HIDE); | |
3511e024 | 830 | #endif |
69b5cec2 VS |
831 | |
832 | int curi; | |
833 | while (status.IsActive()) | |
3379ed37 | 834 | { |
69b5cec2 | 835 | curi = status.GetCurIndex(); |
dabbc6a5 | 836 | if (curi % 32 == 0 |
3511e024 | 837 | #if wxUSE_PROGRESSDLG |
dabbc6a5 | 838 | && !progress.Update(curi) |
3511e024 WS |
839 | #endif |
840 | ) | |
69b5cec2 VS |
841 | break; |
842 | if (status.Search()) | |
843 | { | |
844 | foundstr.Printf(_("Found %i matches"), ++foundcnt); | |
3511e024 | 845 | #if wxUSE_PROGRESSDLG |
69b5cec2 | 846 | progress.Update(status.GetCurIndex(), foundstr); |
3511e024 | 847 | #endif |
91fa114d | 848 | m_SearchList->Append(status.GetName(), (void*)status.GetCurItem()); |
69b5cec2 | 849 | } |
d5bb85a0 | 850 | } |
69b5cec2 | 851 | |
dabbc6a5 | 852 | m_SearchButton->Enable(); |
69b5cec2 VS |
853 | m_SearchText->SetSelection(0, keyword.Length()); |
854 | m_SearchText->SetFocus(); | |
855 | } | |
856 | else if (mode == wxHELP_SEARCH_INDEX) | |
857 | { | |
858 | m_NavigNotebook->SetSelection(m_IndexPage); | |
859 | m_IndexList->Clear(); | |
dabbc6a5 DS |
860 | m_IndexButton->Disable(); |
861 | m_IndexButtonAll->Disable(); | |
69b5cec2 VS |
862 | m_IndexText->SetValue(keyword); |
863 | ||
864 | wxCommandEvent dummy; | |
865 | OnIndexFind(dummy); // what a hack... | |
dabbc6a5 DS |
866 | m_IndexButton->Enable(); |
867 | m_IndexButtonAll->Enable(); | |
69b5cec2 | 868 | foundcnt = m_IndexList->GetCount(); |
8ec2b484 HH |
869 | } |
870 | ||
da4cc40c | 871 | if (foundcnt) |
4f9297b0 | 872 | { |
75d07c0a | 873 | switch ( mode ) |
69b5cec2 | 874 | { |
75d07c0a VZ |
875 | default: |
876 | wxFAIL_MSG( _T("unknown help search mode") ); | |
877 | // fall back | |
878 | ||
879 | case wxHELP_SEARCH_ALL: | |
91fa114d VS |
880 | { |
881 | wxHtmlHelpDataItem *it = | |
882 | (wxHtmlHelpDataItem*) m_SearchList->GetClientData(0); | |
883 | if (it) | |
884 | { | |
885 | m_HtmlWin->LoadPage(it->GetFullPath()); | |
886 | NotifyPageChanged(); | |
887 | } | |
75d07c0a | 888 | break; |
91fa114d | 889 | } |
75d07c0a VZ |
890 | |
891 | case wxHELP_SEARCH_INDEX: | |
91fa114d VS |
892 | { |
893 | wxHtmlHelpMergedIndexItem* it = | |
894 | (wxHtmlHelpMergedIndexItem*) m_IndexList->GetClientData(0); | |
895 | if (it) | |
896 | DisplayIndexItem(it); | |
75d07c0a | 897 | break; |
91fa114d | 898 | } |
69b5cec2 | 899 | } |
75d07c0a | 900 | |
8ec2b484 | 901 | } |
75d07c0a VZ |
902 | |
903 | return foundcnt > 0; | |
8ec2b484 HH |
904 | } |
905 | ||
b5a7b000 | 906 | void wxHtmlHelpFrame::CreateContents() |
8ec2b484 HH |
907 | { |
908 | if (! m_ContentsBox) | |
d5bb85a0 | 909 | return ; |
8ec2b484 | 910 | |
ba8c1601 MB |
911 | if (m_PagesHash) |
912 | { | |
913 | WX_CLEAR_HASH_TABLE(*m_PagesHash); | |
914 | delete m_PagesHash; | |
915 | } | |
91fa114d VS |
916 | |
917 | const wxHtmlHelpDataItems& contents = m_Data->GetContentsArray(); | |
918 | ||
919 | size_t cnt = contents.size(); | |
8ec2b484 | 920 | |
91fa114d | 921 | m_PagesHash = new wxHashTable(wxKEY_STRING, 2 * cnt); |
d5bb85a0 | 922 | |
576507e2 | 923 | const int MAX_ROOTS = 64; |
8ec2b484 | 924 | wxTreeItemId roots[MAX_ROOTS]; |
576507e2 VS |
925 | // VS: this array holds information about whether we've set item icon at |
926 | // given level. This is neccessary because m_Data has flat structure | |
927 | // and there's no way of recognizing if some item has subitems or not. | |
928 | // We set the icon later: when we find an item with level=n, we know | |
929 | // that the last item with level=n-1 was folder with subitems, so we | |
930 | // set its icon accordingly | |
3379ed37 | 931 | bool imaged[MAX_ROOTS]; |
4f9297b0 | 932 | m_ContentsBox->DeleteAllItems(); |
dabbc6a5 | 933 | |
e0952648 | 934 | roots[0] = m_ContentsBox->AddRoot(_("(Help)")); |
dabbc6a5 | 935 | imaged[0] = true; |
8ec2b484 | 936 | |
91fa114d | 937 | for (size_t i = 0; i < cnt; i++) |
4f9297b0 | 938 | { |
91fa114d | 939 | wxHtmlHelpDataItem *it = &contents[i]; |
576507e2 | 940 | // Handle books: |
91fa114d | 941 | if (it->level == 0) |
576507e2 | 942 | { |
e0952648 VS |
943 | if (m_hfStyle & wxHF_MERGE_BOOKS) |
944 | // VS: we don't want book nodes, books' content should | |
945 | // appear under tree's root. This line will create "fake" | |
946 | // record about book node so that the rest of this look | |
947 | // will believe there really _is_ book node and will | |
948 | // behave correctly. | |
949 | roots[1] = roots[0]; | |
950 | else | |
576507e2 | 951 | { |
e0952648 | 952 | roots[1] = m_ContentsBox->AppendItem(roots[0], |
91fa114d | 953 | it->name, IMG_Book, -1, |
576507e2 | 954 | new wxHtmlHelpTreeItemData(i)); |
dabbc6a5 | 955 | m_ContentsBox->SetItemBold(roots[1], true); |
576507e2 | 956 | } |
dabbc6a5 | 957 | imaged[1] = true; |
4f9297b0 | 958 | } |
576507e2 | 959 | // ...and their contents: |
3379ed37 | 960 | else |
576507e2 | 961 | { |
91fa114d VS |
962 | roots[it->level + 1] = m_ContentsBox->AppendItem( |
963 | roots[it->level], it->name, IMG_Page, | |
576507e2 | 964 | -1, new wxHtmlHelpTreeItemData(i)); |
91fa114d | 965 | imaged[it->level + 1] = false; |
576507e2 | 966 | } |
4f9297b0 | 967 | |
576507e2 | 968 | m_PagesHash->Put(it->GetFullPath(), |
91fa114d | 969 | new wxHtmlHelpHashData(i, roots[it->level + 1])); |
576507e2 VS |
970 | |
971 | // Set the icon for the node one level up in the hiearachy, | |
972 | // unless already done (see comment above imaged[] declaration) | |
91fa114d | 973 | if (!imaged[it->level]) |
3379ed37 | 974 | { |
576507e2 VS |
975 | int image = IMG_Folder; |
976 | if (m_hfStyle & wxHF_ICONS_BOOK) | |
977 | image = IMG_Book; | |
978 | else if (m_hfStyle & wxHF_ICONS_BOOK_CHAPTER) | |
91fa114d VS |
979 | image = (it->level == 1) ? IMG_Book : IMG_Folder; |
980 | m_ContentsBox->SetItemImage(roots[it->level], image); | |
981 | m_ContentsBox->SetItemImage(roots[it->level], image, | |
b5f6b52a | 982 | wxTreeItemIcon_Selected); |
91fa114d | 983 | imaged[it->level] = true; |
8ec2b484 HH |
984 | } |
985 | } | |
8ec2b484 HH |
986 | } |
987 | ||
988 | ||
b5a7b000 | 989 | void wxHtmlHelpFrame::CreateIndex() |
8ec2b484 | 990 | { |
f0b6a33f | 991 | if (! m_IndexList) |
d5bb85a0 | 992 | return ; |
8ec2b484 | 993 | |
f0b6a33f | 994 | m_IndexList->Clear(); |
8ec2b484 | 995 | |
91fa114d | 996 | size_t cnt = m_mergedIndex->size(); |
f6bcfd97 | 997 | |
240c2873 | 998 | wxString cnttext; |
91fa114d VS |
999 | if (cnt > INDEX_IS_SMALL) |
1000 | cnttext.Printf(_("%i of %i"), 0, cnt); | |
1001 | else | |
1002 | cnttext.Printf(_("%i of %i"), cnt, cnt); | |
4f9297b0 | 1003 | m_IndexCountInfo->SetLabel(cnttext); |
91fa114d VS |
1004 | if (cnt > INDEX_IS_SMALL) |
1005 | return; | |
8ec2b484 | 1006 | |
91fa114d VS |
1007 | for (size_t i = 0; i < cnt; i++) |
1008 | m_IndexList->Append((*m_mergedIndex)[i].name, | |
1009 | (char*)(&(*m_mergedIndex)[i])); | |
8ec2b484 HH |
1010 | } |
1011 | ||
1012 | void wxHtmlHelpFrame::CreateSearch() | |
1013 | { | |
1014 | if (! (m_SearchList && m_SearchChoice)) | |
d5bb85a0 | 1015 | return ; |
4f9297b0 VS |
1016 | m_SearchList->Clear(); |
1017 | m_SearchChoice->Clear(); | |
1018 | m_SearchChoice->Append(_("Search in all books")); | |
8ec2b484 HH |
1019 | const wxHtmlBookRecArray& bookrec = m_Data->GetBookRecArray(); |
1020 | int i, cnt = bookrec.GetCount(); | |
d5bb85a0 VS |
1021 | for (i = 0; i < cnt; i++) |
1022 | m_SearchChoice->Append(bookrec[i].GetTitle()); | |
8ec2b484 HH |
1023 | m_SearchChoice->SetSelection(0); |
1024 | } | |
1025 | ||
1026 | ||
b5a7b000 | 1027 | void wxHtmlHelpFrame::RefreshLists() |
8ec2b484 | 1028 | { |
91fa114d VS |
1029 | // Update m_mergedIndex: |
1030 | UpdateMergedIndex(); | |
1031 | // Update the controls | |
b5a7b000 VS |
1032 | CreateContents(); |
1033 | CreateIndex(); | |
8ec2b484 HH |
1034 | CreateSearch(); |
1035 | } | |
1036 | ||
1037 | void wxHtmlHelpFrame::ReadCustomization(wxConfigBase *cfg, const wxString& path) | |
1038 | { | |
1039 | wxString oldpath; | |
1040 | wxString tmp; | |
1041 | ||
da4cc40c | 1042 | if (path != wxEmptyString) |
4f9297b0 VS |
1043 | { |
1044 | oldpath = cfg->GetPath(); | |
1045 | cfg->SetPath(_T("/") + path); | |
8ec2b484 HH |
1046 | } |
1047 | ||
4f9297b0 VS |
1048 | m_Cfg.navig_on = cfg->Read(wxT("hcNavigPanel"), m_Cfg.navig_on) != 0; |
1049 | m_Cfg.sashpos = cfg->Read(wxT("hcSashPos"), m_Cfg.sashpos); | |
1050 | m_Cfg.x = cfg->Read(wxT("hcX"), m_Cfg.x); | |
1051 | m_Cfg.y = cfg->Read(wxT("hcY"), m_Cfg.y); | |
1052 | m_Cfg.w = cfg->Read(wxT("hcW"), m_Cfg.w); | |
1053 | m_Cfg.h = cfg->Read(wxT("hcH"), m_Cfg.h); | |
8ec2b484 | 1054 | |
4f9297b0 VS |
1055 | m_FixedFace = cfg->Read(wxT("hcFixedFace"), m_FixedFace); |
1056 | m_NormalFace = cfg->Read(wxT("hcNormalFace"), m_NormalFace); | |
c269cf62 | 1057 | m_FontSize = cfg->Read(wxT("hcBaseFontSize"), m_FontSize); |
83efdf33 | 1058 | |
382e6efe VS |
1059 | { |
1060 | int i; | |
1061 | int cnt; | |
1062 | wxString val, s; | |
f6bcfd97 | 1063 | |
4f9297b0 | 1064 | cnt = cfg->Read(wxT("hcBookmarksCnt"), 0L); |
da4cc40c | 1065 | if (cnt != 0) |
3379ed37 | 1066 | { |
382e6efe VS |
1067 | m_BookmarksNames.Clear(); |
1068 | m_BookmarksPages.Clear(); | |
da4cc40c | 1069 | if (m_Bookmarks) |
3379ed37 | 1070 | { |
4f9297b0 VS |
1071 | m_Bookmarks->Clear(); |
1072 | m_Bookmarks->Append(_("(bookmarks)")); | |
382e6efe | 1073 | } |
f6bcfd97 | 1074 | |
da4cc40c | 1075 | for (i = 0; i < cnt; i++) |
3379ed37 | 1076 | { |
0413cec5 | 1077 | val.Printf(wxT("hcBookmark_%i"), i); |
4f9297b0 | 1078 | s = cfg->Read(val); |
382e6efe | 1079 | m_BookmarksNames.Add(s); |
4f9297b0 | 1080 | if (m_Bookmarks) m_Bookmarks->Append(s); |
0413cec5 | 1081 | val.Printf(wxT("hcBookmark_%i_url"), i); |
4f9297b0 | 1082 | s = cfg->Read(val); |
382e6efe VS |
1083 | m_BookmarksPages.Add(s); |
1084 | } | |
1085 | } | |
1086 | } | |
1087 | ||
8ec2b484 | 1088 | if (m_HtmlWin) |
3e5296e7 | 1089 | m_HtmlWin->ReadCustomization(cfg); |
8ec2b484 HH |
1090 | |
1091 | if (path != wxEmptyString) | |
4f9297b0 | 1092 | cfg->SetPath(oldpath); |
8ec2b484 HH |
1093 | } |
1094 | ||
1095 | void wxHtmlHelpFrame::WriteCustomization(wxConfigBase *cfg, const wxString& path) | |
1096 | { | |
1097 | wxString oldpath; | |
1098 | wxString tmp; | |
8ec2b484 | 1099 | |
da4cc40c | 1100 | if (path != wxEmptyString) |
4f9297b0 VS |
1101 | { |
1102 | oldpath = cfg->GetPath(); | |
1103 | cfg->SetPath(_T("/") + path); | |
8ec2b484 HH |
1104 | } |
1105 | ||
4f9297b0 VS |
1106 | cfg->Write(wxT("hcNavigPanel"), m_Cfg.navig_on); |
1107 | cfg->Write(wxT("hcSashPos"), (long)m_Cfg.sashpos); | |
2b5f62a0 VZ |
1108 | if ( !IsIconized() ) |
1109 | { | |
1110 | // Don't write if iconized as this would make the window | |
1111 | // disappear next time it is shown! | |
1112 | cfg->Write(wxT("hcX"), (long)m_Cfg.x); | |
1113 | cfg->Write(wxT("hcY"), (long)m_Cfg.y); | |
1114 | cfg->Write(wxT("hcW"), (long)m_Cfg.w); | |
1115 | cfg->Write(wxT("hcH"), (long)m_Cfg.h); | |
1116 | } | |
4f9297b0 VS |
1117 | cfg->Write(wxT("hcFixedFace"), m_FixedFace); |
1118 | cfg->Write(wxT("hcNormalFace"), m_NormalFace); | |
c269cf62 | 1119 | cfg->Write(wxT("hcBaseFontSize"), (long)m_FontSize); |
4f9297b0 | 1120 | |
da4cc40c | 1121 | if (m_Bookmarks) |
4f9297b0 | 1122 | { |
382e6efe VS |
1123 | int i; |
1124 | int cnt = m_BookmarksNames.GetCount(); | |
1125 | wxString val; | |
f6bcfd97 | 1126 | |
4f9297b0 | 1127 | cfg->Write(wxT("hcBookmarksCnt"), (long)cnt); |
da4cc40c | 1128 | for (i = 0; i < cnt; i++) |
3379ed37 | 1129 | { |
0413cec5 | 1130 | val.Printf(wxT("hcBookmark_%i"), i); |
4f9297b0 | 1131 | cfg->Write(val, m_BookmarksNames[i]); |
0413cec5 | 1132 | val.Printf(wxT("hcBookmark_%i_url"), i); |
4f9297b0 | 1133 | cfg->Write(val, m_BookmarksPages[i]); |
382e6efe VS |
1134 | } |
1135 | } | |
8ec2b484 HH |
1136 | |
1137 | if (m_HtmlWin) | |
3e5296e7 | 1138 | m_HtmlWin->WriteCustomization(cfg); |
8ec2b484 HH |
1139 | |
1140 | if (path != wxEmptyString) | |
4f9297b0 | 1141 | cfg->SetPath(oldpath); |
8ec2b484 HH |
1142 | } |
1143 | ||
1144 | ||
83efdf33 VS |
1145 | |
1146 | ||
1147 | ||
8eb2940f | 1148 | static void SetFontsToHtmlWin(wxHtmlWindow *win, wxString scalf, wxString fixf, int size) |
83efdf33 | 1149 | { |
c269cf62 VS |
1150 | int f_sizes[7]; |
1151 | f_sizes[0] = int(size * 0.6); | |
1152 | f_sizes[1] = int(size * 0.8); | |
1153 | f_sizes[2] = size; | |
1154 | f_sizes[3] = int(size * 1.2); | |
1155 | f_sizes[4] = int(size * 1.4); | |
1156 | f_sizes[5] = int(size * 1.6); | |
1157 | f_sizes[6] = int(size * 1.8); | |
1158 | ||
1159 | win->SetFonts(scalf, fixf, f_sizes); | |
83efdf33 VS |
1160 | } |
1161 | ||
1162 | ||
1163 | class wxHtmlHelpFrameOptionsDialog : public wxDialog | |
1164 | { | |
c269cf62 VS |
1165 | public: |
1166 | wxComboBox *NormalFont, *FixedFont; | |
1167 | wxSpinCtrl *FontSize; | |
1168 | wxHtmlWindow *TestWin; | |
83efdf33 | 1169 | |
dabbc6a5 DS |
1170 | wxHtmlHelpFrameOptionsDialog(wxWindow *parent) |
1171 | : wxDialog(parent, wxID_ANY, wxString(_("Help Browser Options"))) | |
c269cf62 VS |
1172 | { |
1173 | wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL); | |
1174 | wxFlexGridSizer *sizer = new wxFlexGridSizer(2, 3, 2, 5); | |
1175 | ||
dabbc6a5 DS |
1176 | sizer->Add(new wxStaticText(this, wxID_ANY, _("Normal font:"))); |
1177 | sizer->Add(new wxStaticText(this, wxID_ANY, _("Fixed font:"))); | |
1178 | sizer->Add(new wxStaticText(this, wxID_ANY, _("Font size:"))); | |
c269cf62 | 1179 | |
dabbc6a5 | 1180 | sizer->Add(NormalFont = new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, |
c269cf62 VS |
1181 | wxSize(200, 200), |
1182 | 0, NULL, wxCB_DROPDOWN | wxCB_READONLY)); | |
1183 | ||
dabbc6a5 | 1184 | sizer->Add(FixedFont = new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, |
c269cf62 VS |
1185 | wxSize(200, 200), |
1186 | 0, NULL, wxCB_DROPDOWN | wxCB_READONLY)); | |
1187 | ||
dabbc6a5 | 1188 | sizer->Add(FontSize = new wxSpinCtrl(this, wxID_ANY)); |
c269cf62 VS |
1189 | FontSize->SetRange(2, 100); |
1190 | ||
1191 | topsizer->Add(sizer, 0, wxLEFT|wxRIGHT|wxTOP, 10); | |
1192 | ||
dabbc6a5 | 1193 | topsizer->Add(new wxStaticText(this, wxID_ANY, _("Preview:")), |
c269cf62 | 1194 | 0, wxLEFT | wxTOP, 10); |
dabbc6a5 | 1195 | topsizer->Add(TestWin = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxSize(20, 150), |
c269cf62 VS |
1196 | wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER), |
1197 | 1, wxEXPAND | wxLEFT|wxTOP|wxRIGHT, 10); | |
1198 | ||
1199 | wxBoxSizer *sizer2 = new wxBoxSizer(wxHORIZONTAL); | |
1200 | wxButton *ok; | |
1201 | sizer2->Add(ok = new wxButton(this, wxID_OK, _("OK")), 0, wxALL, 10); | |
1202 | ok->SetDefault(); | |
1203 | sizer2->Add(new wxButton(this, wxID_CANCEL, _("Cancel")), 0, wxALL, 10); | |
1204 | topsizer->Add(sizer2, 0, wxALIGN_RIGHT); | |
1205 | ||
c269cf62 VS |
1206 | SetSizer(topsizer); |
1207 | topsizer->Fit(this); | |
1208 | Centre(wxBOTH); | |
1209 | } | |
f6bcfd97 | 1210 | |
83efdf33 | 1211 | |
c269cf62 VS |
1212 | void UpdateTestWin() |
1213 | { | |
1214 | wxBusyCursor bcur; | |
1215 | SetFontsToHtmlWin(TestWin, | |
1216 | NormalFont->GetStringSelection(), | |
1217 | FixedFont->GetStringSelection(), | |
1218 | FontSize->GetValue()); | |
311ccb86 VZ |
1219 | |
1220 | wxString content(_("font size")); | |
1221 | ||
1222 | content = _T("<font size=-2>") + content + _T(" -2</font><br>") | |
1223 | _T("<font size=-1>") + content + _T(" -1</font><br>") | |
1224 | _T("<font size=+0>") + content + _T(" +0</font><br>") | |
1225 | _T("<font size=+1>") + content + _T(" +1</font><br>") | |
1226 | _T("<font size=+2>") + content + _T(" +2</font><br>") | |
1227 | _T("<font size=+3>") + content + _T(" +3</font><br>") | |
1228 | _T("<font size=+4>") + content + _T(" +4</font><br>") ; | |
1229 | ||
1230 | content = wxString( _T("<html><body><table><tr><td>") ) + | |
1231 | _("Normal face<br>and <u>underlined</u>. ") + | |
1232 | _("<i>Italic face.</i> ") + | |
1233 | _("<b>Bold face.</b> ") + | |
1234 | _("<b><i>Bold italic face.</i></b><br>") + | |
1235 | content + | |
1236 | wxString( _T("</td><td><tt>") ) + | |
1237 | _("Fixed size face.<br> <b>bold</b> <i>italic</i> ") + | |
1238 | _("<b><i>bold italic <u>underlined</u></i></b><br>") + | |
1239 | content + | |
1240 | _T("</tt></td></tr></table></body></html>"); | |
1241 | ||
1242 | TestWin->SetPage( content ); | |
c269cf62 | 1243 | } |
83efdf33 | 1244 | |
c269cf62 VS |
1245 | void OnUpdate(wxCommandEvent& WXUNUSED(event)) |
1246 | { | |
1247 | UpdateTestWin(); | |
1248 | } | |
aab49a0b JS |
1249 | void OnUpdateSpin(wxSpinEvent& WXUNUSED(event)) |
1250 | { | |
1251 | UpdateTestWin(); | |
1252 | } | |
83efdf33 | 1253 | |
c269cf62 | 1254 | DECLARE_EVENT_TABLE() |
22f3361e | 1255 | DECLARE_NO_COPY_CLASS(wxHtmlHelpFrameOptionsDialog) |
83efdf33 VS |
1256 | }; |
1257 | ||
1258 | BEGIN_EVENT_TABLE(wxHtmlHelpFrameOptionsDialog, wxDialog) | |
dabbc6a5 DS |
1259 | EVT_COMBOBOX(wxID_ANY, wxHtmlHelpFrameOptionsDialog::OnUpdate) |
1260 | EVT_SPINCTRL(wxID_ANY, wxHtmlHelpFrameOptionsDialog::OnUpdateSpin) | |
83efdf33 VS |
1261 | END_EVENT_TABLE() |
1262 | ||
83efdf33 VS |
1263 | void wxHtmlHelpFrame::OptionsDialog() |
1264 | { | |
1265 | wxHtmlHelpFrameOptionsDialog dlg(this); | |
1266 | unsigned i; | |
f6bcfd97 | 1267 | |
da4cc40c | 1268 | if (m_NormalFonts == NULL) |
4f9297b0 | 1269 | { |
83efdf33 VS |
1270 | wxFontEnumerator enu; |
1271 | enu.EnumerateFacenames(); | |
1272 | m_NormalFonts = new wxArrayString; | |
1273 | *m_NormalFonts = *enu.GetFacenames(); | |
222ed1d6 | 1274 | m_NormalFonts->Sort(wxStringSortAscending); |
83efdf33 | 1275 | } |
da4cc40c | 1276 | if (m_FixedFonts == NULL) |
4f9297b0 | 1277 | { |
83efdf33 | 1278 | wxFontEnumerator enu; |
dabbc6a5 | 1279 | enu.EnumerateFacenames(wxFONTENCODING_SYSTEM, true /*enum fixed width only*/); |
83efdf33 VS |
1280 | m_FixedFonts = new wxArrayString; |
1281 | *m_FixedFonts = *enu.GetFacenames(); | |
222ed1d6 | 1282 | m_FixedFonts->Sort(wxStringSortAscending); |
83efdf33 | 1283 | } |
dabbc6a5 | 1284 | |
c269cf62 VS |
1285 | // VS: We want to show the font that is actually used by wxHtmlWindow. |
1286 | // If customization dialog wasn't used yet, facenames are empty and | |
1287 | // wxHtmlWindow uses default fonts -- let's find out what they | |
1288 | // are so that we can pass them to the dialog: | |
1289 | if (m_NormalFace.empty()) | |
1290 | { | |
dabbc6a5 | 1291 | wxFont fnt(m_FontSize, wxSWISS, wxNORMAL, wxNORMAL, false); |
c269cf62 VS |
1292 | m_NormalFace = fnt.GetFaceName(); |
1293 | } | |
1294 | if (m_FixedFace.empty()) | |
1295 | { | |
dabbc6a5 | 1296 | wxFont fnt(m_FontSize, wxMODERN, wxNORMAL, wxNORMAL, false); |
c269cf62 VS |
1297 | m_FixedFace = fnt.GetFaceName(); |
1298 | } | |
f6bcfd97 | 1299 | |
4f9297b0 VS |
1300 | for (i = 0; i < m_NormalFonts->GetCount(); i++) |
1301 | dlg.NormalFont->Append((*m_NormalFonts)[i]); | |
1302 | for (i = 0; i < m_FixedFonts->GetCount(); i++) | |
1303 | dlg.FixedFont->Append((*m_FixedFonts)[i]); | |
c269cf62 VS |
1304 | if (!m_NormalFace.empty()) |
1305 | dlg.NormalFont->SetStringSelection(m_NormalFace); | |
1306 | else | |
1affde0a | 1307 | dlg.NormalFont->SetSelection(0); |
c269cf62 VS |
1308 | if (!m_FixedFace.empty()) |
1309 | dlg.FixedFont->SetStringSelection(m_FixedFace); | |
1310 | else | |
1311 | dlg.FixedFont->SetSelection(0); | |
1312 | dlg.FontSize->SetValue(m_FontSize); | |
83efdf33 | 1313 | dlg.UpdateTestWin(); |
f6bcfd97 | 1314 | |
da4cc40c | 1315 | if (dlg.ShowModal() == wxID_OK) |
4f9297b0 VS |
1316 | { |
1317 | m_NormalFace = dlg.NormalFont->GetStringSelection(); | |
1318 | m_FixedFace = dlg.FixedFont->GetStringSelection(); | |
c269cf62 | 1319 | m_FontSize = dlg.FontSize->GetValue(); |
8eb2940f | 1320 | SetFontsToHtmlWin(m_HtmlWin, m_NormalFace, m_FixedFace, m_FontSize); |
83efdf33 VS |
1321 | } |
1322 | } | |
1323 | ||
1324 | ||
1325 | ||
0646614d VS |
1326 | void wxHtmlHelpFrame::NotifyPageChanged() |
1327 | { | |
1328 | if (m_UpdateContents && m_PagesHash) | |
1329 | { | |
4f9297b0 | 1330 | wxString an = m_HtmlWin->GetOpenedAnchor(); |
0646614d VS |
1331 | wxHtmlHelpHashData *ha; |
1332 | if (an.IsEmpty()) | |
4f9297b0 | 1333 | ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage()); |
0646614d | 1334 | else |
4f9297b0 | 1335 | ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage() + wxT("#") + an); |
0646614d VS |
1336 | if (ha) |
1337 | { | |
1338 | bool olduc = m_UpdateContents; | |
dabbc6a5 | 1339 | m_UpdateContents = false; |
4f9297b0 VS |
1340 | m_ContentsBox->SelectItem(ha->m_Id); |
1341 | m_ContentsBox->EnsureVisible(ha->m_Id); | |
0646614d VS |
1342 | m_UpdateContents = olduc; |
1343 | } | |
1344 | } | |
1345 | } | |
1346 | ||
83efdf33 VS |
1347 | |
1348 | ||
8ec2b484 HH |
1349 | /* |
1350 | EVENT HANDLING : | |
1351 | */ | |
1352 | ||
1353 | ||
d45bc436 RR |
1354 | void wxHtmlHelpFrame::OnActivate(wxActivateEvent& event) |
1355 | { | |
1356 | // This saves one mouse click when using the | |
1357 | // wxHTML for context sensitive help systems | |
2b5f62a0 VZ |
1358 | #ifndef __WXGTK__ |
1359 | // NB: wxActivateEvent is a bit broken in wxGTK | |
1360 | // and is sometimes sent when it should not be | |
d45bc436 RR |
1361 | if (event.GetActive() && m_HtmlWin) |
1362 | m_HtmlWin->SetFocus(); | |
2b5f62a0 | 1363 | #endif |
fbd90401 VS |
1364 | |
1365 | event.Skip(); | |
d45bc436 RR |
1366 | } |
1367 | ||
8ec2b484 HH |
1368 | void wxHtmlHelpFrame::OnToolbar(wxCommandEvent& event) |
1369 | { | |
da4cc40c | 1370 | switch (event.GetId()) |
4f9297b0 | 1371 | { |
8ec2b484 | 1372 | case wxID_HTML_BACK : |
4f9297b0 | 1373 | m_HtmlWin->HistoryBack(); |
0646614d | 1374 | NotifyPageChanged(); |
8ec2b484 | 1375 | break; |
382e6efe | 1376 | |
8ec2b484 | 1377 | case wxID_HTML_FORWARD : |
4f9297b0 | 1378 | m_HtmlWin->HistoryForward(); |
0646614d VS |
1379 | NotifyPageChanged(); |
1380 | break; | |
f6bcfd97 BP |
1381 | |
1382 | case wxID_HTML_UP : | |
1383 | if (m_PagesHash) | |
0646614d | 1384 | { |
4f9297b0 | 1385 | wxString an = m_HtmlWin->GetOpenedAnchor(); |
0646614d VS |
1386 | wxHtmlHelpHashData *ha; |
1387 | if (an.IsEmpty()) | |
4f9297b0 | 1388 | ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage()); |
0646614d | 1389 | else |
4f9297b0 VS |
1390 | ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage() + wxT("#") + an); |
1391 | if (ha && ha->m_Index > 0) | |
0646614d | 1392 | { |
91fa114d VS |
1393 | const wxHtmlHelpDataItem& it = m_Data->GetContentsArray()[ha->m_Index - 1]; |
1394 | if (!it.page.empty()) | |
7df9fbc3 | 1395 | { |
91fa114d | 1396 | m_HtmlWin->LoadPage(it.GetFullPath()); |
7df9fbc3 JS |
1397 | NotifyPageChanged(); |
1398 | } | |
0646614d VS |
1399 | } |
1400 | } | |
1401 | break; | |
1402 | ||
f6bcfd97 BP |
1403 | case wxID_HTML_UPNODE : |
1404 | if (m_PagesHash) | |
0646614d | 1405 | { |
4f9297b0 | 1406 | wxString an = m_HtmlWin->GetOpenedAnchor(); |
0646614d VS |
1407 | wxHtmlHelpHashData *ha; |
1408 | if (an.IsEmpty()) | |
4f9297b0 | 1409 | ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage()); |
0646614d | 1410 | else |
4f9297b0 VS |
1411 | ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage() + wxT("#") + an); |
1412 | if (ha && ha->m_Index > 0) | |
0646614d | 1413 | { |
91fa114d VS |
1414 | int level = |
1415 | m_Data->GetContentsArray()[ha->m_Index].level - 1; | |
4f9297b0 | 1416 | int ind = ha->m_Index - 1; |
f6bcfd97 | 1417 | |
91fa114d VS |
1418 | const wxHtmlHelpDataItem *it = |
1419 | &m_Data->GetContentsArray()[ind]; | |
1420 | while (ind >= 0 && it->level != level) | |
1421 | { | |
1422 | ind--, it--; | |
1423 | it = &m_Data->GetContentsArray()[ind]; | |
1424 | } | |
0646614d VS |
1425 | if (ind >= 0) |
1426 | { | |
91fa114d | 1427 | if (!it->page.empty()) |
7df9fbc3 | 1428 | { |
468ae730 | 1429 | m_HtmlWin->LoadPage(it->GetFullPath()); |
7df9fbc3 JS |
1430 | NotifyPageChanged(); |
1431 | } | |
0646614d VS |
1432 | } |
1433 | } | |
1434 | } | |
1435 | break; | |
1436 | ||
f6bcfd97 BP |
1437 | case wxID_HTML_DOWN : |
1438 | if (m_PagesHash) | |
0646614d | 1439 | { |
4f9297b0 | 1440 | wxString an = m_HtmlWin->GetOpenedAnchor(); |
721ab905 | 1441 | wxString adr; |
0646614d | 1442 | wxHtmlHelpHashData *ha; |
f6bcfd97 | 1443 | |
4f9297b0 VS |
1444 | if (an.IsEmpty()) adr = m_HtmlWin->GetOpenedPage(); |
1445 | else adr = m_HtmlWin->GetOpenedPage() + wxT("#") + an; | |
721ab905 | 1446 | |
4f9297b0 | 1447 | ha = (wxHtmlHelpHashData*) m_PagesHash->Get(adr); |
0646614d | 1448 | |
91fa114d VS |
1449 | const wxHtmlHelpDataItems& contents = m_Data->GetContentsArray(); |
1450 | if (ha && ha->m_Index < (int)contents.size() - 1) | |
0646614d | 1451 | { |
91fa114d | 1452 | size_t idx = ha->m_Index + 1; |
f6bcfd97 | 1453 | |
91fa114d | 1454 | while (contents[idx].GetFullPath() == adr) idx++; |
7df9fbc3 | 1455 | |
91fa114d | 1456 | if (!contents[idx].page.empty()) |
7df9fbc3 | 1457 | { |
91fa114d | 1458 | m_HtmlWin->LoadPage(contents[idx].GetFullPath()); |
7df9fbc3 JS |
1459 | NotifyPageChanged(); |
1460 | } | |
0646614d VS |
1461 | } |
1462 | } | |
8ec2b484 | 1463 | break; |
382e6efe | 1464 | |
8ec2b484 | 1465 | case wxID_HTML_PANEL : |
0646614d VS |
1466 | { |
1467 | if (! (m_Splitter && m_NavigPan)) | |
1468 | return ; | |
da4cc40c | 1469 | if (m_Splitter->IsSplit()) |
3379ed37 | 1470 | { |
4f9297b0 VS |
1471 | m_Cfg.sashpos = m_Splitter->GetSashPosition(); |
1472 | m_Splitter->Unsplit(m_NavigPan); | |
dabbc6a5 | 1473 | m_Cfg.navig_on = false; |
da4cc40c | 1474 | } |
3379ed37 VZ |
1475 | else |
1476 | { | |
dabbc6a5 DS |
1477 | m_NavigPan->Show(); |
1478 | m_HtmlWin->Show(); | |
4f9297b0 | 1479 | m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); |
dabbc6a5 | 1480 | m_Cfg.navig_on = true; |
0646614d | 1481 | } |
8ec2b484 HH |
1482 | } |
1483 | break; | |
382e6efe | 1484 | |
83efdf33 VS |
1485 | case wxID_HTML_OPTIONS : |
1486 | OptionsDialog(); | |
1487 | break; | |
f6bcfd97 BP |
1488 | |
1489 | case wxID_HTML_BOOKMARKSADD : | |
382e6efe VS |
1490 | { |
1491 | wxString item; | |
1492 | wxString url; | |
f6bcfd97 | 1493 | |
4f9297b0 VS |
1494 | item = m_HtmlWin->GetOpenedPageTitle(); |
1495 | url = m_HtmlWin->GetOpenedPage(); | |
da4cc40c | 1496 | if (item == wxEmptyString) |
3379ed37 | 1497 | item = url.AfterLast(wxT('/')); |
da4cc40c | 1498 | if (m_BookmarksPages.Index(url) == wxNOT_FOUND) |
3379ed37 | 1499 | { |
4f9297b0 | 1500 | m_Bookmarks->Append(item); |
382e6efe VS |
1501 | m_BookmarksNames.Add(item); |
1502 | m_BookmarksPages.Add(url); | |
1503 | } | |
1504 | } | |
1505 | break; | |
f6bcfd97 BP |
1506 | |
1507 | case wxID_HTML_BOOKMARKSREMOVE : | |
382e6efe VS |
1508 | { |
1509 | wxString item; | |
1510 | int pos; | |
f6bcfd97 | 1511 | |
4f9297b0 | 1512 | item = m_Bookmarks->GetStringSelection(); |
382e6efe | 1513 | pos = m_BookmarksNames.Index(item); |
da4cc40c | 1514 | if (pos != wxNOT_FOUND) |
3379ed37 | 1515 | { |
ba8c1601 MB |
1516 | m_BookmarksNames.RemoveAt(pos); |
1517 | m_BookmarksPages.RemoveAt(pos); | |
4f9297b0 | 1518 | m_Bookmarks->Delete(m_Bookmarks->GetSelection()); |
382e6efe VS |
1519 | } |
1520 | } | |
1521 | break; | |
0646614d VS |
1522 | |
1523 | #if wxUSE_PRINTING_ARCHITECTURE | |
1524 | case wxID_HTML_PRINT : | |
1525 | { | |
f6bcfd97 | 1526 | if (m_Printer == NULL) |
0646614d | 1527 | m_Printer = new wxHtmlEasyPrinting(_("Help Printing"), this); |
4f9297b0 | 1528 | if (!m_HtmlWin->GetOpenedPage()) |
f5ba273e VS |
1529 | wxLogWarning(_("Cannot print empty page.")); |
1530 | else | |
4f9297b0 | 1531 | m_Printer->PrintFile(m_HtmlWin->GetOpenedPage()); |
0646614d VS |
1532 | } |
1533 | break; | |
1534 | #endif | |
1535 | ||
1536 | case wxID_HTML_OPENFILE : | |
1537 | { | |
3527f29c VS |
1538 | wxString filemask = wxString( |
1539 | _("HTML files (*.html;*.htm)|*.html;*.htm|")) + | |
1540 | _("Help books (*.htb)|*.htb|Help books (*.zip)|*.zip|") + | |
1541 | _("HTML Help Project (*.hhp)|*.hhp|") + | |
1542 | #if wxUSE_LIBMSPACK | |
1543 | _("Compressed HTML Help file (*.chm)|*.chm|") + | |
1544 | #endif | |
1545 | _("All files (*.*)|*"); | |
f6bcfd97 BP |
1546 | wxString s = wxFileSelector(_("Open HTML document"), |
1547 | wxEmptyString, | |
1548 | wxEmptyString, | |
1549 | wxEmptyString, | |
3527f29c | 1550 | filemask, |
f6bcfd97 BP |
1551 | wxOPEN | wxFILE_MUST_EXIST, |
1552 | this); | |
0646614d VS |
1553 | if (!s.IsEmpty()) |
1554 | { | |
1555 | wxString ext = s.Right(4).Lower(); | |
3527f29c VS |
1556 | if (ext == _T(".zip") || ext == _T(".htb") || |
1557 | #if wxUSE_LIBMSPACK | |
1558 | ext == _T(".chm") || | |
1559 | #endif | |
1560 | ext == _T(".hhp")) | |
0646614d VS |
1561 | { |
1562 | wxBusyCursor bcur; | |
4f9297b0 | 1563 | m_Data->AddBook(s); |
0646614d VS |
1564 | RefreshLists(); |
1565 | } | |
1566 | else | |
4f9297b0 | 1567 | m_HtmlWin->LoadPage(s); |
0646614d VS |
1568 | } |
1569 | } | |
1570 | break; | |
8ec2b484 HH |
1571 | } |
1572 | } | |
1573 | ||
1574 | ||
1575 | ||
1576 | void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent& event) | |
1577 | { | |
1578 | wxHtmlHelpTreeItemData *pg; | |
1579 | ||
4f9297b0 | 1580 | pg = (wxHtmlHelpTreeItemData*) m_ContentsBox->GetItemData(event.GetItem()); |
f6bcfd97 BP |
1581 | |
1582 | if (pg && m_UpdateContents) | |
0646614d | 1583 | { |
91fa114d | 1584 | const wxHtmlHelpDataItems& contents = m_Data->GetContentsArray(); |
dabbc6a5 | 1585 | m_UpdateContents = false; |
91fa114d VS |
1586 | if (!contents[pg->m_Id].page.empty()) |
1587 | m_HtmlWin->LoadPage(contents[pg->m_Id].GetFullPath()); | |
dabbc6a5 | 1588 | m_UpdateContents = true; |
0646614d | 1589 | } |
8ec2b484 HH |
1590 | } |
1591 | ||
1592 | ||
1593 | ||
a4c97004 | 1594 | void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent& WXUNUSED(event)) |
8ec2b484 | 1595 | { |
91fa114d VS |
1596 | wxHtmlHelpMergedIndexItem *it = (wxHtmlHelpMergedIndexItem*) |
1597 | m_IndexList->GetClientData(m_IndexList->GetSelection()); | |
1598 | if (it) | |
1599 | DisplayIndexItem(it); | |
8ec2b484 HH |
1600 | } |
1601 | ||
1602 | ||
f0b6a33f VS |
1603 | void wxHtmlHelpFrame::OnIndexFind(wxCommandEvent& event) |
1604 | { | |
4f9297b0 | 1605 | wxString sr = m_IndexText->GetLineText(0); |
240c2873 | 1606 | sr.MakeLower(); |
f6bcfd97 | 1607 | if (sr == wxEmptyString) |
4f9297b0 | 1608 | { |
f0b6a33f | 1609 | OnIndexAll(event); |
4f9297b0 | 1610 | } |
da4cc40c | 1611 | else |
4f9297b0 | 1612 | { |
f0b6a33f | 1613 | wxBusyCursor bcur; |
f6bcfd97 | 1614 | |
f0b6a33f | 1615 | m_IndexList->Clear(); |
91fa114d VS |
1616 | const wxHtmlHelpMergedIndex& index = *m_mergedIndex; |
1617 | size_t cnt = index.size(); | |
f0b6a33f | 1618 | |
240c2873 | 1619 | int displ = 0; |
91fa114d | 1620 | for (size_t i = 0; i < cnt; i++) |
240c2873 | 1621 | { |
91fa114d | 1622 | if (index[i].name.Lower().find(sr) != wxString::npos) |
3379ed37 | 1623 | { |
91fa114d VS |
1624 | int pos = m_IndexList->Append(index[i].name, |
1625 | (char*)(&index[i])); | |
1626 | ||
1627 | if (displ++ == 0) | |
3379ed37 | 1628 | { |
91fa114d VS |
1629 | m_IndexList->SetSelection(0); |
1630 | DisplayIndexItem(&index[i]); | |
1631 | } | |
1632 | ||
1633 | // if this is nested item of the index, show its parent(s) | |
1634 | // as well, otherwise it would not be clear what entry is | |
1635 | // shown: | |
1636 | wxHtmlHelpMergedIndexItem *parent = index[i].parent; | |
1637 | while (parent) | |
1638 | { | |
1639 | if (pos == 0 || | |
1640 | (index.Index(*(wxHtmlHelpMergedIndexItem*)m_IndexList->GetClientData(pos-1))) < index.Index(*parent)) | |
1641 | { | |
1642 | m_IndexList->Insert(parent->name, | |
1643 | pos, (char*)parent); | |
1644 | parent = parent->parent; | |
1645 | } | |
1646 | else break; | |
f0b6a33f VS |
1647 | } |
1648 | } | |
240c2873 VS |
1649 | } |
1650 | ||
1651 | wxString cnttext; | |
1652 | cnttext.Printf(_("%i of %i"), displ, cnt); | |
4f9297b0 | 1653 | m_IndexCountInfo->SetLabel(cnttext); |
f0b6a33f | 1654 | |
4f9297b0 VS |
1655 | m_IndexText->SetSelection(0, sr.Length()); |
1656 | m_IndexText->SetFocus(); | |
f0b6a33f VS |
1657 | } |
1658 | } | |
1659 | ||
1660 | void wxHtmlHelpFrame::OnIndexAll(wxCommandEvent& WXUNUSED(event)) | |
1661 | { | |
1662 | wxBusyCursor bcur; | |
f6bcfd97 | 1663 | |
f0b6a33f | 1664 | m_IndexList->Clear(); |
91fa114d VS |
1665 | const wxHtmlHelpMergedIndex& index = *m_mergedIndex; |
1666 | size_t cnt = index.size(); | |
dabbc6a5 | 1667 | bool first = true; |
f0b6a33f | 1668 | |
91fa114d | 1669 | for (size_t i = 0; i < cnt; i++) |
4f9297b0 | 1670 | { |
91fa114d | 1671 | m_IndexList->Append(index[i].name, (char*)(&index[i])); |
da4cc40c | 1672 | if (first) |
3379ed37 | 1673 | { |
91fa114d | 1674 | DisplayIndexItem(&index[i]); |
dabbc6a5 | 1675 | first = false; |
f0b6a33f VS |
1676 | } |
1677 | } | |
240c2873 VS |
1678 | |
1679 | wxString cnttext; | |
1680 | cnttext.Printf(_("%i of %i"), cnt, cnt); | |
4f9297b0 | 1681 | m_IndexCountInfo->SetLabel(cnttext); |
f0b6a33f VS |
1682 | } |
1683 | ||
8ec2b484 | 1684 | |
a4c97004 | 1685 | void wxHtmlHelpFrame::OnSearchSel(wxCommandEvent& WXUNUSED(event)) |
8ec2b484 | 1686 | { |
91fa114d | 1687 | wxHtmlHelpDataItem *it = (wxHtmlHelpDataItem*) m_SearchList->GetClientData(m_SearchList->GetSelection()); |
f6bcfd97 | 1688 | if (it) |
0646614d | 1689 | { |
91fa114d | 1690 | if (!it->page.empty()) |
468ae730 | 1691 | m_HtmlWin->LoadPage(it->GetFullPath()); |
0646614d VS |
1692 | NotifyPageChanged(); |
1693 | } | |
8ec2b484 HH |
1694 | } |
1695 | ||
a4c97004 | 1696 | void wxHtmlHelpFrame::OnSearch(wxCommandEvent& WXUNUSED(event)) |
8ec2b484 | 1697 | { |
4f9297b0 | 1698 | wxString sr = m_SearchText->GetLineText(0); |
8ec2b484 | 1699 | |
69b5cec2 VS |
1700 | if (!sr.empty()) |
1701 | KeywordSearch(sr, wxHELP_SEARCH_ALL); | |
8ec2b484 HH |
1702 | } |
1703 | ||
382e6efe VS |
1704 | void wxHtmlHelpFrame::OnBookmarksSel(wxCommandEvent& WXUNUSED(event)) |
1705 | { | |
4f9297b0 | 1706 | wxString sr = m_Bookmarks->GetStringSelection(); |
382e6efe | 1707 | |
ae80f837 | 1708 | if (sr != wxEmptyString && sr != _("(bookmarks)")) |
0646614d | 1709 | { |
4f9297b0 | 1710 | m_HtmlWin->LoadPage(m_BookmarksPages[m_BookmarksNames.Index(sr)]); |
0646614d VS |
1711 | NotifyPageChanged(); |
1712 | } | |
382e6efe VS |
1713 | } |
1714 | ||
8ec2b484 HH |
1715 | void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent& evt) |
1716 | { | |
68364659 VS |
1717 | GetSize(&m_Cfg.w, &m_Cfg.h); |
1718 | GetPosition(&m_Cfg.x, &m_Cfg.y); | |
5c172c17 | 1719 | |
5152b0e5 JS |
1720 | #ifdef __WXGTK__ |
1721 | if (IsGrabbed()) | |
1722 | { | |
1723 | RemoveGrab(); | |
1724 | } | |
1725 | #endif | |
dabbc6a5 | 1726 | |
4f9297b0 | 1727 | if (m_Splitter && m_Cfg.navig_on) m_Cfg.sashpos = m_Splitter->GetSashPosition(); |
68364659 | 1728 | |
d5bb85a0 VS |
1729 | if (m_Config) |
1730 | WriteCustomization(m_Config, m_ConfigRoot); | |
68364659 | 1731 | |
b4414c1f JS |
1732 | if (m_helpController && m_helpController->IsKindOf(CLASSINFO(wxHtmlHelpController))) |
1733 | { | |
1734 | ((wxHtmlHelpController*) m_helpController)->OnCloseFrame(evt); | |
1735 | } | |
1736 | ||
8ec2b484 HH |
1737 | evt.Skip(); |
1738 | } | |
1739 | ||
d9b21c9f | 1740 | #ifdef __WXMAC__ |
4aa31786 | 1741 | void wxHtmlHelpFrame::OnClose(wxCommandEvent& event) |
d9b21c9f | 1742 | { |
dabbc6a5 | 1743 | Close(true); |
d9b21c9f JS |
1744 | } |
1745 | ||
1746 | void wxHtmlHelpFrame::OnAbout(wxCommandEvent& event) | |
1747 | { | |
91fa114d | 1748 | wxMessageBox(wxT("wxWidgets HTML Help Viewer (c) 1998-2004, Vaclav Slavik et al"), wxT("HelpView"), |
d9b21c9f JS |
1749 | wxICON_INFORMATION|wxOK, this); |
1750 | } | |
1751 | #endif | |
1752 | ||
8ec2b484 | 1753 | BEGIN_EVENT_TABLE(wxHtmlHelpFrame, wxFrame) |
d45bc436 | 1754 | EVT_ACTIVATE(wxHtmlHelpFrame::OnActivate) |
ae80f837 VS |
1755 | EVT_TOOL_RANGE(wxID_HTML_PANEL, wxID_HTML_OPTIONS, wxHtmlHelpFrame::OnToolbar) |
1756 | EVT_BUTTON(wxID_HTML_BOOKMARKSREMOVE, wxHtmlHelpFrame::OnToolbar) | |
1757 | EVT_BUTTON(wxID_HTML_BOOKMARKSADD, wxHtmlHelpFrame::OnToolbar) | |
8ec2b484 HH |
1758 | EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL, wxHtmlHelpFrame::OnContentsSel) |
1759 | EVT_LISTBOX(wxID_HTML_INDEXLIST, wxHtmlHelpFrame::OnIndexSel) | |
1760 | EVT_LISTBOX(wxID_HTML_SEARCHLIST, wxHtmlHelpFrame::OnSearchSel) | |
1761 | EVT_BUTTON(wxID_HTML_SEARCHBUTTON, wxHtmlHelpFrame::OnSearch) | |
1762 | EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT, wxHtmlHelpFrame::OnSearch) | |
f0b6a33f VS |
1763 | EVT_BUTTON(wxID_HTML_INDEXBUTTON, wxHtmlHelpFrame::OnIndexFind) |
1764 | EVT_TEXT_ENTER(wxID_HTML_INDEXTEXT, wxHtmlHelpFrame::OnIndexFind) | |
1765 | EVT_BUTTON(wxID_HTML_INDEXBUTTONALL, wxHtmlHelpFrame::OnIndexAll) | |
382e6efe | 1766 | EVT_COMBOBOX(wxID_HTML_BOOKMARKSLIST, wxHtmlHelpFrame::OnBookmarksSel) |
f6bcfd97 | 1767 | EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow) |
d9b21c9f | 1768 | #ifdef __WXMAC__ |
4aa31786 | 1769 | EVT_MENU(wxID_CLOSE, wxHtmlHelpFrame::OnClose) |
d9b21c9f JS |
1770 | EVT_MENU(wxID_ABOUT, wxHtmlHelpFrame::OnAbout) |
1771 | #endif | |
1772 | ||
8ec2b484 HH |
1773 | END_EVENT_TABLE() |
1774 | ||
3379ed37 VZ |
1775 | #endif // wxUSE_WXHTML_HELP |
1776 |