Added ability for tables, grids, editors and renderers to handle nonstring data.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6195 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2000-02-21 23:17:40 +00:00
parent e0a4aa8a21
commit f2d7623799
4 changed files with 385 additions and 101 deletions

View File

@@ -184,7 +184,11 @@ GridFrame::GridFrame()
// this will create a grid and, by default, an associated grid
// table for string data
//
grid->CreateGrid( 100, 100 );
//grid->CreateGrid( 100, 100 );
grid->SetTable(new SimpleTable(100, 100), TRUE);
// VZ: cell borders don't look nice otherwise :-) (for now...)
grid->SetDefaultCellBackgroundColour(wxColour(200, 200, 180));
grid->SetRowSize( 0, 60 );
grid->SetCellValue( 0, 0, "Ctrl+Home\nwill go to\nthis cell" );
@@ -724,7 +728,7 @@ BugsGridFrame::BugsGridFrame()
// TODO the correct data type must be used for each column
wxGrid *grid = new wxGrid(this, -1);
wxGrid *grid = new wxGrid(this, -1, wxDefaultPosition);
wxGridTableBase *table =
new wxGridStringTable(WXSIZEOF(data), WXSIZEOF(headers));
for ( size_t row = 0; row < WXSIZEOF(data); row++ )

View File

@@ -121,6 +121,24 @@ public:
// memory
// ----------------------------------------------------------------------------
class SimpleTable : public wxGridStringTable {
public:
SimpleTable( int numRows, int numCols )
: wxGridStringTable( numRows, numCols ) {}
// override this to fake a row as all bools
wxString GetTypeName( int row, int col )
{
if (row == 8)
return wxT("bool");
else if (row == 9 && col == 1)
return wxT("unknown type"); // to test fallback
else
return wxGridStringTable::GetTypeName(row, col);
}
};
class BigGridTable : public wxGridTableBase
{
public:
@@ -128,7 +146,6 @@ public:
long GetNumberRows() { return m_sizeGrid; }
long GetNumberCols() { return m_sizeGrid; }
wxString GetValue( int row, int col )
{
return wxString::Format("(%d, %d)", row, col);