]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/grid/griddemo.cpp
Final steps to move to common icon.
[wxWidgets.git] / samples / grid / griddemo.cpp
index 8fe0da43d6b50d0245b3805c4e86f6cef267d4d9..52044f1793a9b0b59d50e2fd93557e9fb860b9f5 100644 (file)
@@ -1,10 +1,10 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        griddemo.cpp
-// Purpose:     Grid control wxWindows sample
+// Purpose:     Grid control wxWidgets sample
 // Author:      Michael Bedward
-// Modified by:
+// Modified by: Santiago Palacios
 // RCS-ID:      $Id$
-// Copyright:   (c) Michael Bedward, Julian Smart
+// Copyright:   (c) Michael Bedward, Julian Smart, Vadim Zeitlin
 // Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
 // headers
 // ----------------------------------------------------------------------------
 
-#if defined(__GNUG__) && !defined(__APPLE__)
-    #pragma implementation
-    #pragma interface
-#endif
-
 // For compilers that support precompilation, includes "wx/wx.h".
 #include "wx/wxprec.h"
 
@@ -34,6 +29,7 @@
 
 #include "wx/colordlg.h"
 #include "wx/fontdlg.h"
+#include "wx/numdlg.h"
 
 #include "wx/grid.h"
 #include "wx/generic/gridctrl.h"
@@ -57,9 +53,9 @@ IMPLEMENT_APP( GridApp )
 bool GridApp::OnInit()
 {
     GridFrame *frame = new GridFrame;
-    frame->Show( TRUE );
+    frame->Show(true);
 
-    return TRUE;
+    return true;
 }
 
 // ----------------------------------------------------------------------------
@@ -72,7 +68,9 @@ BEGIN_EVENT_TABLE( GridFrame, wxFrame )
     EVT_MENU( ID_TOGGLEEDIT, GridFrame::ToggleEditing )
     EVT_MENU( ID_TOGGLEROWSIZING, GridFrame::ToggleRowSizing )
     EVT_MENU( ID_TOGGLECOLSIZING, GridFrame::ToggleColSizing )
+    EVT_MENU( ID_TOGGLECOLMOVING, GridFrame::ToggleColMoving )
     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 )
@@ -97,7 +95,7 @@ BEGIN_EVENT_TABLE( GridFrame, wxFrame )
     EVT_MENU( ID_SET_CELL_FG_COLOUR, GridFrame::SetCellFgColour )
     EVT_MENU( ID_SET_CELL_BG_COLOUR, GridFrame::SetCellBgColour )
 
-    EVT_MENU( ID_ABOUT, GridFrame::About )
+    EVT_MENU( wxID_ABOUT, GridFrame::About )
     EVT_MENU( wxID_EXIT, GridFrame::OnQuit )
     EVT_MENU( ID_VTABLE, GridFrame::OnVTable)
     EVT_MENU( ID_BUGS_TABLE, GridFrame::OnBugsTable)
@@ -112,6 +110,7 @@ BEGIN_EVENT_TABLE( GridFrame, wxFrame )
     EVT_MENU( ID_SELECT_ROW, GridFrame::SelectRow)
     EVT_MENU( ID_SELECT_ALL, GridFrame::SelectAll)
     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_RO_HIGHLIGHT_WIDTH, GridFrame::OnSetROHighlightWidth)
@@ -123,6 +122,7 @@ BEGIN_EVENT_TABLE( GridFrame, wxFrame )
     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 )
@@ -130,13 +130,10 @@ END_EVENT_TABLE()
 
 
 GridFrame::GridFrame()
