]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grid.cpp
Loads of framework and dll fixes
[wxWidgets.git] / src / generic / grid.cpp
index 1fd565857ee09cb032b1a49cca2a72b77160127f..792b92b12c5734497ec32fbce7abd78e0198efc5 100644 (file)
@@ -4243,13 +4243,22 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
 
             if ( coords != wxGridNoCellCoords )
             {
-                if ( !IsSelection() )
-                {
-                    SelectBlock( coords, coords );
-                }
-                else
-                {
-                    SelectBlock( m_currentCellCoords, coords );
+               if ( event.ControlDown() )
+               {
+                   if ( m_selectingKeyboard == wxGridNoCellCoords)
+                       m_selectingKeyboard = coords;
+                   SelectBlock ( m_selectingKeyboard, coords );
+               }
+               else
+               {
+                   if ( !IsSelection() )
+                   {
+                       SelectBlock( coords, coords );
+                   }
+                   else
+                   {
+                       SelectBlock( m_currentCellCoords, coords );
+                   }
                 }
 
                 if (! IsVisible(coords))
@@ -4363,15 +4372,20 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
                 }
                 else
                 {
-                    m_selection->ToggleCellSelection( coords.GetRow(),
-                                                      coords.GetCol(),
-                                                      event.ControlDown(),
-                                                      event.ShiftDown(),
-                                                      event.AltDown(),
-                                                      event.MetaDown() );
-                    m_selectingTopLeft = wxGridNoCellCoords;
-                    m_selectingBottomRight = wxGridNoCellCoords;
-                    SetCurrentCell( coords );
+                   if ( event.ControlDown() )
+                   {
+                       m_selection->ToggleCellSelection( coords.GetRow(),
+                                                         coords.GetCol(),
+                                                         event.ControlDown(),
+                                                         event.ShiftDown(),
+                                                         event.AltDown(),
+                                                         event.MetaDown() );
+                       m_selectingTopLeft = wxGridNoCellCoords;
+                       m_selectingBottomRight = wxGridNoCellCoords;
+                       m_selectingKeyboard = coords;
+                   }
+                   else
+                       SetCurrentCell( coords );
                     m_waitForSlowClick = TRUE;
                 }
             }
