1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHtmlHelpFrame
4 // Notes: Based on htmlhelp.cpp, implementing a monolithic
5 // HTML Help controller class, by Vaclav Slavik
6 // Author: Harm van der Heijden and Vaclav Slavik
8 // Copyright: (c) Harm van der Heijden and Vaclav Slavik
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation
16 // For compilers that support precompilation, includes "wx.h"
18 #include "wx/wxprec.h"
31 #include "wx/html/helpfrm.h"
32 #include "wx/notebook.h"
33 #include "wx/imaglist.h"
34 #include "wx/treectrl.h"
35 #include "wx/tokenzr.h"
36 #include "wx/wfstream.h"
37 #include "wx/html/htmlwin.h"
38 #include "wx/busyinfo.h"
39 #include "wx/progdlg.h"
40 #include "wx/toolbar.h"
41 #include "wx/fontenum.h"
46 #include "bitmaps/wpanel.xpm"
47 #include "bitmaps/wback.xpm"
48 #include "bitmaps/wforward.xpm"
49 #include "bitmaps/wbook.xpm"
50 #include "bitmaps/woptions.xpm"
51 #include "bitmaps/wfolder.xpm"
52 #include "bitmaps/wpage.xpm"
53 #include "bitmaps/whelp.xpm"
54 #include "bitmaps/whlproot.xpm"
57 #include "wx/stream.h"
59 // number of times that the contents/index creation progress dialog
61 #define PROGRESS_STEP 40
63 //--------------------------------------------------------------------------
64 // wxHtmlHelpTreeItemData
65 //--------------------------------------------------------------------------
67 class wxHtmlHelpTreeItemData
: public wxTreeItemData
73 wxHtmlHelpTreeItemData(wxHtmlContentsItem
*it
) : wxTreeItemData()
75 m_Page
= it
-> m_Book
-> GetBasePath() + it
-> m_Page
;
77 const wxString
& GetPage() { return m_Page
; }
80 //---------------------------------------------------------------------------
82 //---------------------------------------------------------------------------
84 IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpFrame
, wxFrame
)
86 wxHtmlHelpFrame::wxHtmlHelpFrame(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
87 int style
, wxHtmlHelpData
* data
)
90 Create(parent
, id
, title
, style
);
93 void wxHtmlHelpFrame::Init(wxHtmlHelpData
* data
)
97 m_DataCreated
= FALSE
;
99 m_Data
= new wxHtmlHelpData();
100 m_DataCreated
= TRUE
;
103 m_ContentsImageList
= new wxImageList(16, 16);
104 m_ContentsImageList
-> Add(wxICON(wbook
));
105 m_ContentsImageList
-> Add(wxICON(wfolder
));
106 m_ContentsImageList
-> Add(wxICON(wpage
));
107 m_ContentsImageList
-> Add(wxICON(whlproot
));
109 m_ContentsBox
= NULL
;
112 m_SearchButton
= NULL
;
114 m_SearchChoice
= NULL
;
119 m_ConfigRoot
= wxEmptyString
;
121 m_Cfg
.x
= m_Cfg
.y
= 0;
125 m_Cfg
.navig_on
= TRUE
;
127 m_NormalFonts
= m_FixedFonts
= NULL
;
129 m_NormalFace
= m_FixedFace
= wxEmptyString
;
130 m_NormalItalic
= m_FixedItalic
= wxSLANT
;
133 // Create: builds the GUI components.
134 // with the style flag it's possible to toggle the toolbar, contents, index and search
136 // m_HtmlWin will *always* be created, but it's important to realize that
137 // m_ContentsBox, m_IndexBox, m_SearchList, m_SearchButton, m_SearchText and
138 // m_SearchButton may be NULL.
139 // moreover, if no contents, index or searchpage is needed, m_Splitter and
140 // m_NavigPan will be NULL too (with m_HtmlWin directly connected to the frame)
142 bool wxHtmlHelpFrame::Create(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
145 // Do the config in two steps. We read the HtmlWindow customization after we
146 // create the window.
148 ReadCustomization(m_Config
, m_ConfigRoot
);
150 wxFrame::Create(parent
, id
, _("Help"), wxPoint(m_Cfg
.x
, m_Cfg
.y
), wxSize(m_Cfg
.w
, m_Cfg
.h
));
152 GetPosition(&m_Cfg
.x
, &m_Cfg
.y
);
154 SetIcon(wxICON(whelp
));
156 int notebook_page
= 0;
161 if (style
& wxHF_TOOLBAR
) {
162 wxToolBar
*toolBar
= CreateToolBar(wxNO_BORDER
| wxTB_HORIZONTAL
| wxTB_DOCKABLE
);
163 toolBar
-> SetMargins(2, 2);
165 toolBar
-> AddTool(wxID_HTML_PANEL
, wxBITMAP(wpanel
), wxNullBitmap
,
166 FALSE
, -1, -1, (wxObject
*) NULL
,
167 _("Show/hide navigation panel"));
168 toolBar
-> AddSeparator();
169 toolBar
-> AddTool(wxID_HTML_BACK
, wxBITMAP(wback
), wxNullBitmap
,
170 FALSE
, -1, -1, (wxObject
*) NULL
,
171 _("Go back to the previous HTML page"));
172 toolBar
-> AddTool(wxID_HTML_FORWARD
, wxBITMAP(wforward
), wxNullBitmap
,
173 FALSE
, -1, -1, (wxObject
*) NULL
,
174 _("Go forward to the next HTML page"));
176 toolBar
-> AddSeparator();
177 toolBar
-> AddTool(wxID_HTML_OPTIONS
, wxBITMAP(woptions
), wxNullBitmap
,
178 FALSE
, -1, -1, (wxObject
*) NULL
,
179 _("Display options dialog"));
181 toolBar
-> Realize();
184 if (style
& (wxHF_CONTENTS
| wxHF_INDEX
| wxHF_SEARCH
)) {
185 // traditional help controller; splitter window with html page on the
186 // right and a notebook containing various pages on the left
187 m_Splitter
= new wxSplitterWindow(this);
189 m_HtmlWin
= new wxHtmlWindow(m_Splitter
);
190 m_NavigPan
= new wxNotebook(m_Splitter
, wxID_HTML_NOTEBOOK
,
191 wxDefaultPosition
, wxDefaultSize
);
192 } else { // only html window, no notebook with index,contents etc
193 m_HtmlWin
= new wxHtmlWindow(this);
196 m_HtmlWin
-> SetRelatedFrame(this, m_TitleFormat
);
197 m_HtmlWin
-> SetRelatedStatusBar(0);
199 m_HtmlWin
-> ReadCustomization(m_Config
, m_ConfigRoot
);
201 // contents tree panel?
202 if (style
& wxHF_CONTENTS
) {
203 m_ContentsBox
= new wxTreeCtrl(m_NavigPan
, wxID_HTML_TREECTRL
,
204 wxDefaultPosition
, wxDefaultSize
,
205 wxTR_HAS_BUTTONS
| wxSUNKEN_BORDER
);
206 m_ContentsBox
-> SetImageList(m_ContentsImageList
);
207 m_NavigPan
-> AddPage(m_ContentsBox
, _("Contents"));
208 m_ContentsPage
= notebook_page
++;
211 // index listbox panel?
212 if (style
& wxHF_INDEX
) {
213 wxWindow
*dummy
= new wxPanel(m_NavigPan
, wxID_HTML_INDEXPAGE
);
214 wxLayoutConstraints
*b1
= new wxLayoutConstraints
;
215 b1
-> top
.SameAs (dummy
, wxTop
, 0);
216 b1
-> left
.SameAs (dummy
, wxLeft
, 0);
217 b1
-> width
.PercentOf (dummy
, wxWidth
, 100);
218 b1
-> bottom
.SameAs (dummy
, wxBottom
, 0);
219 m_IndexBox
= new wxListBox(dummy
, wxID_HTML_INDEXLIST
, wxDefaultPosition
,
220 wxDefaultSize
, 0, NULL
, wxLB_SINGLE
| wxLB_ALWAYS_SB
);
221 m_IndexBox
-> SetConstraints(b1
);
222 dummy
-> SetAutoLayout(TRUE
);
223 m_NavigPan
-> AddPage(dummy
, _("Index"));
224 m_IndexPage
= notebook_page
++;
227 // search list panel?
228 if (style
& wxHF_SEARCH
) {
229 wxWindow
*dummy
= new wxPanel(m_NavigPan
, wxID_HTML_SEARCHPAGE
);
231 wxLayoutConstraints
*b1
= new wxLayoutConstraints
;
232 m_SearchText
= new wxTextCtrl(dummy
, wxID_HTML_SEARCHTEXT
);
233 b1
-> top
.SameAs (dummy
, wxTop
, 10);
234 b1
-> left
.SameAs (dummy
, wxLeft
, 10);
235 b1
-> right
.SameAs (dummy
, wxRight
, 10);
237 m_SearchText
-> SetConstraints(b1
);
239 wxLayoutConstraints
*b2
= new wxLayoutConstraints
;
240 m_SearchButton
= new wxButton(dummy
, wxID_HTML_SEARCHBUTTON
, _("Search"));
241 b2
-> top
.Below (m_SearchText
, 10);
242 b2
-> left
.SameAs (dummy
, wxLeft
, 10);
245 m_SearchButton
-> SetConstraints(b2
);
247 wxLayoutConstraints
*b4
= new wxLayoutConstraints
;
248 m_SearchChoice
= new wxChoice(dummy
, wxID_HTML_SEARCHCHOICE
, wxDefaultPosition
,
250 b4
-> top
.Below (m_SearchText
, 10);
251 b4
-> left
.SameAs (m_SearchButton
, wxRight
, 10);
252 b4
-> right
.SameAs (dummy
, wxRight
, 10);
254 m_SearchChoice
-> SetConstraints(b4
);
256 wxLayoutConstraints
*b3
= new wxLayoutConstraints
;
257 m_SearchList
= new wxListBox(dummy
, wxID_HTML_SEARCHLIST
, wxDefaultPosition
, wxDefaultSize
, 0);
258 b3
-> top
.Below (m_SearchButton
, 10);
259 b3
-> left
.SameAs (dummy
, wxLeft
, 0);
260 b3
-> right
.SameAs (dummy
, wxRight
, 0);
261 b3
-> bottom
.SameAs (dummy
, wxBottom
, 0);
262 m_SearchList
-> SetConstraints(b3
);
264 dummy
-> SetAutoLayout(TRUE
);
266 m_NavigPan
-> AddPage(dummy
, _("Search"));
267 m_SearchPage
= notebook_page
++;
269 m_HtmlWin
-> Show(TRUE
);
274 if (m_NavigPan
&& m_Splitter
) {
275 m_Splitter
-> SetMinimumPaneSize(20);
277 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
279 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
280 m_Splitter
-> Unsplit();
282 if (m_Cfg
.navig_on
) {
283 m_NavigPan
-> Show(TRUE
);
284 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
287 m_NavigPan
-> Show(FALSE
);
288 m_Splitter
-> Initialize(m_HtmlWin
);
294 wxHtmlHelpFrame::~wxHtmlHelpFrame()
296 delete m_ContentsImageList
;
299 if (m_NormalFonts
) delete m_NormalFonts
;
300 if (m_FixedFonts
) delete m_FixedFonts
;
303 bool wxHtmlHelpFrame::Display(const wxString
& x
)
305 wxString url
= m_Data
->FindPageByName(x
);
306 if (! url
.IsEmpty()) {
307 m_HtmlWin
->LoadPage(url
);
313 bool wxHtmlHelpFrame::Display(const int id
)
315 wxString url
= m_Data
->FindPageById(id
);
316 if (! url
.IsEmpty()) {
317 m_HtmlWin
->LoadPage(url
);
325 bool wxHtmlHelpFrame::DisplayContents()
329 if (!m_Splitter
-> IsSplit()) {
330 m_NavigPan
-> Show(TRUE
);
331 m_HtmlWin
-> Show(TRUE
);
332 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
333 m_Cfg
.navig_on
= TRUE
;
335 m_NavigPan
-> SetSelection(0);
341 bool wxHtmlHelpFrame::DisplayIndex()
345 if (!m_Splitter
-> IsSplit()) {
346 m_NavigPan
-> Show(TRUE
);
347 m_HtmlWin
-> Show(TRUE
);
348 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
350 m_NavigPan
-> SetSelection(1);
354 bool wxHtmlHelpFrame::KeywordSearch(const wxString
& keyword
)
356 if (! (m_SearchList
&& m_SearchButton
&& m_SearchText
&& m_SearchChoice
))
361 wxString book
= wxEmptyString
;
363 if (!m_Splitter
-> IsSplit()) {
364 m_NavigPan
-> Show(TRUE
);
365 m_HtmlWin
-> Show(TRUE
);
366 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
368 m_NavigPan
-> SetSelection(m_SearchPage
);
369 m_SearchList
-> Clear();
370 m_SearchText
-> SetValue(keyword
);
371 m_SearchButton
-> Enable(FALSE
);
373 if (m_SearchChoice
->GetSelection() != 0)
374 book
= m_SearchChoice
->GetStringSelection();
376 wxHtmlSearchStatus
status(m_Data
, keyword
, book
);
378 wxProgressDialog
progress(_("Searching..."), _("No matching page found yet"),
379 status
.GetMaxIndex(), this,
380 wxPD_APP_MODAL
| wxPD_CAN_ABORT
| wxPD_AUTO_HIDE
);
382 while (status
.IsActive()) {
383 if (progress
.Update(status
.GetCurIndex()) == FALSE
)
385 if (status
.Search()) {
386 foundstr
.Printf(_("Found %i matches"), ++foundcnt
);
387 progress
.Update(status
.GetCurIndex(), foundstr
);
388 m_SearchList
-> Append(status
.GetName(), status
.GetContentsItem());
393 m_SearchButton
-> Enable(TRUE
);
394 m_SearchText
-> SetSelection(0, keyword
.Length());
395 m_SearchText
-> SetFocus();
397 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_SearchList
-> GetClientData(0);
398 if (it
) m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
400 return (foundcnt
> 0);
405 void wxHtmlHelpFrame::CreateContents(bool show_progress
)
410 wxProgressDialog
*progress
= NULL
;
413 m_ContentsBox
->Clear();
415 int cnt
= m_Data
->GetContentsCnt();
416 int div
= (cnt
/ PROGRESS_STEP
) + 1;
419 wxHtmlContentsItem
*it
;
422 progress
= new wxProgressDialog(_("Building contents tree..."), wxEmptyString
,
423 cnt
, this, wxPD_APP_MODAL
| wxPD_CAN_ABORT
|
426 wxTreeItemId roots
[MAX_ROOTS
];
427 bool imaged
[MAX_ROOTS
];
429 m_ContentsBox
-> DeleteAllItems();
430 roots
[0] = m_ContentsBox
-> AddRoot(_("(Help)"));
431 m_ContentsBox
-> SetItemImage(roots
[0], IMG_RootFolder
);
432 m_ContentsBox
-> SetItemSelectedImage(roots
[0], IMG_RootFolder
);
435 for (it
= m_Data
->GetContents(), i
= 0; i
< cnt
; i
++, it
++) {
436 if (show_progress
&& ((i
% div
) == 0)) {
437 proginfo
.Printf(_("Added %d/%d items"), i
, cnt
);
438 if (! progress
->Update(i
, proginfo
))
442 roots
[it
-> m_Level
+ 1] = m_ContentsBox
-> AppendItem(
443 roots
[it
-> m_Level
], it
-> m_Name
, IMG_Page
, -1,
444 new wxHtmlHelpTreeItemData(it
));
446 if (it
-> m_Level
== 0) {
447 m_ContentsBox
-> SetItemBold(roots
[1], TRUE
);
448 m_ContentsBox
-> SetItemImage(roots
[1], IMG_Book
);
449 m_ContentsBox
-> SetItemSelectedImage(roots
[1], IMG_Book
);
451 } else imaged
[it
-> m_Level
+ 1] = FALSE
;
453 if (!imaged
[it
-> m_Level
]) {
454 m_ContentsBox
-> SetItemImage(roots
[it
-> m_Level
], IMG_Folder
);
455 m_ContentsBox
-> SetItemSelectedImage(roots
[it
-> m_Level
], IMG_Folder
);
456 imaged
[it
-> m_Level
] = TRUE
;
461 m_ContentsBox
-> Expand(roots
[0]);
465 void wxHtmlHelpFrame::CreateIndex(bool show_progress
)
470 wxProgressDialog
*progress
= NULL
;
475 int cnt
= m_Data
->GetIndexCnt();
476 int div
= (cnt
/ PROGRESS_STEP
) + 1;
478 wxHtmlContentsItem
* index
= m_Data
->GetIndex();
481 progress
= new wxProgressDialog(_("Building index list..."), wxEmptyString
,
482 cnt
, this, wxPD_APP_MODAL
| wxPD_CAN_ABORT
|
484 for (int i
= 0; i
< cnt
; i
++) {
485 if (show_progress
&& ((i
% div
) == 0)) {
486 proginfo
.Printf(_("Added %d/%d items"), i
, cnt
);
487 if (! progress
->Update(i
, proginfo
))
491 m_IndexBox
-> Append(index
[i
].m_Name
, (char*)(index
+ i
));
498 void wxHtmlHelpFrame::CreateSearch()
500 if (! (m_SearchList
&& m_SearchChoice
))
502 m_SearchList
-> Clear();
503 m_SearchChoice
-> Clear();
504 m_SearchChoice
-> Append(_("all books"));
505 const wxHtmlBookRecArray
& bookrec
= m_Data
->GetBookRecArray();
506 int i
, cnt
= bookrec
.GetCount();
507 for (i
= 0; i
< cnt
; i
++)
508 m_SearchChoice
->Append(bookrec
[i
].GetTitle());
509 m_SearchChoice
->SetSelection(0);
513 void wxHtmlHelpFrame::RefreshLists(bool show_progress
)
515 CreateContents(show_progress
);
516 CreateIndex(show_progress
);
520 void wxHtmlHelpFrame::ReadCustomization(wxConfigBase
*cfg
, const wxString
& path
)
525 if (path
!= wxEmptyString
) {
526 oldpath
= cfg
-> GetPath();
527 cfg
-> SetPath(path
);
530 m_Cfg
.navig_on
= cfg
-> Read("hcNavigPanel", m_Cfg
.navig_on
) != 0;
531 m_Cfg
.sashpos
= cfg
-> Read("hcSashPos", m_Cfg
.sashpos
);
532 m_Cfg
.x
= cfg
-> Read("hcX", m_Cfg
.x
);
533 m_Cfg
.y
= cfg
-> Read("hcY", m_Cfg
.y
);
534 m_Cfg
.w
= cfg
-> Read("hcW", m_Cfg
.w
);
535 m_Cfg
.h
= cfg
-> Read("hcH", m_Cfg
.h
);
537 m_FixedFace
= cfg
-> Read("hcFixedFace", m_FixedFace
);
538 m_NormalFace
= cfg
-> Read("hcNormalFace", m_NormalFace
);
539 m_FontSize
= cfg
-> Read("hcFontSize", m_FontSize
);
540 m_NormalItalic
= cfg
-> Read("hcNormalItalic", m_NormalItalic
);
541 m_FixedItalic
= cfg
-> Read("hcFixedItalic", m_FixedItalic
);
544 m_HtmlWin
->ReadCustomization(cfg
, path
);
546 if (path
!= wxEmptyString
)
547 cfg
-> SetPath(oldpath
);
550 void wxHtmlHelpFrame::WriteCustomization(wxConfigBase
*cfg
, const wxString
& path
)
555 if (path
!= wxEmptyString
) {
556 oldpath
= cfg
-> GetPath();
557 cfg
-> SetPath(path
);
560 cfg
-> Write("hcNavigPanel", m_Cfg
.navig_on
);
561 cfg
-> Write("hcSashPos", (long)m_Cfg
.sashpos
);
562 cfg
-> Write("hcX", (long)m_Cfg
.x
);
563 cfg
-> Write("hcY", (long)m_Cfg
.y
);
564 cfg
-> Write("hcW", (long)m_Cfg
.w
);
565 cfg
-> Write("hcH", (long)m_Cfg
.h
);
566 cfg
-> Write("hcFixedFace", m_FixedFace
);
567 cfg
-> Write("hcNormalFace", m_NormalFace
);
568 cfg
-> Write("hcFontSize", (long)m_FontSize
);
569 cfg
-> Write("hcNormalItalic", (long)m_NormalItalic
);
570 cfg
-> Write("hcFixedItalic", (long)m_FixedItalic
);
573 m_HtmlWin
->WriteCustomization(cfg
, path
);
575 if (path
!= wxEmptyString
)
576 cfg
-> SetPath(oldpath
);
583 static void SetFontsToHtmlWin(wxHtmlWindow
*win
, wxString scalf
, int scalit
, wxString fixf
, int fixit
, int size
)
585 static int f_sizes
[3][7] =
587 { 8, 9, 12, 14, 16, 19, 22},
588 {10, 12, 14, 16, 19, 24, 32},
589 {14, 16, 18, 24, 32, 38, 45}
592 win
-> SetFonts(scalf
, scalit
, fixf
, fixit
, f_sizes
[size
]);
596 class wxHtmlHelpFrameOptionsDialog
: public wxDialog
599 wxComboBox
*NormalFont
, *FixedFont
;
600 wxRadioButton
*SFI_i
, *SFI_s
, *FFI_i
, *FFI_s
;
601 wxRadioBox
*RadioBox
;
602 wxHtmlWindow
*TestWin
;
604 wxHtmlHelpFrameOptionsDialog(wxWindow
*parent
) : wxDialog(parent
, -1, wxString(_("Help Browser Options")))
606 wxString choices
[3] = {_("small"), _("medium"), _("large")};
607 wxString choices2
[2] = {_("italic"), _("slant")};
608 wxBoxSizer
*topsizer
, *sizer
, *sizer2
, *sizer3
;
610 topsizer
= new wxBoxSizer(wxVERTICAL
);
612 sizer
= new wxBoxSizer(wxHORIZONTAL
);
614 sizer2
= new wxBoxSizer(wxVERTICAL
);
615 sizer2
-> Add(new wxStaticText(this, -1, _("Normal font:")),
616 0, wxLEFT
| wxTOP
, 10);
617 sizer2
-> Add(NormalFont
= new wxComboBox(this, -1, wxEmptyString
, wxDefaultPosition
, wxSize(200, -1), 0, NULL
, wxCB_DROPDOWN
| wxCB_READONLY
),
618 1, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
620 sizer3
= new wxBoxSizer(wxHORIZONTAL
);
621 sizer3
-> Add(SFI_i
= new wxRadioButton(this, -1, _("use italic"), wxDefaultPosition
, wxDefaultSize
, wxRB_GROUP
),
623 sizer3
-> Add(SFI_s
= new wxRadioButton(this, -1, _("use slant"), wxDefaultPosition
, wxDefaultSize
, 0),
625 sizer2
-> Add(sizer3
, 0, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
627 sizer
-> Add(sizer2
, 0, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
629 sizer2
= new wxBoxSizer(wxVERTICAL
);
630 sizer2
-> Add(new wxStaticText(this, -1, _("Fixed font:")),
631 0, wxLEFT
| wxTOP
, 10);
632 sizer2
-> Add(FixedFont
= new wxComboBox(this, -1, wxEmptyString
, wxDefaultPosition
, wxSize(200, -1), 0, NULL
, wxCB_DROPDOWN
| wxCB_READONLY
),
633 1, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
635 sizer3
= new wxBoxSizer(wxHORIZONTAL
);
636 sizer3
-> Add(FFI_i
= new wxRadioButton(this, -1, _("use italic"), wxDefaultPosition
, wxDefaultSize
, wxRB_GROUP
),
638 sizer3
-> Add(FFI_s
= new wxRadioButton(this, -1, _("use slant"), wxDefaultPosition
, wxDefaultSize
, 0),
640 sizer2
-> Add(sizer3
, 0, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
642 sizer
-> Add(sizer2
, 0, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
644 topsizer
-> Add(sizer
);
646 topsizer
-> Add(RadioBox
= new wxRadioBox(this, -1, _("Font size:"),
647 wxDefaultPosition
, wxDefaultSize
, 3, choices
, 3),
648 0, wxEXPAND
| wxLEFT
| wxRIGHT
, 10);
650 topsizer
-> Add(new wxStaticText(this, -1, _("Preview:")),
651 0, wxLEFT
| wxTOP
, 10);
652 topsizer
-> Add(TestWin
= new wxHtmlWindow(this, -1, wxDefaultPosition
, wxSize(-1, 150)),
653 1, wxEXPAND
| wxLEFT
| wxTOP
, 10);
655 sizer
= new wxBoxSizer(wxHORIZONTAL
);
656 sizer
-> Add(new wxButton(this, wxID_OK
, _("OK")), 0, wxALL
, 10);
657 sizer
-> Add(new wxButton(this, wxID_CANCEL
, _("Cancel")), 0, wxALL
, 10);
658 topsizer
-> Add(sizer
, 0, wxALIGN_RIGHT
);
662 topsizer
-> Fit(this);
670 SetFontsToHtmlWin(TestWin
,
671 NormalFont
-> GetStringSelection(), SFI_i
-> GetValue() ? wxITALIC
: wxSLANT
,
672 FixedFont
-> GetStringSelection(), FFI_i
-> GetValue() ? wxITALIC
: wxSLANT
,
673 RadioBox
-> GetSelection());
674 TestWin
-> SetPage(_("<html><body>"
675 "Normal face<br>(and <u>underlined</u>. <i>Italic face.</i> "
676 "<b>Bold face.</b> <b><i>Bold italic face.</i></b><br>"
677 "<font size=-2>font size -2</font><br>"
678 "<font size=-1>font size -1</font><br>"
679 "<font size=+0>font size +0</font><br>"
680 "<font size=+1>font size +1</font><br>"
681 "<font size=+2>font size +2</font><br>"
682 "<font size=+3>font size +3</font><br>"
683 "<font size=+4>font size +4</font><br>"
685 "<p><tt>Fixed size face.<br> <b>bold</b> <i>italic</i> "
686 "<b><i>bold italic <u>underlined</u></i></b></tt><br>"
687 "<font size=-2>font size -2</font><br>"
688 "<font size=-1>font size -1</font><br>"
689 "<font size=+0>font size +0</font><br>"
690 "<font size=+1>font size +1</font><br>"
691 "<font size=+2>font size +2</font><br>"
692 "<font size=+3>font size +3</font><br>"
693 "<font size=+4>font size +4</font>"
697 void OnUpdate(wxCloseEvent
& event
)
702 DECLARE_EVENT_TABLE()
705 BEGIN_EVENT_TABLE(wxHtmlHelpFrameOptionsDialog
, wxDialog
)
706 EVT_COMBOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate
)
707 EVT_RADIOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate
)
708 EVT_RADIOBUTTON(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate
)
712 void wxHtmlHelpFrame::OptionsDialog()
714 wxHtmlHelpFrameOptionsDialog
dlg(this);
717 if (m_NormalFonts
== NULL
) {
718 wxFontEnumerator enu
;
719 enu
.EnumerateFacenames();
720 m_NormalFonts
= new wxArrayString
;
721 *m_NormalFonts
= *enu
.GetFacenames();
722 m_NormalFonts
-> Sort();
724 if (m_FixedFonts
== NULL
) {
725 wxFontEnumerator enu
;
726 enu
.EnumerateFacenames(wxFONTENCODING_SYSTEM
, TRUE
);
727 m_FixedFonts
= new wxArrayString
;
728 *m_FixedFonts
= *enu
.GetFacenames();
729 m_FixedFonts
-> Sort();
732 for (i
= 0; i
< m_NormalFonts
-> GetCount(); i
++)
733 dlg
.NormalFont
-> Append((*m_NormalFonts
)[i
]);
734 for (i
= 0; i
< m_FixedFonts
-> GetCount(); i
++)
735 dlg
.FixedFont
-> Append((*m_FixedFonts
)[i
]);
736 if (!m_NormalFace
.IsEmpty()) dlg
.NormalFont
-> SetStringSelection(m_NormalFace
);
737 else dlg
.NormalFont
-> SetSelection(0);
738 if (!m_FixedFace
.IsEmpty()) dlg
.FixedFont
-> SetStringSelection(m_FixedFace
);
739 else dlg
.FixedFont
-> SetSelection(0);
740 dlg
.RadioBox
-> SetSelection(m_FontSize
);
741 dlg
.SFI_i
-> SetValue(m_NormalItalic
== wxITALIC
);
742 dlg
.SFI_s
-> SetValue(m_NormalItalic
== wxSLANT
);
743 dlg
.FFI_i
-> SetValue(m_FixedItalic
== wxITALIC
);
744 dlg
.FFI_s
-> SetValue(m_FixedItalic
== wxSLANT
);
747 if (dlg
.ShowModal() == wxID_OK
) {
748 m_NormalFace
= dlg
.NormalFont
-> GetStringSelection();
749 m_FixedFace
= dlg
.FixedFont
-> GetStringSelection();
750 m_FontSize
= dlg
.RadioBox
-> GetSelection();
751 m_NormalItalic
= dlg
.SFI_i
-> GetValue() ? wxITALIC
: wxSLANT
;
752 m_FixedItalic
= dlg
.FFI_i
-> GetValue() ? wxITALIC
: wxSLANT
;
753 SetFontsToHtmlWin(m_HtmlWin
, m_NormalFace
, m_NormalItalic
, m_FixedFace
, m_FixedItalic
, m_FontSize
);
766 void wxHtmlHelpFrame::OnToolbar(wxCommandEvent
& event
)
768 switch (event
.GetId()) {
769 case wxID_HTML_BACK
:
770 m_HtmlWin
-> HistoryBack();
772 case wxID_HTML_FORWARD
:
773 m_HtmlWin
-> HistoryForward();
775 case wxID_HTML_PANEL
:
776 if (! (m_Splitter
&& m_NavigPan
))
778 if (m_Splitter
-> IsSplit()) {
779 m_Cfg
.sashpos
= m_Splitter
-> GetSashPosition();
780 m_Splitter
-> Unsplit(m_NavigPan
);
781 m_Cfg
.navig_on
= FALSE
;
783 m_NavigPan
-> Show(TRUE
);
784 m_HtmlWin
-> Show(TRUE
);
785 m_Splitter
-> SplitVertically(m_NavigPan
, m_HtmlWin
, m_Cfg
.sashpos
);
786 m_Cfg
.navig_on
= TRUE
;
789 case wxID_HTML_OPTIONS
:
797 void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent
& event
)
799 wxHtmlHelpTreeItemData
*pg
;
801 pg
= (wxHtmlHelpTreeItemData
*) m_ContentsBox
-> GetItemData(event
.GetItem());
802 if (pg
) m_HtmlWin
-> LoadPage(pg
-> GetPage());
807 void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent
& WXUNUSED(event
))
809 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_IndexBox
-> GetClientData(m_IndexBox
-> GetSelection());
810 m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
815 void wxHtmlHelpFrame::OnSearchSel(wxCommandEvent
& WXUNUSED(event
))
817 wxHtmlContentsItem
*it
= (wxHtmlContentsItem
*) m_SearchList
-> GetClientData(m_SearchList
-> GetSelection());
818 if (it
) m_HtmlWin
-> LoadPage(it
-> m_Book
-> GetBasePath() + it
-> m_Page
);
821 void wxHtmlHelpFrame::OnSearch(wxCommandEvent
& WXUNUSED(event
))
823 wxString sr
= m_SearchText
-> GetLineText(0);
825 if (sr
!= wxEmptyString
) KeywordSearch(sr
);
828 void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent
& evt
)
830 GetSize(&m_Cfg
.w
, &m_Cfg
.h
);
831 GetPosition(&m_Cfg
.x
, &m_Cfg
.y
);
833 if (m_Splitter
&& m_Cfg
.navig_on
) m_Cfg
.sashpos
= m_Splitter
-> GetSashPosition();
836 WriteCustomization(m_Config
, m_ConfigRoot
);
841 BEGIN_EVENT_TABLE(wxHtmlHelpFrame
, wxFrame
)
842 EVT_TOOL_RANGE(wxID_HTML_PANEL
, wxID_HTML_OPTIONS
, wxHtmlHelpFrame::OnToolbar
)
843 EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL
, wxHtmlHelpFrame::OnContentsSel
)
844 EVT_LISTBOX(wxID_HTML_INDEXLIST
, wxHtmlHelpFrame::OnIndexSel
)
845 EVT_LISTBOX(wxID_HTML_SEARCHLIST
, wxHtmlHelpFrame::OnSearchSel
)
846 EVT_BUTTON(wxID_HTML_SEARCHBUTTON
, wxHtmlHelpFrame::OnSearch
)
847 EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT
, wxHtmlHelpFrame::OnSearch
)
848 EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow
)