-        : wxFrame( (wxFrame *)NULL, -1, _T("wxWindows grid class demo"),
+        : wxFrame( (wxFrame *)NULL, wxID_ANY, _T("wxWidgets grid class demo"),
                    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"));
@@ -145,18 +142,20 @@ GridFrame::GridFrame()
     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_TOGGLECOLMOVING, _T("Col drag-&move"), 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;
 
@@ -195,10 +194,14 @@ GridFrame::GridFrame()
     selectMenu->Append( ID_SELECT_UNSELECT, _T("Add new cells to the selection"),
                         _T("When off, old selection is deselected before ")
                         _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_ROW, _T("Select row 2"));
     selectMenu->Append( ID_SELECT_COL, _T("Select col 2"));
     selectMenu->Append( ID_SELECT_CELL, _T("Select cell (3, 1)"));
+    selectMenu->AppendSeparator();
     selectMenu->Append( ID_DESELECT_ALL, _T("Deselect all"));
     selectMenu->Append( ID_DESELECT_ROW, _T("Deselect row 2"));
     selectMenu->Append( ID_DESELECT_COL, _T("Deselect col 2"));
@@ -214,7 +217,7 @@ GridFrame::GridFrame()
 
 
     wxMenu *helpMenu = new wxMenu;
-    helpMenu->Append( ID_ABOUT, _T("&About wxGrid demo") );
+    helpMenu->Append( wxID_ABOUT, _T("&About wxGrid demo") );
 
     wxMenuBar *menuBar = new wxMenuBar;
     menuBar->Append( fileMenu, _T("&File") );
@@ -226,23 +229,28 @@ GridFrame::GridFrame()
 
     SetMenuBar( menuBar );
 
-    m_addToSel = FALSE;
+    m_addToSel = false;
 
     grid = new wxGrid( this,
-                       -1,
+                       wxID_ANY,
                        wxPoint( 0, 0 ),
                        wxSize( 400, 300 ) );
 
+#if wxUSE_LOG
+    int gridW = 600, gridH = 300;
+    int logW = gridW, logH = 100;
+
     logWin = new wxTextCtrl( this,
-                             -1,
+                             wxID_ANY,
                              wxEmptyString,
                              wxPoint( 0, gridH + 20 ),
                              wxSize( logW, logH ),
                              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
@@ -328,7 +336,7 @@ GridFrame::GridFrame()
     grid->SetCellEditor(4, 0, new wxGridCellChoiceEditor(WXSIZEOF(choices), choices));
     grid->SetCellSize(4, 0, 1, 2);
     grid->SetCellValue(4, 0, choices[0]);
-    grid->SetCellOverflow(4, 0, FALSE);
+    grid->SetCellOverflow(4, 0, false);
 
     grid->SetCellSize(7, 1, 3, 4);
     grid->SetCellAlignment(7, 1, wxALIGN_CENTRE, wxALIGN_CENTRE);
@@ -339,15 +347,16 @@ GridFrame::GridFrame()
                    1,
                    wxEXPAND );
 
+#if wxUSE_LOG
     topSizer->Add( logWin,
                    0,
                    wxEXPAND );
+#endif // wxUSE_LOG
 
-    SetAutoLayout( TRUE );
+    SetAutoLayout(true);
     SetSizer( topSizer );
 
     topSizer->Fit( this );
-    topSizer->SetSizeHints( this );
 
     Centre();
     SetDefaults();
@@ -356,20 +365,24 @@ GridFrame::GridFrame()
 
 GridFrame::~GridFrame()
 {
+#if wxUSE_LOG
     delete wxLog::SetActiveTarget(m_logOld);
+#endif // wxUSE_LOG
 }
 
 
 void GridFrame::SetDefaults()
 {
-    GetMenuBar()->Check( ID_TOGGLEROWLABELS, TRUE );
-    GetMenuBar()->Check( ID_TOGGLECOLLABELS, TRUE );
-    GetMenuBar()->Check( ID_TOGGLEEDIT, TRUE );
-    GetMenuBar()->Check( ID_TOGGLEROWSIZING, TRUE );
-    GetMenuBar()->Check( ID_TOGGLECOLSIZING, TRUE );
-    GetMenuBar()->Check( ID_TOGGLEGRIDSIZING, TRUE );
-    GetMenuBar()->Check( ID_TOGGLEGRIDLINES, TRUE );
-    GetMenuBar()->Check( ID_CELLOVERFLOW, TRUE );
+    GetMenuBar()->Check( ID_TOGGLEROWLABELS, true );
+    GetMenuBar()->Check( ID_TOGGLECOLLABELS, true );
+    GetMenuBar()->Check( ID_TOGGLEEDIT, true );
+    GetMenuBar()->Check( ID_TOGGLEROWSIZING, true );
+    GetMenuBar()->Check( ID_TOGGLECOLSIZING, true );
+    GetMenuBar()->Check( ID_TOGGLECOLMOVING, false );
+    GetMenuBar()->Check( ID_TOGGLEGRIDSIZING, true );
+    GetMenuBar()->Check( ID_TOGGLEGRIDDRAGCELL, false );
+    GetMenuBar()->Check( ID_TOGGLEGRIDLINES, true );
+    GetMenuBar()->Check( ID_CELLOVERFLOW, true );
 }
 
 
@@ -419,12 +432,23 @@ void GridFrame::ToggleColSizing( wxCommandEvent& WXUNUSED(ev) )
         GetMenuBar()->IsChecked( ID_TOGGLECOLSIZING ) );
 }
 
