]> git.saurik.com Git - wxWidgets.git/commitdiff
Added check to allow multiple selection by dragging only if property under mouse...
authorJaakko Salli <jaakko.salli@dnainternet.net>
Sun, 6 Sep 2009 07:51:35 +0000 (07:51 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Sun, 6 Sep 2009 07:51:35 +0000 (07:51 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61838 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

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

index c38413477e23d1480145bbb4281f83935fdcb810..86e1c4a4e08d284e62df0c1617845f3ce5c1cab4 100644 (file)
@@ -669,6 +669,11 @@ public:
 
 protected:
 
+    // Utility to check if two properties are visibly next to each other
+    bool ArePropertiesAdjacent( wxPGProperty* prop1,
+                                wxPGProperty* prop2,
+                                int iterFlags = wxPG_ITERATE_VISIBLE ) const;
+
     int DoGetSplitterPosition( int splitterIndex = 0 ) const;
 
     /** Returns column at x coordinate (in GetGrid()->GetPanel()).
index 09ada8704b99ef552c032a73c10a4dfa6c338552..e3e2d584fe61285a21c071238d29e286b6bab7e9 100644 (file)
@@ -4798,13 +4798,32 @@ bool wxPropertyGrid::HandleMouseMove( int x, unsigned int y, wxMouseEvent &event
         //
         // Multi select by dragging
         //
-        if ( GetExtraStyle() & wxPG_EX_MULTIPLE_SELECTION &&
+        if ( (GetExtraStyle() & wxPG_EX_MULTIPLE_SELECTION) &&
              event.LeftIsDown() &&
              m_propHover &&
              GetSelection() &&
              !state->DoIsPropertySelected(m_propHover) )
         {
-            DoAddToSelection(m_propHover);
+            // Additional requirement is that the hovered property
+            // is adjacent to edges of selection.
+            const wxArrayPGProperty& selection = GetSelectedProperties();
+
+            // Since categories cannot be selected along with 'other'
+            // properties, exclude them from iterator flags.
+            int iterFlags = wxPG_ITERATE_VISIBLE & (~wxPG_PROP_CATEGORY);
+
+            for ( int i=(selection.size()-1); i>=0; i-- )
+            {
+                // TODO: This could be optimized by keeping track of
+                //       which properties are at the edges of selection.
+                wxPGProperty* selProp = selection[i];
+                if ( state->ArePropertiesAdjacent(m_propHover, selProp,
+                                                  iterFlags) )
+                {
+                    DoAddToSelection(m_propHover);
+                    break;
+                }
+            }
         }
     }
     return true;
index d95efe3fb90384caf9215e26a092232a8412d55b..91fe89e6f9708aa6251b1c684557d8c369021cc5 100644 (file)
@@ -1139,6 +1139,29 @@ int wxPropertyGridPageState::HitTestH( int x, int* pSplitterHit, int* pSplitterH
     return col;
 }
 
+bool wxPropertyGridPageState::ArePropertiesAdjacent( wxPGProperty* prop1,
+                                                     wxPGProperty* prop2,
+                                                     int iterFlags ) const
+{
+    const wxPGProperty* ap1 =
+        wxPropertyGridConstIterator::OneStep(this,
+                                             iterFlags,
+                                             prop1,
+                                             1);
+    if ( ap1 && ap1 == prop2 )
+        return true;
+
+    const wxPGProperty* ap2 =
+        wxPropertyGridConstIterator::OneStep(this,
+                                             iterFlags,
+                                             prop1,
+                                             -1);
+    if ( ap2 && ap2 == prop2 )
+        return true;
+
+    return false;
+}
+
 // -----------------------------------------------------------------------
 // wxPropertyGridPageState property value setting and getting
 // -----------------------------------------------------------------------