X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3755cfa64d2f5182ec88d9d0bf934769e0269d10..3225a4b8b8656f25dac6cb20684a3c2c273cf796:/src/html/helpctrl.cpp diff --git a/src/html/helpctrl.cpp b/src/html/helpctrl.cpp index cbb26b1b55..66c903a364 100644 --- a/src/html/helpctrl.cpp +++ b/src/html/helpctrl.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: helpctrl.cpp +// Name: src/html/helpctrl.cpp // Purpose: wxHtmlHelpController // Notes: Based on htmlhelp.cpp, implementing a monolithic // HTML Help controller class, by Vaclav Slavik @@ -25,7 +25,7 @@ #include "wx/busyinfo.h" #include "wx/html/helpctrl.h" -#include "wx/html/helpwin.h" +#include "wx/html/helpwnd.h" #include "wx/html/helpfrm.h" #include "wx/html/helpdlg.h" @@ -44,16 +44,23 @@ wxHtmlHelpController::wxHtmlHelpController(int style, wxWindow* parentWindow): wxHelpControllerBase(parentWindow) { m_helpWindow = NULL; + m_helpFrame = NULL; + m_helpDialog = NULL; +#if wxUSE_CONFIG m_Config = NULL; m_ConfigRoot = wxEmptyString; +#endif // wxUSE_CONFIG m_titleFormat = _("Help: %s"); m_FrameStyle = style; + m_shouldPreventAppExit = false; } wxHtmlHelpController::~wxHtmlHelpController() { +#if wxUSE_CONFIG if (m_Config) WriteCustomization(m_Config, m_ConfigRoot); +#endif // wxUSE_CONFIG if (m_helpWindow) DestroyHelpWindow(); } @@ -77,19 +84,33 @@ void wxHtmlHelpController::DestroyHelpWindow() parent->Destroy(); m_helpWindow = NULL; } + m_helpDialog = NULL; + m_helpFrame = NULL; } void wxHtmlHelpController::OnCloseFrame(wxCloseEvent& evt) { +#if wxUSE_CONFIG if (m_Config) WriteCustomization(m_Config, m_ConfigRoot); - +#endif // wxUSE_CONFIG + evt.Skip(); OnQuit(); - m_helpWindow->SetController(NULL); + if ( m_helpWindow ) + m_helpWindow->SetController(NULL); m_helpWindow = NULL; + m_helpDialog = NULL; + m_helpFrame = NULL; +} + +void wxHtmlHelpController::SetShouldPreventAppExit(bool enable) +{ + m_shouldPreventAppExit = enable; + if ( m_helpFrame ) + m_helpFrame->SetShouldPreventAppExit(enable); } void wxHtmlHelpController::SetTitleFormat(const wxString& title) @@ -108,12 +129,7 @@ void wxHtmlHelpController::SetTitleFormat(const wxString& title) // Find the top-most parent window wxWindow* wxHtmlHelpController::FindTopLevelWindow() { - wxWindow* parent = m_helpWindow; - while (parent && !parent->IsTopLevel()) - { - parent = parent->GetParent(); - } - return parent; + return wxGetTopLevelParent(m_helpWindow); } bool wxHtmlHelpController::AddBook(const wxFileName& book_file, bool show_wait_msg) @@ -149,8 +165,14 @@ wxHtmlHelpFrame* wxHtmlHelpController::CreateHelpFrame(wxHtmlHelpData *data) { wxHtmlHelpFrame* frame = new wxHtmlHelpFrame(data); frame->SetController(this); - frame->SetTitleFormat(m_titleFormat); - frame->Create(m_parentWindow, -1, wxEmptyString, m_FrameStyle); + frame->Create(m_parentWindow, -1, wxEmptyString, m_FrameStyle +#if wxUSE_CONFIG + , m_Config, m_ConfigRoot +#endif // wxUSE_CONFIG + ); + frame->SetTitleFormat(m_titleFormat); + frame->SetShouldPreventAppExit(m_shouldPreventAppExit); + m_helpFrame = frame; return frame; } @@ -158,8 +180,9 @@ wxHtmlHelpDialog* wxHtmlHelpController::CreateHelpDialog(wxHtmlHelpData *data) { wxHtmlHelpDialog* dialog = new wxHtmlHelpDialog(data); dialog->SetController(this); - dialog->SetTitleFormat(m_titleFormat); + dialog->SetTitleFormat(m_titleFormat); dialog->Create(m_parentWindow, -1, wxEmptyString, m_FrameStyle); + m_helpDialog = dialog; return dialog; } @@ -176,12 +199,14 @@ wxWindow* wxHtmlHelpController::CreateHelpWindow() return m_helpWindow; } +#if wxUSE_CONFIG if (m_Config == NULL) { m_Config = wxConfigBase::Get(false); if (m_Config != NULL) - m_ConfigRoot = _T("wxWindows/wxHtmlHelpController"); + m_ConfigRoot = wxT("wxWindows/wxHtmlHelpController"); } +#endif // wxUSE_CONFIG if (m_FrameStyle & wxHF_DIALOG) { @@ -203,6 +228,7 @@ wxWindow* wxHtmlHelpController::CreateHelpWindow() return m_helpWindow; } +#if wxUSE_CONFIG void wxHtmlHelpController::ReadCustomization(wxConfigBase* cfg, const wxString& path) { /* should not be called by the user; call UseConfig, and the controller @@ -225,13 +251,14 @@ void wxHtmlHelpController::UseConfig(wxConfigBase *config, const wxString& rootp if (m_helpWindow) m_helpWindow->UseConfig(config, rootpath); ReadCustomization(config, rootpath); } +#endif // wxUSE_CONFIG //// Backward compatibility with wxHelpController API bool wxHtmlHelpController::Initialize(const wxString& file) { wxString dir, filename, ext; - wxSplitPath(file, & dir, & filename, & ext); + wxFileName::SplitPath(file, & dir, & filename, & ext); if (!dir.empty()) dir = dir + wxFILE_SEP_PATH;