+void GridFrame::ToggleColMoving( wxCommandEvent& WXUNUSED(ev) )
+{
+    grid->EnableDragColMove(
+        GetMenuBar()->IsChecked( ID_TOGGLECOLMOVING ) );
+}
+
 void GridFrame::ToggleGridSizing( wxCommandEvent& WXUNUSED(ev) )
 {
     grid->EnableDragGridSize(
         GetMenuBar()->IsChecked( ID_TOGGLEGRIDSIZING ) );
 }
 
+void GridFrame::ToggleGridDragCell( wxCommandEvent& WXUNUSED(ev) )
+{
+    grid->EnableDragCell(
+        GetMenuBar()->IsChecked( ID_TOGGLEGRIDDRAGCELL ) );
+}
 
 void GridFrame::ToggleGridLines( wxCommandEvent& WXUNUSED(ev) )
 {
@@ -539,7 +563,7 @@ void GridFrame::SetRowLabelHorizAlignment( wxCommandEvent& WXUNUSED(ev) )
             break;
     }
 
-    grid->SetRowLabelAlignment( horiz, -1 );
+    grid->SetRowLabelAlignment( horiz, vert );
 }
 
 void GridFrame::SetRowLabelVertAlignment( wxCommandEvent& WXUNUSED(ev) )
@@ -562,7 +586,7 @@ void GridFrame::SetRowLabelVertAlignment( wxCommandEvent& WXUNUSED(ev) )
             break;
     }
 
-    grid->SetRowLabelAlignment( -1, vert );
+    grid->SetRowLabelAlignment( horiz, vert );
 }
 
 
@@ -586,7 +610,7 @@ void GridFrame::SetColLabelHorizAlignment( wxCommandEvent& WXUNUSED(ev) )
             break;
     }
 
-    grid->SetColLabelAlignment( horiz, -1 );
+    grid->SetColLabelAlignment( horiz, vert );
 }
 
 
@@ -610,7 +634,7 @@ void GridFrame::SetColLabelVertAlignment( wxCommandEvent& WXUNUSED(ev) )
             break;
     }
 
-    grid->SetColLabelAlignment( -1, vert );
+    grid->SetColLabelAlignment( horiz, vert );
 }
 
 
@@ -646,10 +670,12 @@ void GridFrame::DeleteSelectedRows( wxCommandEvent& WXUNUSED(ev) )
     {
         grid->BeginBatch();
         for ( int n = 0; n < grid->GetNumberRows(); )
+        {
             if ( grid->IsInSelection( n , 0 ) )
                 grid->DeleteRows( n, 1 );
-        else
-            n++;
+            else
+                n++;
+        }
         grid->EndBatch();
     }
 }
