Merge branch 'grid-selected'

Split the wxGrid RANGE_SELECT event into separate SELECTING and SELECTED
events.

See https://github.com/wxWidgets/wxWidgets/pull/2028
This commit is contained in:
Vadim Zeitlin 2020-08-31 14:55:56 +02:00
commit be2a61519b
9 changed files with 178 additions and 57 deletions

View File

@ -3405,7 +3405,8 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_LABEL_RIGHT_DCLICK, wxGri
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_ROW_SIZE, wxGridSizeEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_COL_SIZE, wxGridSizeEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_COL_AUTO_SIZE, wxGridSizeEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_RANGE_SELECT, wxGridRangeSelectEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_RANGE_SELECTING, wxGridRangeSelectEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_RANGE_SELECTED, wxGridRangeSelectEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_CELL_CHANGING, wxGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_CELL_CHANGED, wxGridEvent );
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_GRID_SELECT_CELL, wxGridEvent );
@ -3459,7 +3460,8 @@ typedef void (wxEvtHandler::*wxGridEditorCreatedEventFunction)(wxGridEditorCreat
#define EVT_GRID_CMD_COL_AUTO_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(COL_AUTO_SIZE, id, fn)
#define EVT_GRID_CMD_COL_MOVE(id, fn) wx__DECLARE_GRIDEVT(COL_MOVE, id, fn)
#define EVT_GRID_CMD_COL_SORT(id, fn) wx__DECLARE_GRIDEVT(COL_SORT, id, fn)
#define EVT_GRID_CMD_RANGE_SELECT(id, fn) wx__DECLARE_GRIDRANGESELEVT(RANGE_SELECT, id, fn)
#define EVT_GRID_CMD_RANGE_SELECTING(id, fn) wx__DECLARE_GRIDRANGESELEVT(RANGE_SELECTING, id, fn)
#define EVT_GRID_CMD_RANGE_SELECTED(id, fn) wx__DECLARE_GRIDRANGESELEVT(RANGE_SELECTED, id, fn)
#define EVT_GRID_CMD_CELL_CHANGING(id, fn) wx__DECLARE_GRIDEVT(CELL_CHANGING, id, fn)
#define EVT_GRID_CMD_CELL_CHANGED(id, fn) wx__DECLARE_GRIDEVT(CELL_CHANGED, id, fn)
#define EVT_GRID_CMD_SELECT_CELL(id, fn) wx__DECLARE_GRIDEVT(SELECT_CELL, id, fn)
@ -3484,7 +3486,8 @@ typedef void (wxEvtHandler::*wxGridEditorCreatedEventFunction)(wxGridEditorCreat
#define EVT_GRID_COL_AUTO_SIZE(fn) EVT_GRID_CMD_COL_AUTO_SIZE(wxID_ANY, fn)
#define EVT_GRID_COL_MOVE(fn) EVT_GRID_CMD_COL_MOVE(wxID_ANY, fn)
#define EVT_GRID_COL_SORT(fn) EVT_GRID_CMD_COL_SORT(wxID_ANY, fn)
#define EVT_GRID_RANGE_SELECT(fn) EVT_GRID_CMD_RANGE_SELECT(wxID_ANY, fn)
#define EVT_GRID_RANGE_SELECTING(fn) EVT_GRID_CMD_RANGE_SELECTING(wxID_ANY, fn)
#define EVT_GRID_RANGE_SELECTED(fn) EVT_GRID_CMD_RANGE_SELECTED(wxID_ANY, fn)
#define EVT_GRID_CELL_CHANGING(fn) EVT_GRID_CMD_CELL_CHANGING(wxID_ANY, fn)
#define EVT_GRID_CELL_CHANGED(fn) EVT_GRID_CMD_CELL_CHANGED(wxID_ANY, fn)
#define EVT_GRID_SELECT_CELL(fn) EVT_GRID_CMD_SELECT_CELL(wxID_ANY, fn)
@ -3505,6 +3508,15 @@ typedef void (wxEvtHandler::*wxGridEditorCreatedEventFunction)(wxGridEditorCreat
#define EVT_GRID_CELL_CHANGE EVT_GRID_CELL_CHANGED
#endif // WXWIN_COMPATIBILITY_2_8
// same as above: RANGE_SELECT was split in RANGE_SELECTING and SELECTED in 3.2,
// but we keep the old name for compatibility
#if WXWIN_COMPATIBILITY_3_0
#define wxEVT_GRID_RANGE_SELECT wxEVT_GRID_RANGE_SELECTED
#define EVT_GRID_RANGE_SELECT EVT_GRID_RANGE_SELECTED
#endif // WXWIN_COMPATIBILITY_3_0
#if 0 // TODO: implement these ? others ?
extern const int wxEVT_GRID_CREATE_CELL;

View File

@ -21,6 +21,8 @@
typedef wxVector<wxGridBlockCoords> wxVectorGridBlockCoords;
// Note: for all eventType arguments of the methods of this class wxEVT_NULL
// may be passed to forbid events generation completely.
class WXDLLIMPEXP_CORE wxGridSelection
{
public:
@ -41,15 +43,15 @@ public:
void SelectBlock(int topRow, int leftCol,
int bottomRow, int rightCol,
const wxKeyboardState& kbd = wxKeyboardState(),
bool sendEvent = true );
wxEventType eventType = wxEVT_GRID_RANGE_SELECTED);
void SelectBlock(const wxGridCellCoords& topLeft,
const wxGridCellCoords& bottomRight,
const wxKeyboardState& kbd = wxKeyboardState(),
bool sendEvent = true )
wxEventType eventType = wxEVT_GRID_RANGE_SELECTED)
{
SelectBlock(topLeft.GetRow(), topLeft.GetCol(),
bottomRight.GetRow(), bottomRight.GetCol(),
kbd, sendEvent);
kbd, eventType);
}
// This function replaces all the existing selected blocks (which become
@ -58,7 +60,7 @@ public:
void DeselectBlock(const wxGridBlockCoords& block,
const wxKeyboardState& kbd = wxKeyboardState(),
bool sendEvent = true );
wxEventType eventType = wxEVT_GRID_RANGE_SELECTED);
// Note that this method refreshes the previously selected blocks and sends
// an event about the selection change.
@ -82,10 +84,16 @@ public:
//
// Both components of both blockStart and blockEnd must be valid.
//
// This function sends an event notifying about the selection change using
// the provided event type, which is wxEVT_GRID_RANGE_SELECTED by default,
// but may also be wxEVT_GRID_RANGE_SELECTING, when the selection is not
// final yet.
//
// Return true if the current block was actually changed.
bool ExtendCurrentBlock(const wxGridCellCoords& blockStart,
const wxGridCellCoords& blockEnd,
const wxKeyboardState& kbd);
const wxKeyboardState& kbd,
wxEventType eventType = wxEVT_GRID_RANGE_SELECTED);
// Return the coordinates of the cell from which the selection should
@ -103,6 +111,8 @@ public:
wxVectorGridBlockCoords& GetBlocks() { return m_selection; }
void EndSelecting();
private:
void SelectBlockNoEvent(const wxGridBlockCoords& block)
{
@ -113,7 +123,8 @@ private:
// Really select the block and don't check for the current selection mode.
void Select(const wxGridBlockCoords& block,
const wxKeyboardState& kbd, bool sendEvent);
const wxKeyboardState& kbd,
wxEventType eventType);
// Ensure that the new "block" becomes part of "blocks", adding it to them
// if necessary and, if we do it, also removing any existing elements of

