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