]> git.saurik.com Git - wxWidgets.git/commitdiff
use a single wxKeyboardEvent parameter instead of 4 bools in tons of places
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 20 Sep 2008 00:09:28 +0000 (00:09 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 20 Sep 2008 00:09:28 +0000 (00:09 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55748 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/generic/grid.h
include/wx/generic/gridsel.h
src/generic/grid.cpp
src/generic/gridsel.cpp

index b9d4935c456689cd59df12b80c878aebae85f3cf..b9700ec2d3019b31ab66a54599b4838c04748256 100644 (file)
@@ -2260,35 +2260,44 @@ private:
 // Grid event class and event types
 // ----------------------------------------------------------------------------
 
-class WXDLLIMPEXP_ADV wxGridEvent : public wxNotifyEvent
+class WXDLLIMPEXP_ADV wxGridEvent : public wxNotifyEvent,
+                                    public wxKeyboardState
 {
 public:
     wxGridEvent()
-        : wxNotifyEvent(), m_row(-1), m_col(-1), m_x(-1), m_y(-1),
-        m_selecting(0), m_control(0), m_meta(0), m_shift(0), m_alt(0)
-        {
-        }
+        : wxNotifyEvent()
+    {
+        Init(-1, -1, -1, -1, false);
+    }
 
-    wxGridEvent(int id, wxEventType type, wxObject* obj,
-                int row=-1, int col=-1, int x=-1, int y=-1, bool sel = true,
-                bool control = false, bool shift = false, bool alt = false, bool meta = false);
+    wxGridEvent(int id,
+                wxEventType type,
+                wxObject* obj,
+                int row = -1, int col = -1,
+                int x = -1, int y = -1,
+                bool sel = true,
+                const wxKeyboardState& kbd = wxKeyboardState())
+        : wxNotifyEvent(type, id),
+          wxKeyboardState(kbd)
+    {
+        Init(row, col, x, y, sel);
+        SetEventObject(obj);
+    }
+
+    wxDEPRECATED(
+    wxGridEvent(int id,
+                wxEventType type,
+                wxObject* obj,
+                int row, int col,
+                int x, int y,
+                bool sel,
+                bool control,
+                bool shift = false, bool alt = false, bool meta = false));
 
     virtual int GetRow() { return m_row; }
     virtual int GetCol() { return m_col; }
     wxPoint     GetPosition() { return wxPoint( m_x, m_y ); }
     bool        Selecting() { return m_selecting; }
-    bool        ControlDown() { return m_control; }
-    bool        MetaDown() { return m_meta; }
-    bool        ShiftDown() { return m_shift; }
-    bool        AltDown() { return m_alt; }
-    bool        CmdDown()
-    {
-#if defined(__WXMAC__) || defined(__WXCOCOA__)
-        return MetaDown();
-#else
-        return ControlDown();
-#endif
-    }
 
     virtual wxEvent *Clone() const { return new wxGridEvent(*this); }
 
@@ -2298,41 +2307,57 @@ protected:
     int         m_x;
     int         m_y;
     bool        m_selecting;
-    bool        m_control;
-    bool        m_meta;
-    bool        m_shift;
-    bool        m_alt;
+
+private:
+    void Init(int row, int col, int x, int y, bool sel)
+    {
+        m_row = row;
+        m_col = col;
+        m_x = x;
+        m_y = y;
+        m_selecting = sel;
+    }
 
     DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEvent)
 };
 
-class WXDLLIMPEXP_ADV wxGridSizeEvent : public wxNotifyEvent
+class WXDLLIMPEXP_ADV wxGridSizeEvent : public wxNotifyEvent,
+                                        public wxKeyboardState
 {
 public:
     wxGridSizeEvent()
-        : wxNotifyEvent(), m_rowOrCol(-1), m_x(-1), m_y(-1),
-        m_control(0), m_meta(0), m_shift(0), m_alt(0)
-        {
-        }
+        : wxNotifyEvent()
+    {
+        Init(-1, -1, -1);
+    }
+
+    wxGridSizeEvent(int id,
+                    wxEventType type,
+                    wxObject* obj,
+                    int rowOrCol = -1,
+                    int x = -1, int y = -1,
+                    const wxKeyboardState& kbd = wxKeyboardState())
+        : wxNotifyEvent(type, id),
+          wxKeyboardState(kbd)
+    {
+        Init(rowOrCol, x, y);
 
-    wxGridSizeEvent(int id, wxEventType type, wxObject* obj,
-                int rowOrCol=-1, int x=-1, int y=-1,
-                bool control = false, bool shift = false, bool alt = false, bool meta = false);
+        SetEventObject(obj);
+    }
+
+    wxDEPRECATED(
+    wxGridSizeEvent(int id,
+                    wxEventType type,
+                    wxObject* obj,
+                    int rowOrCol,
+                    int x, int y,
+                    bool control,
+                    bool shift = false,
+                    bool alt = false,
+                    bool meta = false) );
 
     int         GetRowOrCol() { return m_rowOrCol; }
     wxPoint     GetPosition() { return wxPoint( m_x, m_y ); }
-    bool        ControlDown() { return m_control; }
-    bool        MetaDown() { return m_meta; }
-    bool        ShiftDown() { return m_shift; }
-    bool        AltDown() { return m_alt; }
-    bool        CmdDown()
-    {
-#if defined(__WXMAC__) || defined(__WXCOCOA__)
-        return MetaDown();
-#else
-        return ControlDown();
-#endif
-    }
 
     virtual wxEvent *Clone() const { return new wxGridSizeEvent(*this); }
 
@@ -2340,36 +2365,55 @@ protected:
     int         m_rowOrCol;
     int         m_x;
     int         m_y;
-    bool        m_control;
-    bool        m_meta;
-    bool        m_shift;
-    bool        m_alt;
+
+private:
+    void Init(int rowOrCol, int x, int y)
+    {
+        m_rowOrCol = rowOrCol;
+        m_x = x;
+        m_y = y;
+    }
 
     DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridSizeEvent)
 };
 
 
