X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/66242c80071ebe77246d52d407a7bea6817f090e..3f2965162ce86e5b669cd85d1bce98b6a232d020:/src/generic/grid.cpp diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index c69d269430..8850bc7742 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -187,7 +187,7 @@ wxGridTableMessage::wxGridTableMessage( wxGridTableBase *table, int id, // this is a magic incantation which must be done! #include -WX_DEFINE_OBJARRAY(wxGridStringArray); +WX_DEFINE_OBJARRAY(wxGridStringArray) IMPLEMENT_DYNAMIC_CLASS( wxGridStringTable, wxGridTableBase ) @@ -2048,7 +2048,10 @@ void wxGrid::SetEditControlValue( const wxString& value ) if ( m_table ) { wxString s; - s = ( value == wxEmptyString ? GetCellValue(m_currentCellCoords) : value ); + if ( !value ) + s = GetCellValue(m_currentCellCoords); + else + s = value; if ( IsTopEditControlEnabled() ) { @@ -3351,8 +3354,26 @@ bool wxGrid::InsertRows( int pos, int numRows, bool WXUNUSED(updateLabels) ) // if ( ok ) { + if ( m_numCols == 0 ) + { + m_table->AppendCols( WXGRID_DEFAULT_NUMBER_COLS ); + // + // TODO: perhaps instead of appending the default number of cols + // we should remember what the last non-zero number of cols was ? + // + } + + if ( m_currentCellCoords == wxGridNoCellCoords ) + { + // if we have just inserted cols into an empty grid the current + // cell will be undefined... + // + SelectCell( 0, 0 ); + } + if ( !GetBatchCount() ) Refresh(); } + SetEditControlValue(); return ok; } @@ -3374,6 +3395,14 @@ bool wxGrid::AppendRows( int numRows, bool WXUNUSED(updateLabels) ) if ( m_table && m_table->AppendRows( numRows ) ) { + if ( m_currentCellCoords == wxGridNoCellCoords ) + { + // if we have just inserted cols into an empty grid the current + // cell will be undefined... + // + SelectCell( 0, 0 ); + } + // the table will have sent the results of the append row // operation to this view object as a grid table message // @@ -3429,13 +3458,23 @@ bool wxGrid::InsertCols( int pos, int numCols, bool WXUNUSED(updateLabels) ) { HideCellEditControl(); bool ok = m_table->InsertCols( pos, numCols ); + + // the table will have sent the results of the insert col + // operation to this view object as a grid table message + // if ( ok ) { - // the table will have sent the results of the insert col - // operation to this view object as a grid table message - // + if ( m_currentCellCoords == wxGridNoCellCoords ) + { + // if we have just inserted cols into an empty grid the current + // cell will be undefined... + // + SelectCell( 0, 0 ); + } + if ( !GetBatchCount() ) Refresh(); } + SetEditControlValue(); return ok; } @@ -3460,6 +3499,13 @@ bool wxGrid::AppendCols( int numCols, bool WXUNUSED(updateLabels) ) // the table will have sent the results of the append col // operation to this view object as a grid table message // + if ( m_currentCellCoords == wxGridNoCellCoords ) + { + // if we have just inserted cols into an empty grid the current + // cell will be undefined... + // + SelectCell( 0, 0 ); + } if ( !GetBatchCount() ) Refresh(); return TRUE; }