]> git.saurik.com Git - wxWidgets.git/blob - src/html/helpctrl.cpp
compilation fix for non-threaded compilation (threads are still broken
[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 // RCS-ID: $Id$
8 // Copyright: (c) Harm van der Heijden and Vaclav Slavik
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation
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
31 IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpController, wxEvtHandler)
32
33 BEGIN_EVENT_TABLE(wxHtmlHelpController, wxEvtHandler)
34 EVT_CLOSE(wxHtmlHelpController::OnCloseFrame)
35 END_EVENT_TABLE()
36
37 wxHtmlHelpController::wxHtmlHelpController(int style)
38 {
39 m_helpFrame = NULL;
40 m_Config = NULL;
41 m_ConfigRoot = wxEmptyString;
42 m_titleFormat = _("Help: %s");
43 m_FrameStyle = style;
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
61 bool wxHtmlHelpController::AddBook(const wxString& book, bool show_wait_msg)
62 {
63 wxBusyCursor cur;
64 #if wxUSE_BUSYINFO
65 wxBusyInfo* busy = NULL;
66 wxString info;
67 if (show_wait_msg) {
68 info.Printf(_("Adding book %s"), book.c_str());
69 busy = new wxBusyInfo(info);
70 }
71 #endif
72 bool retval = m_helpData.AddBook(book);
73 #if wxUSE_BUSYINFO
74 if (show_wait_msg)
75 delete busy;
76 #endif
77 return retval;
78 }
79
80 void wxHtmlHelpController::CreateHelpWindow(bool show_progress)
81 {
82 if (m_helpFrame) {
83 m_helpFrame->Raise();
84 return ;
85 }
86 m_helpFrame = new wxHtmlHelpFrame(&m_helpData);
87
88 m_helpFrame->PushEventHandler(this);
89 if (m_Config)
90 m_helpFrame->UseConfig(m_Config, m_ConfigRoot);
91 m_helpFrame->Create(NULL, wxID_HTML_HELPFRAME, wxEmptyString, m_FrameStyle);
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)
102 m_helpFrame->ReadCustomization(cfg, path);
103 }
104
105 void wxHtmlHelpController::WriteCustomization(wxConfigBase* cfg, const wxString& path)
106 {
107 /* typically called by the controllers OnCloseFrame handler */
108 if (m_helpFrame)
109 m_helpFrame->WriteCustomization(cfg, path);
110 }
111
112 #endif