X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fe7b9ed6fdffb7dd72c9d7d4a1070e433189954f..050c9e3c90c58b05d5b3f7384d1556ca9669f13e:/src/generic/grid.cpp diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index dfb0cece64..e2b9e35807 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -2020,7 +2020,7 @@ wxGridCellRenderer* wxGridCellAttr::GetRenderer(wxGrid* grid, int row, int col) { wxGridCellRenderer* renderer = NULL; - if ( m_defGridAttr != this || grid == NULL ) + if ( m_defGridAttr == this || grid == NULL ) { renderer = m_renderer; // use local attribute if ( renderer ) @@ -2088,6 +2088,9 @@ void wxGridCellAttrData::SetAttr(wxGridCellAttr *attr, int row, int col) } else { + // free the old attribute + m_attrs[(size_t)n].attr->DecRef(); + if ( attr ) { // change the attribute @@ -3607,6 +3610,8 @@ void wxGrid::Create() wxDefaultSize ); SetTargetWindow( m_gridWin ); + + Init(); } @@ -3624,7 +3629,9 @@ bool wxGrid::CreateGrid( int numRows, int numCols, m_table->SetView( this ); m_ownTable = TRUE; m_selection = new wxGridSelection( this, selmode ); - Init(); + + CalcDimensions(); + m_created = TRUE; return m_created; @@ -3632,12 +3639,10 @@ bool wxGrid::CreateGrid( int numRows, int numCols, void wxGrid::SetSelectionMode(wxGrid::wxGridSelectionModes selmode) { - if ( !m_created ) - { - wxFAIL_MSG( wxT("Called wxGrid::SetSelectionMode() before calling CreateGrid()") ); - } - else - m_selection->SetSelectionMode( selmode ); + wxCHECK_RET( m_created, + wxT("Called wxGrid::SetSelectionMode() before calling CreateGrid()") ); + + m_selection->SetSelectionMode( selmode ); } bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership, @@ -3664,7 +3669,9 @@ bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership, if (takeOwnership) m_ownTable = TRUE; m_selection = new wxGridSelection( this, selmode ); - Init(); + + CalcDimensions(); + m_created = TRUE; } @@ -3746,8 +3753,6 @@ void wxGrid::Init() m_extraWidth = m_extraHeight = 50; - - CalcDimensions(); } // ---------------------------------------------------------------------------- @@ -5454,7 +5459,7 @@ int wxGrid::SendEvent( const wxEventType type, wxMouseEvent& mouseEv ) { bool claimed; - bool vetoed= false; + bool vetoed= FALSE; if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE ) { @@ -5470,7 +5475,7 @@ int wxGrid::SendEvent( const wxEventType type, mouseEv.ShiftDown(), mouseEv.AltDown(), mouseEv.MetaDown() ); - + claimed = GetEventHandler()->ProcessEvent(gridEvt); vetoed = !gridEvt.IsAllowed(); @@ -5509,12 +5514,12 @@ int wxGrid::SendEvent( const wxEventType type, claimed = GetEventHandler()->ProcessEvent(gridEvt); vetoed = !gridEvt.IsAllowed(); } - - // A Veto'd event may not be `claimed' so test this first + + // A Veto'd event may not be `claimed' so test this first if (vetoed) return -1; return claimed ? 1 : 0; - + } @@ -5525,7 +5530,7 @@ int wxGrid::SendEvent( const wxEventType type, int row, int col ) { bool claimed; - bool vetoed= false; + bool vetoed= FALSE; if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE ) { @@ -5550,7 +5555,7 @@ int wxGrid::SendEvent( const wxEventType type, vetoed = !gridEvt.IsAllowed(); } - // A Veto'd event may not be `claimed' so test this first + // A Veto'd event may not be `claimed' so test this first if (vetoed) return -1; return claimed ? 1 : 0; @@ -6605,8 +6610,8 @@ void wxGrid::EnableCellEditControl( bool enable ) { if ( enable ) { - if (SendEvent( wxEVT_GRID_EDITOR_SHOWN) <0) - return; + if (SendEvent( wxEVT_GRID_EDITOR_SHOWN) <0) + return; // this should be checked by the caller! wxASSERT_MSG( CanEnableCellControl(),