From 8b5f6d9d47549e88538e0e6bf734ce4bc30c9093 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 20 Sep 2008 00:09:28 +0000 Subject: [PATCH] use a single wxKeyboardEvent parameter instead of 4 bools in tons of places git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55748 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/grid.h | 194 +++++++++++++++++++++-------------- include/wx/generic/gridsel.h | 64 ++++++------ src/generic/grid.cpp | 166 ++++++++++-------------------- src/generic/gridsel.cpp | 93 ++++++----------- 4 files changed, 233 insertions(+), 284 deletions(-) diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index b9d4935c45..b9700ec2d3 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -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() diff --git a/include/wx/generic/gridsel.h b/include/wx/generic/gridsel.h index f7cefd4e1d..ead1d9256a 100644 --- a/include/wx/generic/gridsel.h +++ b/include/wx/generic/gridsel.h @@ -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; diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 3830a869ee..e8ca4e0102 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -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); } diff --git a/src/generic/gridsel.cpp b/src/generic/gridsel.cpp index d5ba76cbbb..f87c037888 100644 --- a/src/generic/gridsel.cpp +++ b/src/generic/gridsel.cpp @@ -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; -- 2.45.2