Add a method which can be used to indicate that the help window should prevent
the application from exiting and use it in the help sample to prevent it from
closing prematurely.
Closes #13046.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67228
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
wxHtmlHelpController(int style = wxHF_DEFAULT_STYLE, wxWindow* parentWindow = NULL);
virtual ~wxHtmlHelpController();
+ void SetShouldPreventAppExit(bool enable);
+
void SetTitleFormat(const wxString& format);
void SetTempDir(const wxString& path) { m_helpData.SetTempDir(path); }
bool AddBook(const wxString& book_url, bool show_wait_msg = false);
wxHtmlHelpFrame* m_helpFrame;
wxHtmlHelpDialog* m_helpDialog;
+ bool m_shouldPreventAppExit;
+
wxDECLARE_NO_COPY_CLASS(wxHtmlHelpController);
};
// Override to add custom buttons to the toolbar
virtual void AddToolbarButtons(wxToolBar* WXUNUSED(toolBar), int WXUNUSED(style)) {}
+ void SetShouldPreventAppExit(bool enable);
+
// we don't want to prevent the app from closing just because a help window
// remains opened
- virtual bool ShouldPreventAppExit() const { return false; }
+ virtual bool ShouldPreventAppExit() const { return m_shouldPreventAppExit; }
protected:
void Init(wxHtmlHelpData* data = NULL);
wxString m_TitleFormat; // title of the help frame
wxHtmlHelpWindow *m_HtmlHelpWin;
wxHtmlHelpController* m_helpController;
+ bool m_shouldPreventAppExit;
private:
virtual void ReadCustomization(wxConfigBase* cfg,
const wxString& path = wxEmptyString);
+ /**
+ Sets whether the help frame should prevent application from exiting
+ if it's the only remaining top level window.
+
+ @enable
+ If @true, the application will not quit unless the help frame is
+ closed. Default is @false, i.e. the application does exit if only
+ the help window remains opened.
+
+ @see wxApp::SetExitOnFrameDelete()
+
+ @since 2.9.2
+ */
+ void SetShouldPreventAppExit(bool enable);
+
/**
Sets the path for storing temporary files - cached binary versions of index and
contents files.
delete wxLog::SetActiveTarget(new wxLogGui);
#endif
+ help->SetShouldPreventAppExit(true);
+
help -> DisplayContents();
return true;
#endif // wxUSE_CONFIG
m_titleFormat = _("Help: %s");
m_FrameStyle = style;
+ m_shouldPreventAppExit = false;
}
wxHtmlHelpController::~wxHtmlHelpController()
m_helpFrame = NULL;
}
+void wxHtmlHelpController::SetShouldPreventAppExit(bool enable)
+{
+ m_shouldPreventAppExit = enable;
+ if ( m_helpFrame )
+ m_helpFrame->SetShouldPreventAppExit(enable);
+}
+
void wxHtmlHelpController::SetTitleFormat(const wxString& title)
{
m_titleFormat = title;
#endif // wxUSE_CONFIG
);
frame->SetTitleFormat(m_titleFormat);
+ frame->SetShouldPreventAppExit(m_shouldPreventAppExit);
m_helpFrame = frame;
return frame;
}
m_Data = data;
m_HtmlHelpWin = NULL;
m_helpController = NULL;
+ m_shouldPreventAppExit = false;
}
void wxHtmlHelpFrame::SetController(wxHtmlHelpController* controller)
}
#endif // wxUSE_CONFIG
+void wxHtmlHelpFrame::SetShouldPreventAppExit(bool enable)
+{
+ m_shouldPreventAppExit = enable;
+}
+
#ifdef __WXMAC__
void wxHtmlHelpFrame::OnClose(wxCommandEvent& WXUNUSED(event))
{