]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/wizard.cpp
wxOS2 with Open Watcom: correct PCH usage, missing headers, warning fixes, source...
[wxWidgets.git] / src / generic / wizard.cpp
index 118c11e2c6f9b09fdba3075cd57ac42b85d54c59..84f1f90ed58931766eb9dcf5622332e3314f44be 100644 (file)
@@ -480,6 +480,9 @@ void wxWizard::SetPageSize(const wxSize& size)
 
 void wxWizard::FinishLayout()
 {
 
 void wxWizard::FinishLayout()
 {
+    // Set to enable wxWizardSizer::GetMaxChildSize
+    m_started = true;
+
     m_sizerBmpAndPage->Add(
         m_sizerPage,
         1, // Horizontal stretching
     m_sizerBmpAndPage->Add(
         m_sizerPage,
         1, // Horizontal stretching
@@ -555,7 +558,15 @@ bool wxWizard::ShowPage(wxWizardPage *page, bool goingForward)
     if ( !m_page )
     {
         // terminate successfully
     if ( !m_page )
     {
         // terminate successfully
-        EndModal(wxID_OK);
+        if(IsModal())
+        {
+            EndModal(wxID_OK);
+        }
+        else
+        {
+            SetReturnCode(wxID_OK);
+            Hide();
+        }
 
         // and notify the user code (this is especially useful for modeless
         // wizards)
 
         // and notify the user code (this is especially useful for modeless
         // wizards)
@@ -625,9 +636,6 @@ bool wxWizard::RunWizard(wxWizardPage *firstPage)
 {
     wxCHECK_MSG( firstPage, false, wxT("can't run empty wizard") );
 
 {
     wxCHECK_MSG( firstPage, false, wxT("can't run empty wizard") );
 
-    // Set before FinishLayout to enable wxWizardSizer::GetMaxChildSize
-    m_started = true;
-
     // This cannot be done sooner, because user can change layout options
     // up to this moment
     FinishLayout();
     // This cannot be done sooner, because user can change layout options
     // up to this moment
     FinishLayout();
@@ -695,7 +703,15 @@ void wxWizard::OnCancel(wxCommandEvent& WXUNUSED(eventUnused))
     if ( !win->GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
     {
         // no objections - close the dialog
     if ( !win->GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
     {
         // no objections - close the dialog
-        EndModal(wxID_CANCEL);
+        if(IsModal())
+        {
+            EndModal(wxID_CANCEL);
+        }
+        else
+        {
+            SetReturnCode(wxID_CANCEL);
+            Hide();
+        }
     }
     //else: request to Cancel ignored
 }
     }
     //else: request to Cancel ignored
 }
@@ -755,14 +771,25 @@ void wxWizard::OnWizEvent(wxWizardEvent& event)
     {
         // the event will be propagated anyhow
         event.Skip();
     {
         // the event will be propagated anyhow
         event.Skip();
-        return;
     }
     }
+    else
+    {
+        wxWindow *parent = GetParent();
 
 
-    wxWindow *parent = GetParent();
+        if ( !parent || !parent->GetEventHandler()->ProcessEvent(event) )
+        {
+            event.Skip();
+        }
+    }
 
 
-    if ( !parent || !parent->GetEventHandler()->ProcessEvent(event) )
+    if ( !IsModal() &&
+         event.IsAllowed() &&
+         ( event.GetEventType() == wxEVT_WIZARD_FINISHED ||
+           event.GetEventType() == wxEVT_WIZARD_CANCEL
+         )
+       )
     {
     {
-        event.Skip();
+        Destroy();
     }
 }
 
     }
 }