]>
Commit | Line | Data |
---|---|---|
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 |
31 | IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpController, wxEvtHandler) |
32 | ||
8ec2b484 | 33 | BEGIN_EVENT_TABLE(wxHtmlHelpController, wxEvtHandler) |
d5bb85a0 | 34 | EVT_CLOSE(wxHtmlHelpController::OnCloseFrame) |
8ec2b484 HH |
35 | END_EVENT_TABLE() |
36 | ||
d5bb85a0 | 37 | wxHtmlHelpController::wxHtmlHelpController(int style) |
8ec2b484 HH |
38 | { |
39 | m_helpFrame = NULL; | |
40 | m_Config = NULL; | |
41 | m_ConfigRoot = wxEmptyString; | |
42 | m_titleFormat = _("Help: %s"); | |
d5bb85a0 | 43 | m_FrameStyle = style; |
8ec2b484 HH |
44 | } |
45 | ||
46 | wxHtmlHelpController::~wxHtmlHelpController() | |
47 | { | |
48 | WriteCustomization(m_Config, m_ConfigRoot); | |
49 | if (m_helpFrame) | |
d5bb85a0 | 50 | m_helpFrame->Close(); |
8ec2b484 HH |
51 | } |
52 | ||
53 | void wxHtmlHelpController::SetTitleFormat(const wxString& title) | |
54 | { | |
55 | m_titleFormat = title; | |
56 | if (m_helpFrame) | |
d5bb85a0 | 57 | m_helpFrame->SetTitleFormat(title); |
8ec2b484 HH |
58 | } |
59 | ||
d5bb85a0 | 60 | |
8ec2b484 HH |
61 | bool wxHtmlHelpController::AddBook(const wxString& book, bool show_wait_msg) |
62 | { | |
63 | wxBusyCursor cur; | |
64 | #if wxUSE_BUSYINFO | |
69941f05 | 65 | wxBusyInfo* busy = NULL; |
8ec2b484 HH |
66 | wxString info; |
67 | if (show_wait_msg) { | |
d5bb85a0 VS |
68 | info.Printf(_("Adding book %s"), book.c_str()); |
69 | busy = new wxBusyInfo(info); | |
8ec2b484 HH |
70 | } |
71 | #endif | |
72 | bool retval = m_helpData.AddBook(book); | |
73 | #if wxUSE_BUSYINFO | |
74 | if (show_wait_msg) | |
d5bb85a0 VS |
75 | delete busy; |
76 | #endif | |
8ec2b484 HH |
77 | return retval; |
78 | } | |
79 | ||
80 | void wxHtmlHelpController::CreateHelpWindow(bool show_progress) | |
81 | { | |
82 | if (m_helpFrame) { | |
d5bb85a0 VS |
83 | m_helpFrame->Raise(); |
84 | return ; | |
8ec2b484 HH |
85 | } |
86 | m_helpFrame = new wxHtmlHelpFrame(&m_helpData); | |
d5bb85a0 | 87 | |
8ec2b484 HH |
88 | m_helpFrame->PushEventHandler(this); |
89 | if (m_Config) | |
d5bb85a0 VS |
90 | m_helpFrame->UseConfig(m_Config, m_ConfigRoot); |
91 | m_helpFrame->Create(NULL, wxID_HTML_HELPFRAME, wxEmptyString, m_FrameStyle); | |
8ec2b484 HH |
92 | m_helpFrame->RefreshLists(show_progress); |
93 | m_helpFrame->SetTitleFormat(m_titleFormat); | |
94 | m_helpFrame->Show(TRUE); | |
95 | } | |
96 | ||
97 | void wxHtmlHelpController::ReadCustomization(wxConfigBase* cfg, const wxString& path) | |
98 | { | |
99 | /* should not be called by the user; call UseConfig, and the controller | |
100 | * will do the rest */ | |
101 | if (m_helpFrame) | |
d5bb85a0 | 102 | m_helpFrame->ReadCustomization(cfg, path); |
8ec2b484 HH |
103 | } |
104 | ||
105 | void wxHtmlHelpController::WriteCustomization(wxConfigBase* cfg, const wxString& path) | |
106 | { | |
107 | /* typically called by the controllers OnCloseFrame handler */ | |
108 | if (m_helpFrame) | |
d5bb85a0 | 109 | m_helpFrame->WriteCustomization(cfg, path); |
8ec2b484 HH |
110 | } |
111 | ||
112 | #endif |