-class WXDLLIMPEXP_ADV wxGridRangeSelectEvent : public wxNotifyEvent
+class WXDLLIMPEXP_ADV wxGridRangeSelectEvent : public wxNotifyEvent,
+                                               public wxKeyboardState
 {
 public:
     wxGridRangeSelectEvent()
         : wxNotifyEvent()
-        {
-            m_topLeft     = wxGridNoCellCoords;
-            m_bottomRight = wxGridNoCellCoords;
-            m_selecting   = false;
-            m_control     = false;
-            m_meta        = false;
-            m_shift       = false;
-            m_alt         = false;
-        }
+    {
+        Init(wxGridNoCellCoords, wxGridNoCellCoords, false);
+    }
 
-    wxGridRangeSelectEvent(int id, wxEventType type, wxObject* obj,
+    wxGridRangeSelectEvent(int id,
+                           wxEventType type,
+                           wxObject* obj,
                            const wxGridCellCoords& topLeft,
                            const wxGridCellCoords& bottomRight,
                            bool sel = true,
-                           bool control = false, bool shift = false,
-                           bool alt = false, bool meta = false);
+                           const wxKeyboardState& kbd = wxKeyboardState())
+        : wxNotifyEvent(type, id),
+          wxKeyboardState(kbd)
+    {
+        Init(topLeft, bottomRight, sel);
+
+        SetEventObject(obj);
+    }
+
+    wxDEPRECATED(
+    wxGridRangeSelectEvent(int id,
+                           wxEventType type,
+                           wxObject* obj,
+                           const wxGridCellCoords& topLeft,
+                           const wxGridCellCoords& bottomRight,
+                           bool sel,
+                           bool control,
+                           bool shift = false,
+                           bool alt = false,
+                           bool meta = false) );
 
     wxGridCellCoords GetTopLeftCoords() { return m_topLeft; }
     wxGridCellCoords GetBottomRightCoords() { return m_bottomRight; }
@@ -2378,35 +2422,29 @@ public:
     int         GetLeftCol()   { return m_topLeft.GetCol(); }
     int         GetRightCol()  { return m_bottomRight.GetCol(); }
     bool        Selecting() { return m_selecting; }
-    bool        ControlDown()  { return m_control; }
-    bool        MetaDown()     { return m_meta; }
-    bool        ShiftDown()    { return m_shift; }
-    bool        AltDown()      { return m_alt; }
-    bool        CmdDown()
-    {
-#if defined(__WXMAC__) || defined(__WXCOCOA__)
-        return MetaDown();
-#else
-        return ControlDown();
-#endif
-    }
 
     virtual wxEvent *Clone() const { return new wxGridRangeSelectEvent(*this); }
 
 protected:
+    void Init(const wxGridCellCoords& topLeft,
+              const wxGridCellCoords& bottomRight,
+              bool selecting)
+    {
+        m_topLeft = topLeft;
+        m_bottomRight = bottomRight;
+        m_selecting = selecting;
+    }
+
     wxGridCellCoords  m_topLeft;
     wxGridCellCoords  m_bottomRight;
     bool              m_selecting;
-    bool              m_control;
-    bool              m_meta;
-    bool              m_shift;
-    bool              m_alt;
 
     DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridRangeSelectEvent)
 };
 
 
