added a test command to show the current selection
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36746 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -109,6 +109,7 @@ BEGIN_EVENT_TABLE( GridFrame, wxFrame )
|
|||||||
EVT_MENU( ID_SELECT_ROW, GridFrame::SelectRow)
|
EVT_MENU( ID_SELECT_ROW, GridFrame::SelectRow)
|
||||||
EVT_MENU( ID_SELECT_ALL, GridFrame::SelectAll)
|
EVT_MENU( ID_SELECT_ALL, GridFrame::SelectAll)
|
||||||
EVT_MENU( ID_SELECT_UNSELECT, GridFrame::OnAddToSelectToggle)
|
EVT_MENU( ID_SELECT_UNSELECT, GridFrame::OnAddToSelectToggle)
|
||||||
|
EVT_MENU( ID_SHOW_SELECTION, GridFrame::OnShowSelection)
|
||||||
|
|
||||||
EVT_MENU( ID_SET_HIGHLIGHT_WIDTH, GridFrame::OnSetHighlightWidth)
|
EVT_MENU( ID_SET_HIGHLIGHT_WIDTH, GridFrame::OnSetHighlightWidth)
|
||||||
EVT_MENU( ID_SET_RO_HIGHLIGHT_WIDTH, GridFrame::OnSetROHighlightWidth)
|
EVT_MENU( ID_SET_RO_HIGHLIGHT_WIDTH, GridFrame::OnSetROHighlightWidth)
|
||||||
@@ -191,10 +192,14 @@ GridFrame::GridFrame()
|
|||||||
selectMenu->Append( ID_SELECT_UNSELECT, _T("Add new cells to the selection"),
|
selectMenu->Append( ID_SELECT_UNSELECT, _T("Add new cells to the selection"),
|
||||||
_T("When off, old selection is deselected before ")
|
_T("When off, old selection is deselected before ")
|
||||||
_T("selecting the new cells"), wxITEM_CHECK );
|
_T("selecting the new cells"), wxITEM_CHECK );
|
||||||
|
selectMenu->Append( ID_SHOW_SELECTION,
|
||||||
|
_T("&Show current selection\tCtrl-Alt-S"));
|
||||||
|
selectMenu->AppendSeparator();
|
||||||
selectMenu->Append( ID_SELECT_ALL, _T("Select all"));
|
selectMenu->Append( ID_SELECT_ALL, _T("Select all"));
|
||||||
selectMenu->Append( ID_SELECT_ROW, _T("Select row 2"));
|
selectMenu->Append( ID_SELECT_ROW, _T("Select row 2"));
|
||||||
selectMenu->Append( ID_SELECT_COL, _T("Select col 2"));
|
selectMenu->Append( ID_SELECT_COL, _T("Select col 2"));
|
||||||
selectMenu->Append( ID_SELECT_CELL, _T("Select cell (3, 1)"));
|
selectMenu->Append( ID_SELECT_CELL, _T("Select cell (3, 1)"));
|
||||||
|
selectMenu->AppendSeparator();
|
||||||
selectMenu->Append( ID_DESELECT_ALL, _T("Deselect all"));
|
selectMenu->Append( ID_DESELECT_ALL, _T("Deselect all"));
|
||||||
selectMenu->Append( ID_DESELECT_ROW, _T("Deselect row 2"));
|
selectMenu->Append( ID_DESELECT_ROW, _T("Deselect row 2"));
|
||||||
selectMenu->Append( ID_DESELECT_COL, _T("Deselect col 2"));
|
selectMenu->Append( ID_DESELECT_COL, _T("Deselect col 2"));
|
||||||
@@ -833,6 +838,82 @@ void GridFrame::OnColSize( wxGridSizeEvent& ev )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GridFrame::OnShowSelection(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
// max number of elements to dump -- otherwise it can take too much time
|
||||||
|
static const size_t countMax = 100;
|
||||||
|
|
||||||
|
bool rows = false;
|
||||||
|
|
||||||
|
switch ( grid->GetSelectionMode() )
|
||||||
|
{
|
||||||
|
case wxGrid::wxGridSelectCells:
|
||||||
|
{
|
||||||
|
const wxGridCellCoordsArray cells(grid->GetSelectedCells());
|
||||||
|
size_t count = cells.size();
|
||||||
|
wxLogMessage(_T("%lu cells selected:"), (unsigned long)count);
|
||||||
|
if ( count > countMax )
|
||||||
|
{
|
||||||
|
wxLogMessage(_T("[too many selected cells, ")
|
||||||
|
_T("showing only the first %lu]"),
|
||||||
|
(unsigned long)countMax);
|
||||||
|
count = countMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( size_t n = 0; n < count; n++ )
|
||||||
|
{
|
||||||
|
const wxGridCellCoords& c = cells[n];
|
||||||
|
wxLogMessage(_T(" selected cell %lu: (%d, %d)"),
|
||||||
|
(unsigned long)n, c.GetCol(), c.GetRow());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxGrid::wxGridSelectRows:
|
||||||
|
rows = true;
|
||||||
|
// fall through
|
||||||
|
|
||||||
|
case wxGrid::wxGridSelectColumns:
|
||||||
|
{
|
||||||
|
const wxChar *plural, *single;
|
||||||
|
if ( rows )
|
||||||
|
{
|
||||||
|
plural = _T("rows");
|
||||||
|
single = _T("row");
|
||||||
|
}
|
||||||
|
else // columns
|
||||||
|
{
|
||||||
|
plural = _T("columns");
|
||||||
|
single = _T("column");
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxArrayInt sels(rows ? grid->GetSelectedRows()
|
||||||
|
: grid->GetSelectedCols());
|
||||||
|
size_t count = sels.size();
|
||||||
|
wxLogMessage(_T("%lu %s selected:"),
|
||||||
|
(unsigned long)count, plural);
|
||||||
|
if ( count > countMax )
|
||||||
|
{
|
||||||
|
wxLogMessage(_T("[too many selected %s, ")
|
||||||
|
_T("showing only the first %lu]"),
|
||||||
|
plural, (unsigned long)countMax);
|
||||||
|
count = countMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( size_t n = 0; n < count; n++ )
|
||||||
|
{
|
||||||
|
wxLogMessage(_T(" selected %s %lu: %d"),
|
||||||
|
single, (unsigned long)n, sels[n]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG( _T("unknown wxGrid selection mode") );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GridFrame::OnSelectCell( wxGridEvent& ev )
|
void GridFrame::OnSelectCell( wxGridEvent& ev )
|
||||||
{
|
{
|
||||||
logBuf = wxEmptyString;
|
logBuf = wxEmptyString;
|
||||||
|
@@ -73,6 +73,7 @@ class GridFrame : public wxFrame
|
|||||||
void SelectRow(wxCommandEvent& event);
|
void SelectRow(wxCommandEvent& event);
|
||||||
void SelectAll(wxCommandEvent& event);
|
void SelectAll(wxCommandEvent& event);
|
||||||
void OnAddToSelectToggle(wxCommandEvent& event);
|
void OnAddToSelectToggle(wxCommandEvent& event);
|
||||||
|
void OnShowSelection(wxCommandEvent& event);
|
||||||
|
|
||||||
void OnLabelLeftClick( wxGridEvent& );
|
void OnLabelLeftClick( wxGridEvent& );
|
||||||
void OnCellLeftClick( wxGridEvent& );
|
void OnCellLeftClick( wxGridEvent& );
|
||||||
@@ -137,6 +138,7 @@ public:
|
|||||||
ID_BUGS_TABLE,
|
ID_BUGS_TABLE,
|
||||||
ID_SMALL_GRID,
|
ID_SMALL_GRID,
|
||||||
ID_SELECT_UNSELECT,
|
ID_SELECT_UNSELECT,
|
||||||
|
ID_SHOW_SELECTION,
|
||||||
ID_SELECT_ALL,
|
ID_SELECT_ALL,
|
||||||
ID_SELECT_ROW,
|
ID_SELECT_ROW,
|
||||||
ID_SELECT_COL,
|
ID_SELECT_COL,
|
||||||
|
Reference in New Issue
Block a user