]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grid.cpp
WinCE compilation fix: don't use FNERR_INVALIDFILENAME
[wxWidgets.git] / src / generic / grid.cpp
index f3e87515e50743221c45b5ce1de81b7b0805dce2..de06f058ed5fe38e01b4ddfe9e6dfaba5fc3c761 100644 (file)
@@ -5574,6 +5574,14 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
 
                     if ( m_moveToCol < 0 )
                         markerX = GetColRight( GetColAt( m_numCols - 1 ) );
+                    else if ( x >= (GetColLeft( m_moveToCol ) + (GetColWidth(m_moveToCol) / 2)) )
+                    {
+                        m_moveToCol = GetColAt( GetColPos( m_moveToCol ) + 1 );
+                        if ( m_moveToCol < 0 )
+                            markerX = GetColRight( GetColAt( m_numCols - 1 ) );
+                        else
+                            markerX = GetColLeft( m_moveToCol );
+                    }
                     else
                         markerX = GetColLeft( m_moveToCol );
 
@@ -5599,17 +5607,17 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
                                 DrawColLabel( dc, XToCol( m_dragLastPos ) );
                         }
 
+                        const wxColour *color;
                         //Moving to the same place? Don't draw a marker
                         if ( (m_moveToCol == m_dragRowOrCol)
                           || (GetColPos( m_moveToCol ) == GetColPos( m_dragRowOrCol ) + 1)
                           || (m_moveToCol < 0 && m_dragRowOrCol == GetColAt( m_numCols - 1 )))
-                        {
-                            m_dragLastPos = -1;
-                            return;
-                        }
+                            color = wxLIGHT_GREY;
+                        else
+                            color = wxBLUE;
 
                         //Draw the marker
-                        wxPen pen( *wxBLUE, 2 );
+                        wxPen pen( *color, 2 );
                         dc.SetPen(pen);
 
                         dc.DrawLine( markerX, 0, markerX, ch );
@@ -6135,16 +6143,9 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
                 }
                 else
                 {
-                    m_waitForSlowClick = m_currentCellCoords == coords && coords != wxGridNoCellCoords;
+                    m_waitForSlowClick = m_currentCellCoords == coords &&
+                                                coords != wxGridNoCellCoords;
                     SetCurrentCell( coords );
-                    if ( m_selection )
-                    {
-                        if ( m_selection->GetSelectionMode() !=
-                                wxGrid::wxGridSelectCells )
-                        {
-                            HighlightBlock( coords, coords );
-                        }
-                    }
                 }
             }
         }
@@ -7109,25 +7110,34 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
                 break;
 
             case WXK_SPACE:
-                if ( event.ControlDown() )
+                // Ctrl-Space selects the current column, Shift-Space -- the
+                // current row and Ctrl-Shift-Space -- everything
+                switch ( m_selection ? event.GetModifiers() : wxMOD_NONE )
                 {
-                    if ( m_selection )
-                    {
-                        m_selection->ToggleCellSelection(
-                            m_currentCellCoords.GetRow(),
-                            m_currentCellCoords.GetCol(),
-                            event.ControlDown(),
-                            event.ShiftDown(),
-                            event.AltDown(),
-                            event.MetaDown() );
-                    }
-                    break;
-                }
+                    case wxMOD_CONTROL:
+                        m_selection->SelectCol(m_currentCellCoords.GetCol());
+                        break;
 
-                if ( !IsEditable() )
-                    MoveCursorRight( false );
-                else
-                    event.Skip();
+                    case wxMOD_SHIFT:
+                        m_selection->SelectRow(m_currentCellCoords.GetRow());
+                        break;
+
+                    case wxMOD_CONTROL | wxMOD_SHIFT:
+                        m_selection->SelectBlock(0, 0,
+                                                 m_numRows - 1, m_numCols - 1);
+                        break;
+
+                    case wxMOD_NONE:
+                        if ( !IsEditable() )
+                        {
+                            MoveCursorRight(false);
+                            break;
+                        }
+                        //else: fall through
+
+                    default:
+                        event.Skip();
+                }
                 break;
 
             default:
@@ -8508,11 +8518,18 @@ void wxGrid::HideCellEditControl()
 
         wxGridCellAttr *attr = GetCellAttr(row, col);
         wxGridCellEditor *editor = attr->GetEditor(this, row, col);
+        const bool editorHadFocus = editor->GetControl()->HasFocus();
         editor->Show( false );
         editor->DecRef();
         attr->DecRef();
 
-        m_gridWin->SetFocus();
+        // return the focus to the grid itself if the editor had it
+        //
+        // note that we must not do this unconditionally to avoid stealing
+        // focus from the window which just received it if we are hiding the
+        // editor precisely because we lost focus
+        if ( editorHadFocus )
+            m_gridWin->SetFocus();
 
         // refresh whole row to the right
         wxRect rect( CellToRect(row, col) );