-class WXDLLIMPEXP_ADV wxGridEditorCreatedEvent : public wxCommandEvent {
+class WXDLLIMPEXP_ADV wxGridEditorCreatedEvent : public wxCommandEvent
+{
 public:
     wxGridEditorCreatedEvent()
         : wxCommandEvent()
index f7cefd4e1d4ac1c441552606d6339a95ccb929c5..ead1d9256a73e58d860c0a72ae912230886db414 100644 (file)
@@ -33,45 +33,38 @@ public:
 
     void SetSelectionMode(wxGrid::wxGridSelectionModes selmode);
     wxGrid::wxGridSelectionModes GetSelectionMode() { return m_selectionMode; }
-    void SelectRow( int row,
-                    bool ControlDown = false,  bool ShiftDown = false,
-                    bool AltDown = false, bool MetaDown = false );
-    void SelectCol( int col,
-                    bool ControlDown = false,  bool ShiftDown = false,
-                    bool AltDown = false, bool MetaDown = false );
-    void SelectBlock( int topRow, int leftCol,
-                      int bottomRow, int rightCol,
-                      bool ControlDown = false,  bool ShiftDown = false,
-                      bool AltDown = false, bool MetaDown = false,
-                      bool sendEvent = true );
-    void SelectBlock( const wxGridCellCoords& topLeft,
-                      const wxGridCellCoords& bottomRight,
-                      bool ControlDown = false,  bool ShiftDown = false,
-                      bool AltDown = false, bool MetaDown = false,
-                      bool sendEvent = true )
+    void SelectRow(int row, const wxKeyboardState& kbd = wxKeyboardState());
+    void SelectCol(int col, const wxKeyboardState& kbd = wxKeyboardState());
+    void SelectBlock(int topRow, int leftCol,
+                     int bottomRow, int rightCol,
+                     const wxKeyboardState& kbd = wxKeyboardState(),
+                     bool sendEvent = true );
+    void SelectBlock(const wxGridCellCoords& topLeft,
+                     const wxGridCellCoords& bottomRight,
+                     const wxKeyboardState& kbd = wxKeyboardState(),
+                     bool sendEvent = true )
     {
         SelectBlock(topLeft.GetRow(), topLeft.GetCol(),
                     bottomRight.GetRow(), bottomRight.GetCol(),
-                    ControlDown, ShiftDown, AltDown, MetaDown,
-                    sendEvent);
+                    kbd, sendEvent);
     }
 
-    void SelectCell( int row, int col,
-                     bool ControlDown = false,  bool ShiftDown = false,
-                     bool AltDown = false, bool MetaDown = false,
-                     bool sendEvent = true );
+    void SelectCell(int row, int col,
+                    const wxKeyboardState& kbd = wxKeyboardState(),
+                    bool sendEvent = true);
+    void SelectCell(const wxGridCellCoords& coords,
+                    const wxKeyboardState& kbd = wxKeyboardState(),
+                    bool sendEvent = true)
+    {
+        SelectCell(coords.GetRow(), coords.GetCol(), kbd, sendEvent);
+    }
 
-    void ToggleCellSelection( int row, int col,
-                              bool ControlDown = false,
-                              bool ShiftDown = false,
-                              bool AltDown = false, bool MetaDown = false );
-    void ToggleCellSelection( const wxGridCellCoords& coords,
-                              bool ControlDown = false,
-                              bool ShiftDown = false,
-                              bool AltDown = false, bool MetaDown = false )
+    void ToggleCellSelection(int row, int col,
+                             const wxKeyboardState& kbd = wxKeyboardState());
+    void ToggleCellSelection(const wxGridCellCoords& coords,
+                             const wxKeyboardState& kbd = wxKeyboardState())
     {
-        ToggleCellSelection(coords.GetRow(), coords.GetCol(),
-                            ControlDown, ShiftDown, AltDown, MetaDown);
+        ToggleCellSelection(coords.GetRow(), coords.GetCol(), kbd);
     }
 
     void ClearSelection();
@@ -98,6 +91,13 @@ private:
                  leftCol <= col && col <= rightCol );
     }
 
