EVT_MENU( ID_ABOUT, GridFrame::About )
EVT_MENU( wxID_EXIT, GridFrame::OnQuit )
+ EVT_MENU( ID_VTABLE, GridFrame::OnVTable)
EVT_GRID_LABEL_LEFT_CLICK( GridFrame::OnLabelLeftClick )
EVT_GRID_CELL_LEFT_CLICK( GridFrame::OnCellLeftClick )
int logW = gridW, logH = 80;
wxMenu *fileMenu = new wxMenu;
+ fileMenu->Append( ID_VTABLE, "&Virtual table test");
+ fileMenu->AppendSeparator();
fileMenu->Append( wxID_EXIT, "E&xit\tAlt-X" );
wxMenu *viewMenu = new wxMenu;
Close( TRUE );
}
+void GridFrame::OnVTable(wxCommandEvent& )
+{
+ BigGridFrame* win = new BigGridFrame();
+ win->Show(TRUE);
+}
+
// ----------------------------------------------------------------------------
// MyGridCellRenderer
// ----------------------------------------------------------------------------
// possible to alter the appearance of the cell beyond what the attributes
// allow
void MyGridCellRenderer::Draw(wxGrid& grid,
+ wxGridCellAttr& attr,
wxDC& dc,
const wxRect& rect,
int row, int col,
bool isSelected)
{
- wxGridCellStringRenderer::Draw(grid, dc, rect, row, col, isSelected);
+ wxGridCellStringRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
dc.SetPen(*wxGREEN_PEN);
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawEllipse(rect);
}
+
+
+// ----------------------------------------------------------------------------
+// BigGridFrame and BigGridTable: Sample of a non-standard table
+// ----------------------------------------------------------------------------
+
+BigGridFrame::BigGridFrame()
+ : wxFrame(NULL, -1, "Plugin Virtual Table", wxDefaultPosition,
+ wxSize(500, 450))
+{
+ m_grid = new wxGrid(this, -1, wxDefaultPosition, wxDefaultSize);
+ m_table = new BigGridTable;
+ m_grid->SetTable(m_table, TRUE);
+}
void OnQuit( wxCommandEvent& );
void About( wxCommandEvent& );
+ void OnVTable( wxCommandEvent& );
enum
{
ID_SET_CELL_FG_COLOUR,
ID_SET_CELL_BG_COLOUR,
ID_ABOUT,
+ ID_VTABLE,
ID_TESTFUNC
};
{
public:
virtual void Draw(wxGrid& grid,
+ wxGridCellAttr& attr,
wxDC& dc,
const wxRect& rect,
int row, int col,
bool isSelected);
};
+
+class BigGridTable : public wxGridTableBase {
+public:
+ long GetNumberRows() { return 10000; }
+ long GetNumberCols() { return 10000; }
+
+ wxString GetValue( int row, int col ) {
+ wxString str;
+ str.Printf("(%d, %d)", row, col);
+ return str;
+ }
+
+ void SetValue( int , int , const wxString& ) {}
+ bool IsEmptyCell( int , int ) { return FALSE; }
+};
+
+class BigGridFrame : public wxFrame {
+public:
+ BigGridFrame();
+
+private:
+ wxGrid* m_grid;
+ BigGridTable* m_table;
+};
+
+
#endif