]> git.saurik.com Git - wxWidgets.git/commitdiff
Add wxHtmlHelpController::SetShouldPreventAppExit().
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 18 Mar 2011 09:16:14 +0000 (09:16 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 18 Mar 2011 09:16:14 +0000 (09:16 +0000)
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

include/wx/html/helpctrl.h
include/wx/html/helpfrm.h
interface/wx/html/helpctrl.h
samples/html/helpview/helpview.cpp
src/html/helpctrl.cpp
src/html/helpfrm.cpp

index 13c346ecb092a9d7afcaca5f65f8f804b5821244..c266ae6fc154b557e9a5584d06dd1f54015f5d69 100644 (file)
@@ -48,6 +48,8 @@ public:
     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);
@@ -129,6 +131,8 @@ protected:
     wxHtmlHelpFrame*    m_helpFrame;
     wxHtmlHelpDialog*   m_helpDialog;
 
+    bool                m_shouldPreventAppExit;
+
     wxDECLARE_NO_COPY_CLASS(wxHtmlHelpController);
 };
 
index a678ef60a8ca9f1b848214fa72224d25c52954b4..85056a86a50afbe5d07d7ca9c6b42b87d1c9126e 100644 (file)
@@ -115,9 +115,11 @@ public:
     // 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);
@@ -143,6 +145,7 @@ protected:
     wxString m_TitleFormat;  // title of the help frame
     wxHtmlHelpWindow *m_HtmlHelpWin;
     wxHtmlHelpController* m_helpController;
+    bool m_shouldPreventAppExit;
 
 private:
 
index 54b5b1acafe3237d6bc40f540d1caceac2db8dcf..aed23de6d38272c0010dc092a7988f9696650b9c 100644 (file)
@@ -171,6 +171,21 @@ public:
     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.
index a0b28929ed7f3ed1743d6b7de55c9ab728397588..f0fba2d05685adc9815c908ef05cb83383f21fc9 100644 (file)
@@ -86,6 +86,8 @@ bool MyApp::OnInit()
     delete wxLog::SetActiveTarget(new wxLogGui);
 #endif
 
+    help->SetShouldPreventAppExit(true);
+
     help -> DisplayContents();
 
     return true;
index d093b99b731a83eca918c0f59848032f41b36238..faad6fb6e0c6b9b35ae6b454fc91d2d75fba3798 100644 (file)
@@ -52,6 +52,7 @@ wxHtmlHelpController::wxHtmlHelpController(int style, wxWindow* parentWindow):
 #endif // wxUSE_CONFIG
     m_titleFormat = _("Help: %s");
     m_FrameStyle = style;
+    m_shouldPreventAppExit = false;
 }
 
 wxHtmlHelpController::~wxHtmlHelpController()
@@ -105,6 +106,13 @@ void wxHtmlHelpController::OnCloseFrame(wxCloseEvent& evt)
     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;
@@ -163,6 +171,7 @@ wxHtmlHelpFrame* wxHtmlHelpController::CreateHelpFrame(wxHtmlHelpData *data)
 #endif // wxUSE_CONFIG
         );
     frame->SetTitleFormat(m_titleFormat);
+    frame->SetShouldPreventAppExit(m_shouldPreventAppExit);
     m_helpFrame = frame;
     return frame;
 }
index 9020ad8b55bcb8d4f5b2c12c992014003533ed4b..c726a936eb8c4b9514f7346582405e9be3dcb278 100644 (file)
@@ -89,6 +89,7 @@ void wxHtmlHelpFrame::Init(wxHtmlHelpData* data)
     m_Data = data;
     m_HtmlHelpWin = NULL;
     m_helpController = NULL;
+    m_shouldPreventAppExit = false;
 }
 
 void wxHtmlHelpFrame::SetController(wxHtmlHelpController* controller)
@@ -246,6 +247,11 @@ void wxHtmlHelpFrame::UseConfig(wxConfigBase *config, const wxString& rootPath)
 }
 #endif // wxUSE_CONFIG
 
+void wxHtmlHelpFrame::SetShouldPreventAppExit(bool enable)
+{
+    m_shouldPreventAppExit = enable;
+}
+
 #ifdef __WXMAC__
 void wxHtmlHelpFrame::OnClose(wxCommandEvent& WXUNUSED(event))
 {