+    void SelectBlockNoEvent(int topRow, int leftCol,
+                            int bottomRow, int rightCol)
+    {
+        SelectBlock(topRow, leftCol, bottomRow, rightCol,
+                    wxKeyboardState(), false);
+    }
+
     wxGridCellCoordsArray               m_cellSelection;
     wxGridCellCoordsArray               m_blockSelectionTopLeft;
     wxGridCellCoordsArray               m_blockSelectionBottomRight;
index 3830a869ee62ce3ebee8ac02c2064dd9ec5a40f4..e8ca4e0102b6308b6c98b572587a907a9b1954dc 100644 (file)
@@ -5621,13 +5621,7 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
                     if ( (row = YToRow( y )) >= 0 )
                     {
                         if ( m_selection )
-                        {
-                            m_selection->SelectRow( row,
-                                                    event.ControlDown(),
-                                                    event.ShiftDown(),
-                                                    event.AltDown(),
-                                                    event.MetaDown() );
-                        }
+                            m_selection->SelectRow(row, event);
                     }
                 }
                 break;
@@ -5678,22 +5672,16 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
                 {
                     if ( event.ShiftDown() )
                     {
-                        m_selection->SelectBlock( m_currentCellCoords.GetRow(),
-                                                  0,
-                                                  row,
-                                                  GetNumberCols() - 1,
-                                                  event.ControlDown(),
-                                                  event.ShiftDown(),
-                                                  event.AltDown(),
-                                                  event.MetaDown() );
+                        m_selection->SelectBlock
+                                     (
+                                        m_currentCellCoords.GetRow(), 0,
+                                        row, GetNumberCols() - 1,
+                                        event
+                                     );
                     }
                     else
                     {
-                        m_selection->SelectRow( row,
-                                                event.ControlDown(),
-                                                event.ShiftDown(),
-                                                event.AltDown(),
-                                                event.MetaDown() );
+                        m_selection->SelectRow(row, event);
                     }
                 }
 
@@ -5842,13 +5830,7 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
                     if ( (col = XToCol( x )) >= 0 )
                     {
                         if ( m_selection )
-                        {
-                            m_selection->SelectCol( col,
-                                                    event.ControlDown(),
-                                                    event.ShiftDown(),
-                                                    event.AltDown(),
-                                                    event.MetaDown() );
-                        }
+                            m_selection->SelectCol(col, event);
                     }
                 }
                 break;
@@ -5979,21 +5961,16 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
                     {
                         if ( event.ShiftDown() )
                         {
-                            m_selection->SelectBlock( 0,
-                                                      m_currentCellCoords.GetCol(),
-                                                      GetNumberRows() - 1, col,
-                                                      event.ControlDown(),
-                                                      event.ShiftDown(),
-                                                      event.AltDown(),
-                                                      event.MetaDown() );
+                            m_selection->SelectBlock
+                                         (
+                                            0, m_currentCellCoords.GetCol(),
+                                            GetNumberRows() - 1, col,
+                                            event
+                                         );
                         }
                         else
                         {
-                            m_selection->SelectCol( col,
-                                                    event.ControlDown(),
-                                                    event.ShiftDown(),
-                                                    event.AltDown(),
-                                                    event.MetaDown() );
+                            m_selection->SelectCol(col, event);
                         }
                     }
 
@@ -6373,12 +6350,7 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
     {
         if ( m_selection )
         {
-            m_selection->SelectBlock( m_currentCellCoords,
-                                      coords,
-                                      event.ControlDown(),
-                                      event.ShiftDown(),
-                                      event.AltDown(),
-                                      event.MetaDown() );
+            m_selection->SelectBlock(m_currentCellCoords, coords, event);
             m_selectedBlockCorner = coords;
         }
     }
