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