View File

@ -19,6 +19,7 @@
class WXDLLIMPEXP_CORE wxKeyboardState
{
public:
explicit
wxKeyboardState(bool controlDown = false,
bool shiftDown = false,
bool altDown = false,

View File

@ -6345,13 +6345,41 @@ public:
/**
@class wxGridRangeSelectEvent
Events of this class notify about a range of cells being selected.
When the user uses the mouse for selection, one or more @c SELECTING events
are generated first, with @c SELECTED event generated at the end, when
selection is final. This allows the application to handle either the @c
SELECTING events if it needs to update its state in real-time, as the
selection changes, or just the final @c SELECTED event, if updating its
state on every selection change would be too time-consuming.
Note that if the user performs the selection from keyboard, @c SELECTING
events are not generated at all, so @c SELECTED event still must be
handled.
Finally, contrary to most of the other events with the name ending in
"ing", @c SELECTING event can @e not be vetoed.
@beginEventTable{wxGridRangeSelectEvent}
@event{EVT_GRID_RANGE_SELECT(func)}
@event{EVT_GRID_RANGE_SELECTING(func)}
The user is selecting a group of contiguous cells. Processes a
@c wxEVT_GRID_RANGE_SELECTING event type.
This event is available in wxWidgets 3.1.5 and later only.
@event{EVT_GRID_CMD_RANGE_SELECTING(id, func)}
The user is selecting a group of contiguous cells; variant taking a window
identifier. Processes a @c wxEVT_GRID_RANGE_SELECTING event type.
This event is available in wxWidgets 3.1.5 and later only.
@event{EVT_GRID_RANGE_SELECTED(func)}
The user selected a group of contiguous cells. Processes a
@c wxEVT_GRID_RANGE_SELECT event type.
@event{EVT_GRID_CMD_RANGE_SELECT(id, func)}
@c wxEVT_GRID_RANGE_SELECTED event type.
This event is available in wxWidgets 3.1.5 and later only and was
called @c wxEVT_GRID_RANGE_SELECT in the previous versions.
@event{EVT_GRID_CMD_RANGE_SELECTED(id, func)}
The user selected a group of contiguous cells; variant taking a window
identifier. Processes a @c wxEVT_GRID_RANGE_SELECT event type.
identifier. Processes a @c wxEVT_GRID_RANGE_SELECTED event type.
This event is available in wxWidgets 3.1.5 and later only and was
called @c wxEVT_GRID_RANGE_SELECT in the previous versions.
@endEventTable
@library{wxcore}
@ -6526,7 +6554,8 @@ wxEventType wxEVT_GRID_LABEL_RIGHT_DCLICK;
wxEventType wxEVT_GRID_ROW_SIZE;
wxEventType wxEVT_GRID_COL_SIZE;
wxEventType wxEVT_GRID_COL_AUTO_SIZE;
wxEventType wxEVT_GRID_RANGE_SELECT;
wxEventType wxEVT_GRID_RANGE_SELECTING;
wxEventType wxEVT_GRID_RANGE_SELECTED;
wxEventType wxEVT_GRID_CELL_CHANGING;
wxEventType wxEVT_GRID_CELL_CHANGED;
wxEventType wxEVT_GRID_SELECT_CELL;
@ -6537,4 +6566,3 @@ wxEventType wxEVT_GRID_CELL_BEGIN_DRAG;
wxEventType wxEVT_GRID_COL_MOVE;
wxEventType wxEVT_GRID_COL_SORT;
wxEventType wxEVT_GRID_TABBING;

View File

@ -30,6 +30,7 @@ public:
By default, no modifiers are active.
*/
explicit
wxKeyboardState(bool controlDown = false,
bool shiftDown = false,
bool altDown = false,

View File

@ -325,7 +325,8 @@ wxBEGIN_EVENT_TABLE( GridFrame, wxFrame )
EVT_MENU( ID_SET_CELL_FG_COLOUR, GridFrame::SetCellFgColour )
EVT_MENU( ID_SET_CELL_BG_COLOUR, GridFrame::SetCellBgColour )
EVT_MENU( wxID_ABOUT, GridFrame::About )
EVT_MENU( wxID_ABOUT, GridFrame::OnAbout )
EVT_MENU( wxID_CLEAR, GridFrame::OnClear )
EVT_MENU( wxID_EXIT, GridFrame::OnQuit )
EVT_MENU( ID_VTABLE, GridFrame::OnVTable)
EVT_MENU( ID_BUGS_TABLE, GridFrame::OnBugsTable)
@ -366,7 +367,8 @@ wxBEGIN_EVENT_TABLE( GridFrame, wxFrame )
EVT_GRID_COL_SIZE( GridFrame::OnColSize )
EVT_GRID_COL_AUTO_SIZE( GridFrame::OnColAutoSize )
EVT_GRID_SELECT_CELL( GridFrame::OnSelectCell )
EVT_GRID_RANGE_SELECT( GridFrame::OnRangeSelected )
EVT_GRID_RANGE_SELECTING( GridFrame::OnRangeSelecting )
EVT_GRID_RANGE_SELECTED( GridFrame::OnRangeSelected )
EVT_GRID_CELL_CHANGING( GridFrame::OnCellValueChanging )
EVT_GRID_CELL_CHANGED( GridFrame::OnCellValueChanged )
EVT_GRID_CELL_BEGIN_DRAG( GridFrame::OnCellBeginDrag )
@ -419,6 +421,11 @@ GridFrame::GridFrame()
fileMenu->Append( wxID_PRINT, "Render" );
fileMenu->Append( ID_RENDER_COORDS, "Render G5:P30" );
#if wxUSE_LOG
fileMenu->AppendSeparator();
fileMenu->Append( wxID_CLEAR, "Clear &log\tCtrl-L" );
#endif // wxUSE_LOG
fileMenu->AppendSeparator();
fileMenu->Append( wxID_EXIT, "E&xit\tAlt-X" );
@ -765,14 +772,10 @@ GridFrame::GridFrame()
grid->Bind(wxEVT_CONTEXT_MENU, &GridFrame::OnGridContextMenu, this, grid->GetId());
wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
topSizer->Add( grid,
1,
wxEXPAND );
topSizer->Add(grid, wxSizerFlags(2).Expand());
#if wxUSE_LOG
topSizer->Add( logWin,
0,
wxEXPAND );
topSizer->Add(logWin, wxSizerFlags(1).Expand());
#endif // wxUSE_LOG
SetSizerAndFit( topSizer );
@ -1637,14 +1640,19 @@ void GridFrame::OnSelectCell( wxGridEvent& ev )
ev.Skip();
}
void GridFrame::OnRangeSelected( wxGridRangeSelectEvent& ev )
namespace
{
void
LogRangeSelectEvent(wxGridRangeSelectEvent& ev, const char* suffix)
{
wxString logBuf;
if ( ev.Selecting() )
logBuf << "Selected ";
logBuf << "Select";
else
logBuf << "Deselected ";
logBuf << "cells from row " << ev.GetTopRow()
logBuf << "Deselect";
logBuf << suffix
<< " cells from row " << ev.GetTopRow()
<< " col " << ev.GetLeftCol()
<< " to row " << ev.GetBottomRow()
<< " col " << ev.GetRightCol()
@ -1657,6 +1665,18 @@ void GridFrame::OnRangeSelected( wxGridRangeSelectEvent& ev )
ev.Skip();
}
} // anonymous namespace
void GridFrame::OnRangeSelected( wxGridRangeSelectEvent& ev )
{
LogRangeSelectEvent(ev, "ed");
}
void GridFrame::OnRangeSelecting( wxGridRangeSelectEvent& ev )
{
LogRangeSelectEvent(ev, "ing");
}
void GridFrame::OnCellValueChanging( wxGridEvent& ev )
{
int row = ev.GetRow(),
@ -1733,7 +1753,7 @@ void GridFrame::OnEditorHidden( wxGridEvent& ev )
ev.Skip();
}
void GridFrame::About( wxCommandEvent& WXUNUSED(ev) )
void GridFrame::OnAbout( wxCommandEvent& WXUNUSED(ev) )
{
wxAboutDialogInfo aboutInfo;
aboutInfo.SetName("wxGrid demo");
@ -1753,6 +1773,13 @@ void GridFrame::About( wxCommandEvent& WXUNUSED(ev) )
}
void GridFrame::OnClear( wxCommandEvent& WXUNUSED(ev) )
{
#if wxUSE_LOG
logWin->Clear();
#endif // wxUSE_LOG
}
void GridFrame::OnQuit( wxCommandEvent& WXUNUSED(ev) )
{
Close( true );

View File

@ -110,6 +110,7 @@ class GridFrame : public wxFrame
void OnColAutoSize( wxGridSizeEvent& );
void OnSelectCell( wxGridEvent& );
void OnRangeSelected( wxGridRangeSelectEvent& );
void OnRangeSelecting( wxGridRangeSelectEvent& );
void OnCellValueChanging( wxGridEvent& );
void OnCellValueChanged( wxGridEvent& );
void OnCellBeginDrag( wxGridEvent& );
@ -129,7 +130,8 @@ public:
~GridFrame();
void OnQuit( wxCommandEvent& );
void About( wxCommandEvent& );
void OnClear( wxCommandEvent& );
void OnAbout( wxCommandEvent& );
void OnVTable( wxCommandEvent& );
void OnBugsTable( wxCommandEvent& );
void OnTabularTable( wxCommandEvent& );

View File

@ -147,7 +147,8 @@ wxDEFINE_EVENT( wxEVT_GRID_COL_SIZE, wxGridSizeEvent );
wxDEFINE_EVENT( wxEVT_GRID_COL_AUTO_SIZE, wxGridSizeEvent );
wxDEFINE_EVENT( wxEVT_GRID_COL_MOVE, wxGridEvent );
wxDEFINE_EVENT( wxEVT_GRID_COL_SORT, wxGridEvent );
wxDEFINE_EVENT( wxEVT_GRID_RANGE_SELECT, wxGridRangeSelectEvent );
wxDEFINE_EVENT( wxEVT_GRID_RANGE_SELECTING, wxGridRangeSelectEvent );
wxDEFINE_EVENT( wxEVT_GRID_RANGE_SELECTED, wxGridRangeSelectEvent );
wxDEFINE_EVENT( wxEVT_GRID_CELL_CHANGING, wxGridEvent );
wxDEFINE_EVENT( wxEVT_GRID_CELL_CHANGED, wxGridEvent );
wxDEFINE_EVENT( wxEVT_GRID_SELECT_CELL, wxGridEvent );
@ -3677,7 +3678,8 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event, wxGridRowLabelWindo
m_selection->ExtendCurrentBlock(
wxGridCellCoords(m_currentCellCoords.GetRow(), 0),
wxGridCellCoords(row, GetNumberCols() - 1),
event);
event,
wxEVT_GRID_RANGE_SELECTING);
}
}
break;
@ -3694,9 +3696,6 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event, wxGridRowLabelWindo
if ( m_isDragging && (event.Entering() || event.Leaving()) )
return;
if (m_isDragging)
m_isDragging = false;
// ------------ Entering or leaving the window
//
if ( event.Entering() || event.Leaving() )
@ -3810,6 +3809,7 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event, wxGridRowLabelWindo
ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, rowLabelWin);
m_dragLastPos = -1;
m_isDragging = false;
}
// ------------ Right button down
@ -4020,7 +4020,8 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event, wxGridColLabelWindo
m_selection->ExtendCurrentBlock(
wxGridCellCoords(0, m_currentCellCoords.GetCol()),
wxGridCellCoords(GetNumberRows() - 1, col),
event);
event,
wxEVT_GRID_RANGE_SELECTING);
}
}
break;
@ -4091,9 +4092,6 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event, wxGridColLabelWindo
if ( m_isDragging && (event.Entering() || event.Leaving()) )
return;
if (m_isDragging)
m_isDragging = false;
// ------------ Entering or leaving the window
//
if ( event.Entering() || event.Leaving() )
@ -4263,6 +4261,7 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event, wxGridColLabelWindo
ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, GetColLabelWindow());
m_dragLastPos = -1;
m_isDragging = false;
}
// ------------ Right button down
@ -4377,6 +4376,14 @@ void wxGrid::CancelMouseCapture()
void wxGrid::DoAfterDraggingEnd()
{
if ( m_isDragging &&
(m_cursorMode == WXGRID_CURSOR_SELECT_CELL ||
m_cursorMode == WXGRID_CURSOR_SELECT_ROW ||
m_cursorMode == WXGRID_CURSOR_SELECT_COL) )
{
m_selection->EndSelecting();
}
m_isDragging = false;
m_startDragPos = wxDefaultPosition;
@ -4444,19 +4451,24 @@ void wxGrid::ChangeCursorMode(CursorMode mode,
break;
case WXGRID_CURSOR_MOVE_COL:
// Currently we don't capture mouse when moving columns, which is
// almost certainly wrong.
captureMouse = false;
win->SetCursor( wxCursor(wxCURSOR_HAND) );
break;
default:
case WXGRID_CURSOR_SELECT_CELL:
// Mouse is captured in ProcessGridCellMouseEvent() in this mode.
captureMouse = false;
wxFALLTHROUGH;
case WXGRID_CURSOR_SELECT_ROW:
case WXGRID_CURSOR_SELECT_COL:
win->SetCursor( *wxSTANDARD_CURSOR );
break;
}
// we need to capture mouse when resizing
bool resize = m_cursorMode == WXGRID_CURSOR_RESIZE_ROW ||
m_cursorMode == WXGRID_CURSOR_RESIZE_COL;
if ( captureMouse && resize )
if ( captureMouse )
{
win->CaptureMouse();
m_winCapture = win;
@ -4510,7 +4522,12 @@ wxGrid::DoGridCellDrag(wxMouseEvent& event,
// Ctrl later can't change the dragging behaviour. Only the initial state
// of the modifier keys matters.
if ( m_selection )
m_selection->ExtendCurrentBlock(m_currentCellCoords, coords, event);
{
m_selection->ExtendCurrentBlock(m_currentCellCoords,
coords,
event,
wxEVT_GRID_RANGE_SELECTING);
}
return true;
}

View File

@ -55,6 +55,26 @@ bool wxGridSelection::IsSelection()
return !m_selection.empty();
}
void wxGridSelection::EndSelecting()
{
// It's possible that nothing was selected finally, e.g. the mouse could
// have been dragged around only to return to the starting cell, just don't
// do anything in this case.
if ( !IsSelection() )
return;
// Send RANGE_SELECTED event for the last modified block.
const wxGridBlockCoords& block = m_selection.back();
wxGridRangeSelectEvent gridEvt(m_grid->GetId(),
wxEVT_GRID_RANGE_SELECTED,
m_grid,
block.GetTopLeft(),
block.GetBottomRight(),
true);
m_grid->GetEventHandler()->ProcessEvent(gridEvt);
}
bool wxGridSelection::IsInSelection( int row, int col ) const
{
// Check whether the given cell is contained in one of the selected blocks.
@ -162,7 +182,7 @@ void wxGridSelection::SelectCol(int col, const wxKeyboardState& kbd)
void wxGridSelection::SelectBlock( int topRow, int leftCol,
int bottomRow, int rightCol,
const wxKeyboardState& kbd,
bool sendEvent )
wxEventType eventType )
{
// Fix the coordinates of the block if needed.
int allowed = -1;
@ -204,7 +224,7 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol,
return;
Select(wxGridBlockCoords(topRow, leftCol, bottomRow, rightCol).Canonicalize(),
kbd, sendEvent);
kbd, eventType);
}
void
@ -227,7 +247,7 @@ wxGridSelection::SelectAll()
void
wxGridSelection::DeselectBlock(const wxGridBlockCoords& block,
const wxKeyboardState& kbd,
bool sendEvent)
wxEventType eventType)
{
const wxGridBlockCoords canonicalizedBlock = block.Canonicalize();
@ -341,10 +361,10 @@ wxGridSelection::DeselectBlock(const wxGridBlockCoords& block,
refBlock.GetBottomRow(), refBlock.GetRightCol());
}
if ( sendEvent )
if ( eventType != wxEVT_NULL )
{
wxGridRangeSelectEvent gridEvt(m_grid->GetId(),
wxEVT_GRID_RANGE_SELECT,
eventType,
m_grid,
refBlock.GetTopLeft(),
refBlock.GetBottomRight(),
@ -383,7 +403,7 @@ void wxGridSelection::ClearSelection()
// (No finer grained events for each of the smaller regions
// deselected above!)
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
wxEVT_GRID_RANGE_SELECT,
wxEVT_GRID_RANGE_SELECTED,
m_grid,
wxGridCellCoords( 0, 0 ),
wxGridCellCoords(
@ -494,7 +514,8 @@ void wxGridSelection::UpdateCols( size_t pos, int numCols )
bool wxGridSelection::ExtendCurrentBlock(const wxGridCellCoords& blockStart,
const wxGridCellCoords& blockEnd,
const wxKeyboardState& kbd)
const wxKeyboardState& kbd,
wxEventType eventType)
{
wxASSERT( blockStart.GetRow() != -1 && blockStart.GetCol() != -1 &&
blockEnd.GetRow() != -1 && blockEnd.GetCol() != -1 );
@ -505,7 +526,7 @@ bool wxGridSelection::ExtendCurrentBlock(const wxGridCellCoords& blockStart,
// block to non-selected current cell.
if ( !IsInSelection(m_grid->GetGridCursorCoords()) )
{
SelectBlock(blockStart, blockEnd);
SelectBlock(blockStart, blockEnd, kbd, eventType);
return true;
}
@ -641,7 +662,7 @@ bool wxGridSelection::ExtendCurrentBlock(const wxGridCellCoords& blockStart,
// Send Event.
wxGridRangeSelectEvent gridEvt(m_grid->GetId(),
wxEVT_GRID_RANGE_SELECT,
eventType,
m_grid,
newBlock.GetTopLeft(),
newBlock.GetBottomRight(),
@ -797,7 +818,8 @@ wxArrayInt wxGridSelection::GetColSelection() const
void
wxGridSelection::Select(const wxGridBlockCoords& block,
const wxKeyboardState& kbd, bool sendEvent)
const wxKeyboardState& kbd,
wxEventType eventType)
{
if (m_grid->GetNumberRows() == 0 || m_grid->GetNumberCols() == 0)
return;
@ -811,10 +833,10 @@ wxGridSelection::Select(const wxGridBlockCoords& block,
}
// Send Event, if not disabled.
if ( sendEvent )
if ( eventType != wxEVT_NULL )
{
wxGridRangeSelectEvent gridEvt( m_grid->GetId(),
wxEVT_GRID_RANGE_SELECT,
eventType,
m_grid,
block.GetTopLeft(),
block.GetBottomRight(),