@@ -6391,12 +6363,9 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
         {
             if ( m_selection )
             {
-                m_selection->ToggleCellSelection( coords,
-                                                  event.ControlDown(),
-                                                  event.ShiftDown(),
-                                                  event.AltDown(),
-                                                  event.MetaDown() );
+                m_selection->ToggleCellSelection(coords, event);
             }
+
             m_selectedBlockTopLeft = wxGridNoCellCoords;
             m_selectedBlockBottomRight = wxGridNoCellCoords;
             m_selectedBlockCorner = coords;
@@ -6458,10 +6427,7 @@ wxGrid::DoGridCellLeftUp(wxMouseEvent& event, const wxGridCellCoords& coords)
             {
                 m_selection->SelectBlock( m_selectedBlockTopLeft,
                                           m_selectedBlockBottomRight,
-                                          event.ControlDown(),
-                                          event.ShiftDown(),
-                                          event.AltDown(),
-                                          event.MetaDown() );
+                                          event );
             }
 
             m_selectedBlockTopLeft = wxGridNoCellCoords;
@@ -6927,10 +6893,7 @@ wxGrid::SendEvent(const wxEventType type,
                rowOrCol,
                mouseEv.GetX() + GetRowLabelSize(),
                mouseEv.GetY() + GetColLabelSize(),
-               mouseEv.ControlDown(),
-               mouseEv.ShiftDown(),
-               mouseEv.AltDown(),
-               mouseEv.MetaDown() );
+               mouseEv);
 
        claimed = GetEventHandler()->ProcessEvent(gridEvt);
        vetoed = !gridEvt.IsAllowed();
@@ -6944,10 +6907,7 @@ wxGrid::SendEvent(const wxEventType type,
                m_selectedBlockTopLeft,
                m_selectedBlockBottomRight,
                true,
-               mouseEv.ControlDown(),
-               mouseEv.ShiftDown(),
-               mouseEv.AltDown(),
-               mouseEv.MetaDown() );
+               mouseEv);
 
        claimed = GetEventHandler()->ProcessEvent(gridEvt);
        vetoed = !gridEvt.IsAllowed();
@@ -6971,10 +6931,7 @@ wxGrid::SendEvent(const wxEventType type,
                pos.x,
                pos.y,
                false,
-               mouseEv.ControlDown(),
-               mouseEv.ShiftDown(),
-               mouseEv.AltDown(),
-               mouseEv.MetaDown() );
+               mouseEv);
        claimed = GetEventHandler()->ProcessEvent(gridEvt);
        vetoed = !gridEvt.IsAllowed();
    }
@@ -6987,10 +6944,7 @@ wxGrid::SendEvent(const wxEventType type,
                mouseEv.GetX() + GetRowLabelSize(),
                mouseEv.GetY() + GetColLabelSize(),
                false,
-               mouseEv.ControlDown(),
-               mouseEv.ShiftDown(),
-               mouseEv.AltDown(),
-               mouseEv.MetaDown() );
+               mouseEv);
        claimed = GetEventHandler()->ProcessEvent(gridEvt);
        vetoed = !gridEvt.IsAllowed();
    }
@@ -7328,10 +7282,7 @@ void wxGrid::OnKeyUp( wxKeyEvent& event )
                 m_selection->SelectBlock(
                     m_selectedBlockTopLeft,
                     m_selectedBlockBottomRight,
-                    event.ControlDown(),
-                    true,
-                    event.AltDown(),
-                    event.MetaDown() );
+                    event);
             }
         }
 
@@ -10668,31 +10619,36 @@ void wxGrid::SetCellValue( int row, int col, const wxString& s )
 
 void wxGrid::SelectRow( int row, bool addToSelected )
 {
-    if ( IsSelection() && !addToSelected )
+    if ( !m_selection )
+        return;
+
+    if ( !addToSelected )
         ClearSelection();
 
-    if ( m_selection )
-        m_selection->SelectRow( row, false, addToSelected );
+    m_selection->SelectRow(row);
 }
 
 void wxGrid::SelectCol( int col, bool addToSelected )
 {
-    if ( IsSelection() && !addToSelected )
+    if ( !m_selection )
+        return;
+
+    if ( !addToSelected )
         ClearSelection();
 
-    if ( m_selection )
-        m_selection->SelectCol( col, false, addToSelected );
+    m_selection->SelectCol(col);
 }
 
