]> git.saurik.com Git - wxWidgets.git/commitdiff
Made code that uses wxArrayPGProperty more STL compliant (still can't use wxVector...
authorJaakko Salli <jaakko.salli@dnainternet.net>
Tue, 18 Aug 2009 14:28:08 +0000 (14:28 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Tue, 18 Aug 2009 14:28:08 +0000 (14:28 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61695 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/propgrid/propgridpagestate.h
src/propgrid/propgrid.cpp
src/propgrid/propgridpagestate.cpp

index 9aa0c11335aa659aafc08c9f652a223d3a819999..1f5e00078e3afb2a367e947fabdfff9ea4305c81 100644 (file)
@@ -517,6 +517,8 @@ public:
         return DoSelectProperty(NULL);
     }
 
+    void DoRemoveFromSelection( wxPGProperty* prop );
+
     wxPropertyCategory* GetPropertyCategory( const wxPGProperty* p ) const;
 
     wxPGProperty* GetPropertyByLabel( const wxString& name,
index 5f3801518a72b120dc4c449818a1cd06015c86a4..bedca1688b58a6ef376c06d3998c9f75170b0bc0 100644 (file)
@@ -784,7 +784,7 @@ bool wxPropertyGrid::DoRemoveFromSelection( wxPGProperty* prop, int selFlags )
     }
     else
     {
-        selection.Remove(prop);
+        m_pState->DoRemoveFromSelection(prop);
         RefreshProperty(prop);
         res = true;
     }
index 966a9210023aca65b7ca91c5a6f0ecf5bd3b9912..fa4d8cf261cc5d62261df77f2c1a0ac6acb1c726 100644 (file)
@@ -605,23 +605,6 @@ bool wxPropertyGridPageState::EnableCategories( bool enable )
 
 // -----------------------------------------------------------------------
 
-#if wxUSE_STL
-#include <algorithm>
-
-static bool wxPG_SortFunc_ByFunction(wxPGProperty *p1, wxPGProperty *p2)
-{
-    wxPropertyGrid* pg = p1->GetGrid();
-    wxPGSortCallback sortFunction = pg->GetSortFunction();
-    return sortFunction(pg, p1, p2) < 0;
-}
-
-static bool wxPG_SortFunc_ByLabel(wxPGProperty *p1, wxPGProperty *p2)
-{
-    return p1->GetLabel().CmpNoCase( p2->GetLabel() ) < 0;
-}
-
-#else
-
 static int wxPG_SortFunc_ByFunction(wxPGProperty **pp1, wxPGProperty **pp2)
 {
     wxPGProperty *p1 = *pp1;
@@ -638,6 +621,24 @@ static int wxPG_SortFunc_ByLabel(wxPGProperty **pp1, wxPGProperty **pp2)
     return p1->GetLabel().CmpNoCase( p2->GetLabel() );
 }
 
+#if 0
+//
+// For wxVector w/ wxUSE_STL=1, you would use code like this instead:
+//
+
+#include <algorithm>
+
+static bool wxPG_SortFunc_ByFunction(wxPGProperty *p1, wxPGProperty *p2)
+{
+    wxPropertyGrid* pg = p1->GetGrid();
+    wxPGSortCallback sortFunction = pg->GetSortFunction();
+    return sortFunction(pg, p1, p2) < 0;
+}
+
+static bool wxPG_SortFunc_ByLabel(wxPGProperty *p1, wxPGProperty *p2)
+{
+    return p1->GetLabel().CmpNoCase( p2->GetLabel() ) < 0;
+}
 #endif
 
 void wxPropertyGridPageState::DoSortChildren( wxPGProperty* p,
@@ -658,18 +659,21 @@ void wxPropertyGridPageState::DoSortChildren( wxPGProperty* p,
          && !p->IsCategory() && !p->IsRoot() )
         return;
 
-#if wxUSE_STL
+    if ( GetGrid()->GetSortFunction() )
+        p->m_children.Sort( wxPG_SortFunc_ByFunction );
+    else
+        p->m_children.Sort( wxPG_SortFunc_ByLabel );
+
+#if 0
+    //
+    // For wxVector w/ wxUSE_STL=1, you would use code like this instead:
+    //
     if ( GetGrid()->GetSortFunction() )
         std::sort(p->m_children.begin(), p->m_children.end(),
                   wxPG_SortFunc_ByFunction);
     else
         std::sort(p->m_children.begin(), p->m_children.end(),
                   wxPG_SortFunc_ByLabel);
-#else
-    if ( GetGrid()->GetSortFunction() )
-        p->m_children.Sort( wxPG_SortFunc_ByFunction );
-    else
-        p->m_children.Sort( wxPG_SortFunc_ByLabel );
 #endif
 
     // Fix indices
@@ -1208,6 +1212,20 @@ bool wxPropertyGridPageState::DoIsPropertySelected( wxPGProperty* prop ) const
 
 // -----------------------------------------------------------------------
 
+void wxPropertyGridPageState::DoRemoveFromSelection( wxPGProperty* prop )
+{
+    for ( unsigned int i=0; i<m_selection.size(); i++ )
+    {
+        if ( m_selection[i] == prop )
+        {
+            m_selection.erase( m_selection.begin() + i );
+            return;
+        }
+    }
+}
+
+// -----------------------------------------------------------------------
+
 bool wxPropertyGridPageState::DoCollapse( wxPGProperty* p )
 {
     wxCHECK_MSG( p, false, wxT("invalid property id") );
@@ -1740,7 +1758,7 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
         }
         else
         {
-            m_selection.Remove(item);
+            DoRemoveFromSelection(item);
         }
     }