]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grid.cpp
corrected drawing of the bitmaps for the disabled menu items (replaces patch 1632891...
[wxWidgets.git] / src / generic / grid.cpp
index 6ac0795e12bbf47864bbbfdb02ad7bae44468bb6..a1fc2233dbd53dbd6fd6375d8495271dc52213e7 100644 (file)
@@ -4623,6 +4623,33 @@ void wxGrid::CalcWindowSizes()
     int cw, ch;
     GetClientSize( &cw, &ch );
 
+    // this block of code tries to work around the following problem: the grid
+    // could have been just resized to have enough space to show the full grid
+    // window contents without the scrollbars, but its client size could be
+    // not big enough because the grid has the scrollbars right now and so the
+    // scrollbars would remain even though we don't need them any more
+    //
+    // to prevent this from happening, check if we have enough space for
+    // everything without the scrollbars and explicitly disable them then
+    wxSize size = GetSize() - GetWindowBorderSize();
+    if ( size != wxSize(cw, ch) )
+    {
+        // check if we have enough space for grid window after accounting for
+        // the fixed size elements
+        size.x -= m_rowLabelWidth;
+        size.y -= m_colLabelHeight;
+
+        const wxSize vsize = m_gridWin->GetVirtualSize();
+
+        if ( size.x >= vsize.x && size.y >= vsize.y )
+        {
+            // yes, we do, so remove the scrollbars and use the new client size
+            // (which should be the same as full window size - borders now)
+            SetScrollbars(0, 0, 0, 0);
+            GetClientSize(&cw, &ch);
+        }
+    }
+
     if ( m_cornerLabelWin && m_cornerLabelWin->IsShown() )
         m_cornerLabelWin->SetSize( 0, 0, m_rowLabelWidth, m_colLabelHeight );
 
@@ -8282,7 +8309,8 @@ void wxGrid::ShowCellEditControl()
             // might not cover the entire cell
             wxClientDC dc( m_gridWin );
             PrepareDC( dc );
-            dc.SetBrush(wxBrush(GetCellAttr(row, col)->GetBackgroundColour(), wxSOLID));
+            wxGridCellAttr* attr = GetCellAttr(row, col);
+            dc.SetBrush(wxBrush(attr->GetBackgroundColour(), wxSOLID));
             dc.SetPen(*wxTRANSPARENT_PEN);
             dc.DrawRectangle(rect);
 
@@ -8302,7 +8330,6 @@ void wxGrid::ShowCellEditControl()
             if (rect.y > 0)
                 rect.y--;
 
-            wxGridCellAttr* attr = GetCellAttr(row, col);
             wxGridCellEditor* editor = attr->GetEditor(this, row, col);
             if ( !editor->IsCreated() )
             {