]> git.saurik.com Git - wxWidgets.git/commitdiff
1. Grid cell defaults are now handled by an internal
authorRobin Dunn <robin@alldunn.com>
Sun, 13 Feb 2000 05:38:03 +0000 (05:38 +0000)
committerRobin Dunn <robin@alldunn.com>
Sun, 13 Feb 2000 05:38:03 +0000 (05:38 +0000)
wxGridCellAttr object

2. wxGridCellRenderer::Draw updated to expect an attr object and
use it instead of going back to the grid for everything

3. The selection colours are now initialized from wxSystemSettings,
and are configurable.

4. Now either CreateGrid() or SetTable() can be called to initialize
the grid.  Added a test for using a non-default table.

5. Reduced flicker even more byt using empty EVT_ERASE_BACKGROUND handlers.

6. The beginings of wxGridCellEditor are in there but not activated
yet. (This is the next step.)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5986 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/newgrid/griddemo.cpp
samples/newgrid/griddemo.h

index 99b7a7492ef74d3ff054af2965da9451dd30db83..d263013b2f1e53f685064345bba07c4bd340f222 100644 (file)
@@ -86,6 +86,7 @@ BEGIN_EVENT_TABLE( GridFrame, wxFrame )
 
     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 )
@@ -107,6 +108,8 @@ GridFrame::GridFrame()
     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;
@@ -583,6 +586,12 @@ void GridFrame::OnQuit( wxCommandEvent& WXUNUSED(ev) )
     Close( TRUE );
 }
 
+void GridFrame::OnVTable(wxCommandEvent& )
+{
+    BigGridFrame* win = new BigGridFrame();
+    win->Show(TRUE);
+}
+
 // ----------------------------------------------------------------------------
 // MyGridCellRenderer
 // ----------------------------------------------------------------------------
@@ -591,14 +600,29 @@ void GridFrame::OnQuit( wxCommandEvent& WXUNUSED(ev) )
 // 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);
+}
index c5ab79e0b2a93ee95446738aecb24d277e2bc6d0..25aee5965daaf47012a8d37e5fded94aa3d6cccd 100644 (file)
@@ -68,6 +68,7 @@ public:
 
     void OnQuit( wxCommandEvent& );
     void About( wxCommandEvent& );
+    void OnVTable( wxCommandEvent& );
 
     enum
     {
@@ -91,6 +92,7 @@ public:
         ID_SET_CELL_FG_COLOUR,
         ID_SET_CELL_BG_COLOUR,
         ID_ABOUT,
+        ID_VTABLE,
 
         ID_TESTFUNC
     };
@@ -102,11 +104,38 @@ class MyGridCellRenderer : public wxGridCellStringRenderer
 {
 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