@@ -661,10 +687,12 @@ void GridFrame::DeleteSelectedCols( wxCommandEvent& WXUNUSED(ev) )
     {
         grid->BeginBatch();
         for ( int n = 0; n < grid->GetNumberCols(); )
+        {
             if ( grid->IsInSelection( 0 , n ) )
                 grid->DeleteCols( n, 1 );
-        else
-            n++;
+            else
+                n++;
+        }
         grid->EndBatch();
     }
 }
@@ -707,9 +735,10 @@ void GridFrame::SetCellBgColour( 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);
+        grid->Refresh(true, &r);
     }
 }
 
@@ -760,7 +789,7 @@ void GridFrame::OnAddToSelectToggle(wxCommandEvent& event)
 
 void GridFrame::OnLabelLeftClick( wxGridEvent& ev )
 {
-    logBuf = _T("");
+    logBuf = wxEmptyString;
     if ( ev.GetRow() != -1 )
     {
         logBuf << _T("Left click on row label ") << ev.GetRow();
@@ -786,7 +815,7 @@ void GridFrame::OnLabelLeftClick( wxGridEvent& ev )
 
 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() );
@@ -800,7 +829,7 @@ void GridFrame::OnCellLeftClick( wxGridEvent& ev )
 
 void GridFrame::OnRowSize( wxGridSizeEvent& ev )
 {
-    logBuf = _T("");
+    logBuf = wxEmptyString;
     logBuf << _T("Resized row ") << ev.GetRowOrCol();
     wxLogMessage( wxT("%s"), logBuf.c_str() );
 
@@ -810,7 +839,7 @@ void GridFrame::OnRowSize( wxGridSizeEvent& ev )
 
 void GridFrame::OnColSize( wxGridSizeEvent& ev )
 {
-    logBuf = _T("");
+    logBuf = wxEmptyString;
     logBuf << _T("Resized col ") << ev.GetRowOrCol();
     wxLogMessage( wxT("%s"), logBuf.c_str() );
 
@@ -818,9 +847,85 @@ 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 )
 {
-    logBuf = _T("");
+    logBuf = wxEmptyString;
     if ( ev.Selecting() )
         logBuf << _T("Selected ");
     else
@@ -831,6 +936,11 @@ void GridFrame::OnSelectCell( wxGridEvent& ev )
            << _T(", ShiftDown: ")<< (ev.ShiftDown() ? 'T':'F')
            << _T(", AltDown: ")<< (ev.AltDown() ? 'T':'F')
            << _T(", MetaDown: ")<< (ev.MetaDown() ? 'T':'F') << _T(" )");
+
+    //Indicate whether this column was moved
+    if ( ((wxGrid *)ev.GetEventObject())->GetColPos( ev.GetCol() ) != ev.GetCol() )
+        logBuf << _T(" *** Column moved, current position: ") << ((wxGrid *)ev.GetEventObject())->GetColPos( ev.GetCol() );
+
     wxLogMessage( wxT("%s"), logBuf.c_str() );
 
     // you must call Skip() if you want the default processing
@@ -840,7 +950,7 @@ void GridFrame::OnSelectCell( wxGridEvent& ev )
 
 void GridFrame::OnRangeSelected( wxGridRangeSelectEvent& ev )
 {
-    logBuf = _T("");
+    logBuf = wxEmptyString;
     if ( ev.Selecting() )
         logBuf << _T("Selected ");
     else
@@ -860,7 +970,7 @@ void GridFrame::OnRangeSelected( wxGridRangeSelectEvent& ev )
 
 void GridFrame::OnCellValueChanged( wxGridEvent& ev )
 {
-    logBuf = _T("");
+    logBuf = wxEmptyString;
     logBuf  << _T("Value changed for cell at")
             << _T(" row ") << ev.GetRow()
             << _T(" col ") << ev.GetCol();
@@ -870,6 +980,18 @@ void GridFrame::OnCellValueChanged( wxGridEvent& ev )
     ev.Skip();
 }
 
+void GridFrame::OnCellBeginDrag( wxGridEvent& ev )
+{
+    logBuf = wxEmptyString;
+    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 )
 {
 
@@ -907,8 +1029,7 @@ void GridFrame::OnEditorHidden( wxGridEvent& ev )
 void GridFrame::About(  wxCommandEvent& WXUNUSED(ev) )
 {
     (void)wxMessageBox( _T("\n\nwxGrid demo \n\n")
-                        _T("Michael Bedward \n")
-                        _T("mbedward@ozemail.com.au \n\n"),
+                        _T("Michael Bedward, Julian Smart, Vadim Zeitlin"),
                         _T("About"),
                         wxOK );
 }
@@ -916,24 +1037,24 @@ void GridFrame::About(  wxCommandEvent& WXUNUSED(ev) )
 
 void GridFrame::OnQuit( wxCommandEvent& WXUNUSED(ev) )
 {
-    Close( TRUE );
+    Close( true );
 }
 
 void GridFrame::OnBugsTable(wxCommandEvent& )
 {
     BugsGridFrame *frame = new BugsGridFrame;
-    frame->Show(TRUE);
+    frame->Show(true);
 }
 
 void GridFrame::OnSmallGrid(wxCommandEvent& )
 {
-    wxFrame* frame = new wxFrame(NULL, -1, _T("A Small Grid"),
+    wxFrame* frame = new wxFrame(NULL, wxID_ANY, _T("A Small Grid"),
                                  wxDefaultPosition, wxSize(640, 480));
-    wxPanel* panel = new wxPanel(frame, -1);
-    wxGrid* grid = new wxGrid(panel, -1, wxPoint(10,10), wxSize(400,400),
+    wxPanel* panel = new wxPanel(frame, wxID_ANY);
+    wxGrid* grid = new wxGrid(panel, wxID_ANY, wxPoint(10,10), wxSize(400,400),
                               wxWANTS_CHARS | wxSIMPLE_BORDER);
     grid->CreateGrid(3,3);
-    frame->Show(TRUE);
+    frame->Show(true);
 }
 
 void GridFrame::OnVTable(wxCommandEvent& )
@@ -961,7 +1082,7 @@ void GridFrame::OnVTable(wxCommandEvent& )
     if ( s_sizeGrid != -1 )
     {
         BigGridFrame* win = new BigGridFrame(s_sizeGrid);
-        win->Show(TRUE);
+        win->Show(true);
     }
 }
 
@@ -1033,17 +1154,17 @@ wxGridCellAttr *MyGridCellAttrProvider::GetAttr(int row, int col,
 // ============================================================================
 
 BigGridFrame::BigGridFrame(long sizeGrid)
-            : wxFrame(NULL, -1, _T("Plugin Virtual Table"),
+            : wxFrame(NULL, wxID_ANY, _T("Plugin Virtual Table"),
                       wxDefaultPosition, wxSize(500, 450))
 {
-    m_grid = new wxGrid(this, -1, wxDefaultPosition, wxDefaultSize);
+    m_grid = new wxGrid(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
     m_table = new BigGridTable(sizeGrid);
 
     // VZ: I don't understand why this slows down the display that much,
     //     must profile it...
     //m_table->SetAttrProvider(new MyGridCellAttrProvider);
 
-    m_grid->SetTable(m_table, TRUE);
+    m_grid->SetTable(m_table, true);
 
 #if defined __WXMOTIF__
     // MB: the grid isn't getting a sensible default size under wxMotif
@@ -1101,10 +1222,10 @@ static struct BugsGridData
     bool opened;
 } gs_dataBugsGrid [] =
 {
-    { 18, _T("foo doesn't work"), Sev_Major, 1, _T("wxMSW"), TRUE },
-    { 27, _T("bar crashes"), Sev_Critical, 1, _T("all"), FALSE },
-    { 45, _T("printing is slow"), Sev_Minor, 3, _T("wxMSW"), TRUE },
-    { 68, _T("Rectangle() fails"), Sev_Normal, 1, _T("wxMSW"), FALSE },
+    { 18, _T("foo doesn't work"), Sev_Major, 1, _T("wxMSW"), true },
+    { 27, _T("bar crashes"), Sev_Critical, 1, _T("all"), false },
+    { 45, _T("printing is slow"), Sev_Minor, 3, _T("wxMSW"), true },
+    { 68, _T("Rectangle() fails"), Sev_Normal, 1, _T("wxMSW"), false },
 };
 
 static const wxChar *headers[Col_Max] =
@@ -1157,9 +1278,9 @@ int BugsGridTable::GetNumberCols()
     return Col_Max;
 }
 
-bool BugsGridTable::IsEmptyCell( int row, int col )
+bool BugsGridTable::IsEmptyCell( int WXUNUSED(row), int WXUNUSED(col) )
 {
-    return FALSE;
+    return false;
 }
 
 wxString BugsGridTable::GetValue( int row, int col )
@@ -1169,10 +1290,13 @@ wxString BugsGridTable::GetValue( int row, int col )
     switch ( col )
     {
         case Col_Id:
+            return wxString::Format(_T("%d"), gd.id);
+
         case Col_Priority:
+            return wxString::Format(_T("%d"), gd.prio);
+
         case Col_Opened:
-            wxFAIL_MSG(_T("unexpected column"));
-            break;
+            return gd.opened ? _T("1") : _T("0");
 
         case Col_Severity:
             return severities[gd.severity];
@@ -1230,11 +1354,14 @@ void BugsGridTable::SetValue( int row, int col, const wxString& value )
     }
 }
 
-bool BugsGridTable::CanGetValueAs( int WXUNUSED(row), int col, const wxString& typeName )
+bool
+BugsGridTable::CanGetValueAs(int WXUNUSED(row),
+                             int col,
+                             const wxString& typeName)
 {
     if ( typeName == wxGRID_VALUE_STRING )
     {
-        return TRUE;
+        return true;
     }
     else if ( typeName == wxGRID_VALUE_BOOL )
     {
@@ -1246,7 +1373,7 @@ bool BugsGridTable::CanGetValueAs( int WXUNUSED(row), int col, const wxString& t
     }
     else
     {
-        return FALSE;
+        return false;
     }
 }
 
@@ -1286,7 +1413,7 @@ bool BugsGridTable::GetValueAsBool( int row, int col )
     {
         wxFAIL_MSG(_T("unexpected column"));
 
-        return FALSE;
+        return false;
     }
 }
 
@@ -1322,22 +1449,18 @@ wxString BugsGridTable::GetColLabelValue( int col )
     return headers[col];
 }
 
-BugsGridTable::BugsGridTable()
-{
-}
-
 // ----------------------------------------------------------------------------
 // BugsGridFrame
 // ----------------------------------------------------------------------------
 
 BugsGridFrame::BugsGridFrame()
-             : wxFrame(NULL, -1, _T("Bugs table"),
+             : wxFrame(NULL, wxID_ANY, _T("Bugs table"),
                        wxDefaultPosition, wxSize(500, 300))
 {
-    wxGrid *grid = new wxGrid(this, -1, wxDefaultPosition);
+    wxGrid *grid = new wxGrid(this, wxID_ANY, wxDefaultPosition);
     wxGridTableBase *table = new BugsGridTable();
     table->SetAttrProvider(new MyGridCellAttrProvider);
-    grid->SetTable(table, TRUE);
+    grid->SetTable(table, true);
 
     wxGridCellAttr *attrRO = new wxGridCellAttr,
                    *attrRangeEditor = new wxGridCellAttr,