X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ad603bf790cdfb219bf566f304ff4593fe8d1532..7948c0c24401c496c04da3c28f1f1f2f282ba327:/src/generic/grid.cpp diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index c00faac20d..dc65ee909e 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -6788,7 +6788,6 @@ void wxGrid::DrawTextRectangle( wxDC& dc, { wxArrayString lines; - dc.SetClippingRegion( rect ); StringToLines( value, lines ); @@ -6810,6 +6809,7 @@ void wxGrid::DrawTextRectangle( wxDC& dc, long textWidth, textHeight; long lineWidth, lineHeight; + dc.SetClippingRegion( rect ); if ( lines.GetCount() ) { GetTextBoxSize( dc, lines, &textWidth, &textHeight ); @@ -8509,11 +8509,17 @@ bool wxGrid::LookupAttr(int row, int col, wxGridCellAttr **attr) const wxGridCellAttr *wxGrid::GetCellAttr(int row, int col) const { - wxGridCellAttr *attr; - if ( !LookupAttr(row, col, &attr) ) + wxGridCellAttr *attr = NULL; + // Additional test to avoid looking at the cache e.g. for + // wxNoCellCoords, as this will confuse memory management. + if ( row >= 0 ) { - attr = m_table ? m_table->GetAttr(row, col , wxGridCellAttr::Any) : (wxGridCellAttr *)NULL; - CacheAttr(row, col, attr); + if ( !LookupAttr(row, col, &attr) ) + { + attr = m_table ? m_table->GetAttr(row, col , wxGridCellAttr::Any) + : (wxGridCellAttr *)NULL; + CacheAttr(row, col, attr); + } } if (attr) { @@ -9181,8 +9187,17 @@ wxSize wxGrid::DoGetBestSize() const // 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() @@ -9333,7 +9348,7 @@ bool wxGrid::IsSelection() 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() &&