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