]> git.saurik.com Git - wxWidgets.git/blob - src/html/helpctrl.cpp
New HTML help system. The old controller class has been split in
[wxWidgets.git] / src / html / helpctrl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: helpctrl.cpp
3 // Purpose: wxHtmlHelpController
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
7 // Created:
8 // RCS-ID:
9 // Copyright: (c) Harm van der Heijden and Vaclav Slavik
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifdef __GNUG__
14 #pragma implementation "helpctrl.h"
15 #endif
16
17 // For compilers that support precompilation, includes "wx.h".
18 #include "wx/wxprec.h"
19
20 #ifdef __BORLANDC__
21 #pragma hdrstop
22 #endif
23
24 #include "wx/defs.h"
25
26 #if wxUSE_HTML
27
28 #include "wx/html/helpctrl.h"
29 #include "wx/wx.h"
30 #include "wx/busyinfo.h"
31
32 BEGIN_EVENT_TABLE(wxHtmlHelpController, wxEvtHandler)
33 EVT_CLOSE(wxHtmlHelpController::OnCloseFrame)
34 END_EVENT_TABLE()
35
36 wxHtmlHelpController::wxHtmlHelpController()
37 {
38 m_helpFrame = NULL;
39 m_Config = NULL;
40 m_ConfigRoot = wxEmptyString;
41 m_titleFormat = _("Help: %s");
42 }
43
44 wxHtmlHelpController::~wxHtmlHelpController()
45 {
46 WriteCustomization(m_Config, m_ConfigRoot);
47 if (m_helpFrame)
48 m_helpFrame->Close();
49 }
50
51 void wxHtmlHelpController::SetTitleFormat(const wxString& title)
52 {
53 m_titleFormat = title;
54 if (m_helpFrame)
55 m_helpFrame->SetTitleFormat(title);
56 }
57
58 bool wxHtmlHelpController::AddBook(const wxString& book, bool show_wait_msg)
59 {
60 wxBusyCursor cur;
61 #if wxUSE_BUSYINFO
62 wxBusyInfo* busy;
63 wxString info;
64 if (show_wait_msg) {
65 info.Printf(_("Adding book %s"), book.c_str());
66 busy = new wxBusyInfo(info);
67 }
68 #endif
69 bool retval = m_helpData.AddBook(book);
70 #if wxUSE_BUSYINFO
71 if (show_wait_msg)
72 delete busy;
73 #endif
74 return retval;
75 }
76
77 void wxHtmlHelpController::CreateHelpWindow(bool show_progress)
78 {
79 if (m_helpFrame) {
80 m_helpFrame->Raise();
81 return;
82 }
83 m_helpFrame = new wxHtmlHelpFrame(&m_helpData);
84 m_helpFrame->PushEventHandler(this);
85 if (m_Config)
86 m_helpFrame->UseConfig(m_Config, m_ConfigRoot);
87 m_helpFrame->Create(NULL, wxID_HTML_HELPFRAME);
88 m_helpFrame->RefreshLists(show_progress);
89 m_helpFrame->SetTitleFormat(m_titleFormat);
90 m_helpFrame->Show(TRUE);
91 }
92
93 void wxHtmlHelpController::ReadCustomization(wxConfigBase* cfg, const wxString& path)
94 {
95 /* should not be called by the user; call UseConfig, and the controller
96 * will do the rest */
97 if (m_helpFrame)
98 m_helpFrame->ReadCustomization(cfg, path);
99 }
100
101 void wxHtmlHelpController::WriteCustomization(wxConfigBase* cfg, const wxString& path)
102 {
103 /* typically called by the controllers OnCloseFrame handler */
104 if (m_helpFrame)
105 m_helpFrame->WriteCustomization(cfg, path);
106 }
107
108 #endif