]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/preferencesg.cpp
Test handling of events from the toolbar in an MDI parent frame.
[wxWidgets.git] / src / generic / preferencesg.cpp
index 1481c633025b8b0f6fe3aa95b2dcb9f2fd404866..65eeaa4b9d73f87b9a40ca90037f192638709629 100644 (file)
 
 #ifndef wxHAS_PREF_EDITOR_NATIVE
 
+#include "wx/app.h"
 #include "wx/dialog.h"
 #include "wx/notebook.h"
 #include "wx/sizer.h"
 #include "wx/sharedptr.h"
 #include "wx/scopedptr.h"
+#include "wx/scopeguard.h"
 #include "wx/vector.h"
 
 namespace
@@ -100,7 +102,12 @@ protected:
     wxGenericPrefsDialog *CreateDialog(wxWindow *parent)
     {
         if ( m_title.empty() )
-            m_title = _("Preferences");
+        {
+            // Use the default title, which should include the application name
+            // under both MSW and GTK (and OSX uses its own native
+            // implementation anyhow).
+            m_title.Printf(_("%s Preferences"), wxTheApp->GetAppDisplayName());
+        }
 
         wxGenericPrefsDialog *dlg = new wxGenericPrefsDialog(parent, m_title);
 
@@ -118,6 +125,8 @@ protected:
             dlg->AddPage(i->get());
         }
 
+        dlg->Fit();
+
         return dlg;
     }
 
@@ -187,13 +196,18 @@ class wxModalPreferencesEditorImpl : public wxGenericPreferencesEditorImplBase
 public:
     wxModalPreferencesEditorImpl()
     {
+        m_dlg = NULL;
         m_currentPage = -1;
     }
 
     virtual void Show(wxWindow* parent)
     {
         wxScopedPtr<wxGenericPrefsDialog> dlg(CreateDialog(parent));
-        dlg->Fit();
+
+        // Store it for Dismiss() but ensure that the pointer is reset to NULL
+        // when the dialog is destroyed on leaving this function.
+        m_dlg = dlg.get();
+        wxON_BLOCK_EXIT_NULL(m_dlg);
 
         // Restore the previously selected page, if any.
         if ( m_currentPage != -1 )
@@ -206,11 +220,18 @@ public:
 
     virtual void Dismiss()
     {
-        // nothing to do
+        if ( m_dlg )
+        {
+            m_dlg->EndModal(wxID_CANCEL);
+            m_dlg = NULL;
+        }
     }
 
 private:
+    wxGenericPrefsDialog* m_dlg;
     int m_currentPage;
+
+    wxDECLARE_NO_COPY_CLASS(wxModalPreferencesEditorImpl);
 };
 
 inline