@@ -5015,14 +5029,16 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
         if ( !event.ShiftDown() && 
              m_selectingKeyboard != wxGridNoCellCoords )
         {
-            m_selection->SelectBlock( m_selectingTopLeft.GetRow(),
-                                      m_selectingTopLeft.GetCol(),
-                                      m_selectingBottomRight.GetRow(),
-                                      m_selectingBottomRight.GetCol(),
-                                      event.ControlDown(),
-                                      event.ShiftDown(),
-                                      event.AltDown(),
-                                      event.MetaDown() );
+           if ( m_selectingTopLeft != wxGridNoCellCoords &&
+                m_selectingBottomRight != wxGridNoCellCoords )
+               m_selection->SelectBlock( m_selectingTopLeft.GetRow(),
+                                         m_selectingTopLeft.GetCol(),
+                                         m_selectingBottomRight.GetRow(),
+                                         m_selectingBottomRight.GetCol(),
+                                         event.ControlDown(),
+                                         event.ShiftDown(),
+                                         event.AltDown(),
+                                         event.MetaDown() );
             m_selectingTopLeft = wxGridNoCellCoords;
             m_selectingBottomRight = wxGridNoCellCoords;
             m_selectingKeyboard = wxGridNoCellCoords;
@@ -5128,24 +5144,23 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
                 MovePageDown();
                 break;
 
-#if 1
             case WXK_SPACE:
+               if ( event.ControlDown() )
+               {
+                   m_selection->ToggleCellSelection( m_currentCellCoords.GetRow(),
+                                                     m_currentCellCoords.GetCol(),
+                                                     event.ControlDown(),
+                                                     event.ShiftDown(),
+                                                     event.AltDown(),
+                                                     event.MetaDown() );
+                   break;
+               }
                 if ( !IsEditable() )
                 {
                     MoveCursorRight( FALSE );
                     break;
                 }
                 // Otherwise fall through to default
-#else
-            case WXK_SPACE:
-                m_selection->ToggleCellSelection( m_currentCellCoords.GetRow(),
-                                                  m_currentCellCoords.GetCol(),
-                                                  event.ControlDown(),
-                                                  event.ShiftDown(),
-                                                  event.AltDown(),
-                                                  event.MetaDown() );
-                break;
-#endif
 
             default:
                 // alphanumeric keys or F2 (special key just for this) enable
@@ -6161,18 +6176,23 @@ bool wxGrid::MoveCursorUp( bool expandSelection )
     if ( m_currentCellCoords != wxGridNoCellCoords  &&
          m_currentCellCoords.GetRow() > 0 )
     {
-        MakeCellVisible( m_currentCellCoords.GetRow() - 1,
-                         m_currentCellCoords.GetCol() );
         if ( expandSelection )
         {
             if ( m_selectingKeyboard == wxGridNoCellCoords )
                 m_selectingKeyboard = m_currentCellCoords;
             m_selectingKeyboard.SetRow( m_selectingKeyboard.GetRow() - 1 );
+           MakeCellVisible( m_selectingKeyboard.GetRow(),
+                            m_selectingKeyboard.GetCol() );
             SelectBlock( m_currentCellCoords, m_selectingKeyboard );
         }
         else
+       {
+           ClearSelection();
+           MakeCellVisible( m_currentCellCoords.GetRow() - 1,
+                            m_currentCellCoords.GetCol() );
             SetCurrentCell( m_currentCellCoords.GetRow() - 1,
                             m_currentCellCoords.GetCol() );
+       }
         return TRUE;
     }
 
@@ -6185,18 +6205,23 @@ bool wxGrid::MoveCursorDown( bool expandSelection )
     if ( m_currentCellCoords != wxGridNoCellCoords  &&
          m_currentCellCoords.GetRow() < m_numRows-1 )
     {
-        MakeCellVisible( m_currentCellCoords.GetRow() + 1,
-                         m_currentCellCoords.GetCol() );
         if ( expandSelection )
         {
             if ( m_selectingKeyboard == wxGridNoCellCoords )
                 m_selectingKeyboard = m_currentCellCoords;
             m_selectingKeyboard.SetRow( m_selectingKeyboard.GetRow() + 1 );
+           MakeCellVisible( m_selectingKeyboard.GetRow(),
+                            m_selectingKeyboard.GetCol() );
             SelectBlock( m_currentCellCoords, m_selectingKeyboard );
         }
         else
+       {
+           ClearSelection();
+           MakeCellVisible( m_currentCellCoords.GetRow() + 1,
+                            m_currentCellCoords.GetCol() );
             SetCurrentCell( m_currentCellCoords.GetRow() + 1,
                             m_currentCellCoords.GetCol() );
+       }
         return TRUE;
     }
 
@@ -6209,18 +6234,23 @@ bool wxGrid::MoveCursorLeft( bool expandSelection )
     if ( m_currentCellCoords != wxGridNoCellCoords  &&
          m_currentCellCoords.GetCol() > 0 )
     {
-        MakeCellVisible( m_currentCellCoords.GetRow(),
-                         m_currentCellCoords.GetCol() - 1 );
         if ( expandSelection )
         {
             if ( m_selectingKeyboard == wxGridNoCellCoords )
                 m_selectingKeyboard = m_currentCellCoords;
             m_selectingKeyboard.SetCol( m_selectingKeyboard.GetCol() - 1 );
+           MakeCellVisible( m_selectingKeyboard.GetRow(),
+                            m_selectingKeyboard.GetCol() );
             SelectBlock( m_currentCellCoords, m_selectingKeyboard );
         }
         else
+       {
+           ClearSelection();
+           MakeCellVisible( m_currentCellCoords.GetRow(),
+                            m_currentCellCoords.GetCol() - 1 );
             SetCurrentCell( m_currentCellCoords.GetRow(),
                             m_currentCellCoords.GetCol() - 1 );
+       }
         return TRUE;
     }
 
@@ -6233,19 +6263,23 @@ bool wxGrid::MoveCursorRight( bool expandSelection )
     if ( m_currentCellCoords != wxGridNoCellCoords  &&
          m_currentCellCoords.GetCol() < m_numCols - 1 )
     {
-        MakeCellVisible( m_currentCellCoords.GetRow(),
-                        m_currentCellCoords.GetCol() + 1 );
-
         if ( expandSelection )
         {
             if ( m_selectingKeyboard == wxGridNoCellCoords )
                 m_selectingKeyboard = m_currentCellCoords;
             m_selectingKeyboard.SetCol( m_selectingKeyboard.GetCol() + 1 );
+           MakeCellVisible( m_selectingKeyboard.GetRow(),
+                            m_selectingKeyboard.GetCol() );
             SelectBlock( m_currentCellCoords, m_selectingKeyboard );
         }
         else
-            SetCurrentCell( m_currentCellCoords.GetRow(),
+       {
+           ClearSelection();
+           MakeCellVisible( m_currentCellCoords.GetRow(),
+                            m_currentCellCoords.GetCol() + 1 );
+           SetCurrentCell( m_currentCellCoords.GetRow(),
                             m_currentCellCoords.GetCol() + 1 );
+       }
         return TRUE;
     }
 
@@ -6366,8 +6400,10 @@ bool wxGrid::MoveCursorUpBlock( bool expandSelection )
             SelectBlock( m_currentCellCoords, m_selectingKeyboard );
         }
         else
-            SetCurrentCell( row, col );
-
+       {
+           ClearSelection();
+           SetCurrentCell( row, col );
+       }
         return TRUE;
     }
 
@@ -6427,7 +6463,10 @@ bool wxGrid::MoveCursorDownBlock( bool expandSelection )
             SelectBlock( m_currentCellCoords, m_selectingKeyboard );
         }
         else
-            SetCurrentCell( row, col );
+       {
+           ClearSelection();
+           SetCurrentCell( row, col );
+       }
 
         return TRUE;
     }
@@ -6488,7 +6527,10 @@ bool wxGrid::MoveCursorLeftBlock( bool expandSelection )
             SelectBlock( m_currentCellCoords, m_selectingKeyboard );
         }
         else
-            SetCurrentCell( row, col );
+       {
+           ClearSelection();
+           SetCurrentCell( row, col );
+       }
 
         return TRUE;
     }
@@ -6549,7 +6591,10 @@ bool wxGrid::MoveCursorRightBlock( bool expandSelection )
             SelectBlock( m_currentCellCoords, m_selectingKeyboard );
         }
         else
-            SetCurrentCell( row, col );
+       {
+           ClearSelection();
+           SetCurrentCell( row, col );
+       }
 
         return TRUE;
     }