]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grid.cpp
Partially reverted last changes because of problems under wxMotif
[wxWidgets.git] / src / generic / grid.cpp
index a999ea3e08a6717f7f331a6dacd0caf4e4ddf0b5..c931804e3efa805096c5ee1fc3e38c52ded1e00f 100644 (file)
@@ -940,6 +940,16 @@ wxGrid::~wxGrid()
 
 void wxGrid::Create()
 {
+    m_created = FALSE;    // set to TRUE by CreateGrid
+    m_displayed = FALSE;  // set to TRUE by OnPaint
+
+    m_table        = (wxGridTableBase *) NULL;
+    m_cellEditCtrl = (wxWindow *) NULL;
+
+    m_numRows = 0;
+    m_numCols = 0;
+    m_currentCellCoords = wxGridNoCellCoords;
+    
     int colLblH = WXGRID_DEFAULT_COL_LABEL_HEIGHT;
     int rowLblW = WXGRID_DEFAULT_ROW_LABEL_WIDTH;
 
@@ -2381,6 +2391,8 @@ void wxGrid::OnPaint( wxPaintEvent& WXUNUSED(event) )
         SetEditControlValue();
         ShowCellEditControl();
     }
+
+    m_displayed = TRUE;
 }
 
 
@@ -2540,10 +2552,8 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
         return;
     }
 
-    wxClientDC dc( m_gridWin );
-    PrepareDC( dc );
-
-    if ( m_currentCellCoords != wxGridNoCellCoords )
+    if ( m_displayed  &&
+         m_currentCellCoords != wxGridNoCellCoords )
     {
         HideCellEditControl();
         SaveEditControlValue();
@@ -2552,13 +2562,17 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords )
     m_currentCellCoords = coords;
 
     SetEditControlValue();
-    ShowCellEditControl();
 
-    if ( IsSelection() )
+    if ( m_displayed )
     {
-        wxRect r( SelectionToDeviceRect() );
-        ClearSelection();
-        if ( !GetBatchCount() ) m_gridWin->Refresh( FALSE, &r );
+        ShowCellEditControl();
+
+        if ( IsSelection() )
+        {
+            wxRect r( SelectionToDeviceRect() );
+            ClearSelection();
+            if ( !GetBatchCount() ) m_gridWin->Refresh( FALSE, &r );
+        }
     }
 }