]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grid.cpp
moved wxDash typedef to gdicmn.h
[wxWidgets.git] / src / generic / grid.cpp
index 60eb6e5a0364eff9dcb6a5492f093a1386adee3b..65a3603c05aef9ecabc2a4567fcb6691c02b061e 100644 (file)
 #include "wx/grid.h"
 #include "wx/generic/gridsel.h"
 
 #include "wx/grid.h"
 #include "wx/generic/gridsel.h"
 
+#if defined(__WXMOTIF__)
+    #define WXUNUSED_MOTIF(identifier)  WXUNUSED(identifier)
+#else
+    #define WXUNUSED_MOTIF(identifier)  identifier
+#endif
+
+#if defined(__WXGTK__)
+    #define WXUNUSED_GTK(identifier)    WXUNUSED(identifier)
+#else
+    #define WXUNUSED_GTK(identifier)    identifier
+#endif
+
+// Required for wxIs... functions
+#include <ctype.h>
+
 // ----------------------------------------------------------------------------
 // array classes
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // array classes
 // ----------------------------------------------------------------------------
@@ -283,6 +298,7 @@ WX_DEFINE_ARRAY(wxGridDataTypeInfo*, wxGridDataTypeInfoArray);
 class WXDLLEXPORT wxGridTypeRegistry
 {
 public:
 class WXDLLEXPORT wxGridTypeRegistry
 {
 public:
+  wxGridTypeRegistry() {}
     ~wxGridTypeRegistry();
 
     void RegisterDataType(const wxString& typeName,
     ~wxGridTypeRegistry();
 
     void RegisterDataType(const wxString& typeName,
@@ -584,7 +600,7 @@ void wxGridCellTextEditor::StartingKey(wxKeyEvent& event)
     if ( !event.AltDown() && !event.MetaDown() && !event.ControlDown() )
     {
         // insert the key in the control
     if ( !event.AltDown() && !event.MetaDown() && !event.ControlDown() )
     {
         // insert the key in the control
-        long keycode = event.KeyCode();
+        int keycode = (int)event.KeyCode();
         if ( isprint(keycode) )
         {
             // FIXME this is not going to work for non letters...
         if ( isprint(keycode) )
         {
             // FIXME this is not going to work for non letters...
@@ -603,11 +619,12 @@ void wxGridCellTextEditor::StartingKey(wxKeyEvent& event)
     event.Skip();
 }
 
     event.Skip();
 }
 
-void wxGridCellTextEditor::HandleReturn(wxKeyEvent& event)
+void wxGridCellTextEditor::HandleReturn( wxKeyEvent&
+                                         WXUNUSED_GTK(WXUNUSED_MOTIF(event)) )
 {
 #if defined(__WXMOTIF__) || defined(__WXGTK__)
     // wxMotif needs a little extra help...
 {
 #if defined(__WXMOTIF__) || defined(__WXGTK__)
     // wxMotif needs a little extra help...
-    int pos = Text()->GetInsertionPoint();
+    size_t pos = (size_t)( Text()->GetInsertionPoint() );
     wxString s( Text()->GetValue() );
     s = s.Left(pos) + "\n" + s.Mid(pos);
     Text()->SetValue(s);
     wxString s( Text()->GetValue() );
     s = s.Left(pos) + "\n" + s.Mid(pos);
     Text()->SetValue(s);
@@ -696,7 +713,7 @@ void wxGridCellNumberEditor::BeginEdit(int row, int col, wxGrid* grid)
 
     if ( HasRange() )
     {
 
     if ( HasRange() )
     {
-        Spin()->SetValue(m_valueOld);
+        Spin()->SetValue((int)m_valueOld);
     }
     else
     {
     }
     else
     {
@@ -735,7 +752,7 @@ void wxGridCellNumberEditor::Reset()
 {
     if ( HasRange() )
     {
 {
     if ( HasRange() )
     {
-        Spin()->SetValue(m_valueOld);
+        Spin()->SetValue((int)m_valueOld);
     }
     else
     {
     }
     else
     {
@@ -747,7 +764,7 @@ void wxGridCellNumberEditor::StartingKey(wxKeyEvent& event)
 {
     if ( !HasRange() )
     {
 {
     if ( !HasRange() )
     {
-        long keycode = event.KeyCode();
+        int keycode = (int) event.KeyCode();
         if ( isdigit(keycode) || keycode == '+' || keycode == '-' )
         {
             wxGridCellTextEditor::StartingKey(event);
         if ( isdigit(keycode) || keycode == '+' || keycode == '-' )
         {
             wxGridCellTextEditor::StartingKey(event);
@@ -851,7 +868,7 @@ void wxGridCellFloatEditor::Reset()
 
 void wxGridCellFloatEditor::StartingKey(wxKeyEvent& event)
 {
 
 void wxGridCellFloatEditor::StartingKey(wxKeyEvent& event)
 {
-    long keycode = event.KeyCode();
+    int keycode = (int)event.KeyCode();
     if ( isdigit(keycode) ||
          keycode == '+' || keycode == '-' || keycode == '.' )
     {
     if ( isdigit(keycode) ||
          keycode == '+' || keycode == '-' || keycode == '.' )
     {
@@ -1170,7 +1187,7 @@ void wxGridCellRenderer::Draw(wxGrid& grid,
                               wxGridCellAttr& attr,
                               wxDC& dc,
                               const wxRect& rect,
                               wxGridCellAttr& attr,
                               wxDC& dc,
                               const wxRect& rect,
-                              int row, int col,
+                              int WXUNUSED(row), int WXUNUSED(col),
                               bool isSelected)
 {
     dc.SetBackgroundMode( wxSOLID );
                               bool isSelected)
 {
     dc.SetBackgroundMode( wxSOLID );
@@ -2246,7 +2263,8 @@ void wxGridTableBase::UpdateAttrCols( size_t pos, int numCols )
     }
 }
 
     }
 }
 
-bool wxGridTableBase::InsertRows( size_t pos, size_t numRows )
+bool wxGridTableBase::InsertRows( size_t WXUNUSED(pos),
+                                  size_t WXUNUSED(numRows) )
 {
     wxFAIL_MSG( wxT("Called grid table class function InsertRows\n"
                     "but your derived table class does not override this function") );
 {
     wxFAIL_MSG( wxT("Called grid table class function InsertRows\n"
                     "but your derived table class does not override this function") );
@@ -2254,7 +2272,7 @@ bool wxGridTableBase::InsertRows( size_t pos, size_t numRows )
     return FALSE;
 }
 
     return FALSE;
 }
 
-bool wxGridTableBase::AppendRows( size_t numRows )
+bool wxGridTableBase::AppendRows( size_t WXUNUSED(numRows) )
 {
     wxFAIL_MSG( wxT("Called grid table class function AppendRows\n"
                     "but your derived table class does not override this function"));
 {
     wxFAIL_MSG( wxT("Called grid table class function AppendRows\n"
                     "but your derived table class does not override this function"));
@@ -2262,7 +2280,8 @@ bool wxGridTableBase::AppendRows( size_t numRows )
     return FALSE;
 }
 
     return FALSE;
 }
 
-bool wxGridTableBase::DeleteRows( size_t pos, size_t numRows )
+bool wxGridTableBase::DeleteRows( size_t WXUNUSED(pos),
+                                  size_t WXUNUSED(numRows) )
 {
     wxFAIL_MSG( wxT("Called grid table class function DeleteRows\n"
                     "but your derived table class does not override this function"));
 {
     wxFAIL_MSG( wxT("Called grid table class function DeleteRows\n"
                     "but your derived table class does not override this function"));
@@ -2270,7 +2289,8 @@ bool wxGridTableBase::DeleteRows( size_t pos, size_t numRows )
     return FALSE;
 }
 
     return FALSE;
 }
 
-bool wxGridTableBase::InsertCols( size_t pos, size_t numCols )
+bool wxGridTableBase::InsertCols( size_t WXUNUSED(pos),
+                                  size_t WXUNUSED(numCols) )
 {
     wxFAIL_MSG( wxT("Called grid table class function InsertCols\n"
                   "but your derived table class does not override this function"));
 {
     wxFAIL_MSG( wxT("Called grid table class function InsertCols\n"
                   "but your derived table class does not override this function"));
@@ -2278,7 +2298,7 @@ bool wxGridTableBase::InsertCols( size_t pos, size_t numCols )
     return FALSE;
 }
 
     return FALSE;
 }
 
-bool wxGridTableBase::AppendCols( size_t numCols )
+bool wxGridTableBase::AppendCols( size_t WXUNUSED(numCols) )
 {
     wxFAIL_MSG(wxT("Called grid table class function AppendCols\n"
                    "but your derived table class does not override this function"));
 {
     wxFAIL_MSG(wxT("Called grid table class function AppendCols\n"
                    "but your derived table class does not override this function"));
@@ -2286,7 +2306,8 @@ bool wxGridTableBase::AppendCols( size_t numCols )
     return FALSE;
 }
 
     return FALSE;
 }
 
-bool wxGridTableBase::DeleteCols( size_t pos, size_t numCols )
+bool wxGridTableBase::DeleteCols( size_t WXUNUSED(pos),
+                                  size_t WXUNUSED(numCols) )
 {
     wxFAIL_MSG( wxT("Called grid table class function DeleteCols\n"
                     "but your derived table class does not override this function"));
 {
     wxFAIL_MSG( wxT("Called grid table class function DeleteCols\n"
                     "but your derived table class does not override this function"));
@@ -2453,12 +2474,12 @@ wxGridStringTable::~wxGridStringTable()
 {
 }
 
 {
 }
 
-long wxGridStringTable::GetNumberRows()
+int wxGridStringTable::GetNumberRows()
 {
     return m_data.GetCount();
 }
 
 {
     return m_data.GetCount();
 }
 
-long wxGridStringTable::GetNumberCols()
+int wxGridStringTable::GetNumberCols()
 {
     if ( m_data.GetCount() > 0 )
         return m_data[0].GetCount();
 {
     if ( m_data.GetCount() > 0 )
         return m_data[0].GetCount();
@@ -2824,7 +2845,7 @@ wxGridRowLabelWindow::wxGridRowLabelWindow( wxGrid *parent,
     m_owner = parent;
 }
 
     m_owner = parent;
 }
 
-void wxGridRowLabelWindow::OnPaint( wxPaintEvent &event )
+void wxGridRowLabelWindow::OnPaint( wxPaintEvent& WXUNUSED(event) )
 {
     wxPaintDC dc(this);
 
 {
     wxPaintDC dc(this);
 
@@ -2877,7 +2898,7 @@ wxGridColLabelWindow::wxGridColLabelWindow( wxGrid *parent,
     m_owner = parent;
 }
 
     m_owner = parent;
 }
 
-void wxGridColLabelWindow::OnPaint( wxPaintEvent &event )
+void wxGridColLabelWindow::OnPaint( wxPaintEvent& WXUNUSED(event) )
 {
     wxPaintDC dc(this);
 
 {
     wxPaintDC dc(this);
 
@@ -3031,7 +3052,7 @@ void wxGridWindow::OnKeyDown( wxKeyEvent& event )
 }
 
 
 }
 
 
-void wxGridWindow::OnEraseBackground(wxEraseEvent& event)
+void wxGridWindow::OnEraseBackground( wxEraseEvent& WXUNUSED(event) )
 {
 }
 
 {
 }
 
@@ -3090,7 +3111,6 @@ wxGrid::~wxGrid()
 void wxGrid::Create()
 {
     m_created = FALSE;    // set to TRUE by CreateGrid
 void wxGrid::Create()
 {
     m_created = FALSE;    // set to TRUE by CreateGrid
-    m_displayed = TRUE; // FALSE;  // set to TRUE by OnPaint
 
     m_table        = (wxGridTableBase *) NULL;
     m_ownTable     = FALSE;
 
     m_table        = (wxGridTableBase *) NULL;
     m_ownTable     = FALSE;
@@ -3165,9 +3185,9 @@ bool wxGrid::CreateGrid( int numRows, int numCols,
         m_table->SetView( this );
         m_ownTable = TRUE;
         Init();
         m_table->SetView( this );
         m_ownTable = TRUE;
         Init();
+        m_selection = new wxGridSelection( this, selmode );
         m_created = TRUE;
     }
         m_created = TRUE;
     }
-    m_selection = new wxGridSelection( this, selmode );
     return m_created;
 }
 
     return m_created;
 }
 
@@ -3181,7 +3201,8 @@ void wxGrid::SetSelectionMode(wxGrid::wxGridSelectionModes selmode)
         m_selection->SetSelectionMode( selmode );
 }
 
         m_selection->SetSelectionMode( selmode );
 }
 
-bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership )
+bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership,
+                       wxGrid::wxGridSelectionModes selmode )
 {
     if ( m_created )
     {
 {
     if ( m_created )
     {
@@ -3190,6 +3211,7 @@ bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership )
         // View at runtime.  Is there anything in the implmentation that would
         // prevent this?
 
         // View at runtime.  Is there anything in the implmentation that would
         // prevent this?
 
+        // At least, you now have to cope with m_selection
         wxFAIL_MSG( wxT("wxGrid::CreateGrid or wxGrid::SetTable called more than once") );
         return FALSE;
     }
         wxFAIL_MSG( wxT("wxGrid::CreateGrid or wxGrid::SetTable called more than once") );
         return FALSE;
     }
@@ -3203,6 +3225,7 @@ bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership )
         if (takeOwnership)
             m_ownTable = TRUE;
         Init();
         if (takeOwnership)
             m_ownTable = TRUE;
         Init();
+        m_selection = new wxGridSelection( this, selmode );
         m_created = TRUE;
     }
 
         m_created = TRUE;
     }
 
@@ -3798,10 +3821,13 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
                 break;
 
                 case WXGRID_CURSOR_SELECT_ROW:
                 break;
 
                 case WXGRID_CURSOR_SELECT_ROW:
-                    if ( (row = YToRow( y )) >= 0  &&
-                         !IsInSelection( row, 0 ) )
+                    if ( (row = YToRow( y )) >= 0 )
                     {
                     {
-                        SelectRow( row, TRUE );
+                        m_selection->SelectRow( row,
+                                                event.ControlDown(),
+                                                event.ShiftDown(),
+                                                event.AltDown(),
+                                                event.MetaDown() );
                     }
 
                 // default label to suppress warnings about "enumeration value
                     }
 
                 // default label to suppress warnings about "enumeration value
@@ -3838,7 +3864,23 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
             if ( row >= 0  &&
                  !SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, row, -1, event ) )
             {
             if ( row >= 0  &&
                  !SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, row, -1, event ) )
             {
-                SelectRow( row, event.ShiftDown() );
+                if ( !event.ShiftDown() && !event.ControlDown() )
+                    ClearSelection();
+                if ( event.ShiftDown() )
+                    m_selection->SelectBlock( m_currentCellCoords.GetRow(),
+                                              0,
+                                              row,
+                                              GetNumberCols() - 1,
+                                              event.ControlDown(),
+                                              event.ShiftDown(),
+                                              event.AltDown(),
+                                              event.MetaDown() );
+                else
+                    m_selection->SelectRow( row,
+                                            event.ControlDown(),
+                                            event.ShiftDown(),
+                                            event.AltDown(),
+                                            event.MetaDown() );
                 ChangeCursorMode(WXGRID_CURSOR_SELECT_ROW, m_rowLabelWin);
             }
         }
                 ChangeCursorMode(WXGRID_CURSOR_SELECT_ROW, m_rowLabelWin);
             }
         }
@@ -3965,10 +4007,13 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
                 break;
 
                 case WXGRID_CURSOR_SELECT_COL:
                 break;
 
                 case WXGRID_CURSOR_SELECT_COL:
-                    if ( (col = XToCol( x )) >= 0  &&
-                         !IsInSelection( 0, col ) )
+                    if ( (col = XToCol( x )) >= 0 )
                     {
                     {
-                        SelectCol( col, TRUE );
+                        m_selection->SelectCol( col,
+                                                event.ControlDown(),
+                                                event.ShiftDown(),
+                                                event.AltDown(),
+                                                event.MetaDown() );
                     }
 
                 // default label to suppress warnings about "enumeration value
                     }
 
                 // default label to suppress warnings about "enumeration value
@@ -4005,7 +4050,22 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
             if ( col >= 0  &&
                  !SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, -1, col, event ) )
             {
             if ( col >= 0  &&
                  !SendEvent( wxEVT_GRID_LABEL_LEFT_CLICK, -1, col, event ) )
             {
-                SelectCol( col, event.ShiftDown() );
+                if ( !event.ShiftDown() && !event.ControlDown() )
+                    ClearSelection();
+                if ( event.ShiftDown() )
+                    m_selection->SelectBlock( 0,
+                                              m_currentCellCoords.GetCol(),
+                                              GetNumberRows() - 1, col,
+                                              event.ControlDown(),
+                                              event.ShiftDown(),
+                                              event.AltDown(),
+                                              event.MetaDown() );
+                else
+                    m_selection->SelectCol( col,
+                                            event.ControlDown(),
+                                            event.ShiftDown(),
+                                            event.AltDown(),
+                                            event.MetaDown() );
                 ChangeCursorMode(WXGRID_CURSOR_SELECT_COL, m_colLabelWin);
             }
         }
                 ChangeCursorMode(WXGRID_CURSOR_SELECT_COL, m_colLabelWin);
             }
         }
@@ -4241,20 +4301,29 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
 
             if ( coords != wxGridNoCellCoords )
             {
 
             if ( coords != wxGridNoCellCoords )
             {
-                if ( !IsSelection() )
+                if ( event.ControlDown() )
                 {
                 {
-                    SelectBlock( coords, coords );
+                    if ( m_selectingKeyboard == wxGridNoCellCoords)
+                        m_selectingKeyboard = coords;
+                    SelectBlock ( m_selectingKeyboard, coords );
                 }
                 else
                 {
                 }
                 else
                 {
-                    SelectBlock( m_currentCellCoords, coords );
+                    if ( !IsSelection() )
+                    {
+                        SelectBlock( coords, coords );
+                    }
+                    else
+                    {
+                        SelectBlock( m_currentCellCoords, coords );
+                    }
                 }
 
                 if (! IsVisible(coords))
                 {
                     MakeCellVisible(coords);
                     // TODO: need to introduce a delay or something here.  The
                 }
 
                 if (! IsVisible(coords))
                 {
                     MakeCellVisible(coords);
                     // TODO: need to introduce a delay or something here.  The
-                    // scrolling is way to fast, at least on MSW.
+                    // scrolling is way to fast, at least on MSW - also on GTK.
                 }
             }
         }
                 }
             }
         }
@@ -4321,7 +4390,14 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
             ClearSelection();
         if ( event.ShiftDown() )
         {
             ClearSelection();
         if ( event.ShiftDown() )
         {
-            SelectBlock( m_currentCellCoords, coords );
+            m_selection->SelectBlock( m_currentCellCoords.GetRow(),
+                                      m_currentCellCoords.GetCol(),
+                                      coords.GetRow(),
+                                      coords.GetCol(),
+                                      event.ControlDown(),
+                                      event.ShiftDown(),
+                                      event.AltDown(),
+                                      event.MetaDown() );
         }
         else if ( XToEdgeOfCol(x) < 0  &&
                   YToEdgeOfRow(y) < 0 )
         }
         else if ( XToEdgeOfCol(x) < 0  &&
                   YToEdgeOfRow(y) < 0 )
@@ -4354,11 +4430,20 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
                 }
                 else
                 {
                 }
                 else
                 {
-                    m_selection->ToggleCellSelection( coords.GetRow(),
-                                                      coords.GetCol() );
-                    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;
                 }
             }
                     m_waitForSlowClick = TRUE;
                 }
             }
@@ -4391,16 +4476,21 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event )
             if ( m_selectingTopLeft != wxGridNoCellCoords &&
                  m_selectingBottomRight != wxGridNoCellCoords )
             {
             if ( m_selectingTopLeft != wxGridNoCellCoords &&
                  m_selectingBottomRight != wxGridNoCellCoords )
             {
-                 m_selection->SelectBlock( m_selectingTopLeft.GetRow(),
-                                           m_selectingTopLeft.GetCol(),
-                                           m_selectingBottomRight.GetRow(),
-                                           m_selectingBottomRight.GetCol() );
                 if (m_winCapture)
                 {
                     m_winCapture->ReleaseMouse();
                     m_winCapture = NULL;
                 }
                 if (m_winCapture)
                 {
                     m_winCapture->ReleaseMouse();
                     m_winCapture = NULL;
                 }
-                SendEvent( wxEVT_GRID_RANGE_SELECT, -1, -1, event );
+                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;
             }
 
             // Show the edit control, if it has been hidden for
             }
 
             // Show the edit control, if it has been hidden for
@@ -4894,11 +4984,13 @@ bool wxGrid::SendEvent( const wxEventType type,
     }
     else if ( type == wxEVT_GRID_RANGE_SELECT )
     {
     }
     else if ( type == wxEVT_GRID_RANGE_SELECT )
     {
+        // Right now, it should _never_ end up here! 
         wxGridRangeSelectEvent gridEvt( GetId(),
                                         type,
                                         this,
                                         m_selectingTopLeft,
                                         m_selectingBottomRight,
         wxGridRangeSelectEvent gridEvt( GetId(),
                                         type,
                                         this,
                                         m_selectingTopLeft,
                                         m_selectingBottomRight,
+                                        TRUE,
                                         mouseEv.ControlDown(),
                                         mouseEv.ShiftDown(),
                                         mouseEv.AltDown(),
                                         mouseEv.ControlDown(),
                                         mouseEv.ShiftDown(),
                                         mouseEv.AltDown(),
@@ -4913,6 +5005,7 @@ bool wxGrid::SendEvent( const wxEventType type,
                              this,
                              row, col,
                              mouseEv.GetX(), mouseEv.GetY(),
                              this,
                              row, col,
                              mouseEv.GetX(), mouseEv.GetY(),
+                             FALSE,
                              mouseEv.ControlDown(),
                              mouseEv.ShiftDown(),
                              mouseEv.AltDown(),
                              mouseEv.ControlDown(),
                              mouseEv.ShiftDown(),
                              mouseEv.AltDown(),
@@ -4955,15 +5048,6 @@ bool wxGrid::SendEvent( const wxEventType type,
 void wxGrid::OnPaint( wxPaintEvent& WXUNUSED(event) )
 {
     wxPaintDC dc( this );
 void wxGrid::OnPaint( wxPaintEvent& WXUNUSED(event) )
 {
     wxPaintDC dc( this );
-
-    if ( m_currentCellCoords == wxGridNoCellCoords  &&
-         m_numRows && m_numCols )
-    {
-        m_currentCellCoords.Set(0, 0);
-        ShowCellEditControl();
-    }
-
-    m_displayed = TRUE;
 }
 
 
 }
 
 
@@ -4971,7 +5055,7 @@ void wxGrid::OnPaint( wxPaintEvent& WXUNUSED(event) )
 // the grid view is resized... then the size event is skipped to allow
 // the box sizers to handle everything
 //
 // the grid view is resized... then the size event is skipped to allow
 // the box sizers to handle everything
 //
-void wxGrid::OnSize( wxSizeEvent& event )
+void wxGrid::OnSize( wxSizeEvent& WXUNUSED(event) )
 {
     CalcWindowSizes();
     CalcDimensions();
 {
     CalcWindowSizes();
     CalcDimensions();
@@ -4998,56 +5082,69 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
     if ( !parent->GetEventHandler()->ProcessEvent( keyEvt ) )
     {
 
     if ( !parent->GetEventHandler()->ProcessEvent( keyEvt ) )
     {
 
-        // TODO:  Should also support Shift-cursor keys for
-        //        extending the selection.  Maybe add a flag to
-        //        MoveCursorXXX() and MoveCursorXXXBlock() and
-        //        just send event.ShiftDown().
-
         // try local handlers
         //
         // try local handlers
         //
+        if ( !event.ShiftDown() && 
+             m_selectingKeyboard != wxGridNoCellCoords )
+        {
+            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;
+        }
+
         switch ( event.KeyCode() )
         {
             case WXK_UP:
                 if ( event.ControlDown() )
                 {
         switch ( event.KeyCode() )
         {
             case WXK_UP:
                 if ( event.ControlDown() )
                 {
-                    MoveCursorUpBlock();
+                    MoveCursorUpBlock( event.ShiftDown() );
                 }
                 else
                 {
                 }
                 else
                 {
-                    MoveCursorUp();
+                    MoveCursorUp( event.ShiftDown() );
                 }
                 break;
 
             case WXK_DOWN:
                 if ( event.ControlDown() )
                 {
                 }
                 break;
 
             case WXK_DOWN:
                 if ( event.ControlDown() )
                 {
-                    MoveCursorDownBlock();
+                    MoveCursorDownBlock( event.ShiftDown() );
                 }
                 else
                 {
                 }
                 else
                 {
-                    MoveCursorDown();
+                    MoveCursorDown( event.ShiftDown() );
                 }
                 break;
 
             case WXK_LEFT:
                 if ( event.ControlDown() )
                 {
                 }
                 break;
 
             case WXK_LEFT:
                 if ( event.ControlDown() )
                 {
-                    MoveCursorLeftBlock();
+                    MoveCursorLeftBlock( event.ShiftDown() );
                 }
                 else
                 {
                 }
                 else
                 {
-                    MoveCursorLeft();
+                    MoveCursorLeft( event.ShiftDown() );
                 }
                 break;
 
             case WXK_RIGHT:
                 if ( event.ControlDown() )
                 {
                 }
                 break;
 
             case WXK_RIGHT:
                 if ( event.ControlDown() )
                 {
-                    MoveCursorRightBlock();
+                    MoveCursorRightBlock( event.ShiftDown() );
                 }
                 else
                 {
                 }
                 else
                 {
-                    MoveCursorRight();
+                    MoveCursorRight( event.ShiftDown() );
                 }
                 break;
 
                 }
                 break;
 
@@ -5058,15 +5155,19 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
                 }
                 else
                 {
                 }
                 else
                 {
-                    MoveCursorDown();
+                    MoveCursorDown( event.ShiftDown() );
                 }
                 break;
 
                 }
                 break;
 
+            case WXK_ESCAPE:
+                ClearSelection();
+                break;
+
             case WXK_TAB:
                 if (event.ShiftDown())
             case WXK_TAB:
                 if (event.ShiftDown())
-                    MoveCursorLeft();
+                    MoveCursorLeft( FALSE );
                 else
                 else
-                    MoveCursorRight();
+                    MoveCursorRight( FALSE );
                 break;
 
             case WXK_HOME:
                 break;
 
             case WXK_HOME:
@@ -5102,9 +5203,19 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
                 break;
 
             case WXK_SPACE:
                 break;
 
             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() )
                 {
                 if ( !IsEditable() )
                 {
-                    MoveCursorRight();
+                    MoveCursorRight( FALSE );
                     break;
                 }
                 // Otherwise fall through to default
                     break;
                 }
                 // Otherwise fall through to default
@@ -5112,10 +5223,15 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
             default:
                 // alphanumeric keys or F2 (special key just for this) enable
                 // the cell edit control
             default:
                 // alphanumeric keys or F2 (special key just for this) enable
                 // the cell edit control
+                // On just Shift/Control I get values for event.KeyCode()
+                // that are outside the range where isalnum's behaviour is
+                // well defined, so do an additional sanity check.
                 if ( !(event.AltDown() ||
                        event.MetaDown() ||
                        event.ControlDown()) &&
                 if ( !(event.AltDown() ||
                        event.MetaDown() ||
                        event.ControlDown()) &&
-                     (isalnum(event.KeyCode()) || event.KeyCode() == WXK_F2) &&
+                     ((isalnum((int)event.KeyCode()) &&
+                       (event.KeyCode() < 256 && event.KeyCode() >= 0)) ||
+                      event.KeyCode() == WXK_F2) &&
                      !IsCellEditControlEnabled() &&
                      CanEnableCellControl() )
                 {
                      !IsCellEditControlEnabled() &&
                      CanEnableCellControl() )
                 {
@@ -5141,21 +5257,13 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
     m_inOnKeyDown = FALSE;
 }
 
     m_inOnKeyDown = FALSE;
 }
 
-
 void wxGrid::OnEraseBackground(wxEraseEvent&)
 {
 }
 
 void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
 {
 void wxGrid::OnEraseBackground(wxEraseEvent&)
 {
 }
 
 void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
 {
-    if ( SendEvent( wxEVT_GRID_SELECT_CELL, coords.GetRow(), coords.GetCol() ) )
-    {
-        // the event has been intercepted - do nothing
-        return;
-    }
-
-    if ( m_displayed  &&
-         m_currentCellCoords != wxGridNoCellCoords )
+    if ( m_currentCellCoords != wxGridNoCellCoords )
     {
         HideCellEditControl();
         DisableCellEditControl();
     {
         HideCellEditControl();
         DisableCellEditControl();
@@ -5171,14 +5279,13 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
 
     m_currentCellCoords = coords;
 
 
     m_currentCellCoords = coords;
 
-    if ( m_displayed )
-    {
-        wxClientDC dc(m_gridWin);
-        PrepareDC(dc);
+    wxClientDC dc(m_gridWin);
+    PrepareDC(dc);
+
+    wxGridCellAttr* attr = GetCellAttr(coords);
+    DrawCellHighlight(dc, attr);
+    attr->DecRef();
 
 
-        wxGridCellAttr* attr = GetCellAttr(coords);
-        DrawCellHighlight(dc, attr);
-        attr->DecRef();
 #if 0
         // SN: For my extended selection code, automatic
         //     deselection is definitely not a good idea.
 #if 0
         // SN: For my extended selection code, automatic
         //     deselection is definitely not a good idea.
@@ -5189,7 +5296,6 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
             if ( !GetBatchCount() ) m_gridWin->Refresh( FALSE, &r );
         }
 #endif
             if ( !GetBatchCount() ) m_gridWin->Refresh( FALSE, &r );
         }
 #endif
-    }
 }
 
 
 }
 
 
@@ -5392,6 +5498,15 @@ void wxGrid::DrawCellBorder( wxDC& dc, const wxGridCellCoords& coords )
 
 void wxGrid::DrawHighlight(wxDC& dc)
 {
 
 void wxGrid::DrawHighlight(wxDC& dc)
 {
+    // This if block was previously in wxGrid::OnPaint but that doesn't
+    // seem to get called under wxGTK - MB
+    //
+    if ( m_currentCellCoords == wxGridNoCellCoords  &&
+         m_numRows && m_numCols )
+    {
+        m_currentCellCoords.Set(0, 0);
+    }
+
     if ( IsCellEditControlEnabled() )
     {
         // don't show highlight when the edit control is shown
     if ( IsCellEditControlEnabled() )
     {
         // don't show highlight when the edit control is shown
@@ -5418,7 +5533,7 @@ void wxGrid::DrawHighlight(wxDC& dc)
 // This is used to redraw all grid lines e.g. when the grid line colour
 // has been changed
 //
 // This is used to redraw all grid lines e.g. when the grid line colour
 // has been changed
 //
-void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & reg )
+void wxGrid::DrawAllGridLines( wxDC& dc, const wxRegion & WXUNUSED_GTK(reg) )
 {
     if ( !m_gridLinesEnabled ||
          !m_numRows ||
 {
     if ( !m_gridLinesEnabled ||
          !m_numRows ||
@@ -5648,7 +5763,7 @@ void wxGrid::DrawTextRectangle( wxDC& dc,
 
         for ( size_t i = 0;  i < lines.GetCount();  i++ )
         {
 
         for ( size_t i = 0;  i < lines.GetCount();  i++ )
         {
-            dc.DrawText( lines[i], (long)x, (long)y );
+            dc.DrawText( lines[i], (int)x, (int)y );
             y += lineHeight;
         }
     }
             y += lineHeight;
         }
     }
@@ -6114,17 +6229,28 @@ void wxGrid::MakeCellVisible( int row, int col )
 // ------ Grid cursor movement functions
 //
 
 // ------ Grid cursor movement functions
 //
 
-bool wxGrid::MoveCursorUp()
+bool wxGrid::MoveCursorUp( bool expandSelection )
 {
     if ( m_currentCellCoords != wxGridNoCellCoords  &&
          m_currentCellCoords.GetRow() > 0 )
     {
 {
     if ( m_currentCellCoords != wxGridNoCellCoords  &&
          m_currentCellCoords.GetRow() > 0 )
     {
-        MakeCellVisible( m_currentCellCoords.GetRow() - 1,
-                        m_currentCellCoords.GetCol() );
-
-        SetCurrentCell( 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;
     }
 
         return TRUE;
     }
 
@@ -6132,19 +6258,28 @@ bool wxGrid::MoveCursorUp()
 }
 
 
 }
 
 
-bool wxGrid::MoveCursorDown()
+bool wxGrid::MoveCursorDown( bool expandSelection )
 {
 {
-    // TODO: allow for scrolling
-    //
     if ( m_currentCellCoords != wxGridNoCellCoords  &&
          m_currentCellCoords.GetRow() < m_numRows-1 )
     {
     if ( m_currentCellCoords != wxGridNoCellCoords  &&
          m_currentCellCoords.GetRow() < m_numRows-1 )
     {
-        MakeCellVisible( m_currentCellCoords.GetRow() + 1,
-                        m_currentCellCoords.GetCol() );
-
-        SetCurrentCell( 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;
     }
 
         return TRUE;
     }
 
@@ -6152,17 +6287,28 @@ bool wxGrid::MoveCursorDown()
 }
 
 
 }
 
 
-bool wxGrid::MoveCursorLeft()
+bool wxGrid::MoveCursorLeft( bool expandSelection )
 {
     if ( m_currentCellCoords != wxGridNoCellCoords  &&
          m_currentCellCoords.GetCol() > 0 )
     {
 {
     if ( m_currentCellCoords != wxGridNoCellCoords  &&
          m_currentCellCoords.GetCol() > 0 )
     {
-        MakeCellVisible( m_currentCellCoords.GetRow(),
-                        m_currentCellCoords.GetCol() - 1 );
-
-        SetCurrentCell( 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;
     }
 
         return TRUE;
     }
 
@@ -6170,17 +6316,28 @@ bool wxGrid::MoveCursorLeft()
 }
 
 
 }
 
 
-bool wxGrid::MoveCursorRight()
+bool wxGrid::MoveCursorRight( bool expandSelection )
 {
     if ( m_currentCellCoords != wxGridNoCellCoords  &&
          m_currentCellCoords.GetCol() < m_numCols - 1 )
     {
 {
     if ( m_currentCellCoords != wxGridNoCellCoords  &&
          m_currentCellCoords.GetCol() < m_numCols - 1 )
     {
-        MakeCellVisible( m_currentCellCoords.GetRow(),
-                        m_currentCellCoords.GetCol() + 1 );
-
-        SetCurrentCell( 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;
     }
 
         return TRUE;
     }
 
@@ -6248,7 +6405,7 @@ bool wxGrid::MovePageDown()
     return FALSE;
 }
 
     return FALSE;
 }
 
-bool wxGrid::MoveCursorUpBlock()
+bool wxGrid::MoveCursorUpBlock( bool expandSelection )
 {
     if ( m_table &&
          m_currentCellCoords != wxGridNoCellCoords  &&
 {
     if ( m_table &&
          m_currentCellCoords != wxGridNoCellCoords  &&
@@ -6295,15 +6452,23 @@ bool wxGrid::MoveCursorUpBlock()
         }
 
         MakeCellVisible( row, col );
         }
 
         MakeCellVisible( row, col );
-        SetCurrentCell( row, col );
-
+        if ( expandSelection )
+        {
+            m_selectingKeyboard = wxGridCellCoords( row, col );
+            SelectBlock( m_currentCellCoords, m_selectingKeyboard );
+        }
+        else
+        {
+            ClearSelection();
+            SetCurrentCell( row, col );
+        }
         return TRUE;
     }
 
     return FALSE;
 }
 
         return TRUE;
     }
 
     return FALSE;
 }
 
-bool wxGrid::MoveCursorDownBlock()
+bool wxGrid::MoveCursorDownBlock( bool expandSelection )
 {
     if ( m_table &&
          m_currentCellCoords != wxGridNoCellCoords  &&
 {
     if ( m_table &&
          m_currentCellCoords != wxGridNoCellCoords  &&
@@ -6350,7 +6515,16 @@ bool wxGrid::MoveCursorDownBlock()
         }
 
         MakeCellVisible( row, col );
         }
 
         MakeCellVisible( row, col );
-        SetCurrentCell( row, col );
+        if ( expandSelection )
+        {
+            m_selectingKeyboard = wxGridCellCoords( row, col );
+            SelectBlock( m_currentCellCoords, m_selectingKeyboard );
+        }
+        else
+        {
+            ClearSelection();
+            SetCurrentCell( row, col );
+        }
 
         return TRUE;
     }
 
         return TRUE;
     }
@@ -6358,7 +6532,7 @@ bool wxGrid::MoveCursorDownBlock()
     return FALSE;
 }
 
     return FALSE;
 }
 
-bool wxGrid::MoveCursorLeftBlock()
+bool wxGrid::MoveCursorLeftBlock( bool expandSelection )
 {
     if ( m_table &&
          m_currentCellCoords != wxGridNoCellCoords  &&
 {
     if ( m_table &&
          m_currentCellCoords != wxGridNoCellCoords  &&
@@ -6405,7 +6579,16 @@ bool wxGrid::MoveCursorLeftBlock()
         }
 
         MakeCellVisible( row, col );
         }
 
         MakeCellVisible( row, col );
-        SetCurrentCell( row, col );
+        if ( expandSelection )
+        {
+            m_selectingKeyboard = wxGridCellCoords( row, col );
+            SelectBlock( m_currentCellCoords, m_selectingKeyboard );
+        }
+        else
+        {
+            ClearSelection();
+            SetCurrentCell( row, col );
+        }
 
         return TRUE;
     }
 
         return TRUE;
     }
@@ -6413,7 +6596,7 @@ bool wxGrid::MoveCursorLeftBlock()
     return FALSE;
 }
 
     return FALSE;
 }
 
-bool wxGrid::MoveCursorRightBlock()
+bool wxGrid::MoveCursorRightBlock( bool expandSelection )
 {
     if ( m_table &&
          m_currentCellCoords != wxGridNoCellCoords  &&
 {
     if ( m_table &&
          m_currentCellCoords != wxGridNoCellCoords  &&
@@ -6460,7 +6643,16 @@ bool wxGrid::MoveCursorRightBlock()
         }
 
         MakeCellVisible( row, col );
         }
 
         MakeCellVisible( row, col );
-        SetCurrentCell( row, col );
+        if ( expandSelection )
+        {
+            m_selectingKeyboard = wxGridCellCoords( row, col );
+            SelectBlock( m_currentCellCoords, m_selectingKeyboard );
+        }
+        else
+        {
+            ClearSelection();
+            SetCurrentCell( row, col );
+        }
 
         return TRUE;
     }
 
         return TRUE;
     }
@@ -7414,6 +7606,12 @@ void wxGrid::Fit()
     AutoSize();
 }
 
     AutoSize();
 }
 
+
+wxPen& wxGrid::GetDividerPen() const
+{
+    return wxNullPen;
+}
+
 // ----------------------------------------------------------------------------
 // cell value accessor functions
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // cell value accessor functions
 // ----------------------------------------------------------------------------
@@ -7448,34 +7646,18 @@ void wxGrid::SetCellValue( int row, int col, const wxString& s )
 void wxGrid::SelectRow( int row, bool addToSelected )
 {
     if ( IsSelection() && !addToSelected )
 void wxGrid::SelectRow( int row, bool addToSelected )
 {
     if ( IsSelection() && !addToSelected )
-        m_selection->ClearSelection();
+        ClearSelection();
 
     m_selection->SelectRow( row );
 
     m_selection->SelectRow( row );
-
-    wxGridRangeSelectEvent gridEvt( GetId(),
-                                    wxEVT_GRID_RANGE_SELECT,
-                                    this,
-                                    wxGridCellCoords( row, 0 ),
-                                    wxGridCellCoords( row, m_numCols - 1 ) );
-
-    GetEventHandler()->ProcessEvent(gridEvt);
 }
 
 
 void wxGrid::SelectCol( int col, bool addToSelected )
 {
     if ( IsSelection() && !addToSelected )
 }
 
 
 void wxGrid::SelectCol( int col, bool addToSelected )
 {
     if ( IsSelection() && !addToSelected )
-        m_selection->ClearSelection();
+        ClearSelection();
 
     m_selection->SelectCol( col );
 
     m_selection->SelectCol( col );
-
-    wxGridRangeSelectEvent gridEvt( GetId(),
-                                    wxEVT_GRID_RANGE_SELECT,
-                                    this,
-                                    wxGridCellCoords( 0, col ),
-                                    wxGridCellCoords( m_numRows - 1, col ) );
-
-    GetEventHandler()->ProcessEvent(gridEvt);
 }
 
 
 }
 
 
@@ -7598,19 +7780,8 @@ void wxGrid::SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol )
                 m_gridWin->Refresh( FALSE, &(rect[i]) );
     }
 
                 m_gridWin->Refresh( FALSE, &(rect[i]) );
     }
 
-    // only generate an event if the block is not being selected by
-    // dragging the mouse (in which case the event will be generated in
-    // the mouse event handler)
-    if ( !m_isDragging )
-    {
-        wxGridRangeSelectEvent gridEvt( GetId(),
-                                        wxEVT_GRID_RANGE_SELECT,
-                                        this,
-                                        m_selectingTopLeft,
-                                        m_selectingBottomRight );
-
-        GetEventHandler()->ProcessEvent(gridEvt);
-    }
+    // never generate an event as it will be generated from
+    // wxGridSelection::SelectBlock!
 }
 
 void wxGrid::SelectAll()
 }
 
 void wxGrid::SelectAll()
@@ -7697,7 +7868,7 @@ wxRect wxGrid::BlockToDeviceRect( const wxGridCellCoords &topLeft,
 IMPLEMENT_DYNAMIC_CLASS( wxGridEvent, wxEvent )
 
 wxGridEvent::wxGridEvent( int id, wxEventType type, wxObject* obj,
 IMPLEMENT_DYNAMIC_CLASS( wxGridEvent, wxEvent )
 
 wxGridEvent::wxGridEvent( int id, wxEventType type, wxObject* obj,
-                          int row, int col, int x, int y,
+                          int row, int col, int x, int y, bool sel,
                           bool control, bool shift, bool alt, bool meta )
         : wxNotifyEvent( type, id )
 {
                           bool control, bool shift, bool alt, bool meta )
         : wxNotifyEvent( type, id )
 {
@@ -7705,6 +7876,7 @@ wxGridEvent::wxGridEvent( int id, wxEventType type, wxObject* obj,
     m_col = col;
     m_x = x;
     m_y = y;
     m_col = col;
     m_x = x;
     m_y = y;
+    m_selecting = sel;
     m_control = control;
     m_shift = shift;
     m_alt = alt;
     m_control = control;
     m_shift = shift;
     m_alt = alt;
@@ -7738,11 +7910,13 @@ IMPLEMENT_DYNAMIC_CLASS( wxGridRangeSelectEvent, wxEvent )
 wxGridRangeSelectEvent::wxGridRangeSelectEvent(int id, wxEventType type, wxObject* obj,
                                                const wxGridCellCoords& topLeft,
                                                const wxGridCellCoords& bottomRight,
 wxGridRangeSelectEvent::wxGridRangeSelectEvent(int id, wxEventType type, wxObject* obj,
                                                const wxGridCellCoords& topLeft,
                                                const wxGridCellCoords& bottomRight,
-                                               bool control, bool shift, bool alt, bool meta )
+                                               bool sel, bool control,
+                                               bool shift, bool alt, bool meta )
         : wxNotifyEvent( type, id )
 {
     m_topLeft     = topLeft;
     m_bottomRight = bottomRight;
         : wxNotifyEvent( type, id )
 {
     m_topLeft     = topLeft;
     m_bottomRight = bottomRight;
+    m_selecting   = sel;
     m_control     = control;
     m_shift       = shift;
     m_alt         = alt;
     m_control     = control;
     m_shift       = shift;
     m_alt         = alt;