]> git.saurik.com Git - wxWidgets.git/commitdiff
Added chainable wxWizardPageSimple::Chain() overload.
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 10 Apr 2013 12:12:57 +0000 (12:12 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 10 Apr 2013 12:12:57 +0000 (12:12 +0000)
Add the simplest and most fool proof of chaining the pages in static wizards:
just chain several calls to the new, non-static, wxWizardPageSimple::Chain()
overload.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73806 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/wizard.h
interface/wx/wizard.h
samples/wizard/wizard.cpp

index 0e17ef80d477145b31891e10f4c1bfc85f2b33c8..4fb411a567ea581b0c88bdef530261ff30a57b76 100644 (file)
@@ -628,6 +628,7 @@ All (GUI):
 - Added wxDocument::Activate() (troelsk).
 - Added wxDocManager::FindDocumentByPath() (troelsk).
 - Added wxEVT_GRID_COL_AUTO_SIZE event (Igor Korot).
+- Added chainable wxWizardPageSimple::Chain() overload.
 
 wxGTK:
 
index 2d38be5b879baa935f1a2d1c8ed863947957155b..59fe14f870e53559c5c1e91ac135043cf9122174 100644 (file)
@@ -147,7 +147,15 @@ public:
     void SetPrev(wxWizardPage *prev) { m_prev = prev; }
     void SetNext(wxWizardPage *next) { m_next = next; }
 
-    // a convenience function to make the pages follow each other
+    // Convenience functions to make the pages follow each other without having
+    // to call their SetPrev() or SetNext() explicitly.
+    wxWizardPageSimple& Chain(wxWizardPageSimple* next)
+    {
+        SetNext(next);
+        next->SetPrev(this);
+        return *next;
+    }
+
     static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second)
     {
         wxCHECK_RET( first && second,
index ca6287f53ab31536ea5f2ed997c63493e08692f5..986d5b1270e11a55c66d750c392a9c8dfa4206aa 100644 (file)
@@ -226,6 +226,28 @@ public:
                 wxWizardPage *next = NULL,
                 const wxBitmap& bitmap = wxNullBitmap);
 
+    /**
+        A helper chaining this page with the next one.
+
+        Notice that this method returns a reference to the next page, so the
+        calls to it can, in turn, be chained:
+
+        @code
+        wxWizardPageSimple* firstPage = new FirstPage;
+        (*firstPage).Chain(new SecondPage)
+                    .Chain(new ThirdPage)
+                    .Chain(new LastPage);
+        @endcode
+
+        This makes this method the simplest way to define the order of changes
+        in fully static wizards, i.e. in those where the order doesn't depend
+        on the choices made by the user in the wizard pages during run-time.
+
+        @param next A non-@NULL pointer to the next page.
+        @return Reference to @a next on which Chain() can be called again.
+
+        @since 2.9.5
+     */
     /**
         A convenience function to make the pages follow each other.
         Example:
index fcbcdb6b8ff8af36de9624b4f3f88f99cae5e271..215f686f8532d57735f2ce7be5d49d3fc7cfb83d 100644 (file)
@@ -414,8 +414,10 @@ MyWizard::MyWizard(wxFrame *frame, bool useSizer)
     wxValidationPage *page4 = new wxValidationPage(this);
 
     // set the page order using a convenience function - could also use
-    // SetNext/Prev directly as below
-    wxWizardPageSimple::Chain(page3, page4);
+    // SetNext/Prev directly as below, but Chain() is shorter, avoids the risk
+    // of an error and can itself be chained, e.g. you could write
+    // page3.Chain(page4).Chain(page5) and so on.
+    page3->Chain(page4);
 
     // this page is not a wxWizardPageSimple, so we use SetNext/Prev to insert
     // it into the chain of pages