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