-void wxGrid::SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol,
-                          bool addToSelected )
+void wxGrid::SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol,
+                         bool addToSelected)
 {
-    if ( IsSelection() && !addToSelected )
+    if ( !m_selection )
+        return;
+
+    if ( !addToSelected )
         ClearSelection();
 
-    if ( m_selection )
-        m_selection->SelectBlock( topRow, leftCol, bottomRow, rightCol,
-                                  false, addToSelected );
+    m_selection->SelectBlock(topRow, leftCol, bottomRow, rightCol);
 }
 
 void wxGrid::SelectAll()
@@ -10988,36 +10944,23 @@ IMPLEMENT_DYNAMIC_CLASS( wxGridEvent, wxNotifyEvent )
 wxGridEvent::wxGridEvent( int id, wxEventType type, wxObject* obj,
                           int row, int col, int x, int y, bool sel,
                           bool control, bool shift, bool alt, bool meta )
-        : wxNotifyEvent( type, id )
+        : wxNotifyEvent( type, id ),
+          wxKeyboardState(control, shift, alt, meta)
 {
-    m_row = row;
-    m_col = col;
-    m_x = x;
-    m_y = y;
-    m_selecting = sel;
-    m_control = control;
-    m_shift = shift;
-    m_alt = alt;
-    m_meta = meta;
+    Init(row, col, x, y, sel);
 
     SetEventObject(obj);
 }
 
-
 IMPLEMENT_DYNAMIC_CLASS( wxGridSizeEvent, wxNotifyEvent )
 
 wxGridSizeEvent::wxGridSizeEvent( int id, wxEventType type, wxObject* obj,
                                   int rowOrCol, int x, int y,
                                   bool control, bool shift, bool alt, bool meta )
-        : wxNotifyEvent( type, id )
+        : wxNotifyEvent( type, id ),
+          wxKeyboardState(control, shift, alt, meta)
 {
-    m_rowOrCol = rowOrCol;
-    m_x = x;
-    m_y = y;
-    m_control = control;
-    m_shift = shift;
-    m_alt = alt;
-    m_meta = meta;
+    Init(rowOrCol, x, y);
 
     SetEventObject(obj);
 }
@@ -11030,15 +10973,10 @@ wxGridRangeSelectEvent::wxGridRangeSelectEvent(int id, wxEventType type, wxObjec
                                                const wxGridCellCoords& bottomRight,
                                                bool sel, bool control,
                                                bool shift, bool alt, bool meta )
-        : wxNotifyEvent( type, id )
-{
-    m_topLeft = topLeft;
-    m_bottomRight = bottomRight;
-    m_selecting = sel;
-    m_control = control;
-    m_shift = shift;
-    m_alt = alt;
-    m_meta = meta;
+        : wxNotifyEvent( type, id ),
+          wxKeyboardState(control, shift, alt, meta)
+{
+    Init(topLeft, bottomRight, sel);
 
     SetEventObject(obj);
 }
index d5ba76cbbb5da898ccc53e574ba6a7f936840c7c..f87c0378885915371538d3d98659ea51461748ca 100644 (file)
@@ -160,9 +160,8 @@ void wxGridSelection::SetSelectionMode( wxGrid::wxGridSelectionModes selmode )
                 {
                     m_blockSelectionTopLeft.RemoveAt(n);
                     m_blockSelectionBottomRight.RemoveAt(n);
-                    SelectBlock( topRow, 0,
-                                 bottomRow, m_grid->GetNumberCols() - 1,
-                                 false, false, false, false, false );
+                    SelectBlockNoEvent( topRow, 0,
+                                 bottomRow, m_grid->GetNumberCols() - 1);
                 }
             }
             else // selmode == wxGridSelectColumns)
@@ -171,9 +170,8 @@ void wxGridSelection::SetSelectionMode( wxGrid::wxGridSelectionModes selmode )
                 {
                     m_blockSelectionTopLeft.RemoveAt(n);
                     m_blockSelectionBottomRight.RemoveAt(n);
-                    SelectBlock( 0, leftCol,
-                                 m_grid->GetNumberRows() - 1, rightCol,
-                                 false, false, false, false, false );
+                    SelectBlockNoEvent(0, leftCol,
+                                 m_grid->GetNumberRows() - 1, rightCol);
                 }
             }
         }
