]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied patch #876800: "Alphabetical order of tabs in widgets sample".
authorDimitri Schoolwerth <dimitri.schoolwerth@gmail.com>
Mon, 19 Jan 2004 13:27:24 +0000 (13:27 +0000)
committerDimitri Schoolwerth <dimitri.schoolwerth@gmail.com>
Mon, 19 Jan 2004 13:27:24 +0000 (13:27 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25249 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/widgets/widgets.cpp
samples/widgets/widgets.h

index 40d24365aa01b99a4728640f2ef501d821558d67..89836f02ec4eda944eddf4541db4cef2c8698346 100644 (file)
@@ -354,8 +354,54 @@ WidgetsPageInfo::WidgetsPageInfo(Constructor ctor, const wxChar *label)
 {
     m_ctor = ctor;
 
-    m_next = WidgetsPage::ms_widgetPages;
-    WidgetsPage::ms_widgetPages = this;
+    m_next = NULL;
+
+    // dummy sorting: add and immediately sort on list according to label
+
+    if(WidgetsPage::ms_widgetPages)
+    {
+        WidgetsPageInfo *node_prev = WidgetsPage::ms_widgetPages;
+        if(wxStrcmp(label,node_prev->GetLabel().c_str())<0)
+        {
+            // add as first
+            m_next = node_prev;
+            WidgetsPage::ms_widgetPages = this;
+        }
+        else
+        {
+            WidgetsPageInfo *node_next;
+            do
+            {
+                node_next = node_prev->GetNext();
+                if(node_next)
+                {
+                    // add if between two
+                    if(wxStrcmp(label,node_next->GetLabel().c_str())<0)
+                    {
+                        node_prev->SetNext(this);
+                        m_next = node_next;
+                        // force to break loop
+                        node_next = NULL;
+                    }
+                }
+                else
+                {
+                    // add as last
+                    node_prev->SetNext(this);
+                    m_next = node_next;
+                }
+                node_prev = node_next;
+            }while(node_next);
+        }
+    }
+    else
+    {
+        // add when first
+
+        WidgetsPage::ms_widgetPages = this;
+
+    }
+
 }
 
 // ----------------------------------------------------------------------------
index d05402ecd26076f1b5a249a3da43c87612d84926..679b8b369a9f8144ba2f6b467b28f7153d8630ca 100644 (file)
@@ -82,6 +82,8 @@ public:
     Constructor GetCtor() const { return m_ctor; }
     WidgetsPageInfo *GetNext() const { return m_next; }
 
+    void SetNext(WidgetsPageInfo *next) { m_next = next; }
+
 private:
     // the label of the page
     wxString m_label;