EVT_MENU( ID_TOGGLEROWSIZING, GridFrame::ToggleRowSizing )
EVT_MENU( ID_TOGGLECOLSIZING, GridFrame::ToggleColSizing )
EVT_MENU( ID_TOGGLEGRIDSIZING, GridFrame::ToggleGridSizing )
+ EVT_MENU( ID_TOGGLEGRIDDRAGCELL, GridFrame::ToggleGridDragCell )
EVT_MENU( ID_TOGGLEGRIDLINES, GridFrame::ToggleGridLines )
EVT_MENU( ID_AUTOSIZECOLS, GridFrame::AutoSizeCols )
EVT_MENU( ID_CELLOVERFLOW, GridFrame::CellOverflow )
EVT_GRID_SELECT_CELL( GridFrame::OnSelectCell )
EVT_GRID_RANGE_SELECT( GridFrame::OnRangeSelected )
EVT_GRID_CELL_CHANGE( GridFrame::OnCellValueChanged )
+ EVT_GRID_CELL_BEGIN_DRAG( GridFrame::OnCellBeginDrag )
EVT_GRID_EDITOR_SHOWN( GridFrame::OnEditorShown )
EVT_GRID_EDITOR_HIDDEN( GridFrame::OnEditorHidden )
wxDefaultPosition,
wxDefaultSize )
{
- int gridW = 600, gridH = 300;
- int logW = gridW, logH = 100;
-
wxMenu *fileMenu = new wxMenu;
fileMenu->Append( ID_VTABLE, _T("&Virtual table test\tCtrl-V"));
fileMenu->Append( ID_BUGS_TABLE, _T("&Bugs table test\tCtrl-B"));
fileMenu->Append( wxID_EXIT, _T("E&xit\tAlt-X") );
wxMenu *viewMenu = new wxMenu;
- viewMenu->Append( ID_TOGGLEROWLABELS, _T("&Row labels"), _T(""), wxITEM_CHECK );
- viewMenu->Append( ID_TOGGLECOLLABELS, _T("&Col labels"), _T(""), wxITEM_CHECK );
- viewMenu->Append( ID_TOGGLEEDIT, _T("&Editable"), _T(""), wxITEM_CHECK );
- viewMenu->Append( ID_TOGGLEROWSIZING, _T("Ro&w drag-resize"), _T(""), wxITEM_CHECK );
- viewMenu->Append( ID_TOGGLECOLSIZING, _T("C&ol drag-resize"), _T(""), wxITEM_CHECK );
- viewMenu->Append( ID_TOGGLEGRIDSIZING, _T("&Grid drag-resize"), _T(""), wxITEM_CHECK );
- viewMenu->Append( ID_TOGGLEGRIDLINES, _T("&Grid Lines"), _T(""), wxITEM_CHECK );
- viewMenu->Append( ID_SET_HIGHLIGHT_WIDTH, _T("&Set Cell Highlight Width..."), _T("") );
- viewMenu->Append( ID_SET_RO_HIGHLIGHT_WIDTH, _T("&Set Cell RO Highlight Width..."), _T("") );
+ viewMenu->Append( ID_TOGGLEROWLABELS, _T("&Row labels"), wxEmptyString, wxITEM_CHECK );
+ viewMenu->Append( ID_TOGGLECOLLABELS, _T("&Col labels"), wxEmptyString, wxITEM_CHECK );
+ viewMenu->Append( ID_TOGGLEEDIT, _T("&Editable"), wxEmptyString, wxITEM_CHECK );
+ viewMenu->Append( ID_TOGGLEROWSIZING, _T("Ro&w drag-resize"), wxEmptyString, wxITEM_CHECK );
+ viewMenu->Append( ID_TOGGLECOLSIZING, _T("C&ol drag-resize"), wxEmptyString, wxITEM_CHECK );
+ viewMenu->Append( ID_TOGGLEGRIDSIZING, _T("&Grid drag-resize"), wxEmptyString, wxITEM_CHECK );
+ viewMenu->Append( ID_TOGGLEGRIDDRAGCELL, _T("&Grid drag-cell"), wxEmptyString, wxITEM_CHECK );
+ viewMenu->Append( ID_TOGGLEGRIDLINES, _T("&Grid Lines"), wxEmptyString, wxITEM_CHECK );
+ viewMenu->Append( ID_SET_HIGHLIGHT_WIDTH, _T("&Set Cell Highlight Width...") );
+ viewMenu->Append( ID_SET_RO_HIGHLIGHT_WIDTH, _T("&Set Cell RO Highlight Width...") );
viewMenu->Append( ID_AUTOSIZECOLS, _T("&Auto-size cols") );
- viewMenu->Append( ID_CELLOVERFLOW, _T("&Overflow cells"), _T(""), wxITEM_CHECK );
- viewMenu->Append( ID_RESIZECELL, _T("&Resize cell (7,1)"), _T(""), wxITEM_CHECK );
+ viewMenu->Append( ID_CELLOVERFLOW, _T("&Overflow cells"), wxEmptyString, wxITEM_CHECK );
+ viewMenu->Append( ID_RESIZECELL, _T("&Resize cell (7,1)"), wxEmptyString, wxITEM_CHECK );
wxMenu *rowLabelMenu = new wxMenu;
wxPoint( 0, 0 ),
wxSize( 400, 300 ) );
+#if wxUSE_LOG
+ int gridW = 600, gridH = 300;
+ int logW = gridW, logH = 100;
+
logWin = new wxTextCtrl( this,
wxID_ANY,
wxEmptyString,
wxTE_MULTILINE );
logger = new wxLogTextCtrl( logWin );
- m_logOld = logger->SetActiveTarget( logger );
- logger->SetTimestamp( NULL );
+ m_logOld = wxLog::SetActiveTarget( logger );
+ wxLog::SetTimestamp( NULL );
+#endif // wxUSE_LOG
// this will create a grid and, by default, an associated grid
// table for strings
1,
wxEXPAND );
+#if wxUSE_LOG
topSizer->Add( logWin,
0,
wxEXPAND );
+#endif // wxUSE_LOG
SetAutoLayout(true);
SetSizer( topSizer );
topSizer->Fit( this );
- topSizer->SetSizeHints( this );
Centre();
SetDefaults();
GridFrame::~GridFrame()
{
+#if wxUSE_LOG
delete wxLog::SetActiveTarget(m_logOld);
+#endif // wxUSE_LOG
}
GetMenuBar()->Check( ID_TOGGLEROWSIZING, true );
GetMenuBar()->Check( ID_TOGGLECOLSIZING, true );
GetMenuBar()->Check( ID_TOGGLEGRIDSIZING, true );
+ GetMenuBar()->Check( ID_TOGGLEGRIDDRAGCELL, false );
GetMenuBar()->Check( ID_TOGGLEGRIDLINES, true );
GetMenuBar()->Check( ID_CELLOVERFLOW, true );
}
GetMenuBar()->IsChecked( ID_TOGGLEGRIDSIZING ) );
}
+void GridFrame::ToggleGridDragCell( wxCommandEvent& WXUNUSED(ev) )
+{
+ grid->EnableDragCell(
+ GetMenuBar()->IsChecked( ID_TOGGLEGRIDDRAGCELL ) );
+}
void GridFrame::ToggleGridLines( wxCommandEvent& WXUNUSED(ev) )
{
{
// Check the new Refresh function by passing it a rectangle
// which exactly fits the grid.
- wxRect r(wxPoint(0, 0), grid->GetSize());
+ wxPoint pt(0, 0);
+ wxRect r(pt, grid->GetSize());
grid->SetDefaultCellBackgroundColour(col);
grid->Refresh(true, &r);
}
void GridFrame::OnLabelLeftClick( wxGridEvent& ev )
{
- logBuf = _T("");
+ logBuf = wxEmptyString;
if ( ev.GetRow() != -1 )
{
logBuf << _T("Left click on row label ") << ev.GetRow();
void GridFrame::OnCellLeftClick( wxGridEvent& ev )
{
- logBuf = _T("");
+ logBuf = wxEmptyString;
logBuf << _T("Left click at row ") << ev.GetRow()
<< _T(" col ") << ev.GetCol();
wxLogMessage( wxT("%s"), logBuf.c_str() );
void GridFrame::OnRowSize( wxGridSizeEvent& ev )
{
- logBuf = _T("");
+ logBuf = wxEmptyString;
logBuf << _T("Resized row ") << ev.GetRowOrCol();
wxLogMessage( wxT("%s"), logBuf.c_str() );
void GridFrame::OnColSize( wxGridSizeEvent& ev )
{
- logBuf = _T("");
+ logBuf = wxEmptyString;
logBuf << _T("Resized col ") << ev.GetRowOrCol();
wxLogMessage( wxT("%s"), logBuf.c_str() );
void GridFrame::OnSelectCell( wxGridEvent& ev )
{
- logBuf = _T("");
+ logBuf = wxEmptyString;
if ( ev.Selecting() )
logBuf << _T("Selected ");
else
void GridFrame::OnRangeSelected( wxGridRangeSelectEvent& ev )
{
- logBuf = _T("");
+ logBuf = wxEmptyString;
if ( ev.Selecting() )
logBuf << _T("Selected ");
else
void GridFrame::OnCellValueChanged( wxGridEvent& ev )
{
- logBuf = _T("");
+ logBuf = wxEmptyString;
logBuf << _T("Value changed for cell at")
<< _T(" row ") << ev.GetRow()
<< _T(" col ") << ev.GetCol();
ev.Skip();
}
+void GridFrame::OnCellBeginDrag( wxGridEvent& ev )
+{
+ logBuf = _T("");
+ logBuf << _T("Got request to drag cell at")
+ << _T(" row ") << ev.GetRow()
+ << _T(" col ") << ev.GetCol();
+
+ wxLogMessage( wxT("%s"), logBuf.c_str() );
+
+ ev.Skip();
+}
+
void GridFrame::OnEditorShown( wxGridEvent& ev )
{
return headers[col];
}
-BugsGridTable::BugsGridTable()
-{
-}
-
// ----------------------------------------------------------------------------
// BugsGridFrame
// ----------------------------------------------------------------------------