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
This commit is contained in:
Vadim Zeitlin
2008-09-20 00:09:28 +00:00
parent ba4d737a9e
commit 8b5f6d9d47
4 changed files with 233 additions and 284 deletions

View File

@@ -2260,35 +2260,44 @@ private:
// Grid event class and event types // Grid event class and event types
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxGridEvent : public wxNotifyEvent class WXDLLIMPEXP_ADV wxGridEvent : public wxNotifyEvent,
public wxKeyboardState
{ {
public: public:
wxGridEvent() wxGridEvent()
: wxNotifyEvent(), m_row(-1), m_col(-1), m_x(-1), m_y(-1), : wxNotifyEvent()
m_selecting(0), m_control(0), m_meta(0), m_shift(0), m_alt(0) {
{ Init(-1, -1, -1, -1, false);
} }
wxGridEvent(int id, wxEventType type, wxObject* obj, wxGridEvent(int id,
int row=-1, int col=-1, int x=-1, int y=-1, bool sel = true, wxEventType type,
bool control = false, bool shift = false, bool alt = false, bool meta = false); 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 GetRow() { return m_row; }
virtual int GetCol() { return m_col; } virtual int GetCol() { return m_col; }
wxPoint GetPosition() { return wxPoint( m_x, m_y ); } wxPoint GetPosition() { return wxPoint( m_x, m_y ); }
bool Selecting() { return m_selecting; } 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); } virtual wxEvent *Clone() const { return new wxGridEvent(*this); }
@@ -2298,41 +2307,57 @@ protected:
int m_x; int m_x;
int m_y; int m_y;
bool m_selecting; bool m_selecting;
bool m_control;
bool m_meta; private:
bool m_shift; void Init(int row, int col, int x, int y, bool sel)
bool m_alt; {
m_row = row;
m_col = col;
m_x = x;
m_y = y;
m_selecting = sel;
}
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEvent) DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEvent)
}; };
class WXDLLIMPEXP_ADV wxGridSizeEvent : public wxNotifyEvent class WXDLLIMPEXP_ADV wxGridSizeEvent : public wxNotifyEvent,
public wxKeyboardState
{ {
public: public:
wxGridSizeEvent() wxGridSizeEvent()
: wxNotifyEvent(), m_rowOrCol(-1), m_x(-1), m_y(-1), : wxNotifyEvent()
m_control(0), m_meta(0), m_shift(0), m_alt(0) {
{ Init(-1, -1, -1);
} }
wxGridSizeEvent(int id, wxEventType type, wxObject* obj, wxGridSizeEvent(int id,
int rowOrCol=-1, int x=-1, int y=-1, wxEventType type,
bool control = false, bool shift = false, bool alt = false, bool meta = false); wxObject* obj,
int rowOrCol = -1,
int x = -1, int y = -1,
const wxKeyboardState& kbd = wxKeyboardState())
: wxNotifyEvent(type, id),
wxKeyboardState(kbd)
{
Init(rowOrCol, x, y);
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; } int GetRowOrCol() { return m_rowOrCol; }
wxPoint GetPosition() { return wxPoint( m_x, m_y ); } 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); } virtual wxEvent *Clone() const { return new wxGridSizeEvent(*this); }
@@ -2340,36 +2365,55 @@ protected:
int m_rowOrCol; int m_rowOrCol;
int m_x; int m_x;
int m_y; int m_y;
bool m_control;
bool m_meta; private:
bool m_shift; void Init(int rowOrCol, int x, int y)
bool m_alt; {
m_rowOrCol = rowOrCol;
m_x = x;
m_y = y;
}
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridSizeEvent) DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridSizeEvent)
}; };
class WXDLLIMPEXP_ADV wxGridRangeSelectEvent : public wxNotifyEvent class WXDLLIMPEXP_ADV wxGridRangeSelectEvent : public wxNotifyEvent,
public wxKeyboardState
{ {
public: public:
wxGridRangeSelectEvent() wxGridRangeSelectEvent()
: wxNotifyEvent() : wxNotifyEvent()
{ {
m_topLeft = wxGridNoCellCoords; Init(wxGridNoCellCoords, wxGridNoCellCoords, false);
m_bottomRight = wxGridNoCellCoords; }
m_selecting = false;
m_control = false;
m_meta = false;
m_shift = false;
m_alt = false;
}
wxGridRangeSelectEvent(int id, wxEventType type, wxObject* obj, wxGridRangeSelectEvent(int id,
wxEventType type,
wxObject* obj,
const wxGridCellCoords& topLeft, const wxGridCellCoords& topLeft,
const wxGridCellCoords& bottomRight, const wxGridCellCoords& bottomRight,
bool sel = true, bool sel = true,
bool control = false, bool shift = false, const wxKeyboardState& kbd = wxKeyboardState())
bool alt = false, bool meta = false); : 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 GetTopLeftCoords() { return m_topLeft; }
wxGridCellCoords GetBottomRightCoords() { return m_bottomRight; } wxGridCellCoords GetBottomRightCoords() { return m_bottomRight; }
@@ -2378,35 +2422,29 @@ public:
int GetLeftCol() { return m_topLeft.GetCol(); } int GetLeftCol() { return m_topLeft.GetCol(); }
int GetRightCol() { return m_bottomRight.GetCol(); } int GetRightCol() { return m_bottomRight.GetCol(); }
bool Selecting() { return m_selecting; } 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); } virtual wxEvent *Clone() const { return new wxGridRangeSelectEvent(*this); }
protected: 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_topLeft;
wxGridCellCoords m_bottomRight; wxGridCellCoords m_bottomRight;
bool m_selecting; bool m_selecting;
bool m_control;
bool m_meta;
bool m_shift;
bool m_alt;
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridRangeSelectEvent) DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridRangeSelectEvent)
}; };
class WXDLLIMPEXP_ADV wxGridEditorCreatedEvent : public wxCommandEvent { class WXDLLIMPEXP_ADV wxGridEditorCreatedEvent : public wxCommandEvent
{
public: public:
wxGridEditorCreatedEvent() wxGridEditorCreatedEvent()
: wxCommandEvent() : wxCommandEvent()

View File

@@ -33,45 +33,38 @@ public:
void SetSelectionMode(wxGrid::wxGridSelectionModes selmode); void SetSelectionMode(wxGrid::wxGridSelectionModes selmode);
wxGrid::wxGridSelectionModes GetSelectionMode() { return m_selectionMode; } wxGrid::wxGridSelectionModes GetSelectionMode() { return m_selectionMode; }
void SelectRow( int row, void SelectRow(int row, const wxKeyboardState& kbd = wxKeyboardState());
bool ControlDown = false, bool ShiftDown = false, void SelectCol(int col, const wxKeyboardState& kbd = wxKeyboardState());
bool AltDown = false, bool MetaDown = false ); void SelectBlock(int topRow, int leftCol,
void SelectCol( int col, int bottomRow, int rightCol,
bool ControlDown = false, bool ShiftDown = false, const wxKeyboardState& kbd = wxKeyboardState(),
bool AltDown = false, bool MetaDown = false ); bool sendEvent = true );
void SelectBlock( int topRow, int leftCol, void SelectBlock(const wxGridCellCoords& topLeft,
int bottomRow, int rightCol, const wxGridCellCoords& bottomRight,
bool ControlDown = false, bool ShiftDown = false, const wxKeyboardState& kbd = wxKeyboardState(),
bool AltDown = false, bool MetaDown = false, bool sendEvent = true )
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 )
{ {
SelectBlock(topLeft.GetRow(), topLeft.GetCol(), SelectBlock(topLeft.GetRow(), topLeft.GetCol(),
bottomRight.GetRow(), bottomRight.GetCol(), bottomRight.GetRow(), bottomRight.GetCol(),
ControlDown, ShiftDown, AltDown, MetaDown, kbd, sendEvent);
sendEvent);
} }
void SelectCell( int row, int col, void SelectCell(int row, int col,
bool ControlDown = false, bool ShiftDown = false, const wxKeyboardState& kbd = wxKeyboardState(),
bool AltDown = false, bool MetaDown = false, bool sendEvent = true);
bool sendEvent = true ); void SelectCell(const wxGridCellCoords& coords,
const wxKeyboardState& kbd = wxKeyboardState(),
void ToggleCellSelection( int row, int col, bool sendEvent = true)
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 )
{ {
ToggleCellSelection(coords.GetRow(), coords.GetCol(), SelectCell(coords.GetRow(), coords.GetCol(), kbd, sendEvent);
ControlDown, ShiftDown, AltDown, MetaDown); }
void ToggleCellSelection(int row, int col,
const wxKeyboardState& kbd = wxKeyboardState());
void ToggleCellSelection(const wxGridCellCoords& coords,
const wxKeyboardState& kbd = wxKeyboardState())
{
ToggleCellSelection(coords.GetRow(), coords.GetCol(), kbd);
} }
void ClearSelection(); void ClearSelection();
@@ -98,6 +91,13 @@ private:
leftCol <= col && col <= rightCol ); 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_cellSelection;
wxGridCellCoordsArray m_blockSelectionTopLeft; wxGridCellCoordsArray m_blockSelectionTopLeft;
wxGridCellCoordsArray m_blockSelectionBottomRight; wxGridCellCoordsArray m_blockSelectionBottomRight;

View File

@@ -5621,13 +5621,7 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
if ( (row = YToRow( y )) >= 0 ) if ( (row = YToRow( y )) >= 0 )
{ {
if ( m_selection ) if ( m_selection )
{ m_selection->SelectRow(row, event);
m_selection->SelectRow( row,
event.ControlDown(),
event.ShiftDown(),
event.AltDown(),
event.MetaDown() );
}
} }
} }
break; break;
@@ -5678,22 +5672,16 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
{ {
if ( event.ShiftDown() ) if ( event.ShiftDown() )
{ {
m_selection->SelectBlock( m_currentCellCoords.GetRow(), m_selection->SelectBlock
0, (
row, m_currentCellCoords.GetRow(), 0,
GetNumberCols() - 1, row, GetNumberCols() - 1,
event.ControlDown(), event
event.ShiftDown(), );
event.AltDown(),
event.MetaDown() );
} }
else else
{ {
m_selection->SelectRow( row, m_selection->SelectRow(row, event);
event.ControlDown(),
event.ShiftDown(),
event.AltDown(),
event.MetaDown() );
} }
} }
@@ -5842,13 +5830,7 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
if ( (col = XToCol( x )) >= 0 ) if ( (col = XToCol( x )) >= 0 )
{ {
if ( m_selection ) if ( m_selection )
{ m_selection->SelectCol(col, event);
m_selection->SelectCol( col,
event.ControlDown(),
event.ShiftDown(),
event.AltDown(),
event.MetaDown() );
}
} }
} }
break; break;
@@ -5979,21 +5961,16 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
{ {
if ( event.ShiftDown() ) if ( event.ShiftDown() )
{ {
m_selection->SelectBlock( 0, m_selection->SelectBlock
m_currentCellCoords.GetCol(), (
GetNumberRows() - 1, col, 0, m_currentCellCoords.GetCol(),
event.ControlDown(), GetNumberRows() - 1, col,
event.ShiftDown(), event
event.AltDown(), );
event.MetaDown() );
} }
else else
{ {
m_selection->SelectCol( col, m_selection->SelectCol(col, event);
event.ControlDown(),
event.ShiftDown(),
event.AltDown(),
event.MetaDown() );
} }
} }
@@ -6373,12 +6350,7 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
{ {
if ( m_selection ) if ( m_selection )
{ {
m_selection->SelectBlock( m_currentCellCoords, m_selection->SelectBlock(m_currentCellCoords, coords, event);
coords,
event.ControlDown(),
event.ShiftDown(),
event.AltDown(),
event.MetaDown() );
m_selectedBlockCorner = coords; m_selectedBlockCorner = coords;
} }
} }
@@ -6391,12 +6363,9 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
{ {
if ( m_selection ) if ( m_selection )
{ {
m_selection->ToggleCellSelection( coords, m_selection->ToggleCellSelection(coords, event);
event.ControlDown(),
event.ShiftDown(),
event.AltDown(),
event.MetaDown() );
} }
m_selectedBlockTopLeft = wxGridNoCellCoords; m_selectedBlockTopLeft = wxGridNoCellCoords;
m_selectedBlockBottomRight = wxGridNoCellCoords; m_selectedBlockBottomRight = wxGridNoCellCoords;
m_selectedBlockCorner = coords; m_selectedBlockCorner = coords;
@@ -6458,10 +6427,7 @@ wxGrid::DoGridCellLeftUp(wxMouseEvent& event, const wxGridCellCoords& coords)
{ {
m_selection->SelectBlock( m_selectedBlockTopLeft, m_selection->SelectBlock( m_selectedBlockTopLeft,
m_selectedBlockBottomRight, m_selectedBlockBottomRight,
event.ControlDown(), event );
event.ShiftDown(),
event.AltDown(),
event.MetaDown() );
} }
m_selectedBlockTopLeft = wxGridNoCellCoords; m_selectedBlockTopLeft = wxGridNoCellCoords;
@@ -6927,10 +6893,7 @@ wxGrid::SendEvent(const wxEventType type,
rowOrCol, rowOrCol,
mouseEv.GetX() + GetRowLabelSize(), mouseEv.GetX() + GetRowLabelSize(),
mouseEv.GetY() + GetColLabelSize(), mouseEv.GetY() + GetColLabelSize(),
mouseEv.ControlDown(), mouseEv);
mouseEv.ShiftDown(),
mouseEv.AltDown(),
mouseEv.MetaDown() );
claimed = GetEventHandler()->ProcessEvent(gridEvt); claimed = GetEventHandler()->ProcessEvent(gridEvt);
vetoed = !gridEvt.IsAllowed(); vetoed = !gridEvt.IsAllowed();
@@ -6944,10 +6907,7 @@ wxGrid::SendEvent(const wxEventType type,
m_selectedBlockTopLeft, m_selectedBlockTopLeft,
m_selectedBlockBottomRight, m_selectedBlockBottomRight,
true, true,
mouseEv.ControlDown(), mouseEv);
mouseEv.ShiftDown(),
mouseEv.AltDown(),
mouseEv.MetaDown() );
claimed = GetEventHandler()->ProcessEvent(gridEvt); claimed = GetEventHandler()->ProcessEvent(gridEvt);
vetoed = !gridEvt.IsAllowed(); vetoed = !gridEvt.IsAllowed();
@@ -6971,10 +6931,7 @@ wxGrid::SendEvent(const wxEventType type,
pos.x, pos.x,
pos.y, pos.y,
false, false,
mouseEv.ControlDown(), mouseEv);
mouseEv.ShiftDown(),
mouseEv.AltDown(),
mouseEv.MetaDown() );
claimed = GetEventHandler()->ProcessEvent(gridEvt); claimed = GetEventHandler()->ProcessEvent(gridEvt);
vetoed = !gridEvt.IsAllowed(); vetoed = !gridEvt.IsAllowed();
} }
@@ -6987,10 +6944,7 @@ wxGrid::SendEvent(const wxEventType type,
mouseEv.GetX() + GetRowLabelSize(), mouseEv.GetX() + GetRowLabelSize(),
mouseEv.GetY() + GetColLabelSize(), mouseEv.GetY() + GetColLabelSize(),
false, false,
mouseEv.ControlDown(), mouseEv);
mouseEv.ShiftDown(),
mouseEv.AltDown(),
mouseEv.MetaDown() );
claimed = GetEventHandler()->ProcessEvent(gridEvt); claimed = GetEventHandler()->ProcessEvent(gridEvt);
vetoed = !gridEvt.IsAllowed(); vetoed = !gridEvt.IsAllowed();
} }
@@ -7328,10 +7282,7 @@ void wxGrid::OnKeyUp( wxKeyEvent& event )
m_selection->SelectBlock( m_selection->SelectBlock(
m_selectedBlockTopLeft, m_selectedBlockTopLeft,
m_selectedBlockBottomRight, m_selectedBlockBottomRight,
event.ControlDown(), event);
true,
event.AltDown(),
event.MetaDown() );
} }
} }
@@ -10668,31 +10619,36 @@ void wxGrid::SetCellValue( int row, int col, const wxString& s )
void wxGrid::SelectRow( int row, bool addToSelected ) void wxGrid::SelectRow( int row, bool addToSelected )
{ {
if ( IsSelection() && !addToSelected ) if ( !m_selection )
return;
if ( !addToSelected )
ClearSelection(); ClearSelection();
if ( m_selection ) m_selection->SelectRow(row);
m_selection->SelectRow( row, false, addToSelected );
} }
void wxGrid::SelectCol( int col, bool addToSelected ) void wxGrid::SelectCol( int col, bool addToSelected )
{ {
if ( IsSelection() && !addToSelected ) if ( !m_selection )
return;
if ( !addToSelected )
ClearSelection(); ClearSelection();
if ( m_selection ) m_selection->SelectCol(col);
m_selection->SelectCol( col, false, addToSelected );
} }
void wxGrid::SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol, void wxGrid::SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol,
bool addToSelected ) bool addToSelected)
{ {
if ( IsSelection() && !addToSelected ) if ( !m_selection )
return;
if ( !addToSelected )
ClearSelection(); ClearSelection();
if ( m_selection ) m_selection->SelectBlock(topRow, leftCol, bottomRow, rightCol);
m_selection->SelectBlock( topRow, leftCol, bottomRow, rightCol,
false, addToSelected );
} }
void wxGrid::SelectAll() void wxGrid::SelectAll()
@@ -10988,36 +10944,23 @@ IMPLEMENT_DYNAMIC_CLASS( wxGridEvent, wxNotifyEvent )
wxGridEvent::wxGridEvent( int id, wxEventType type, wxObject* obj, wxGridEvent::wxGridEvent( int id, wxEventType type, wxObject* obj,
int row, int col, int x, int y, bool sel, int row, int col, int x, int y, bool sel,
bool control, bool shift, bool alt, bool meta ) bool control, bool shift, bool alt, bool meta )
: wxNotifyEvent( type, id ) : wxNotifyEvent( type, id ),
wxKeyboardState(control, shift, alt, meta)
{ {
m_row = row; Init(row, col, x, y, sel);
m_col = col;
m_x = x;
m_y = y;
m_selecting = sel;
m_control = control;
m_shift = shift;
m_alt = alt;
m_meta = meta;
SetEventObject(obj); SetEventObject(obj);
} }
IMPLEMENT_DYNAMIC_CLASS( wxGridSizeEvent, wxNotifyEvent ) IMPLEMENT_DYNAMIC_CLASS( wxGridSizeEvent, wxNotifyEvent )
wxGridSizeEvent::wxGridSizeEvent( int id, wxEventType type, wxObject* obj, wxGridSizeEvent::wxGridSizeEvent( int id, wxEventType type, wxObject* obj,
int rowOrCol, int x, int y, int rowOrCol, int x, int y,
bool control, bool shift, bool alt, bool meta ) bool control, bool shift, bool alt, bool meta )
: wxNotifyEvent( type, id ) : wxNotifyEvent( type, id ),
wxKeyboardState(control, shift, alt, meta)
{ {
m_rowOrCol = rowOrCol; Init(rowOrCol, x, y);
m_x = x;
m_y = y;
m_control = control;
m_shift = shift;
m_alt = alt;
m_meta = meta;
SetEventObject(obj); SetEventObject(obj);
} }
@@ -11030,15 +10973,10 @@ wxGridRangeSelectEvent::wxGridRangeSelectEvent(int id, wxEventType type, wxObjec
const wxGridCellCoords& bottomRight, const wxGridCellCoords& bottomRight,
bool sel, bool control, bool sel, bool control,
bool shift, bool alt, bool meta ) bool shift, bool alt, bool meta )
: wxNotifyEvent( type, id ) : wxNotifyEvent( type, id ),
wxKeyboardState(control, shift, alt, meta)
{ {
m_topLeft = topLeft; Init(topLeft, bottomRight, sel);
m_bottomRight = bottomRight;
m_selecting = sel;
m_control = control;
m_shift = shift;
m_alt = alt;
m_meta = meta;
SetEventObject(obj); SetEventObject(obj);
} }

