]> git.saurik.com Git - wxWidgets.git/commitdiff
Make wxPG_EX_MULTIPLE_SELECTION behave more like a Windows list box (regarding Ctrl...
authorJaakko Salli <jaakko.salli@dnainternet.net>
Mon, 14 Dec 2009 16:13:21 +0000 (16:13 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Mon, 14 Dec 2009 16:13:21 +0000 (16:13 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62885 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/propgrid/propgrid.cpp

index 1120d4ce516aa171f5962abd45dc5df7472fef8b..c11f78d36fa8f4c676bdfdcf620cfccf8f433122 100644 (file)
@@ -779,9 +779,12 @@ bool wxPropertyGrid::AddToSelectionFromInputEvent( wxPGProperty* prop,
                                                    wxMouseEvent* mouseEvent,
                                                    int selFlags )
 {
+    const wxArrayPGProperty& selection = GetSelectedProperties();
     bool alreadySelected = m_pState->DoIsPropertySelected(prop);
     bool res = true;
-    bool addToExistingSelection;
+
+    // Set to 2 if also add all items in between
+    int addToExistingSelection = 0;
 
     if ( GetExtraStyle() & wxPG_EX_MULTIPLE_SELECTION )
     {
@@ -799,21 +802,24 @@ bool wxPropertyGrid::AddToSelectionFromInputEvent( wxPGProperty* prop,
             }
             else
             {
-                addToExistingSelection = mouseEvent->ShiftDown();
+                if ( mouseEvent->ControlDown() )
+                {
+                    addToExistingSelection = 1;
+                }
+                else if ( mouseEvent->ShiftDown() )
+                {
+                    if ( selection.size() > 0 && !prop->IsCategory() )
+                        addToExistingSelection = 2;
+                    else
+                        addToExistingSelection = 1;
+                }
             }
         }
-        else
-        {
-            addToExistingSelection = false;
-        }
-    }
-    else
-    {
-        addToExistingSelection = false;
     }
 
-    if ( addToExistingSelection )
+    if ( addToExistingSelection == 1 )
     {
+        // Add/remove one
         if ( !alreadySelected )
         {
             res = DoAddToSelection(prop, selFlags);
@@ -823,6 +829,59 @@ bool wxPropertyGrid::AddToSelectionFromInputEvent( wxPGProperty* prop,
             res = DoRemoveFromSelection(prop, selFlags);
         }
     }
+    else if ( addToExistingSelection == 2 )
+    {
+        // Add this, and all in between
+
+        // Find top selected property
+        wxPGProperty* topSelProp = selection[0];
+        int topSelPropY = topSelProp->GetY();
+        for ( unsigned int i=1; i<selection.size(); i++ )
+        {
+            wxPGProperty* p = selection[i];
+            int y = p->GetY();
+            if ( y < topSelPropY )
+            {
+                topSelProp = p;
+                topSelPropY = y;
+            }
+        }
+
+        wxPGProperty* startFrom;
+        wxPGProperty* stopAt;
+
+        if ( prop->GetY() <= topSelPropY )
+        {
+            // Property is above selection (or same)
+            startFrom = prop;
+            stopAt = topSelProp;
+        }
+        else
+        {
+            // Property is below selection
+            startFrom = topSelProp;
+            stopAt = prop;
+        }
+
+        // Iterate through properties in-between, and select them
+        wxPropertyGridIterator it;
+
+        for ( it = GetIterator(wxPG_ITERATE_VISIBLE, startFrom);
+              !it.AtEnd();
+              it++ )
+        {
+            wxPGProperty* p = *it;
+
+            if ( !p->IsCategory() &&
+                 !m_pState->DoIsPropertySelected(p) )
+            {
+                DoAddToSelection(p, selFlags);
+            }
+
+            if ( p == stopAt )
+                break;
+        }
+    }
     else
     {
         res = DoSelectAndEdit(prop, colIndex, selFlags);