X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/27f35b6674b796e61986681261ec7a96bef93502..7948c0c24401c496c04da3c28f1f1f2f282ba327:/src/generic/grid.cpp diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index c5ad5fc40c..dc65ee909e 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -5746,10 +5746,10 @@ void wxGrid::OnPaint( wxPaintEvent& WXUNUSED(event) ) wxPaintDC dc(this); // needed to prevent zillions of paint events on MSW } -void wxGrid::Refresh(bool eraseb, wxRect* rect= NULL) +void wxGrid::Refresh(bool eraseb, wxRect* rect) { - //Don't do anything if between Begin/EndBatch... - // endbatch will do all this on the last nested one anyway. + // Don't do anything if between Begin/EndBatch... + // EndBatch() will do all this on the last nested one anyway. if (! GetBatchCount()) { wxScrolledWindow::Refresh(eraseb,rect); @@ -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() &&