// ------ edit control functions
     //
-    bool IsEditable() { return m_editable; }
+    bool IsEditable() const { return m_editable; }
     void EnableEditing( bool edit );
 
     void EnableCellEditControl( bool enable = TRUE );
 
     void ClearSelection();
 
-    bool IsInSelection( int row, int col );
+    bool IsInSelection( int row, int col ) const;
 
-    bool IsInSelection( const wxGridCellCoords& coords )
+    bool IsInSelection( const wxGridCellCoords& coords ) const
         { return IsInSelection( coords.GetRow(), coords.GetCol() ); }
 
 
 
     // don't set sizes, only calculate them
     wxGrid *self = (wxGrid *)this;  // const_cast
 
-    return wxSize(self->SetOrCalcColumnSizes(TRUE),
-                  self->SetOrCalcRowSizes(TRUE));
+    int width, height;
+    width = self->SetOrCalcColumnSizes(TRUE);
+    height = self->SetOrCalcRowSizes(TRUE);
+
+    int maxwidth, maxheight;
+    wxDisplaySize( & maxwidth, & maxheight );
+
+    if ( width > maxwidth ) width = maxwidth;
+    if ( height > maxheight ) height = maxheight;
+
+    return wxSize( width, height );
 }
 
 void wxGrid::Fit()
                m_selectingBottomRight != wxGridNoCellCoords) ) );
 }
 
-bool wxGrid::IsInSelection( int row, int col )
+bool wxGrid::IsInSelection( int row, int col ) const
 {
     return ( m_selection && (m_selection->IsInSelection( row, col ) ||
              ( row >= m_selectingTopLeft.GetRow() &&