X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1dc17bcafb89b0bde0406e692df79111c197d38e..404b319a85dadd7decf7a5a5331020520031a41c:/src/generic/grid.cpp?ds=sidebyside diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index ca15ddc2cc..9c795c276b 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -2414,6 +2414,8 @@ wxGrid::SetTable(wxGridTableBase *table, m_created = true; } + InvalidateBestSize(); + return m_created; } @@ -3068,6 +3070,8 @@ bool wxGrid::Redimension( wxGridTableMessage& msg ) break; } + InvalidateBestSize(); + if (result && !GetBatchCount() ) m_gridWin->Refresh(); @@ -5558,7 +5562,7 @@ void wxGrid::DrawCell( wxDC& dc, const wxGridCellCoords& coords ) // implicitly, causing this out-of order render. #if !defined(__WXMAC__) wxGridCellEditor *editor = attr->GetEditor(this, row, col); - editor->PaintBackground(rect, attr); + editor->PaintBackground(dc, rect, *attr); editor->DecRef(); #endif } @@ -6659,7 +6663,7 @@ int wxGrid::XToPos(int x) const return PosToLinePos(x, true /* clip */, wxGridColumnOperations()); } -// return the row number such that the y coord is near the edge of, or -1 if +// return the row/col number such that the pos is near the edge of, or -1 if // not near an edge. // // notice that position can only possibly be near an edge if the row/column is @@ -6668,7 +6672,8 @@ int wxGrid::XToPos(int x) const // _never_ be considered to be near the edge). int wxGrid::PosToEdgeOfLine(int pos, const wxGridOperations& oper) const { - const int line = oper.PosToLine(this, pos, true); + // Get the bottom or rightmost line that could match. + int line = oper.PosToLine(this, pos, true); if ( oper.GetLineSize(this, line) > WXGRID_LABEL_EDGE_ZONE ) { @@ -6680,7 +6685,16 @@ int wxGrid::PosToEdgeOfLine(int pos, const wxGridOperations& oper) const pos - oper.GetLineStartPos(this, line) < WXGRID_LABEL_EDGE_ZONE ) { - return oper.GetLineBefore(this, line); + // We need to find the previous visible line, so skip all the + // hidden (of size 0) ones. + do + { + line = oper.GetLineBefore(this, line); + } + while ( line >= 0 && oper.GetLineSize(this, line) == 0 ); + + // It can possibly be -1 here. + return line; } } @@ -7117,6 +7131,7 @@ void wxGrid::SetRowLabelSize( int width ) } m_rowLabelWidth = width; + InvalidateBestSize(); CalcWindowSizes(); wxScrolledWindow::Refresh( true ); } @@ -7146,6 +7161,7 @@ void wxGrid::SetColLabelSize( int height ) } m_colLabelHeight = height; + InvalidateBestSize(); CalcWindowSizes(); wxScrolledWindow::Refresh( true ); } @@ -8100,8 +8116,11 @@ int UpdateRowOrColSize(int& sizeCurrent, int sizeNew) // We're showing back a previously hidden row/column. wxASSERT_MSG( sizeNew == -1, wxS("New size must be positive or -1.") ); - wxASSERT_MSG( sizeCurrent < 0, wxS("May only show back if hidden.") ); + // If it's already visible, simply do nothing. + if ( sizeCurrent >= 0 ) + return 0; + // Otherwise show it by restoring its old size. sizeCurrent = -sizeCurrent; // This is positive which is correct. @@ -8110,8 +8129,13 @@ int UpdateRowOrColSize(int& sizeCurrent, int sizeNew) else if ( sizeNew == 0 ) { // We're hiding a row/column. - wxASSERT_MSG( sizeCurrent > 0, wxS("Can't hide if already hidden.") ); + // If it's already hidden, simply do nothing. + if ( sizeCurrent <= 0 ) + return 0; + + // Otherwise hide it and also remember the shown size to be able to + // restore it later. sizeCurrent = -sizeCurrent; // This is negative which is correct. @@ -8175,6 +8199,8 @@ void wxGrid::DoSetRowSize( int row, int height ) m_rowBottoms[i] += diff; } + InvalidateBestSize(); + if ( !GetBatchCount() ) { CalcDimensions(); @@ -8259,6 +8285,8 @@ void wxGrid::DoSetColSize( int col, int width ) m_colRights[GetColAt(colPos)] += diff; } + InvalidateBestSize(); + if ( !GetBatchCount() ) { CalcDimensions(); @@ -8668,11 +8696,6 @@ wxSize wxGrid::DoGetBestSize() const wxSize size(self->SetOrCalcColumnSizes(true) - m_rowLabelWidth + m_extraWidth, self->SetOrCalcRowSizes(true) - m_colLabelHeight + m_extraHeight); - // NOTE: This size should be cached, but first we need to add calls to - // InvalidateBestSize everywhere that could change the results of this - // calculation. - // CacheBestSize(size); - return wxSize(size.x + m_rowLabelWidth, size.y + m_colLabelHeight) + GetWindowBorderSize(); }