@@ -182,9 +180,7 @@ void wxGridSelection::SetSelectionMode( wxGrid::wxGridSelectionModes selmode )
     }
 }
 
-void wxGridSelection::SelectRow( int row,
-                                 bool ControlDown,  bool ShiftDown,
-                                 bool AltDown, bool MetaDown )
+void wxGridSelection::SelectRow(int row, const wxKeyboardState& kbd)
 {
     if ( m_selectionMode == wxGrid::wxGridSelectColumns )
         return;
@@ -275,15 +271,12 @@ void wxGridSelection::SelectRow( int row,
                                     wxGridCellCoords( row, 0 ),
                                     wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ),
                                     true,
-                                    ControlDown,  ShiftDown,
-                                    AltDown, MetaDown );
+                                    kbd);
 
     m_grid->GetEventHandler()->ProcessEvent( gridEvt );
 }
 
-void wxGridSelection::SelectCol( int col,
-                                 bool ControlDown,  bool ShiftDown,
-                                 bool AltDown, bool MetaDown )
+void wxGridSelection::SelectCol(int col, const wxKeyboardState& kbd)
 {
     if ( m_selectionMode == wxGrid::wxGridSelectRows )
         return;
@@ -372,16 +365,14 @@ void wxGridSelection::SelectCol( int col,
                                     wxGridCellCoords( 0, col ),
                                     wxGridCellCoords( m_grid->GetNumberRows() - 1, col ),
                                     true,
-                                    ControlDown,  ShiftDown,
-                                    AltDown, MetaDown );
+                                    kbd );
 
     m_grid->GetEventHandler()->ProcessEvent( gridEvt );
 }
 
 void wxGridSelection::SelectBlock( int topRow, int leftCol,
                                    int bottomRow, int rightCol,
-                                   bool ControlDown, bool ShiftDown,
-                                   bool AltDown, bool MetaDown,
+                                   const wxKeyboardState& kbd,
                                    bool sendEvent )
 {
     // Fix the coordinates of the block if needed.
@@ -432,8 +423,7 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol,
     if ( m_selectionMode == wxGrid::wxGridSelectCells &&
          topRow == bottomRow && leftCol == rightCol )
     {
-        SelectCell( topRow, leftCol, ControlDown,  ShiftDown,
-                    AltDown, MetaDown, sendEvent );
+        SelectCell( topRow, leftCol, kbd, sendEvent );
     }
 
     size_t count, n;
@@ -553,28 +543,24 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol,
             wxGridCellCoords( topRow, leftCol ),
             wxGridCellCoords( bottomRow, rightCol ),
             true,
-            ControlDown, ShiftDown,
-            AltDown, MetaDown );
+            kbd);
         m_grid->GetEventHandler()->ProcessEvent( gridEvt );
     }
 }
 
 void wxGridSelection::SelectCell( int row, int col,
-                                  bool ControlDown, bool ShiftDown,
-                                  bool AltDown, bool MetaDown,
+                                  const wxKeyboardState& kbd,
                                   bool sendEvent )
 {
     if ( m_selectionMode == wxGrid::wxGridSelectRows )
     {
-        SelectBlock(row, 0, row, m_grid->GetNumberCols() - 1,
-                    ControlDown, ShiftDown, AltDown, MetaDown, sendEvent);
+        SelectBlock(row, 0, row, m_grid->GetNumberCols() - 1, kbd, sendEvent);
 
         return;
     }
     else if ( m_selectionMode == wxGrid::wxGridSelectColumns )
     {
-        SelectBlock(0, col, m_grid->GetNumberRows() - 1, col,
-                    ControlDown, ShiftDown, AltDown, MetaDown, sendEvent);
+        SelectBlock(0, col, m_grid->GetNumberRows() - 1, col, kbd, sendEvent);
 
         return;
     }
@@ -601,20 +587,19 @@ void wxGridSelection::SelectCell( int row, int col,
             wxGridCellCoords( row, col ),
             wxGridCellCoords( row, col ),
             true,
-            ControlDown, ShiftDown,
-            AltDown, MetaDown );
+            kbd);
         m_grid->GetEventHandler()->ProcessEvent( gridEvt );
     }
 }
 
