EVT_MENU( ID_COLLABELHORIZALIGN, GridFrame::SetColLabelHorizAlignment )
EVT_MENU( ID_COLLABELVERTALIGN, GridFrame::SetColLabelVertAlignment )
EVT_MENU( ID_GRIDLINECOLOUR, GridFrame::SetGridLineColour )
+ EVT_MENU( ID_INSERTROW, GridFrame::InsertRow )
+ EVT_MENU( ID_INSERTCOL, GridFrame::InsertCol )
+ EVT_MENU( ID_DELETEROW, GridFrame::DeleteRow )
+ EVT_MENU( ID_DELETECOL, GridFrame::DeleteCol )
EVT_MENU( ID_CLEARGRID, GridFrame::ClearGrid )
EVT_MENU( ID_ABOUT, GridFrame::About )
EVT_MENU( wxID_EXIT, GridFrame::OnQuit )
- EVT_WXGRID_LABEL_LEFT_CLICK( GridFrame::OnLabelLeftClick )
- EVT_WXGRID_CELL_LEFT_CLICK( GridFrame::OnCellLeftClick )
- EVT_WXGRID_ROW_SIZE( GridFrame::OnRowSize )
- EVT_WXGRID_COL_SIZE( GridFrame::OnColSize )
- EVT_WXGRID_RANGE_SELECT( GridFrame::OnRangeSelected )
- EVT_WXGRID_CELL_CHANGE( GridFrame::OnCellValueChanged )
+ EVT_GRID_LABEL_LEFT_CLICK( GridFrame::OnLabelLeftClick )
+ EVT_GRID_CELL_LEFT_CLICK( GridFrame::OnCellLeftClick )
+ EVT_GRID_ROW_SIZE( GridFrame::OnRowSize )
+ EVT_GRID_COL_SIZE( GridFrame::OnColSize )
+ EVT_GRID_SELECT_CELL( GridFrame::OnSelectCell )
+ EVT_GRID_RANGE_SELECT( GridFrame::OnRangeSelected )
+ EVT_GRID_CELL_CHANGE( GridFrame::OnCellValueChanged )
END_EVENT_TABLE()
colLabelMenu->Append( ID_COLLABELVERTALIGN, "&Vertical" );
viewMenu->Append( ID_GRIDLINECOLOUR, "&Grid line colour" );
- viewMenu->Append( ID_CLEARGRID, "Cl&ear grid cell contents" );
+ wxMenu *editMenu = new wxMenu;
+ editMenu->Append( ID_INSERTROW, "Insert &row" );
+ editMenu->Append( ID_INSERTCOL, "Insert &column" );
+ editMenu->Append( ID_DELETEROW, "Delete ro&w" );
+ editMenu->Append( ID_DELETECOL, "Delete co&l" );
+ editMenu->Append( ID_CLEARGRID, "Cl&ear grid cell contents" );
+
wxMenu *helpMenu = new wxMenu;
helpMenu->Append( ID_ABOUT, "&About wxGrid demo" );
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append( fileMenu, "&File" );
menuBar->Append( viewMenu, "&View" );
+ menuBar->Append( editMenu, "&Edit" );
menuBar->Append( helpMenu, "&Help" );
SetMenuBar( menuBar );
}
+void GridFrame::InsertRow( wxCommandEvent& WXUNUSED(ev) )
+{
+ grid->InsertRows( 0, 1 );
+}
+
+
+void GridFrame::InsertCol( wxCommandEvent& WXUNUSED(ev) )
+{
+ grid->InsertCols( 0, 1 );
+}
+
+
+void GridFrame::DeleteRow( wxCommandEvent& WXUNUSED(ev) )
+{
+ grid->DeleteRows( 0, 1 );
+}
+
+
+void GridFrame::DeleteCol( wxCommandEvent& WXUNUSED(ev) )
+{
+ grid->DeleteCols( 0, 1 );
+}
+
+
void GridFrame::ClearGrid( wxCommandEvent& WXUNUSED(ev) )
{
grid->ClearGrid();
logBuf = "";
if ( ev.GetRow() != -1 )
{
- logBuf << "row label " << ev.GetRow();
+ logBuf << "Left click on row label " << ev.GetRow();
}
else if ( ev.GetCol() != -1 )
{
- logBuf << "col label " << ev.GetCol();
+ logBuf << "Left click on col label " << ev.GetCol();
}
else
{
- logBuf << "corner label";
+ logBuf << "Left click on corner label";
}
if ( ev.ShiftDown() ) logBuf << " (shift down)";
wxLogMessage( "%s", logBuf.c_str() );
+ // you must call event skip if you want default grid processing
+ //
ev.Skip();
}
void GridFrame::OnCellLeftClick( wxGridEvent& ev )
{
logBuf = "";
- logBuf << "Cell at row " << ev.GetRow()
+ logBuf << "Left click at row " << ev.GetRow()
<< " col " << ev.GetCol();
wxLogMessage( "%s", logBuf.c_str() );
-
+
// you must call event skip if you want default grid processing
// (cell highlighting etc.)
//
ev.Skip();
}
+
+void GridFrame::OnSelectCell( wxGridEvent& ev )
+{
+ logBuf = "";
+ logBuf << "Selected cell at row " << ev.GetRow()
+ << " col " << ev.GetCol();
+ wxLogMessage( "%s", logBuf.c_str() );
+
+ // you must call Skip() if you want the default processing
+ // to occur in wxGrid
+ ev.Skip();
+}
+
void GridFrame::OnRangeSelected( wxGridRangeSelectEvent& ev )
{
logBuf = "";