+// ----------------------------------------------------------------------------
+// MyGridCellAttrProvider
+// ----------------------------------------------------------------------------
+
+MyGridCellAttrProvider::MyGridCellAttrProvider()
+{
+ m_attrForOddRows = new wxGridCellAttr;
+ m_attrForOddRows->SetBackgroundColour(*wxLIGHT_GREY);
+}
+
+MyGridCellAttrProvider::~MyGridCellAttrProvider()
+{
+ m_attrForOddRows->DecRef();
+}
+
+wxGridCellAttr *MyGridCellAttrProvider::GetAttr(int row, int col,
+ wxGridCellAttr::wxAttrKind kind /* = wxGridCellAttr::Any */) const
+{
+ wxGridCellAttr *attr = wxGridCellAttrProvider::GetAttr(row, col, kind);
+
+ if ( row % 2 )
+ {
+ if ( !attr )
+ {
+ attr = m_attrForOddRows;
+ attr->IncRef();
+ }
+ else
+ {
+ if ( !attr->HasBackgroundColour() )
+ {
+ wxGridCellAttr *attrNew = attr->Clone();
+ attr->DecRef();
+ attr = attrNew;
+ attr->SetBackgroundColour(*wxLIGHT_GREY);
+ }
+ }
+ }
+
+ return attr;
+}
+
+// ----------------------------------------------------------------------------
+
+void GridFrame::OnTabularGrid(wxCommandEvent& )
+{
+ wxFrame* frame = new wxFrame(NULL, wxID_ANY, _T("A small tabular Grid"),
+ wxDefaultPosition, wxSize(640, 480));
+ wxGrid* grid = new wxGrid(frame, wxID_ANY, wxPoint(10,10), wxSize(40,40),
+ wxWANTS_CHARS | wxBORDER_SUNKEN);
+ grid->SetRowLabelSize( 0 );
+ grid->DisableDragRowSize();
+ grid->SetUseNativeColLabels();
+ grid->CreateGrid(10,10);
+ grid->SetSelectionMode( wxGrid::wxGridSelectRows );
+
+ frame->Show(true);
+}
+