]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/docview.cpp
All char, char *, and char arrays changed to use wxChar or wxString. 99% backward...
[wxWidgets.git] / src / common / docview.cpp
index 02fdca8fe46e8164b25e0fd330ad1bd7c6855ae3..b745d1fbb1635b499e4f18488653c4bd86e79990 100644 (file)
@@ -1441,15 +1441,34 @@ wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates,
     wxDocTemplate **data = new wxDocTemplate *[noTemplates];
     int i;
     int n = 0;
-    for (i = 0; i < noTemplates; i++)
-    {
-        if (templates[i]->IsVisible())
-        {
-            strings.Add(templates[i]->m_description);
-            data[n] = templates[i];
-            n ++;
-        }
-    }
+       for (i = 0; i < noTemplates; i++)
+       {
+               if (templates[i]->IsVisible())
+               {
+                       strings.Add(templates[i]->m_description);
+                       if (!sort)
+                       {
+                               data[n] = templates[i];
+                               n ++;
+                       }
+               }
+       }  // for
+
+       if (sort)
+       {
+               // Yes, this will be slow, but template lists
+               // are typically short.
+               int j;
+               n = strings.Count();
+               for (i = 0; i < n; i++)
+               {
+                       for (j = 0; j < noTemplates; j++)
+                       {
+                               if (strings[i] == templates[j]->m_description)
+                                       data[i] = templates[j];
+                       }
+               }
+       }
 
     wxDocTemplate *theTemplate;
 
@@ -1495,11 +1514,30 @@ wxDocTemplate *wxDocManager::SelectViewType(wxDocTemplate **templates,
         if ( templ->IsVisible() && !templ->GetViewName().empty() )
         {
             strings.Add(templ->m_viewTypeName);
-            data[n] = templ;
-            n ++;
+                       if (!sort)
+                       {
+                               data[n] = templ;
+                               n ++;
+                       }
         }
     }
 
+       if (sort)
+       {
+               // Yes, this will be slow, but template lists
+               // are typically short.
+               int j;
+               n = strings.Count();
+               for (i = 0; i < n; i++)
+               {
+                       for (j = 0; j < noTemplates; j++)
+                       {
+                               if (strings[i] == templates[j]->m_viewTypeName)
+                                       data[i] = templates[j];
+                       }
+               }
+       }
+
     wxDocTemplate *theTemplate;
 
     // the same logic as above