View File

@@ -160,9 +160,8 @@ void wxGridSelection::SetSelectionMode( wxGrid::wxGridSelectionModes selmode )
{ {
m_blockSelectionTopLeft.RemoveAt(n); m_blockSelectionTopLeft.RemoveAt(n);
m_blockSelectionBottomRight.RemoveAt(n); m_blockSelectionBottomRight.RemoveAt(n);
SelectBlock( topRow, 0, SelectBlockNoEvent( topRow, 0,
bottomRow, m_grid->GetNumberCols() - 1, bottomRow, m_grid->GetNumberCols() - 1);
false, false, false, false, false );
} }
} }
else // selmode == wxGridSelectColumns) else // selmode == wxGridSelectColumns)
@@ -171,9 +170,8 @@ void wxGridSelection::SetSelectionMode( wxGrid::wxGridSelectionModes selmode )
{ {
m_blockSelectionTopLeft.RemoveAt(n); m_blockSelectionTopLeft.RemoveAt(n);
m_blockSelectionBottomRight.RemoveAt(n); m_blockSelectionBottomRight.RemoveAt(n);
SelectBlock( 0, leftCol, SelectBlockNoEvent(0, leftCol,
m_grid->GetNumberRows() - 1, rightCol, m_grid->GetNumberRows() - 1, rightCol);
false, false, false, false, false );
} }
} }
} }
@@ -182,9 +180,7 @@ void wxGridSelection::SetSelectionMode( wxGrid::wxGridSelectionModes selmode )
} }
} }
void wxGridSelection::SelectRow( int row, void wxGridSelection::SelectRow(int row, const wxKeyboardState& kbd)
bool ControlDown, bool ShiftDown,
bool AltDown, bool MetaDown )
{ {
if ( m_selectionMode == wxGrid::wxGridSelectColumns ) if ( m_selectionMode == wxGrid::wxGridSelectColumns )
return; return;
@@ -275,15 +271,12 @@ void wxGridSelection::SelectRow( int row,
wxGridCellCoords( row, 0 ), wxGridCellCoords( row, 0 ),
wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ), wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ),
true, true,
ControlDown, ShiftDown, kbd);
AltDown, MetaDown );
m_grid->GetEventHandler()->ProcessEvent( gridEvt ); m_grid->GetEventHandler()->ProcessEvent( gridEvt );
} }
void wxGridSelection::SelectCol( int col, void wxGridSelection::SelectCol(int col, const wxKeyboardState& kbd)
bool ControlDown, bool ShiftDown,
bool AltDown, bool MetaDown )
{ {
if ( m_selectionMode == wxGrid::wxGridSelectRows ) if ( m_selectionMode == wxGrid::wxGridSelectRows )
return; return;
@@ -372,16 +365,14 @@ void wxGridSelection::SelectCol( int col,
wxGridCellCoords( 0, col ), wxGridCellCoords( 0, col ),
wxGridCellCoords( m_grid->GetNumberRows() - 1, col ), wxGridCellCoords( m_grid->GetNumberRows() - 1, col ),
true, true,
ControlDown, ShiftDown, kbd );
AltDown, MetaDown );
m_grid->GetEventHandler()->ProcessEvent( gridEvt ); m_grid->GetEventHandler()->ProcessEvent( gridEvt );
} }
void wxGridSelection::SelectBlock( int topRow, int leftCol, void wxGridSelection::SelectBlock( int topRow, int leftCol,
int bottomRow, int rightCol, int bottomRow, int rightCol,
bool ControlDown, bool ShiftDown, const wxKeyboardState& kbd,
bool AltDown, bool MetaDown,
bool sendEvent ) bool sendEvent )
{ {
// Fix the coordinates of the block if needed. // Fix the coordinates of the block if needed.
@@ -432,8 +423,7 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol,
if ( m_selectionMode == wxGrid::wxGridSelectCells && if ( m_selectionMode == wxGrid::wxGridSelectCells &&
topRow == bottomRow && leftCol == rightCol ) topRow == bottomRow && leftCol == rightCol )
{ {
SelectCell( topRow, leftCol, ControlDown, ShiftDown, SelectCell( topRow, leftCol, kbd, sendEvent );
AltDown, MetaDown, sendEvent );
} }
size_t count, n; size_t count, n;
@@ -553,28 +543,24 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol,
wxGridCellCoords( topRow, leftCol ), wxGridCellCoords( topRow, leftCol ),
wxGridCellCoords( bottomRow, rightCol ), wxGridCellCoords( bottomRow, rightCol ),
true, true,
ControlDown, ShiftDown, kbd);
AltDown, MetaDown );
m_grid->GetEventHandler()->ProcessEvent( gridEvt ); m_grid->GetEventHandler()->ProcessEvent( gridEvt );
} }
} }
void wxGridSelection::SelectCell( int row, int col, void wxGridSelection::SelectCell( int row, int col,
bool ControlDown, bool ShiftDown, const wxKeyboardState& kbd,
bool AltDown, bool MetaDown,
bool sendEvent ) bool sendEvent )
{ {
if ( m_selectionMode == wxGrid::wxGridSelectRows ) if ( m_selectionMode == wxGrid::wxGridSelectRows )
{ {
SelectBlock(row, 0, row, m_grid->GetNumberCols() - 1, SelectBlock(row, 0, row, m_grid->GetNumberCols() - 1, kbd, sendEvent);
ControlDown, ShiftDown, AltDown, MetaDown, sendEvent);
return; return;
} }
else if ( m_selectionMode == wxGrid::wxGridSelectColumns ) else if ( m_selectionMode == wxGrid::wxGridSelectColumns )
{ {
SelectBlock(0, col, m_grid->GetNumberRows() - 1, col, SelectBlock(0, col, m_grid->GetNumberRows() - 1, col, kbd, sendEvent);
ControlDown, ShiftDown, AltDown, MetaDown, sendEvent);
return; return;
} }
@@ -601,20 +587,19 @@ void wxGridSelection::SelectCell( int row, int col,
wxGridCellCoords( row, col ), wxGridCellCoords( row, col ),
wxGridCellCoords( row, col ), wxGridCellCoords( row, col ),
true, true,
ControlDown, ShiftDown, kbd);
AltDown, MetaDown );
m_grid->GetEventHandler()->ProcessEvent( gridEvt ); m_grid->GetEventHandler()->ProcessEvent( gridEvt );
} }
} }
void wxGridSelection::ToggleCellSelection( int row, int col, void
bool ControlDown, bool ShiftDown, wxGridSelection::ToggleCellSelection(int row, int col,
bool AltDown, bool MetaDown ) const wxKeyboardState& kbd)
{ {
// if the cell is not selected, select it // if the cell is not selected, select it
if ( !IsInSelection ( row, col ) ) if ( !IsInSelection ( row, col ) )
{ {
SelectCell( row, col, ControlDown, ShiftDown, AltDown, MetaDown ); SelectCell(row, col, kbd);
return; return;
} }
@@ -651,8 +636,7 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
wxGridCellCoords( row, col ), wxGridCellCoords( row, col ),
wxGridCellCoords( row, col ), wxGridCellCoords( row, col ),
false, false,
ControlDown, ShiftDown, kbd );
AltDown, MetaDown );
m_grid->GetEventHandler()->ProcessEvent( gridEvt ); m_grid->GetEventHandler()->ProcessEvent( gridEvt );
return; return;
@@ -701,21 +685,17 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
if ( m_selectionMode != wxGrid::wxGridSelectColumns ) if ( m_selectionMode != wxGrid::wxGridSelectColumns )
{ {
if ( topRow < row ) if ( topRow < row )
SelectBlock( topRow, leftCol, row - 1, rightCol, SelectBlockNoEvent(topRow, leftCol, row - 1, rightCol);
false, false, false, false, false );
if ( bottomRow > row ) if ( bottomRow > row )
SelectBlock( row + 1, leftCol, bottomRow, rightCol, SelectBlockNoEvent(row + 1, leftCol, bottomRow, rightCol);
false, false, false, false, false );
} }
if ( m_selectionMode != wxGrid::wxGridSelectRows ) if ( m_selectionMode != wxGrid::wxGridSelectRows )
{ {
if ( leftCol < col ) if ( leftCol < col )
SelectBlock( row, leftCol, row, col - 1, SelectBlockNoEvent(row, leftCol, row, col - 1);
false, false, false, false, false );
if ( rightCol > col ) if ( rightCol > col )
SelectBlock( row, col + 1, row, rightCol, SelectBlockNoEvent(row, col + 1, row, rightCol);
false, false, false, false, false );
} }
} }
} }
@@ -735,12 +715,10 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
if (m_selectionMode == wxGrid::wxGridSelectCells) if (m_selectionMode == wxGrid::wxGridSelectCells)
{ {
if ( col > 0 ) if ( col > 0 )
SelectBlock( row, 0, row, col - 1, SelectBlockNoEvent(row, 0, row, col - 1);
false, false, false, false, false );
if ( col < m_grid->GetNumberCols() - 1 ) if ( col < m_grid->GetNumberCols() - 1 )
SelectBlock( row, col + 1, SelectBlockNoEvent( row, col + 1,
row, m_grid->GetNumberCols() - 1, row, m_grid->GetNumberCols() - 1);
false, false, false, false, false );
} }
} }
} }
@@ -761,12 +739,10 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
if (m_selectionMode == wxGrid::wxGridSelectCells) if (m_selectionMode == wxGrid::wxGridSelectCells)
{ {
if ( row > 0 ) if ( row > 0 )
SelectBlock( 0, col, row - 1, col, SelectBlockNoEvent(0, col, row - 1, col);
false, false, false, false, false );
if ( row < m_grid->GetNumberRows() - 1 ) if ( row < m_grid->GetNumberRows() - 1 )
SelectBlock( row + 1, col, SelectBlockNoEvent(row + 1, col,
m_grid->GetNumberRows() - 1, col, m_grid->GetNumberRows() - 1, col);
false, false, false, false, false );
} }
} }
} }
@@ -793,8 +769,7 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
wxGridCellCoords( row, col ), wxGridCellCoords( row, col ),
wxGridCellCoords( row, col ), wxGridCellCoords( row, col ),
false, false,
ControlDown, ShiftDown, kbd );
AltDown, MetaDown );
m_grid->GetEventHandler()->ProcessEvent( gridEvt ); m_grid->GetEventHandler()->ProcessEvent( gridEvt );
} }
break; break;
@@ -815,8 +790,7 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
wxGridCellCoords( row, 0 ), wxGridCellCoords( row, 0 ),
wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ), wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ),
false, false,
ControlDown, ShiftDown, kbd );
AltDown, MetaDown );
m_grid->GetEventHandler()->ProcessEvent( gridEvt ); m_grid->GetEventHandler()->ProcessEvent( gridEvt );
} }
break; break;
@@ -837,8 +811,7 @@ void wxGridSelection::ToggleCellSelection( int row, int col,
wxGridCellCoords( 0, col ), wxGridCellCoords( 0, col ),
wxGridCellCoords( m_grid->GetNumberRows() - 1, col ), wxGridCellCoords( m_grid->GetNumberRows() - 1, col ),
false, false,
ControlDown, ShiftDown, kbd );
AltDown, MetaDown );
m_grid->GetEventHandler()->ProcessEvent( gridEvt ); m_grid->GetEventHandler()->ProcessEvent( gridEvt );
} }
break; break;