]>
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 HH |
8 | // Copyright: (c) Harm van der Heijden and Vaclav Slavik |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
69941f05 | 13 | #pragma implementation |
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 | ||
24 | #include "wx/defs.h" | |
25 | ||
f6bcfd97 | 26 | #if wxUSE_HTML && wxUSE_STREAMS |
8ec2b484 | 27 | #ifndef WXPRECOMP |
3096bd2f | 28 | #include "wx/wx.h" |
8ec2b484 HH |
29 | #endif |
30 | ||
31 | #include "wx/html/helpfrm.h" | |
b4414c1f | 32 | #include "wx/html/helpctrl.h" |
8ec2b484 HH |
33 | #include "wx/notebook.h" |
34 | #include "wx/imaglist.h" | |
35 | #include "wx/treectrl.h" | |
36 | #include "wx/tokenzr.h" | |
37 | #include "wx/wfstream.h" | |
38 | #include "wx/html/htmlwin.h" | |
39 | #include "wx/busyinfo.h" | |
40 | #include "wx/progdlg.h" | |
2bd5bbc9 | 41 | #include "wx/toolbar.h" |
83efdf33 | 42 | #include "wx/fontenum.h" |
0646614d VS |
43 | #include "wx/stream.h" |
44 | #include "wx/filedlg.h" | |
8ec2b484 HH |
45 | |
46 | // Bitmaps: | |
47 | ||
48 | #ifndef __WXMSW__ | |
83efdf33 VS |
49 | #include "bitmaps/wpanel.xpm" |
50 | #include "bitmaps/wback.xpm" | |
51 | #include "bitmaps/wforward.xpm" | |
52 | #include "bitmaps/wbook.xpm" | |
53 | #include "bitmaps/woptions.xpm" | |
54 | #include "bitmaps/wfolder.xpm" | |
55 | #include "bitmaps/wpage.xpm" | |
56 | #include "bitmaps/whelp.xpm" | |
57 | #include "bitmaps/whlproot.xpm" | |
382e6efe VS |
58 | #include "bitmaps/wbkadd.xpm" |
59 | #include "bitmaps/wbkdel.xpm" | |
0646614d VS |
60 | #include "bitmaps/wup.xpm" |
61 | #include "bitmaps/wupnode.xpm" | |
62 | #include "bitmaps/wdown.xpm" | |
63 | #include "bitmaps/wopen.xpm" | |
64 | #include "bitmaps/wprint.xpm" | |
8ec2b484 HH |
65 | #endif |
66 | ||
8ec2b484 | 67 | |
f0b6a33f VS |
68 | // what is considered "small index"? |
69 | #define INDEX_IS_SMALL 100 | |
70 | ||
71 | ||
8ec2b484 | 72 | //-------------------------------------------------------------------------- |
382e6efe | 73 | // wxHtmlHelpTreeItemData (private) |
8ec2b484 HH |
74 | //-------------------------------------------------------------------------- |
75 | ||
76 | class wxHtmlHelpTreeItemData : public wxTreeItemData | |
77 | { | |
0646614d | 78 | public: |
da4cc40c DW |
79 | #if defined(__VISAGECPP__) |
80 | // VA needs a default ctor for some reason.... | |
81 | wxHtmlHelpTreeItemData() : wxTreeItemData() | |
82 | { m_Id = 0; } | |
83 | #endif | |
0646614d VS |
84 | wxHtmlHelpTreeItemData(int id) : wxTreeItemData() |
85 | { m_Id = id;} | |
86 | ||
87 | int m_Id; | |
88 | }; | |
8ec2b484 | 89 | |
0646614d VS |
90 | |
91 | //-------------------------------------------------------------------------- | |
92 | // wxHtmlHelpHashData (private) | |
93 | //-------------------------------------------------------------------------- | |
94 | ||
95 | class wxHtmlHelpHashData : public wxObject | |
96 | { | |
8ec2b484 | 97 | public: |
0646614d VS |
98 | wxHtmlHelpHashData(int index, wxTreeItemId id) : wxObject() |
99 | { m_Index = index; m_Id = id;} | |
f5ba273e | 100 | ~wxHtmlHelpHashData() {} |
f6bcfd97 | 101 | |
0646614d VS |
102 | int m_Index; |
103 | wxTreeItemId m_Id; | |
8ec2b484 HH |
104 | }; |
105 | ||
382e6efe | 106 | |
0646614d VS |
107 | //-------------------------------------------------------------------------- |
108 | // wxHtmlHelpHtmlWindow (private) | |
109 | //-------------------------------------------------------------------------- | |
110 | ||
111 | class wxHtmlHelpHtmlWindow : public wxHtmlWindow | |
112 | { | |
113 | public: | |
114 | wxHtmlHelpHtmlWindow(wxHtmlHelpFrame *fr, wxWindow *parent) : wxHtmlWindow(parent), m_Frame(fr) {} | |
115 | ||
116 | virtual void OnLinkClicked(const wxHtmlLinkInfo& link) | |
117 | { | |
118 | wxHtmlWindow::OnLinkClicked(link); | |
4f9297b0 | 119 | m_Frame->NotifyPageChanged(); |
0646614d VS |
120 | } |
121 | ||
f6bcfd97 | 122 | private: |
0646614d VS |
123 | wxHtmlHelpFrame *m_Frame; |
124 | }; | |
125 | ||
382e6efe VS |
126 | |
127 | ||
8ec2b484 HH |
128 | //--------------------------------------------------------------------------- |
129 | // wxHtmlHelpFrame | |
130 | //--------------------------------------------------------------------------- | |
131 | ||
132 | IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpFrame, wxFrame) | |
133 | ||
134 | wxHtmlHelpFrame::wxHtmlHelpFrame(wxWindow* parent, wxWindowID id, const wxString& title, | |
d5bb85a0 | 135 | int style, wxHtmlHelpData* data) |
8ec2b484 HH |
136 | { |
137 | Init(data); | |
138 | Create(parent, id, title, style); | |
139 | } | |
d5bb85a0 | 140 | |
8ec2b484 HH |
141 | void wxHtmlHelpFrame::Init(wxHtmlHelpData* data) |
142 | { | |
da4cc40c | 143 | if (data) |
4f9297b0 | 144 | { |
d5bb85a0 VS |
145 | m_Data = data; |
146 | m_DataCreated = FALSE; | |
da4cc40c | 147 | } else |
4f9297b0 | 148 | { |
d5bb85a0 VS |
149 | m_Data = new wxHtmlHelpData(); |
150 | m_DataCreated = TRUE; | |
8ec2b484 HH |
151 | } |
152 | ||
8ec2b484 | 153 | m_ContentsBox = NULL; |
f0b6a33f VS |
154 | m_IndexList = NULL; |
155 | m_IndexButton = NULL; | |
156 | m_IndexButtonAll = NULL; | |
157 | m_IndexText = NULL; | |
8ec2b484 HH |
158 | m_SearchList = NULL; |
159 | m_SearchButton = NULL; | |
160 | m_SearchText = NULL; | |
161 | m_SearchChoice = NULL; | |
240c2873 | 162 | m_IndexCountInfo = NULL; |
8ec2b484 HH |
163 | m_Splitter = NULL; |
164 | m_NavigPan = NULL; | |
165 | m_HtmlWin = NULL; | |
382e6efe | 166 | m_Bookmarks = NULL; |
c4971147 VS |
167 | m_SearchCaseSensitive = NULL; |
168 | m_SearchWholeWords = NULL; | |
169 | ||
8ec2b484 HH |
170 | m_Config = NULL; |
171 | m_ConfigRoot = wxEmptyString; | |
172 | ||
173 | m_Cfg.x = m_Cfg.y = 0; | |
d5bb85a0 VS |
174 | m_Cfg.w = 700; |
175 | m_Cfg.h = 480; | |
8ec2b484 HH |
176 | m_Cfg.sashpos = 240; |
177 | m_Cfg.navig_on = TRUE; | |
83efdf33 VS |
178 | |
179 | m_NormalFonts = m_FixedFonts = NULL; | |
83efdf33 | 180 | m_NormalFace = m_FixedFace = wxEmptyString; |
0646614d | 181 | m_FontSize = 1; |
f6bcfd97 | 182 | |
0646614d VS |
183 | #if wxUSE_PRINTING_ARCHITECTURE |
184 | m_Printer = NULL; | |
185 | #endif | |
186 | ||
187 | m_PagesHash = NULL; | |
188 | m_UpdateContents = TRUE; | |
b4414c1f | 189 | m_helpController = (wxHelpControllerBase*) NULL; |
8ec2b484 HH |
190 | } |
191 | ||
d5bb85a0 VS |
192 | // Create: builds the GUI components. |
193 | // with the style flag it's possible to toggle the toolbar, contents, index and search | |
194 | // controls. | |
195 | // m_HtmlWin will *always* be created, but it's important to realize that | |
f0b6a33f | 196 | // m_ContentsBox, m_IndexList, m_SearchList, m_SearchButton, m_SearchText and |
d5bb85a0 VS |
197 | // m_SearchButton may be NULL. |
198 | // moreover, if no contents, index or searchpage is needed, m_Splitter and | |
199 | // m_NavigPan will be NULL too (with m_HtmlWin directly connected to the frame) | |
200 | ||
8ec2b484 | 201 | bool wxHtmlHelpFrame::Create(wxWindow* parent, wxWindowID id, const wxString& title, |
d5bb85a0 | 202 | int style) |
8ec2b484 | 203 | { |
8fd2b35c VS |
204 | wxImageList *ContentsImageList = new wxImageList(16, 16); |
205 | ContentsImageList->Add(wxICON(wbook)); | |
206 | ContentsImageList->Add(wxICON(wfolder)); | |
207 | ContentsImageList->Add(wxICON(wpage)); | |
208 | ContentsImageList->Add(wxICON(whlproot)); | |
209 | ||
8ec2b484 HH |
210 | // Do the config in two steps. We read the HtmlWindow customization after we |
211 | // create the window. | |
d5bb85a0 VS |
212 | if (m_Config) |
213 | ReadCustomization(m_Config, m_ConfigRoot); | |
8ec2b484 | 214 | |
8eb2940f | 215 | wxFrame::Create(parent, id, _("Help"), wxPoint(m_Cfg.x, m_Cfg.y), wxSize(m_Cfg.w, m_Cfg.h), wxDEFAULT_FRAME_STYLE, "wxHtmlHelp"); |
8ec2b484 | 216 | |
5c172c17 VS |
217 | GetPosition(&m_Cfg.x, &m_Cfg.y); |
218 | ||
83efdf33 | 219 | SetIcon(wxICON(whelp)); |
9ffdee80 | 220 | |
8ec2b484 HH |
221 | int notebook_page = 0; |
222 | ||
223 | CreateStatusBar(); | |
224 | ||
225 | // toolbar? | |
da4cc40c | 226 | if (style & (wxHF_TOOLBAR | wxHF_FLATTOOLBAR)) |
4f9297b0 | 227 | { |
f6bcfd97 BP |
228 | wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | |
229 | wxTB_DOCKABLE | | |
230 | (style & wxHF_FLATTOOLBAR ? wxTB_FLAT : 0)); | |
00655497 | 231 | toolBar->SetMargins( 2, 2 ); |
b854b7b8 | 232 | AddToolbarButtons(toolBar, style); |
4f9297b0 | 233 | toolBar->Realize(); |
8ec2b484 | 234 | } |
d5bb85a0 | 235 | |
da4cc40c | 236 | if (style & (wxHF_CONTENTS | wxHF_INDEX | wxHF_SEARCH)) |
4f9297b0 | 237 | { |
d5bb85a0 VS |
238 | // traditional help controller; splitter window with html page on the |
239 | // right and a notebook containing various pages on the left | |
240 | m_Splitter = new wxSplitterWindow(this); | |
241 | ||
0646614d | 242 | m_HtmlWin = new wxHtmlHelpHtmlWindow(this, m_Splitter); |
d5bb85a0 VS |
243 | m_NavigPan = new wxNotebook(m_Splitter, wxID_HTML_NOTEBOOK, |
244 | wxDefaultPosition, wxDefaultSize); | |
da4cc40c DW |
245 | } |
246 | else | |
4f9297b0 | 247 | { // only html window, no notebook with index,contents etc |
d5bb85a0 | 248 | m_HtmlWin = new wxHtmlWindow(this); |
8ec2b484 HH |
249 | } |
250 | ||
4f9297b0 VS |
251 | m_HtmlWin->SetRelatedFrame(this, m_TitleFormat); |
252 | m_HtmlWin->SetRelatedStatusBar(0); | |
d5bb85a0 | 253 | if (m_Config) |
4f9297b0 | 254 | m_HtmlWin->ReadCustomization(m_Config, m_ConfigRoot); |
8ec2b484 HH |
255 | |
256 | // contents tree panel? | |
da4cc40c | 257 | if (style & wxHF_CONTENTS) |
4f9297b0 | 258 | { |
ae80f837 VS |
259 | wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_INDEXPAGE); |
260 | ||
da4cc40c | 261 | if (style & wxHF_BOOKMARKS) |
4f9297b0 | 262 | { |
ae80f837 VS |
263 | wxLayoutConstraints *b1 = new wxLayoutConstraints; |
264 | wxBitmapButton *bmpbt = new wxBitmapButton(dummy, wxID_HTML_BOOKMARKSREMOVE, wxBITMAP(wbkdel), wxDefaultPosition, wxSize(20,20)); | |
265 | ||
4f9297b0 VS |
266 | b1->top.SameAs (dummy, wxTop, 10); |
267 | b1->right.SameAs (dummy, wxRight, 10); | |
268 | b1->height.AsIs(); | |
269 | b1->width.AsIs(); | |
270 | bmpbt->SetConstraints(b1); | |
ae80f837 VS |
271 | |
272 | wxLayoutConstraints *b2 = new wxLayoutConstraints; | |
273 | wxBitmapButton *bmpbt2 = new wxBitmapButton(dummy, wxID_HTML_BOOKMARKSADD, wxBITMAP(wbkadd), wxDefaultPosition, wxSize(20,20)); | |
274 | ||
4f9297b0 VS |
275 | b2->top.SameAs (dummy, wxTop, 10); |
276 | b2->right.LeftOf (bmpbt, 2); | |
277 | b2->height.AsIs(); | |
278 | b2->width.AsIs(); | |
279 | bmpbt2->SetConstraints(b2); | |
ae80f837 VS |
280 | |
281 | #if wxUSE_TOOLTIPS | |
4f9297b0 VS |
282 | bmpbt->SetToolTip(_("Remove current page from bookmarks")); |
283 | bmpbt2->SetToolTip(_("Add current page to bookmarks")); | |
ae80f837 VS |
284 | #endif //wxUSE_TOOLTIPS |
285 | ||
286 | wxLayoutConstraints *b3 = new wxLayoutConstraints; | |
287 | m_Bookmarks = new wxComboBox(dummy, wxID_HTML_BOOKMARKSLIST, wxEmptyString, | |
288 | wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY | wxCB_SORT); | |
4f9297b0 | 289 | m_Bookmarks->Append(_("(bookmarks)")); |
ae80f837 | 290 | for (unsigned i = 0; i < m_BookmarksNames.GetCount(); i++) |
4f9297b0 VS |
291 | m_Bookmarks->Append(m_BookmarksNames[i]); |
292 | m_Bookmarks->SetSelection(0); | |
ae80f837 | 293 | |
4f9297b0 VS |
294 | b3->centreY.SameAs (bmpbt2, wxCentreY); |
295 | b3->left.SameAs (dummy, wxLeft, 10); | |
296 | b3->right.LeftOf (bmpbt2, 5); | |
297 | b3->height.AsIs(); | |
298 | m_Bookmarks->SetConstraints(b3); | |
ae80f837 VS |
299 | |
300 | ||
301 | wxLayoutConstraints *b4 = new wxLayoutConstraints; | |
302 | m_ContentsBox = new wxTreeCtrl(dummy, wxID_HTML_TREECTRL, | |
303 | wxDefaultPosition, wxDefaultSize, | |
304 | wxTR_HAS_BUTTONS | wxSUNKEN_BORDER); | |
4f9297b0 | 305 | m_ContentsBox->AssignImageList(ContentsImageList); |
ae80f837 | 306 | |
4f9297b0 VS |
307 | b4->top.Below (m_Bookmarks, 10); |
308 | b4->left.SameAs (dummy, wxLeft, 0); | |
309 | b4->right.SameAs (dummy, wxRight, 0); | |
310 | b4->bottom.SameAs (dummy, wxBottom, 0); | |
311 | m_ContentsBox->SetConstraints(b4); | |
ae80f837 | 312 | |
4f9297b0 VS |
313 | dummy->SetAutoLayout(TRUE); |
314 | dummy->Layout(); | |
ae80f837 | 315 | |
4f9297b0 | 316 | m_NavigPan->AddPage(dummy, _("Contents")); |
ae80f837 VS |
317 | } |
318 | ||
319 | else | |
320 | { | |
321 | m_ContentsBox = new wxTreeCtrl(m_NavigPan, wxID_HTML_TREECTRL, | |
322 | wxDefaultPosition, wxDefaultSize, | |
323 | wxTR_HAS_BUTTONS | wxSUNKEN_BORDER); | |
4f9297b0 VS |
324 | m_ContentsBox->AssignImageList(ContentsImageList); |
325 | m_NavigPan->AddPage(m_ContentsBox, _("Contents")); | |
ae80f837 VS |
326 | } |
327 | ||
d5bb85a0 | 328 | m_ContentsPage = notebook_page++; |
8ec2b484 HH |
329 | } |
330 | ||
331 | // index listbox panel? | |
da4cc40c | 332 | if (style & wxHF_INDEX) |
4f9297b0 | 333 | { |
d5bb85a0 | 334 | wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_INDEXPAGE); |
f0b6a33f | 335 | |
d5bb85a0 | 336 | wxLayoutConstraints *b1 = new wxLayoutConstraints; |
f0b6a33f | 337 | m_IndexText = new wxTextCtrl(dummy, wxID_HTML_INDEXTEXT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); |
4f9297b0 VS |
338 | b1->top.SameAs (dummy, wxTop, 10); |
339 | b1->left.SameAs (dummy, wxLeft, 10); | |
340 | b1->right.SameAs (dummy, wxRight, 10); | |
341 | b1->height.AsIs(); | |
342 | m_IndexText->SetConstraints(b1); | |
f0b6a33f VS |
343 | |
344 | wxLayoutConstraints *b4 = new wxLayoutConstraints; | |
345 | m_IndexButtonAll = new wxButton(dummy, wxID_HTML_INDEXBUTTONALL, _("Show all")); | |
7618e374 | 346 | |
4f9297b0 VS |
347 | b4->top.Below (m_IndexText, 10); |
348 | b4->right.SameAs (dummy, wxRight, 10); | |
349 | b4->width.AsIs(); | |
350 | b4->height.AsIs(); | |
351 | m_IndexButtonAll->SetConstraints(b4); | |
f0b6a33f VS |
352 | |
353 | wxLayoutConstraints *b2 = new wxLayoutConstraints; | |
354 | m_IndexButton = new wxButton(dummy, wxID_HTML_INDEXBUTTON, _("Find")); | |
4f9297b0 VS |
355 | b2->top.Below (m_IndexText, 10); |
356 | b2->right.LeftOf (m_IndexButtonAll, 10); | |
357 | b2->width.AsIs(); | |
358 | b2->height.AsIs(); | |
359 | m_IndexButton->SetConstraints(b2); | |
f0b6a33f | 360 | |
240c2873 VS |
361 | wxLayoutConstraints *b5 = new wxLayoutConstraints; |
362 | m_IndexCountInfo = new wxStaticText(dummy, wxID_HTML_COUNTINFO, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT | wxST_NO_AUTORESIZE); | |
363 | ||
4f9297b0 VS |
364 | b5->top.Below (m_IndexButton, 5); |
365 | b5->right.SameAs (dummy, wxRight, 10); | |
366 | b5->left.SameAs (dummy, wxLeft, 10); | |
367 | b5->height.AsIs(); | |
368 | m_IndexCountInfo->SetConstraints(b5); | |
240c2873 | 369 | |
f0b6a33f | 370 | wxLayoutConstraints *b3 = new wxLayoutConstraints; |
721ab905 | 371 | m_IndexList = new wxListBox(dummy, wxID_HTML_INDEXLIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE); |
4f9297b0 VS |
372 | b3->top.Below (m_IndexCountInfo, 5); |
373 | b3->left.SameAs (dummy, wxLeft, 0); | |
374 | b3->right.SameAs (dummy, wxRight, 0); | |
375 | b3->bottom.SameAs (dummy, wxBottom, 0); | |
376 | m_IndexList->SetConstraints(b3); | |
f0b6a33f | 377 | |
7618e374 | 378 | #if wxUSE_TOOLTIPS |
4f9297b0 VS |
379 | m_IndexButtonAll->SetToolTip(_("Show all items in index")); |
380 | m_IndexButton->SetToolTip(_("Display all index items that contain given substring. Search is case insensitive.")); | |
7618e374 VS |
381 | #endif //wxUSE_TOOLTIPS |
382 | ||
4f9297b0 VS |
383 | dummy->SetAutoLayout(TRUE); |
384 | dummy->Layout(); | |
f0b6a33f | 385 | |
4f9297b0 | 386 | m_NavigPan->AddPage(dummy, _("Index")); |
d5bb85a0 | 387 | m_IndexPage = notebook_page++; |
8ec2b484 HH |
388 | } |
389 | ||
390 | // search list panel? | |
da4cc40c | 391 | if (style & wxHF_SEARCH) |
4f9297b0 | 392 | { |
d5bb85a0 VS |
393 | wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_SEARCHPAGE); |
394 | ||
395 | wxLayoutConstraints *b1 = new wxLayoutConstraints; | |
f0b6a33f | 396 | m_SearchText = new wxTextCtrl(dummy, wxID_HTML_SEARCHTEXT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); |
4f9297b0 VS |
397 | b1->top.SameAs (dummy, wxTop, 10); |
398 | b1->left.SameAs (dummy, wxLeft, 10); | |
399 | b1->right.SameAs (dummy, wxRight, 10); | |
400 | b1->height.AsIs(); | |
401 | m_SearchText->SetConstraints(b1); | |
d5bb85a0 | 402 | |
d5bb85a0 VS |
403 | wxLayoutConstraints *b4 = new wxLayoutConstraints; |
404 | m_SearchChoice = new wxChoice(dummy, wxID_HTML_SEARCHCHOICE, wxDefaultPosition, | |
405 | wxDefaultSize); | |
4f9297b0 VS |
406 | b4->top.Below (m_SearchText, 10); |
407 | b4->left.SameAs (dummy, wxLeft, 10); | |
408 | b4->right.SameAs (dummy, wxRight, 10); | |
409 | b4->height.AsIs(); | |
410 | m_SearchChoice->SetConstraints(b4); | |
d5bb85a0 | 411 | |
c4971147 VS |
412 | wxLayoutConstraints *b5 = new wxLayoutConstraints; |
413 | m_SearchCaseSensitive = new wxCheckBox(dummy, -1, _("Case sensitive")); | |
4f9297b0 VS |
414 | b5->top.Below (m_SearchChoice, 10); |
415 | b5->left.SameAs (dummy, wxLeft, 10); | |
416 | b5->width.AsIs(); | |
417 | b5->height.AsIs (); | |
418 | m_SearchCaseSensitive->SetConstraints(b5); | |
c4971147 VS |
419 | |
420 | wxLayoutConstraints *b6 = new wxLayoutConstraints; | |
421 | m_SearchWholeWords = new wxCheckBox(dummy, -1, _("Whole words only")); | |
4f9297b0 VS |
422 | b6->top.Below (m_SearchCaseSensitive, 0); |
423 | b6->left.SameAs (dummy, wxLeft, 10); | |
424 | b6->width.AsIs(); | |
425 | b6->height.AsIs (); | |
426 | m_SearchWholeWords->SetConstraints(b6); | |
c4971147 | 427 | |
ae80f837 VS |
428 | wxLayoutConstraints *b2 = new wxLayoutConstraints; |
429 | m_SearchButton = new wxButton(dummy, wxID_HTML_SEARCHBUTTON, _("Search")); | |
430 | #if wxUSE_TOOLTIPS | |
4f9297b0 | 431 | m_SearchButton->SetToolTip(_("Search contents of help book(s) for all occurences of the text you typed above")); |
ae80f837 | 432 | #endif //wxUSE_TOOLTIPS |
4f9297b0 VS |
433 | b2->top.Below (m_SearchWholeWords, 0); |
434 | b2->right.SameAs (dummy, wxRight, 10); | |
435 | b2->width.AsIs(); | |
436 | b2->height.AsIs(); | |
437 | m_SearchButton->SetConstraints(b2); | |
ae80f837 | 438 | |
954269e6 | 439 | wxLayoutConstraints *b3 = new wxLayoutConstraints; |
721ab905 | 440 | m_SearchList = new wxListBox(dummy, wxID_HTML_SEARCHLIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE); |
4f9297b0 VS |
441 | b3->top.Below (m_SearchButton, 10); |
442 | b3->left.SameAs (dummy, wxLeft, 0); | |
443 | b3->right.SameAs (dummy, wxRight, 0); | |
444 | b3->bottom.SameAs (dummy, wxBottom, 0); | |
445 | m_SearchList->SetConstraints(b3); | |
446 | ||
447 | dummy->SetAutoLayout(TRUE); | |
448 | dummy->Layout(); | |
449 | m_NavigPan->AddPage(dummy, _("Search")); | |
d5bb85a0 | 450 | m_SearchPage = notebook_page++; |
8ec2b484 | 451 | } |
4f9297b0 | 452 | m_HtmlWin->Show(TRUE); |
f6bcfd97 | 453 | |
b5a7b000 | 454 | RefreshLists(); |
8ec2b484 HH |
455 | |
456 | // showtime | |
da4cc40c | 457 | if (m_NavigPan && m_Splitter) |
4f9297b0 VS |
458 | { |
459 | m_Splitter->SetMinimumPaneSize(20); | |
f38374d0 | 460 | if (m_Cfg.navig_on) |
4f9297b0 | 461 | m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); |
da4cc40c | 462 | else |
4f9297b0 VS |
463 | { |
464 | m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); | |
465 | m_Splitter->Unsplit(); | |
f38374d0 | 466 | } |
4f9297b0 | 467 | |
da4cc40c | 468 | if (m_Cfg.navig_on) |
4f9297b0 VS |
469 | { |
470 | m_NavigPan->Show(TRUE); | |
471 | m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); | |
c32bfc10 | 472 | } |
da4cc40c | 473 | else |
4f9297b0 VS |
474 | { |
475 | m_NavigPan->Show(FALSE); | |
476 | m_Splitter->Initialize(m_HtmlWin); | |
68364659 | 477 | } |
8ec2b484 | 478 | } |
8ec2b484 HH |
479 | return TRUE; |
480 | } | |
481 | ||
482 | wxHtmlHelpFrame::~wxHtmlHelpFrame() | |
483 | { | |
b4414c1f | 484 | // PopEventHandler(); // wxhtmlhelpcontroller (not any more!) |
8ec2b484 | 485 | if (m_DataCreated) |
d5bb85a0 | 486 | delete m_Data; |
83efdf33 VS |
487 | if (m_NormalFonts) delete m_NormalFonts; |
488 | if (m_FixedFonts) delete m_FixedFonts; | |
70aedad6 | 489 | if (m_PagesHash) delete m_PagesHash; |
8ec2b484 HH |
490 | } |
491 | ||
b854b7b8 VS |
492 | |
493 | void wxHtmlHelpFrame::AddToolbarButtons(wxToolBar *toolBar, int style) | |
494 | { | |
f6bcfd97 BP |
495 | wxBitmap wpanelBitmap = wxBITMAP(wpanel); |
496 | wxBitmap wbackBitmap = wxBITMAP(wback); | |
497 | wxBitmap wforwardBitmap = wxBITMAP(wforward); | |
498 | wxBitmap wupnodeBitmap = wxBITMAP(wupnode); | |
499 | wxBitmap wupBitmap = wxBITMAP(wup); | |
500 | wxBitmap wdownBitmap = wxBITMAP(wdown); | |
501 | wxBitmap wopenBitmap = wxBITMAP(wopen); | |
502 | wxBitmap wprintBitmap = wxBITMAP(wprint); | |
503 | wxBitmap woptionsBitmap = wxBITMAP(woptions); | |
504 | ||
505 | wxASSERT_MSG( (wpanelBitmap.Ok() && wbackBitmap.Ok() && | |
506 | wforwardBitmap.Ok() && wupnodeBitmap.Ok() && | |
507 | wupBitmap.Ok() && wdownBitmap.Ok() && | |
508 | wopenBitmap.Ok() && wprintBitmap.Ok() && | |
509 | woptionsBitmap.Ok()), | |
510 | wxT("One or more HTML help frame toolbar bitmap could not be loaded.")) ; | |
511 | ||
512 | ||
4f9297b0 | 513 | toolBar->AddTool(wxID_HTML_PANEL, wpanelBitmap, wxNullBitmap, |
b854b7b8 VS |
514 | FALSE, -1, -1, (wxObject *) NULL, |
515 | _("Show/hide navigation panel")); | |
0646614d | 516 | |
4f9297b0 VS |
517 | toolBar->AddSeparator(); |
518 | toolBar->AddTool(wxID_HTML_BACK, wbackBitmap, wxNullBitmap, | |
b854b7b8 | 519 | FALSE, -1, -1, (wxObject *) NULL, |
0646614d | 520 | _("Go back")); |
4f9297b0 | 521 | toolBar->AddTool(wxID_HTML_FORWARD, wforwardBitmap, wxNullBitmap, |
b854b7b8 | 522 | FALSE, -1, -1, (wxObject *) NULL, |
0646614d | 523 | _("Go forward")); |
4f9297b0 | 524 | toolBar->AddSeparator(); |
b854b7b8 | 525 | |
4f9297b0 | 526 | toolBar->AddTool(wxID_HTML_UPNODE, wupnodeBitmap, wxNullBitmap, |
0646614d VS |
527 | FALSE, -1, -1, (wxObject *) NULL, |
528 | _("Go one level up in document hierarchy")); | |
4f9297b0 | 529 | toolBar->AddTool(wxID_HTML_UP, wupBitmap, wxNullBitmap, |
0646614d VS |
530 | FALSE, -1, -1, (wxObject *) NULL, |
531 | _("Previous page")); | |
4f9297b0 | 532 | toolBar->AddTool(wxID_HTML_DOWN, wdownBitmap, wxNullBitmap, |
0646614d VS |
533 | FALSE, -1, -1, (wxObject *) NULL, |
534 | _("Next page")); | |
535 | ||
536 | if ((style & wxHF_PRINT) || (style & wxHF_OPENFILES)) | |
4f9297b0 | 537 | toolBar->AddSeparator(); |
f6bcfd97 | 538 | |
0646614d | 539 | if (style & wxHF_OPENFILES) |
4f9297b0 | 540 | toolBar->AddTool(wxID_HTML_OPENFILE, wopenBitmap, wxNullBitmap, |
0646614d VS |
541 | FALSE, -1, -1, (wxObject *) NULL, |
542 | _("Open HTML document")); | |
543 | ||
544 | #if wxUSE_PRINTING_ARCHITECTURE | |
545 | if (style & wxHF_PRINT) | |
4f9297b0 | 546 | toolBar->AddTool(wxID_HTML_PRINT, wprintBitmap, wxNullBitmap, |
0646614d VS |
547 | FALSE, -1, -1, (wxObject *) NULL, |
548 | _("Print this page")); | |
549 | #endif | |
550 | ||
4f9297b0 VS |
551 | toolBar->AddSeparator(); |
552 | toolBar->AddTool(wxID_HTML_OPTIONS, woptionsBitmap, wxNullBitmap, | |
b854b7b8 VS |
553 | FALSE, -1, -1, (wxObject *) NULL, |
554 | _("Display options dialog")); | |
555 | } | |
556 | ||
557 | ||
721ab905 VS |
558 | void wxHtmlHelpFrame::SetTitleFormat(const wxString& format) |
559 | { | |
560 | if (m_HtmlWin) | |
561 | m_HtmlWin->SetRelatedFrame(this, format); | |
562 | m_TitleFormat = format; | |
563 | } | |
564 | ||
b854b7b8 | 565 | |
8ec2b484 HH |
566 | bool wxHtmlHelpFrame::Display(const wxString& x) |
567 | { | |
568 | wxString url = m_Data->FindPageByName(x); | |
da4cc40c | 569 | if (!url.IsEmpty()) |
4f9297b0 | 570 | { |
d5bb85a0 | 571 | m_HtmlWin->LoadPage(url); |
0646614d | 572 | NotifyPageChanged(); |
d5bb85a0 | 573 | return TRUE; |
8ec2b484 HH |
574 | } |
575 | return FALSE; | |
576 | } | |
577 | ||
578 | bool wxHtmlHelpFrame::Display(const int id) | |
579 | { | |
580 | wxString url = m_Data->FindPageById(id); | |
da4cc40c | 581 | if (!url.IsEmpty()) |
4f9297b0 | 582 | { |
d5bb85a0 | 583 | m_HtmlWin->LoadPage(url); |
0646614d | 584 | NotifyPageChanged(); |
d5bb85a0 | 585 | return TRUE; |
8ec2b484 HH |
586 | } |
587 | return FALSE; | |
588 | } | |
589 | ||
590 | ||
591 | ||
592 | bool wxHtmlHelpFrame::DisplayContents() | |
593 | { | |
594 | if (! m_ContentsBox) | |
d5bb85a0 | 595 | return FALSE; |
da4cc40c | 596 | if (!m_Splitter->IsSplit()) |
4f9297b0 VS |
597 | { |
598 | m_NavigPan->Show(TRUE); | |
599 | m_HtmlWin->Show(TRUE); | |
600 | m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); | |
c32bfc10 | 601 | m_Cfg.navig_on = TRUE; |
8ec2b484 | 602 | } |
4f9297b0 | 603 | m_NavigPan->SetSelection(0); |
71d04f7f JS |
604 | if (m_Data->GetBookRecArray().GetCount() > 0) |
605 | { | |
606 | wxHtmlBookRecord& book = m_Data->GetBookRecArray()[0]; | |
607 | if (!book.GetStart().IsEmpty()) | |
468ae730 | 608 | m_HtmlWin->LoadPage(book.GetFullPath(book.GetStart())); |
71d04f7f | 609 | } |
8ec2b484 HH |
610 | return TRUE; |
611 | } | |
612 | ||
613 | ||
614 | ||
615 | bool wxHtmlHelpFrame::DisplayIndex() | |
616 | { | |
f0b6a33f | 617 | if (! m_IndexList) |
d5bb85a0 | 618 | return FALSE; |
da4cc40c | 619 | if (!m_Splitter->IsSplit()) |
4f9297b0 VS |
620 | { |
621 | m_NavigPan->Show(TRUE); | |
622 | m_HtmlWin->Show(TRUE); | |
623 | m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); | |
8ec2b484 | 624 | } |
4f9297b0 | 625 | m_NavigPan->SetSelection(1); |
71d04f7f JS |
626 | if (m_Data->GetBookRecArray().GetCount() > 0) |
627 | { | |
628 | wxHtmlBookRecord& book = m_Data->GetBookRecArray()[0]; | |
629 | if (!book.GetStart().IsEmpty()) | |
468ae730 | 630 | m_HtmlWin->LoadPage(book.GetFullPath(book.GetStart())); |
71d04f7f | 631 | } |
8ec2b484 HH |
632 | return TRUE; |
633 | } | |
634 | ||
b854b7b8 VS |
635 | |
636 | ||
8ec2b484 HH |
637 | bool wxHtmlHelpFrame::KeywordSearch(const wxString& keyword) |
638 | { | |
639 | if (! (m_SearchList && m_SearchButton && m_SearchText && m_SearchChoice)) | |
d5bb85a0 | 640 | return FALSE; |
8ec2b484 | 641 | |
c4971147 | 642 | int foundcnt = 0, curi; |
8ec2b484 HH |
643 | wxString foundstr; |
644 | wxString book = wxEmptyString; | |
645 | ||
da4cc40c | 646 | if (!m_Splitter->IsSplit()) |
4f9297b0 VS |
647 | { |
648 | m_NavigPan->Show(TRUE); | |
649 | m_HtmlWin->Show(TRUE); | |
650 | m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); | |
8ec2b484 | 651 | } |
4f9297b0 VS |
652 | m_NavigPan->SetSelection(m_SearchPage); |
653 | m_SearchList->Clear(); | |
654 | m_SearchText->SetValue(keyword); | |
655 | m_SearchButton->Enable(FALSE); | |
8ec2b484 HH |
656 | |
657 | if (m_SearchChoice->GetSelection() != 0) | |
d5bb85a0 | 658 | book = m_SearchChoice->GetStringSelection(); |
8ec2b484 | 659 | |
f6bcfd97 | 660 | wxHtmlSearchStatus status(m_Data, keyword, |
4f9297b0 | 661 | m_SearchCaseSensitive->GetValue(), m_SearchWholeWords->GetValue(), |
c4971147 | 662 | book); |
8ec2b484 | 663 | |
d5bb85a0 VS |
664 | wxProgressDialog progress(_("Searching..."), _("No matching page found yet"), |
665 | status.GetMaxIndex(), this, | |
b4414c1f | 666 | wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_AUTO_HIDE); |
8ec2b484 | 667 | |
da4cc40c | 668 | while (status.IsActive()) |
4f9297b0 | 669 | { |
c4971147 | 670 | curi = status.GetCurIndex(); |
b5a7b000 | 671 | if (curi % 32 == 0 && progress.Update(curi) == FALSE) |
d5bb85a0 | 672 | break; |
da4cc40c | 673 | if (status.Search()) |
4f9297b0 | 674 | { |
d5bb85a0 VS |
675 | foundstr.Printf(_("Found %i matches"), ++foundcnt); |
676 | progress.Update(status.GetCurIndex(), foundstr); | |
4f9297b0 | 677 | m_SearchList->Append(status.GetName(), status.GetContentsItem()); |
d5bb85a0 | 678 | } |
8ec2b484 HH |
679 | } |
680 | ||
4f9297b0 VS |
681 | m_SearchButton->Enable(TRUE); |
682 | m_SearchText->SetSelection(0, keyword.Length()); | |
683 | m_SearchText->SetFocus(); | |
da4cc40c | 684 | if (foundcnt) |
4f9297b0 VS |
685 | { |
686 | wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_SearchList->GetClientData(0); | |
f6bcfd97 | 687 | if (it) |
0646614d | 688 | { |
468ae730 | 689 | m_HtmlWin->LoadPage(it->GetFullPath()); |
0646614d VS |
690 | NotifyPageChanged(); |
691 | } | |
8ec2b484 HH |
692 | } |
693 | return (foundcnt > 0); | |
694 | } | |
695 | ||
696 | #define MAX_ROOTS 64 | |
697 | ||
b5a7b000 | 698 | void wxHtmlHelpFrame::CreateContents() |
8ec2b484 HH |
699 | { |
700 | if (! m_ContentsBox) | |
d5bb85a0 | 701 | return ; |
8ec2b484 | 702 | |
8ec2b484 | 703 | m_ContentsBox->Clear(); |
f6bcfd97 | 704 | |
0646614d | 705 | if (m_PagesHash) delete m_PagesHash; |
4f9297b0 VS |
706 | m_PagesHash = new wxHashTable(wxKEY_STRING, 2 * m_Data->GetContentsCnt()); |
707 | m_PagesHash->DeleteContents(TRUE); | |
8ec2b484 HH |
708 | |
709 | int cnt = m_Data->GetContentsCnt(); | |
8ec2b484 HH |
710 | int i; |
711 | ||
83efdf33 | 712 | wxHtmlContentsItem *it; |
d5bb85a0 | 713 | |
8ec2b484 HH |
714 | wxTreeItemId roots[MAX_ROOTS]; |
715 | bool imaged[MAX_ROOTS]; | |
716 | ||
4f9297b0 VS |
717 | m_ContentsBox->DeleteAllItems(); |
718 | roots[0] = m_ContentsBox->AddRoot(_("(Help)")); | |
719 | m_ContentsBox->SetItemImage(roots[0], IMG_RootFolder); | |
720 | m_ContentsBox->SetItemSelectedImage(roots[0], IMG_RootFolder); | |
8ec2b484 HH |
721 | imaged[0] = TRUE; |
722 | ||
da4cc40c | 723 | for (it = m_Data->GetContents(), i = 0; i < cnt; i++, it++) |
4f9297b0 VS |
724 | { |
725 | roots[it->m_Level + 1] = m_ContentsBox->AppendItem( | |
726 | roots[it->m_Level], it->m_Name, IMG_Page, -1, | |
0646614d | 727 | new wxHtmlHelpTreeItemData(i)); |
468ae730 | 728 | m_PagesHash->Put(it->GetFullPath(), |
4f9297b0 VS |
729 | new wxHtmlHelpHashData(i, roots[it->m_Level + 1])); |
730 | ||
da4cc40c | 731 | if (it->m_Level == 0) |
4f9297b0 VS |
732 | { |
733 | m_ContentsBox->SetItemBold(roots[1], TRUE); | |
734 | m_ContentsBox->SetItemImage(roots[1], IMG_Book); | |
735 | m_ContentsBox->SetItemSelectedImage(roots[1], IMG_Book); | |
8ec2b484 | 736 | imaged[1] = TRUE; |
4f9297b0 | 737 | } |
da4cc40c | 738 | else |
4f9297b0 VS |
739 | imaged[it->m_Level + 1] = FALSE; |
740 | ||
da4cc40c | 741 | if (!imaged[it->m_Level]) |
4f9297b0 VS |
742 | { |
743 | m_ContentsBox->SetItemImage(roots[it->m_Level], IMG_Folder); | |
744 | m_ContentsBox->SetItemSelectedImage(roots[it->m_Level], IMG_Folder); | |
745 | imaged[it->m_Level] = TRUE; | |
8ec2b484 HH |
746 | } |
747 | } | |
4f9297b0 | 748 | m_ContentsBox->Expand(roots[0]); |
8ec2b484 HH |
749 | } |
750 | ||
751 | ||
b5a7b000 | 752 | void wxHtmlHelpFrame::CreateIndex() |
8ec2b484 | 753 | { |
f0b6a33f | 754 | if (! m_IndexList) |
d5bb85a0 | 755 | return ; |
8ec2b484 | 756 | |
f0b6a33f | 757 | m_IndexList->Clear(); |
8ec2b484 HH |
758 | |
759 | int cnt = m_Data->GetIndexCnt(); | |
f6bcfd97 | 760 | |
240c2873 VS |
761 | wxString cnttext; |
762 | if (cnt > INDEX_IS_SMALL) cnttext.Printf(_("%i of %i"), 0, cnt); | |
763 | else cnttext.Printf(_("%i of %i"), cnt, cnt); | |
4f9297b0 | 764 | m_IndexCountInfo->SetLabel(cnttext); |
f0b6a33f | 765 | if (cnt > INDEX_IS_SMALL) return; |
f6bcfd97 | 766 | |
8ec2b484 HH |
767 | wxHtmlContentsItem* index = m_Data->GetIndex(); |
768 | ||
f6bcfd97 | 769 | for (int i = 0; i < cnt; i++) |
4f9297b0 | 770 | m_IndexList->Append(index[i].m_Name, (char*)(index + i)); |
8ec2b484 HH |
771 | } |
772 | ||
773 | void wxHtmlHelpFrame::CreateSearch() | |
774 | { | |
775 | if (! (m_SearchList && m_SearchChoice)) | |
d5bb85a0 | 776 | return ; |
4f9297b0 VS |
777 | m_SearchList->Clear(); |
778 | m_SearchChoice->Clear(); | |
779 | m_SearchChoice->Append(_("Search in all books")); | |
8ec2b484 HH |
780 | const wxHtmlBookRecArray& bookrec = m_Data->GetBookRecArray(); |
781 | int i, cnt = bookrec.GetCount(); | |
d5bb85a0 VS |
782 | for (i = 0; i < cnt; i++) |
783 | m_SearchChoice->Append(bookrec[i].GetTitle()); | |
8ec2b484 HH |
784 | m_SearchChoice->SetSelection(0); |
785 | } | |
786 | ||
787 | ||
b5a7b000 | 788 | void wxHtmlHelpFrame::RefreshLists() |
8ec2b484 | 789 | { |
b5a7b000 VS |
790 | CreateContents(); |
791 | CreateIndex(); | |
8ec2b484 HH |
792 | CreateSearch(); |
793 | } | |
794 | ||
795 | void wxHtmlHelpFrame::ReadCustomization(wxConfigBase *cfg, const wxString& path) | |
796 | { | |
797 | wxString oldpath; | |
798 | wxString tmp; | |
799 | ||
da4cc40c | 800 | if (path != wxEmptyString) |
4f9297b0 VS |
801 | { |
802 | oldpath = cfg->GetPath(); | |
803 | cfg->SetPath(_T("/") + path); | |
8ec2b484 HH |
804 | } |
805 | ||
4f9297b0 VS |
806 | m_Cfg.navig_on = cfg->Read(wxT("hcNavigPanel"), m_Cfg.navig_on) != 0; |
807 | m_Cfg.sashpos = cfg->Read(wxT("hcSashPos"), m_Cfg.sashpos); | |
808 | m_Cfg.x = cfg->Read(wxT("hcX"), m_Cfg.x); | |
809 | m_Cfg.y = cfg->Read(wxT("hcY"), m_Cfg.y); | |
810 | m_Cfg.w = cfg->Read(wxT("hcW"), m_Cfg.w); | |
811 | m_Cfg.h = cfg->Read(wxT("hcH"), m_Cfg.h); | |
8ec2b484 | 812 | |
4f9297b0 VS |
813 | m_FixedFace = cfg->Read(wxT("hcFixedFace"), m_FixedFace); |
814 | m_NormalFace = cfg->Read(wxT("hcNormalFace"), m_NormalFace); | |
815 | m_FontSize = cfg->Read(wxT("hcFontSize"), m_FontSize); | |
83efdf33 | 816 | |
382e6efe VS |
817 | { |
818 | int i; | |
819 | int cnt; | |
820 | wxString val, s; | |
f6bcfd97 | 821 | |
4f9297b0 | 822 | cnt = cfg->Read(wxT("hcBookmarksCnt"), 0L); |
da4cc40c | 823 | if (cnt != 0) |
4f9297b0 | 824 | { |
382e6efe VS |
825 | m_BookmarksNames.Clear(); |
826 | m_BookmarksPages.Clear(); | |
da4cc40c | 827 | if (m_Bookmarks) |
4f9297b0 VS |
828 | { |
829 | m_Bookmarks->Clear(); | |
830 | m_Bookmarks->Append(_("(bookmarks)")); | |
382e6efe | 831 | } |
f6bcfd97 | 832 | |
da4cc40c | 833 | for (i = 0; i < cnt; i++) |
4f9297b0 | 834 | { |
0413cec5 | 835 | val.Printf(wxT("hcBookmark_%i"), i); |
4f9297b0 | 836 | s = cfg->Read(val); |
382e6efe | 837 | m_BookmarksNames.Add(s); |
4f9297b0 | 838 | if (m_Bookmarks) m_Bookmarks->Append(s); |
0413cec5 | 839 | val.Printf(wxT("hcBookmark_%i_url"), i); |
4f9297b0 | 840 | s = cfg->Read(val); |
382e6efe VS |
841 | m_BookmarksPages.Add(s); |
842 | } | |
843 | } | |
844 | } | |
845 | ||
8ec2b484 | 846 | if (m_HtmlWin) |
3e5296e7 | 847 | m_HtmlWin->ReadCustomization(cfg); |
8ec2b484 HH |
848 | |
849 | if (path != wxEmptyString) | |
4f9297b0 | 850 | cfg->SetPath(oldpath); |
8ec2b484 HH |
851 | } |
852 | ||
853 | void wxHtmlHelpFrame::WriteCustomization(wxConfigBase *cfg, const wxString& path) | |
854 | { | |
855 | wxString oldpath; | |
856 | wxString tmp; | |
8ec2b484 | 857 | |
da4cc40c | 858 | if (path != wxEmptyString) |
4f9297b0 VS |
859 | { |
860 | oldpath = cfg->GetPath(); | |
861 | cfg->SetPath(_T("/") + path); | |
8ec2b484 HH |
862 | } |
863 | ||
4f9297b0 VS |
864 | cfg->Write(wxT("hcNavigPanel"), m_Cfg.navig_on); |
865 | cfg->Write(wxT("hcSashPos"), (long)m_Cfg.sashpos); | |
866 | cfg->Write(wxT("hcX"), (long)m_Cfg.x); | |
867 | cfg->Write(wxT("hcY"), (long)m_Cfg.y); | |
868 | cfg->Write(wxT("hcW"), (long)m_Cfg.w); | |
869 | cfg->Write(wxT("hcH"), (long)m_Cfg.h); | |
870 | cfg->Write(wxT("hcFixedFace"), m_FixedFace); | |
871 | cfg->Write(wxT("hcNormalFace"), m_NormalFace); | |
872 | cfg->Write(wxT("hcFontSize"), (long)m_FontSize); | |
873 | ||
da4cc40c | 874 | if (m_Bookmarks) |
4f9297b0 | 875 | { |
382e6efe VS |
876 | int i; |
877 | int cnt = m_BookmarksNames.GetCount(); | |
878 | wxString val; | |
f6bcfd97 | 879 | |
4f9297b0 | 880 | cfg->Write(wxT("hcBookmarksCnt"), (long)cnt); |
da4cc40c | 881 | for (i = 0; i < cnt; i++) |
4f9297b0 | 882 | { |
0413cec5 | 883 | val.Printf(wxT("hcBookmark_%i"), i); |
4f9297b0 | 884 | cfg->Write(val, m_BookmarksNames[i]); |
0413cec5 | 885 | val.Printf(wxT("hcBookmark_%i_url"), i); |
4f9297b0 | 886 | cfg->Write(val, m_BookmarksPages[i]); |
382e6efe VS |
887 | } |
888 | } | |
8ec2b484 HH |
889 | |
890 | if (m_HtmlWin) | |
3e5296e7 | 891 | m_HtmlWin->WriteCustomization(cfg); |
8ec2b484 HH |
892 | |
893 | if (path != wxEmptyString) | |
4f9297b0 | 894 | cfg->SetPath(oldpath); |
8ec2b484 HH |
895 | } |
896 | ||
897 | ||
83efdf33 VS |
898 | |
899 | ||
900 | ||
8eb2940f | 901 | static void SetFontsToHtmlWin(wxHtmlWindow *win, wxString scalf, wxString fixf, int size) |
83efdf33 | 902 | { |
f6bcfd97 | 903 | static int f_sizes[5][7] = |
83efdf33 | 904 | { |
0646614d | 905 | { 6, 7, 9, 12, 14, 16, 19}, |
f151e8b5 | 906 | { 8, 9, 12, 14, 16, 19, 22}, |
83efdf33 | 907 | {10, 12, 14, 16, 19, 24, 32}, |
0646614d VS |
908 | {14, 16, 18, 24, 32, 38, 45}, |
909 | {16, 20, 24, 32, 38, 45, 50} | |
83efdf33 | 910 | }; |
f151e8b5 | 911 | |
4f9297b0 | 912 | win->SetFonts(scalf, fixf, f_sizes[size]); |
83efdf33 VS |
913 | } |
914 | ||
915 | ||
916 | class wxHtmlHelpFrameOptionsDialog : public wxDialog | |
917 | { | |
918 | public: | |
f151e8b5 | 919 | wxComboBox *NormalFont, *FixedFont; |
83efdf33 VS |
920 | wxRadioBox *RadioBox; |
921 | wxHtmlWindow *TestWin; | |
922 | ||
923 | wxHtmlHelpFrameOptionsDialog(wxWindow *parent) : wxDialog(parent, -1, wxString(_("Help Browser Options"))) | |
924 | { | |
0646614d | 925 | wxString choices[5] = {_("very small"), _("small"), _("medium"), _("large"), _("very large")}; |
8eb2940f | 926 | wxBoxSizer *topsizer, *sizer, *sizer2; |
83efdf33 VS |
927 | |
928 | topsizer = new wxBoxSizer(wxVERTICAL); | |
929 | ||
930 | sizer = new wxBoxSizer(wxHORIZONTAL); | |
931 | ||
6f67eafe | 932 | sizer2 = new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Normal font:")), wxVERTICAL); |
4f9297b0 | 933 | sizer2->Add(NormalFont = new wxComboBox(this, -1, wxEmptyString, wxDefaultPosition, |
f6bcfd97 | 934 | wxSize(200, 200), |
382e6efe | 935 | 0, NULL, wxCB_DROPDOWN | wxCB_READONLY), |
83efdf33 VS |
936 | 1, wxEXPAND | wxLEFT | wxRIGHT, 10); |
937 | ||
4f9297b0 | 938 | sizer->Add(sizer2, 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10); |
83efdf33 | 939 | |
6f67eafe | 940 | sizer2 = new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Fixed font:")), wxVERTICAL); |
4f9297b0 | 941 | sizer2->Add(FixedFont = new wxComboBox(this, -1, wxEmptyString, wxDefaultPosition, |
f6bcfd97 BP |
942 | wxSize(200, 200), |
943 | 0, NULL, wxCB_DROPDOWN | wxCB_READONLY), | |
83efdf33 VS |
944 | 1, wxEXPAND | wxLEFT | wxRIGHT, 10); |
945 | ||
4f9297b0 | 946 | sizer->Add(sizer2, 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10); |
83efdf33 | 947 | |
4f9297b0 | 948 | topsizer->Add(sizer); |
83efdf33 | 949 | |
4f9297b0 | 950 | topsizer->Add(RadioBox = new wxRadioBox(this, -1, _("Font size:"), |
f6bcfd97 | 951 | wxDefaultPosition, wxDefaultSize, 5, choices, 5), |
6f67eafe | 952 | 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10); |
f6bcfd97 | 953 | |
4f9297b0 | 954 | topsizer->Add(new wxStaticText(this, -1, _("Preview:")), |
83efdf33 | 955 | 0, wxLEFT | wxTOP, 10); |
4f9297b0 | 956 | topsizer->Add(TestWin = new wxHtmlWindow(this, -1, wxDefaultPosition, wxSize(-1, 150)), |
6f67eafe | 957 | 1, wxEXPAND | wxLEFT|wxTOP|wxRIGHT, 10); |
83efdf33 VS |
958 | |
959 | sizer = new wxBoxSizer(wxHORIZONTAL); | |
4f9297b0 VS |
960 | sizer->Add(new wxButton(this, wxID_OK, _("OK")), 0, wxALL, 10); |
961 | sizer->Add(new wxButton(this, wxID_CANCEL, _("Cancel")), 0, wxALL, 10); | |
962 | topsizer->Add(sizer, 0, wxALIGN_RIGHT); | |
83efdf33 VS |
963 | |
964 | SetAutoLayout(TRUE); | |
965 | SetSizer(topsizer); | |
4f9297b0 | 966 | topsizer->Fit(this); |
83efdf33 VS |
967 | Centre(wxBOTH); |
968 | } | |
f6bcfd97 | 969 | |
83efdf33 VS |
970 | |
971 | void UpdateTestWin() | |
972 | { | |
973 | wxBusyCursor bcur; | |
f6bcfd97 | 974 | SetFontsToHtmlWin(TestWin, |
4f9297b0 VS |
975 | NormalFont->GetStringSelection(), |
976 | FixedFont->GetStringSelection(), | |
977 | RadioBox->GetSelection()); | |
978 | TestWin->SetPage(_( | |
f6bcfd97 BP |
979 | "<html><body>\ |
980 | Normal face<br>(and <u>underlined</u>. <i>Italic face.</i> \ | |
981 | <b>Bold face.</b> <b><i>Bold italic face.</i></b><br>\ | |
982 | <font size=-2>font size -2</font><br>\ | |
983 | <font size=-1>font size -1</font><br>\ | |
984 | <font size=+0>font size +0</font><br>\ | |
985 | <font size=+1>font size +1</font><br>\ | |
986 | <font size=+2>font size +2</font><br>\ | |
987 | <font size=+3>font size +3</font><br>\ | |
988 | <font size=+4>font size +4</font><br>\ | |
989 | \ | |
990 | <p><tt>Fixed size face.<br> <b>bold</b> <i>italic</i> \ | |
991 | <b><i>bold italic <u>underlined</u></i></b><br>\ | |
992 | <font size=-2>font size -2</font><br>\ | |
993 | <font size=-1>font size -1</font><br>\ | |
994 | <font size=+0>font size +0</font><br>\ | |
995 | <font size=+1>font size +1</font><br>\ | |
996 | <font size=+2>font size +2</font><br>\ | |
997 | <font size=+3>font size +3</font><br>\ | |
998 | <font size=+4>font size +4</font></tt>\ | |
999 | </body></html>" | |
1000 | )); | |
83efdf33 VS |
1001 | } |
1002 | ||
658fb8e6 | 1003 | void OnUpdate(wxCommandEvent& event) |
83efdf33 VS |
1004 | { |
1005 | UpdateTestWin(); | |
1006 | } | |
1007 | ||
1008 | DECLARE_EVENT_TABLE() | |
1009 | }; | |
1010 | ||
1011 | BEGIN_EVENT_TABLE(wxHtmlHelpFrameOptionsDialog, wxDialog) | |
f151e8b5 | 1012 | EVT_COMBOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate) |
83efdf33 | 1013 | EVT_RADIOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate) |
83efdf33 VS |
1014 | END_EVENT_TABLE() |
1015 | ||
1016 | ||
1017 | void wxHtmlHelpFrame::OptionsDialog() | |
1018 | { | |
1019 | wxHtmlHelpFrameOptionsDialog dlg(this); | |
1020 | unsigned i; | |
f6bcfd97 | 1021 | |
da4cc40c | 1022 | if (m_NormalFonts == NULL) |
4f9297b0 | 1023 | { |
83efdf33 VS |
1024 | wxFontEnumerator enu; |
1025 | enu.EnumerateFacenames(); | |
1026 | m_NormalFonts = new wxArrayString; | |
1027 | *m_NormalFonts = *enu.GetFacenames(); | |
4f9297b0 | 1028 | m_NormalFonts->Sort(); |
83efdf33 | 1029 | } |
da4cc40c | 1030 | if (m_FixedFonts == NULL) |
4f9297b0 | 1031 | { |
83efdf33 VS |
1032 | wxFontEnumerator enu; |
1033 | enu.EnumerateFacenames(wxFONTENCODING_SYSTEM, TRUE); | |
1034 | m_FixedFonts = new wxArrayString; | |
1035 | *m_FixedFonts = *enu.GetFacenames(); | |
4f9297b0 | 1036 | m_FixedFonts->Sort(); |
83efdf33 | 1037 | } |
f6bcfd97 | 1038 | |
4f9297b0 VS |
1039 | for (i = 0; i < m_NormalFonts->GetCount(); i++) |
1040 | dlg.NormalFont->Append((*m_NormalFonts)[i]); | |
1041 | for (i = 0; i < m_FixedFonts->GetCount(); i++) | |
1042 | dlg.FixedFont->Append((*m_FixedFonts)[i]); | |
1043 | if (!m_NormalFace.IsEmpty()) dlg.NormalFont->SetStringSelection(m_NormalFace); | |
1044 | else dlg.NormalFont->SetSelection(0); | |
1045 | if (!m_FixedFace.IsEmpty()) dlg.FixedFont->SetStringSelection(m_FixedFace); | |
1046 | else dlg.FixedFont->SetSelection(0); | |
1047 | dlg.RadioBox->SetSelection(m_FontSize); | |
83efdf33 | 1048 | dlg.UpdateTestWin(); |
f6bcfd97 | 1049 | |
da4cc40c | 1050 | if (dlg.ShowModal() == wxID_OK) |
4f9297b0 VS |
1051 | { |
1052 | m_NormalFace = dlg.NormalFont->GetStringSelection(); | |
1053 | m_FixedFace = dlg.FixedFont->GetStringSelection(); | |
1054 | m_FontSize = dlg.RadioBox->GetSelection(); | |
8eb2940f | 1055 | SetFontsToHtmlWin(m_HtmlWin, m_NormalFace, m_FixedFace, m_FontSize); |
83efdf33 VS |
1056 | } |
1057 | } | |
1058 | ||
1059 | ||
1060 | ||
0646614d VS |
1061 | void wxHtmlHelpFrame::NotifyPageChanged() |
1062 | { | |
1063 | if (m_UpdateContents && m_PagesHash) | |
1064 | { | |
4f9297b0 | 1065 | wxString an = m_HtmlWin->GetOpenedAnchor(); |
0646614d VS |
1066 | wxHtmlHelpHashData *ha; |
1067 | if (an.IsEmpty()) | |
4f9297b0 | 1068 | ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage()); |
0646614d | 1069 | else |
4f9297b0 | 1070 | ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage() + wxT("#") + an); |
0646614d VS |
1071 | if (ha) |
1072 | { | |
1073 | bool olduc = m_UpdateContents; | |
1074 | m_UpdateContents = FALSE; | |
4f9297b0 VS |
1075 | m_ContentsBox->SelectItem(ha->m_Id); |
1076 | m_ContentsBox->EnsureVisible(ha->m_Id); | |
0646614d VS |
1077 | m_UpdateContents = olduc; |
1078 | } | |
1079 | } | |
1080 | } | |
1081 | ||
83efdf33 VS |
1082 | |
1083 | ||
8ec2b484 HH |
1084 | /* |
1085 | EVENT HANDLING : | |
1086 | */ | |
1087 | ||
1088 | ||
1089 | void wxHtmlHelpFrame::OnToolbar(wxCommandEvent& event) | |
1090 | { | |
da4cc40c | 1091 | switch (event.GetId()) |
4f9297b0 | 1092 | { |
8ec2b484 | 1093 | case wxID_HTML_BACK : |
4f9297b0 | 1094 | m_HtmlWin->HistoryBack(); |
0646614d | 1095 | NotifyPageChanged(); |
8ec2b484 | 1096 | break; |
382e6efe | 1097 | |
8ec2b484 | 1098 | case wxID_HTML_FORWARD : |
4f9297b0 | 1099 | m_HtmlWin->HistoryForward(); |
0646614d VS |
1100 | NotifyPageChanged(); |
1101 | break; | |
f6bcfd97 BP |
1102 | |
1103 | case wxID_HTML_UP : | |
1104 | if (m_PagesHash) | |
0646614d | 1105 | { |
4f9297b0 | 1106 | wxString an = m_HtmlWin->GetOpenedAnchor(); |
0646614d VS |
1107 | wxHtmlHelpHashData *ha; |
1108 | if (an.IsEmpty()) | |
4f9297b0 | 1109 | ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage()); |
0646614d | 1110 | else |
4f9297b0 VS |
1111 | ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage() + wxT("#") + an); |
1112 | if (ha && ha->m_Index > 0) | |
0646614d | 1113 | { |
4f9297b0 | 1114 | wxHtmlContentsItem *it = m_Data->GetContents() + (ha->m_Index - 1); |
7df9fbc3 JS |
1115 | if (it->m_Page[0] != 0) |
1116 | { | |
468ae730 | 1117 | m_HtmlWin->LoadPage(it->GetFullPath()); |
7df9fbc3 JS |
1118 | NotifyPageChanged(); |
1119 | } | |
0646614d VS |
1120 | } |
1121 | } | |
1122 | break; | |
1123 | ||
f6bcfd97 BP |
1124 | case wxID_HTML_UPNODE : |
1125 | if (m_PagesHash) | |
0646614d | 1126 | { |
4f9297b0 | 1127 | wxString an = m_HtmlWin->GetOpenedAnchor(); |
0646614d VS |
1128 | wxHtmlHelpHashData *ha; |
1129 | if (an.IsEmpty()) | |
4f9297b0 | 1130 | ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage()); |
0646614d | 1131 | else |
4f9297b0 VS |
1132 | ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage() + wxT("#") + an); |
1133 | if (ha && ha->m_Index > 0) | |
0646614d | 1134 | { |
4f9297b0 | 1135 | int level = m_Data->GetContents()[ha->m_Index].m_Level - 1; |
0646614d | 1136 | wxHtmlContentsItem *it; |
4f9297b0 | 1137 | int ind = ha->m_Index - 1; |
f6bcfd97 | 1138 | |
4f9297b0 VS |
1139 | it = m_Data->GetContents() + ind; |
1140 | while (ind >= 0 && it->m_Level != level) ind--, it--; | |
0646614d VS |
1141 | if (ind >= 0) |
1142 | { | |
7df9fbc3 JS |
1143 | if (it->m_Page[0] != 0) |
1144 | { | |
468ae730 | 1145 | m_HtmlWin->LoadPage(it->GetFullPath()); |
7df9fbc3 JS |
1146 | NotifyPageChanged(); |
1147 | } | |
0646614d VS |
1148 | } |
1149 | } | |
1150 | } | |
1151 | break; | |
1152 | ||
f6bcfd97 BP |
1153 | case wxID_HTML_DOWN : |
1154 | if (m_PagesHash) | |
0646614d | 1155 | { |
4f9297b0 | 1156 | wxString an = m_HtmlWin->GetOpenedAnchor(); |
721ab905 | 1157 | wxString adr; |
0646614d | 1158 | wxHtmlHelpHashData *ha; |
f6bcfd97 | 1159 | |
4f9297b0 VS |
1160 | if (an.IsEmpty()) adr = m_HtmlWin->GetOpenedPage(); |
1161 | else adr = m_HtmlWin->GetOpenedPage() + wxT("#") + an; | |
721ab905 | 1162 | |
4f9297b0 | 1163 | ha = (wxHtmlHelpHashData*) m_PagesHash->Get(adr); |
0646614d | 1164 | |
4f9297b0 | 1165 | if (ha && ha->m_Index < m_Data->GetContentsCnt() - 1) |
0646614d | 1166 | { |
4f9297b0 | 1167 | wxHtmlContentsItem *it = m_Data->GetContents() + (ha->m_Index + 1); |
f6bcfd97 | 1168 | |
468ae730 | 1169 | while (it->GetFullPath() == adr) it++; |
7df9fbc3 JS |
1170 | |
1171 | if (it->m_Page[0] != 0) | |
1172 | { | |
468ae730 | 1173 | m_HtmlWin->LoadPage(it->GetFullPath()); |
7df9fbc3 JS |
1174 | NotifyPageChanged(); |
1175 | } | |
0646614d VS |
1176 | } |
1177 | } | |
8ec2b484 | 1178 | break; |
382e6efe | 1179 | |
8ec2b484 | 1180 | case wxID_HTML_PANEL : |
0646614d VS |
1181 | { |
1182 | if (! (m_Splitter && m_NavigPan)) | |
1183 | return ; | |
da4cc40c | 1184 | if (m_Splitter->IsSplit()) |
4f9297b0 VS |
1185 | { |
1186 | m_Cfg.sashpos = m_Splitter->GetSashPosition(); | |
1187 | m_Splitter->Unsplit(m_NavigPan); | |
0646614d | 1188 | m_Cfg.navig_on = FALSE; |
da4cc40c DW |
1189 | } |
1190 | else | |
4f9297b0 VS |
1191 | { |
1192 | m_NavigPan->Show(TRUE); | |
1193 | m_HtmlWin->Show(TRUE); | |
1194 | m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); | |
0646614d VS |
1195 | m_Cfg.navig_on = TRUE; |
1196 | } | |
8ec2b484 HH |
1197 | } |
1198 | break; | |
382e6efe | 1199 | |
83efdf33 VS |
1200 | case wxID_HTML_OPTIONS : |
1201 | OptionsDialog(); | |
1202 | break; | |
f6bcfd97 BP |
1203 | |
1204 | case wxID_HTML_BOOKMARKSADD : | |
382e6efe VS |
1205 | { |
1206 | wxString item; | |
1207 | wxString url; | |
f6bcfd97 | 1208 | |
4f9297b0 VS |
1209 | item = m_HtmlWin->GetOpenedPageTitle(); |
1210 | url = m_HtmlWin->GetOpenedPage(); | |
da4cc40c | 1211 | if (item == wxEmptyString) |
4f9297b0 | 1212 | item = url.AfterLast(wxT('/')); |
da4cc40c | 1213 | if (m_BookmarksPages.Index(url) == wxNOT_FOUND) |
4f9297b0 VS |
1214 | { |
1215 | m_Bookmarks->Append(item); | |
382e6efe VS |
1216 | m_BookmarksNames.Add(item); |
1217 | m_BookmarksPages.Add(url); | |
1218 | } | |
1219 | } | |
1220 | break; | |
f6bcfd97 BP |
1221 | |
1222 | case wxID_HTML_BOOKMARKSREMOVE : | |
382e6efe VS |
1223 | { |
1224 | wxString item; | |
1225 | int pos; | |
f6bcfd97 | 1226 | |
4f9297b0 | 1227 | item = m_Bookmarks->GetStringSelection(); |
382e6efe | 1228 | pos = m_BookmarksNames.Index(item); |
da4cc40c | 1229 | if (pos != wxNOT_FOUND) |
4f9297b0 | 1230 | { |
382e6efe VS |
1231 | m_BookmarksNames.Remove(pos); |
1232 | m_BookmarksPages.Remove(pos); | |
4f9297b0 | 1233 | m_Bookmarks->Delete(m_Bookmarks->GetSelection()); |
382e6efe VS |
1234 | } |
1235 | } | |
1236 | break; | |
0646614d VS |
1237 | |
1238 | #if wxUSE_PRINTING_ARCHITECTURE | |
1239 | case wxID_HTML_PRINT : | |
1240 | { | |
f6bcfd97 | 1241 | if (m_Printer == NULL) |
0646614d | 1242 | m_Printer = new wxHtmlEasyPrinting(_("Help Printing"), this); |
4f9297b0 | 1243 | if (!m_HtmlWin->GetOpenedPage()) |
f5ba273e VS |
1244 | wxLogWarning(_("Cannot print empty page.")); |
1245 | else | |
4f9297b0 | 1246 | m_Printer->PrintFile(m_HtmlWin->GetOpenedPage()); |
0646614d VS |
1247 | } |
1248 | break; | |
1249 | #endif | |
1250 | ||
1251 | case wxID_HTML_OPENFILE : | |
1252 | { | |
f6bcfd97 BP |
1253 | wxString s = wxFileSelector(_("Open HTML document"), |
1254 | wxEmptyString, | |
1255 | wxEmptyString, | |
1256 | wxEmptyString, | |
1257 | _( | |
1258 | "HTML files (*.htm)|*.htm|HTML files (*.html)|*.html|\ | |
1259 | Help books (*.htb)|*.htb|Help books (*.zip)|*.zip|\ | |
1260 | HTML Help Project (*.hhp)|*.hhp|\ | |
1261 | All files (*.*)|*" | |
1262 | ), | |
1263 | wxOPEN | wxFILE_MUST_EXIST, | |
1264 | this); | |
0646614d VS |
1265 | if (!s.IsEmpty()) |
1266 | { | |
1267 | wxString ext = s.Right(4).Lower(); | |
1268 | if (ext == _T(".zip") || ext == _T(".htb") || ext == _T(".hhp")) | |
1269 | { | |
1270 | wxBusyCursor bcur; | |
4f9297b0 | 1271 | m_Data->AddBook(s); |
0646614d VS |
1272 | RefreshLists(); |
1273 | } | |
1274 | else | |
4f9297b0 | 1275 | m_HtmlWin->LoadPage(s); |
0646614d VS |
1276 | } |
1277 | } | |
1278 | break; | |
8ec2b484 HH |
1279 | } |
1280 | } | |
1281 | ||
1282 | ||
1283 | ||
1284 | void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent& event) | |
1285 | { | |
1286 | wxHtmlHelpTreeItemData *pg; | |
0646614d | 1287 | wxHtmlContentsItem *it; |
8ec2b484 | 1288 | |
4f9297b0 | 1289 | pg = (wxHtmlHelpTreeItemData*) m_ContentsBox->GetItemData(event.GetItem()); |
f6bcfd97 BP |
1290 | |
1291 | if (pg && m_UpdateContents) | |
0646614d | 1292 | { |
4f9297b0 | 1293 | it = m_Data->GetContents() + (pg->m_Id); |
0646614d | 1294 | m_UpdateContents = FALSE; |
7df9fbc3 | 1295 | if (it->m_Page[0] != 0) |
468ae730 | 1296 | m_HtmlWin->LoadPage(it->GetFullPath()); |
0646614d VS |
1297 | m_UpdateContents = TRUE; |
1298 | } | |
8ec2b484 HH |
1299 | } |
1300 | ||
1301 | ||
1302 | ||
a4c97004 | 1303 | void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent& WXUNUSED(event)) |
8ec2b484 | 1304 | { |
4f9297b0 | 1305 | wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_IndexList->GetClientData(m_IndexList->GetSelection()); |
7df9fbc3 | 1306 | if (it->m_Page[0] != 0) |
468ae730 | 1307 | m_HtmlWin->LoadPage(it->GetFullPath()); |
0646614d | 1308 | NotifyPageChanged(); |
8ec2b484 HH |
1309 | } |
1310 | ||
1311 | ||
f0b6a33f VS |
1312 | void wxHtmlHelpFrame::OnIndexFind(wxCommandEvent& event) |
1313 | { | |
4f9297b0 | 1314 | wxString sr = m_IndexText->GetLineText(0); |
240c2873 | 1315 | sr.MakeLower(); |
f6bcfd97 | 1316 | if (sr == wxEmptyString) |
4f9297b0 | 1317 | { |
f0b6a33f | 1318 | OnIndexAll(event); |
4f9297b0 | 1319 | } |
da4cc40c | 1320 | else |
4f9297b0 | 1321 | { |
f0b6a33f VS |
1322 | wxBusyCursor bcur; |
1323 | const wxChar *cstr = sr.c_str(); | |
240c2873 | 1324 | wxChar mybuff[512], *ptr; |
f0b6a33f | 1325 | bool first = TRUE; |
f6bcfd97 | 1326 | |
f0b6a33f VS |
1327 | m_IndexList->Clear(); |
1328 | int cnt = m_Data->GetIndexCnt(); | |
1329 | wxHtmlContentsItem* index = m_Data->GetIndex(); | |
1330 | ||
240c2873 | 1331 | int displ = 0; |
f0b6a33f | 1332 | for (int i = 0; i < cnt; i++) |
240c2873 VS |
1333 | { |
1334 | wxStrncpy(mybuff, index[i].m_Name, 512); | |
f6bcfd97 BP |
1335 | mybuff[511] = _T('\0'); |
1336 | for (ptr = mybuff; *ptr != 0; ptr++) | |
1337 | if (*ptr >= _T('A') && *ptr <= _T('Z')) | |
1338 | *ptr -= (wxChar)(_T('A') - _T('a')); | |
da4cc40c | 1339 | if (wxStrstr(mybuff, cstr) != NULL) |
4f9297b0 VS |
1340 | { |
1341 | m_IndexList->Append(index[i].m_Name, (char*)(index + i)); | |
240c2873 | 1342 | displ++; |
da4cc40c | 1343 | if (first) |
4f9297b0 | 1344 | { |
7df9fbc3 | 1345 | if (index[i].m_Page[0] != 0) |
468ae730 | 1346 | m_HtmlWin->LoadPage(index[i].GetFullPath()); |
0646614d | 1347 | NotifyPageChanged(); |
f0b6a33f VS |
1348 | first = FALSE; |
1349 | } | |
1350 | } | |
240c2873 VS |
1351 | } |
1352 | ||
1353 | wxString cnttext; | |
1354 | cnttext.Printf(_("%i of %i"), displ, cnt); | |
4f9297b0 | 1355 | m_IndexCountInfo->SetLabel(cnttext); |
f0b6a33f | 1356 | |
4f9297b0 VS |
1357 | m_IndexText->SetSelection(0, sr.Length()); |
1358 | m_IndexText->SetFocus(); | |
f0b6a33f VS |
1359 | } |
1360 | } | |
1361 | ||
1362 | void wxHtmlHelpFrame::OnIndexAll(wxCommandEvent& WXUNUSED(event)) | |
1363 | { | |
1364 | wxBusyCursor bcur; | |
f6bcfd97 | 1365 | |
f0b6a33f VS |
1366 | m_IndexList->Clear(); |
1367 | int cnt = m_Data->GetIndexCnt(); | |
1368 | bool first = TRUE; | |
1369 | wxHtmlContentsItem* index = m_Data->GetIndex(); | |
1370 | ||
da4cc40c | 1371 | for (int i = 0; i < cnt; i++) |
4f9297b0 VS |
1372 | { |
1373 | m_IndexList->Append(index[i].m_Name, (char*)(index + i)); | |
da4cc40c | 1374 | if (first) |
4f9297b0 | 1375 | { |
7df9fbc3 | 1376 | if (index[i].m_Page[0] != 0) |
468ae730 | 1377 | m_HtmlWin->LoadPage(index[i].GetFullPath()); |
0646614d | 1378 | NotifyPageChanged(); |
f0b6a33f VS |
1379 | first = FALSE; |
1380 | } | |
1381 | } | |
240c2873 VS |
1382 | |
1383 | wxString cnttext; | |
1384 | cnttext.Printf(_("%i of %i"), cnt, cnt); | |
4f9297b0 | 1385 | m_IndexCountInfo->SetLabel(cnttext); |
f0b6a33f VS |
1386 | } |
1387 | ||
8ec2b484 | 1388 | |
a4c97004 | 1389 | void wxHtmlHelpFrame::OnSearchSel(wxCommandEvent& WXUNUSED(event)) |
8ec2b484 | 1390 | { |
4f9297b0 | 1391 | wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_SearchList->GetClientData(m_SearchList->GetSelection()); |
f6bcfd97 | 1392 | if (it) |
0646614d | 1393 | { |
7df9fbc3 | 1394 | if (it->m_Page[0] != 0) |
468ae730 | 1395 | m_HtmlWin->LoadPage(it->GetFullPath()); |
0646614d VS |
1396 | NotifyPageChanged(); |
1397 | } | |
8ec2b484 HH |
1398 | } |
1399 | ||
a4c97004 | 1400 | void wxHtmlHelpFrame::OnSearch(wxCommandEvent& WXUNUSED(event)) |
8ec2b484 | 1401 | { |
4f9297b0 | 1402 | wxString sr = m_SearchText->GetLineText(0); |
8ec2b484 HH |
1403 | |
1404 | if (sr != wxEmptyString) KeywordSearch(sr); | |
1405 | } | |
1406 | ||
382e6efe VS |
1407 | void wxHtmlHelpFrame::OnBookmarksSel(wxCommandEvent& WXUNUSED(event)) |
1408 | { | |
4f9297b0 | 1409 | wxString sr = m_Bookmarks->GetStringSelection(); |
382e6efe | 1410 | |
ae80f837 | 1411 | if (sr != wxEmptyString && sr != _("(bookmarks)")) |
0646614d | 1412 | { |
4f9297b0 | 1413 | m_HtmlWin->LoadPage(m_BookmarksPages[m_BookmarksNames.Index(sr)]); |
0646614d VS |
1414 | NotifyPageChanged(); |
1415 | } | |
382e6efe VS |
1416 | } |
1417 | ||
8ec2b484 HH |
1418 | void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent& evt) |
1419 | { | |
68364659 VS |
1420 | GetSize(&m_Cfg.w, &m_Cfg.h); |
1421 | GetPosition(&m_Cfg.x, &m_Cfg.y); | |
5c172c17 | 1422 | |
4f9297b0 | 1423 | if (m_Splitter && m_Cfg.navig_on) m_Cfg.sashpos = m_Splitter->GetSashPosition(); |
68364659 | 1424 | |
d5bb85a0 VS |
1425 | if (m_Config) |
1426 | WriteCustomization(m_Config, m_ConfigRoot); | |
68364659 | 1427 | |
b4414c1f JS |
1428 | if (m_helpController && m_helpController->IsKindOf(CLASSINFO(wxHtmlHelpController))) |
1429 | { | |
1430 | ((wxHtmlHelpController*) m_helpController)->OnCloseFrame(evt); | |
1431 | } | |
1432 | ||
8ec2b484 HH |
1433 | evt.Skip(); |
1434 | } | |
1435 | ||
1436 | BEGIN_EVENT_TABLE(wxHtmlHelpFrame, wxFrame) | |
ae80f837 VS |
1437 | EVT_TOOL_RANGE(wxID_HTML_PANEL, wxID_HTML_OPTIONS, wxHtmlHelpFrame::OnToolbar) |
1438 | EVT_BUTTON(wxID_HTML_BOOKMARKSREMOVE, wxHtmlHelpFrame::OnToolbar) | |
1439 | EVT_BUTTON(wxID_HTML_BOOKMARKSADD, wxHtmlHelpFrame::OnToolbar) | |
8ec2b484 HH |
1440 | EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL, wxHtmlHelpFrame::OnContentsSel) |
1441 | EVT_LISTBOX(wxID_HTML_INDEXLIST, wxHtmlHelpFrame::OnIndexSel) | |
1442 | EVT_LISTBOX(wxID_HTML_SEARCHLIST, wxHtmlHelpFrame::OnSearchSel) | |
1443 | EVT_BUTTON(wxID_HTML_SEARCHBUTTON, wxHtmlHelpFrame::OnSearch) | |
1444 | EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT, wxHtmlHelpFrame::OnSearch) | |
f0b6a33f VS |
1445 | EVT_BUTTON(wxID_HTML_INDEXBUTTON, wxHtmlHelpFrame::OnIndexFind) |
1446 | EVT_TEXT_ENTER(wxID_HTML_INDEXTEXT, wxHtmlHelpFrame::OnIndexFind) | |
1447 | EVT_BUTTON(wxID_HTML_INDEXBUTTONALL, wxHtmlHelpFrame::OnIndexAll) | |
382e6efe | 1448 | EVT_COMBOBOX(wxID_HTML_BOOKMARKSLIST, wxHtmlHelpFrame::OnBookmarksSel) |
f6bcfd97 | 1449 | EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow) |
8ec2b484 HH |
1450 | END_EVENT_TABLE() |
1451 | ||
1452 | #endif |