]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/wizard.cpp
Make wxBase compiled for wxMotif compatible with wxbase compiled
[wxWidgets.git] / src / generic / wizard.cpp
index 9beedbfa47197e364f7f654240c65939ad400339..84f1f90ed58931766eb9dcf5622332e3314f44be 100644 (file)
@@ -391,6 +391,15 @@ void wxWizard::AddButtonRow(wxBoxSizer *mainColumn)
     // was created before the 'next' button.
 
     wxBoxSizer *buttonRow = new wxBoxSizer(wxHORIZONTAL);
+#ifdef __WXMAC__
+    if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON)
+        mainColumn->Add(
+            buttonRow,
+            0, // Vertically unstretchable
+            wxGROW|wxALIGN_CENTRE
+            );
+    else
+#endif
     mainColumn->Add(
         buttonRow,
         0, // Vertically unstretchable
@@ -399,20 +408,33 @@ void wxWizard::AddButtonRow(wxBoxSizer *mainColumn)
 
     // Desired TAB order is 'next', 'cancel', 'help', 'back'. This makes the 'back' button the last control on the page.
     // Create the buttons in the right order...
+    wxButton *btnHelp=0;
+#ifdef __WXMAC__
+    if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON)
+        btnHelp=new wxButton(this, wxID_HELP, _("&Help"));
+#endif
+
     m_btnNext = new wxButton(this, wxID_FORWARD, _("&Next >"));
     wxButton *btnCancel=new wxButton(this, wxID_CANCEL, _("&Cancel"));
-    wxButton *btnHelp=0;
+#ifndef __WXMAC__
     if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON)
         btnHelp=new wxButton(this, wxID_HELP, _("&Help"));
+#endif
     m_btnPrev = new wxButton(this, wxID_BACKWARD, _("< &Back"));
 
     if (btnHelp)
+    {
         buttonRow->Add(
             btnHelp,
             0, // Horizontally unstretchable
             wxALL, // Border all around, top aligned
             5 // Border width
-        );
+            );
+#ifdef __WXMAC__
+        // Put stretchable space between help button and others
+        buttonRow->Add(0, 0, 1, wxALIGN_CENTRE, 0);
+#endif
+    }
 
     AddBackNextPair(buttonRow);
 
@@ -458,6 +480,9 @@ void wxWizard::SetPageSize(const wxSize& size)
 
 void wxWizard::FinishLayout()
 {
+    // Set to enable wxWizardSizer::GetMaxChildSize
+    m_started = true;
+
     m_sizerBmpAndPage->Add(
         m_sizerPage,
         1, // Horizontal stretching
@@ -533,7 +558,15 @@ bool wxWizard::ShowPage(wxWizardPage *page, bool goingForward)
     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)
@@ -603,9 +636,6 @@ bool wxWizard::RunWizard(wxWizardPage *firstPage)
 {
     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();
@@ -645,7 +675,11 @@ wxSize wxWizard::GetManualPageSize() const
 {
     // default width and height of the page
     static const int DEFAULT_PAGE_WIDTH = 270;
-    static const int DEFAULT_PAGE_HEIGHT = 290;
+    //static const int DEFAULT_PAGE_HEIGHT = 290;
+    // For compatibility with 2.4: there's too much
+    // space under the bitmap, probably due to differences in
+    // the sizer implementation. This makes it reasonable again.
+    static const int DEFAULT_PAGE_HEIGHT = 270;
 
     wxSize totalPageSize(DEFAULT_PAGE_WIDTH,DEFAULT_PAGE_HEIGHT);
 
@@ -669,7 +703,15 @@ void wxWizard::OnCancel(wxCommandEvent& WXUNUSED(eventUnused))
     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
 }
@@ -729,14 +771,25 @@ void wxWizard::OnWizEvent(wxWizardEvent& event)
     {
         // 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();
     }
 }