-void wxGridSelection::ToggleCellSelection( int row, int col,
-                                           bool ControlDown, bool ShiftDown,
-                                           bool AltDown, bool MetaDown )
+void
+wxGridSelection::ToggleCellSelection(int row, int col,
+                                     const wxKeyboardState& kbd)
 {
     // if the cell is not selected, select it
     if ( !IsInSelection ( row, col ) )
     {
-        SelectCell( row, col, ControlDown, ShiftDown, AltDown, MetaDown );
+        SelectCell(row, col, kbd);
 
         return;
     }
@@ -651,8 +636,7 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
                                                 wxGridCellCoords( row, col ),
                                                 wxGridCellCoords( row, col ),
                                                 false,
-                                                ControlDown, ShiftDown,
-                                                AltDown, MetaDown );
+                                                kbd );
                 m_grid->GetEventHandler()->ProcessEvent( gridEvt );
 
                 return;
@@ -701,21 +685,17 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
             if ( m_selectionMode != wxGrid::wxGridSelectColumns )
             {
                 if ( topRow < row )
-                    SelectBlock( topRow, leftCol, row - 1, rightCol,
-                                 false, false, false, false, false );
+                    SelectBlockNoEvent(topRow, leftCol, row - 1, rightCol);
                 if ( bottomRow > row )
-                    SelectBlock( row + 1, leftCol, bottomRow, rightCol,
-                                 false, false, false, false, false );
+                    SelectBlockNoEvent(row + 1, leftCol, bottomRow, rightCol);
             }
 
             if ( m_selectionMode != wxGrid::wxGridSelectRows )
             {
                 if ( leftCol < col )
-                    SelectBlock( row, leftCol, row, col - 1,
-                                 false, false, false, false, false );
+                    SelectBlockNoEvent(row, leftCol, row, col - 1);
                 if ( rightCol > col )
-                    SelectBlock( row, col + 1, row, rightCol,
-                                 false, false, false, false, false );
+                    SelectBlockNoEvent(row, col + 1, row, rightCol);
             }
         }
     }
@@ -735,12 +715,10 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
                 if (m_selectionMode == wxGrid::wxGridSelectCells)
                 {
                     if ( col > 0 )
-                        SelectBlock( row, 0, row, col - 1,
-                                     false, false, false, false, false );
+                        SelectBlockNoEvent(row, 0, row, col - 1);
                     if ( col < m_grid->GetNumberCols() - 1 )
-                        SelectBlock( row, col + 1,
-                                     row, m_grid->GetNumberCols() - 1,
-                                     false, false, false, false, false );
+                        SelectBlockNoEvent( row, col + 1,
+                                     row, m_grid->GetNumberCols() - 1);
                 }
             }
         }
@@ -761,12 +739,10 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
                 if (m_selectionMode == wxGrid::wxGridSelectCells)
                 {
                     if ( row > 0 )
-                        SelectBlock( 0, col, row - 1, col,
-                                     false, false, false, false, false );
+                        SelectBlockNoEvent(0, col, row - 1, col);
                     if ( row < m_grid->GetNumberRows() - 1 )
-                        SelectBlock( row + 1, col,
-                                     m_grid->GetNumberRows() - 1, col,
-                                     false, false, false, false, false );
+                        SelectBlockNoEvent(row + 1, col,
+                                     m_grid->GetNumberRows() - 1, col);
                 }
             }
         }
@@ -793,8 +769,7 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
                 wxGridCellCoords( row, col ),
                 wxGridCellCoords( row, col ),
                 false,
-                ControlDown, ShiftDown,
-                AltDown, MetaDown );
+                kbd );
             m_grid->GetEventHandler()->ProcessEvent( gridEvt );
         }
             break;
@@ -815,8 +790,7 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
                 wxGridCellCoords( row, 0 ),
                 wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ),
                 false,
-                ControlDown, ShiftDown,
-                AltDown, MetaDown );
+                kbd );
             m_grid->GetEventHandler()->ProcessEvent( gridEvt );
         }
             break;
@@ -837,8 +811,7 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
                 wxGridCellCoords( 0, col ),
                 wxGridCellCoords( m_grid->GetNumberRows() - 1, col ),
                 false,
-                ControlDown, ShiftDown,
-                AltDown, MetaDown );
+                kbd );
             m_grid->GetEventHandler()->ProcessEvent( gridEvt );
         }
             break;