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
9 changed files with 178 additions and 57 deletions

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& );