]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/grid.cpp
Use kControlContentIconRef when recreating the tool for toggled state
[wxWidgets.git] / src / generic / grid.cpp
index 6ac0795e12bbf47864bbbfdb02ad7bae44468bb6..2fab29c85ccc76a2033ec514e9f80223e7e63f22 100644 (file)
@@ -627,7 +627,11 @@ void wxGridCellTextEditor::Create(wxWindow* parent,
     m_control = new wxTextCtrl(parent, id, wxEmptyString,
                                wxDefaultPosition, wxDefaultSize
 #if defined(__WXMSW__)
-                               , wxTE_PROCESS_TAB | wxTE_AUTO_SCROLL | wxNO_BORDER
+                               ,
+                               wxTE_PROCESS_ENTER |
+                               wxTE_PROCESS_TAB |
+                               wxTE_AUTO_SCROLL |
+                               wxNO_BORDER
 #endif
                               );
 
@@ -4623,6 +4627,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 +8313,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 +8334,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() )
             {