X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b8d24d4edd1f91339918134d2420af39c324aa1f..55e18dbe2faca047b2008734782d52a6eb140115:/src/generic/grid.cpp diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 6841247663..511bed5c93 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -3913,16 +3913,18 @@ bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership, { if ( m_created ) { - // RD: Actually, this should probably be allowed. I think it would be - // nice to be able to switch multiple Tables in and out of a single - // View at runtime. Is there anything in the implementation that - // would prevent this? - - // At least, you now have to cope with m_selection - wxFAIL_MSG( wxT("wxGrid::CreateGrid or wxGrid::SetTable called more than once") ); - return FALSE; - } - else + if (m_ownTable) + delete m_table; + delete m_selection; + + // stop all processing + m_table=0; + m_selection=0; + m_created = FALSE; + m_numRows=0; + m_numCols=0; + } + if (table) { m_numRows = table->GetNumberRows(); m_numCols = table->GetNumberCols(); @@ -5767,7 +5769,9 @@ bool wxGrid::InsertRows( int pos, int numRows, bool WXUNUSED(updateLabels) ) if (IsCellEditControlEnabled()) DisableCellEditControl(); - return m_table->InsertRows( pos, numRows ); + bool done = m_table->InsertRows( pos, numRows ); + m_numRows = m_table->GetNumberRows(); + return done; // the table will have sent the results of the insert row // operation to this view object as a grid table message @@ -5786,9 +5790,15 @@ bool wxGrid::AppendRows( int numRows, bool WXUNUSED(updateLabels) ) return FALSE; } - return ( m_table && m_table->AppendRows( numRows ) ); - // the table will have sent the results of the append row - // operation to this view object as a grid table message + if ( m_table ) + { + bool done = m_table && m_table->AppendRows( numRows ); + m_numRows = m_table->GetNumberRows(); + return done; + // the table will have sent the results of the append row + // operation to this view object as a grid table message + } + return FALSE; } @@ -5807,7 +5817,9 @@ bool wxGrid::DeleteRows( int pos, int numRows, bool WXUNUSED(updateLabels) ) if (IsCellEditControlEnabled()) DisableCellEditControl(); - return (m_table->DeleteRows( pos, numRows )); + bool done = m_table->DeleteRows( pos, numRows ); + m_numRows = m_table->GetNumberRows(); + return done; // the table will have sent the results of the delete row // operation to this view object as a grid table message } @@ -5830,7 +5842,9 @@ bool wxGrid::InsertCols( int pos, int numCols, bool WXUNUSED(updateLabels) ) if (IsCellEditControlEnabled()) DisableCellEditControl(); - return m_table->InsertCols( pos, numCols ); + bool done = m_table->InsertCols( pos, numCols ); + m_numCols = m_table->GetNumberCols(); + return done; // the table will have sent the results of the insert col // operation to this view object as a grid table message } @@ -5848,9 +5862,15 @@ bool wxGrid::AppendCols( int numCols, bool WXUNUSED(updateLabels) ) return FALSE; } - return ( m_table && m_table->AppendCols( numCols ) ); - // the table will have sent the results of the append col - // operation to this view object as a grid table message + if ( m_table ) + { + bool done = m_table->AppendCols( numCols ); + m_numCols = m_table->GetNumberCols(); + return done; + // the table will have sent the results of the append col + // operation to this view object as a grid table message + } + return FALSE; } @@ -5869,7 +5889,9 @@ bool wxGrid::DeleteCols( int pos, int numCols, bool WXUNUSED(updateLabels) ) if (IsCellEditControlEnabled()) DisableCellEditControl(); - return ( m_table->DeleteCols( pos, numCols ) ); + bool done = m_table->DeleteCols( pos, numCols ); + m_numCols = m_table->GetNumberCols(); + return done; // the table will have sent the results of the delete col // operation to this view object as a grid table message } @@ -9269,6 +9291,8 @@ void wxGrid::SetRowSize( int row, int height ) { wxCHECK_RET( row >= 0 && row < m_numRows, _T("invalid row index") ); + // See comment in SetColSize + if ( height < GetRowMinimalAcceptableHeight()) { return; } if ( m_rowHeights.IsEmpty() ) { @@ -9311,7 +9335,15 @@ void wxGrid::SetColSize( int col, int width ) wxCHECK_RET( col >= 0 && col < m_numCols, _T("invalid column index") ); // should we check that it's bigger than GetColMinimalWidth(col) here? - + // (VZ) + // No, because it is reasonable to assume the library user know's + // what he is doing. However whe should test against the weaker + // constariant of minimalAcceptableWidth, as this breaks rendering + // + // This test then fixes sf.net bug #645734 + + if ( width < GetColMinimalAcceptableWidth()) { return; } + if ( m_colWidths.IsEmpty() ) { // need to really create the array