From 8e726db6675f48ad88ee99069ee4701ecb5c3be0 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 12 May 2019 10:41:49 +0200 Subject: [PATCH] Use dedicated function to check if wxPropertyGridPageState object is now displayed There is implemented IsDisplayed() function to check whether wxPropertyGrid current state refers to this state. --- src/propgrid/propgridpagestate.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/propgrid/propgridpagestate.cpp b/src/propgrid/propgridpagestate.cpp index 19c4ee626d..5e37752801 100644 --- a/src/propgrid/propgridpagestate.cpp +++ b/src/propgrid/propgridpagestate.cpp @@ -276,7 +276,7 @@ void wxPropertyGridPageState::InitNonCatMode() void wxPropertyGridPageState::DoClear() { - if ( m_pPropGrid && m_pPropGrid->GetState() == this ) + if ( m_pPropGrid && IsDisplayed() ) { m_pPropGrid->ClearSelection(false); } @@ -399,7 +399,7 @@ void wxPropertyGridPageState::OnClientWidthChange( int newWidth, int widthChange } } - if ( pg->GetState() == this ) + if ( IsDisplayed() ) { pg->SendEvent(wxEVT_PG_COLS_RESIZED, (wxPGProperty*)NULL); } @@ -642,7 +642,7 @@ bool wxPropertyGridPageState::EnableCategories( bool enable ) VirtualHeightChanged(); - if ( m_pPropGrid->GetState() == this ) + if ( IsDisplayed() ) m_pPropGrid->RecalculateVirtualSize(); return true; @@ -994,7 +994,7 @@ wxSize wxPropertyGridPageState::DoFitColumns( bool WXUNUSED(allowGridResize) ) m_fSplitterX = (double) firstSplitterX; // Don't allow initial splitter auto-positioning after this. - if ( pg->GetState() == this ) + if ( IsDisplayed() ) { pg->SetSplitterPosition(firstSplitterX, false); pg->Refresh(); @@ -1072,7 +1072,7 @@ void wxPropertyGridPageState::CheckColumnWidths( int widthChange ) m_width = colsWidth; // If width changed, recalculate virtual size - if ( pg->GetState() == this ) + if ( IsDisplayed() ) pg->RecalculateVirtualSize(); } @@ -1167,7 +1167,7 @@ void wxPropertyGridPageState::SetColumnCount( int colCount ) m_colWidths.resize(colCount, wxPG_DRAG_MARGIN); m_columnProportions.resize(colCount, 1); - if ( m_pPropGrid->GetState() == this ) + if ( IsDisplayed() ) m_pPropGrid->RecalculateVirtualSize(); else CheckColumnWidths(); @@ -1280,8 +1280,7 @@ bool wxPropertyGridPageState::DoSetPropertyValueString( wxPGProperty* p, const w if ( res ) { p->SetValue(variant); - if ( p == m_pPropGrid->GetSelection() && - this == m_pPropGrid->GetState() ) + if ( p == m_pPropGrid->GetSelection() && IsDisplayed() ) m_pPropGrid->RefreshEditor(); } @@ -1297,8 +1296,7 @@ bool wxPropertyGridPageState::DoSetPropertyValue( wxPGProperty* p, wxVariant& va if ( p ) { p->SetValue(value); - if ( p == m_pPropGrid->GetSelection() && - this == m_pPropGrid->GetState() ) + if ( p == m_pPropGrid->GetSelection() && IsDisplayed() ) m_pPropGrid->RefreshEditor(); return true; @@ -1338,7 +1336,7 @@ void wxPropertyGridPageState::DoRemoveFromSelection( wxPGProperty* prop ) if ( m_selection[i] == prop ) { wxPropertyGrid* pg = m_pPropGrid; - if ( i == 0 && pg->GetState() == this ) + if ( i == 0 && IsDisplayed() ) { // If first item (i.e. one with the active editor) was // deselected, then we need to take some extra measures. @@ -1400,7 +1398,7 @@ bool wxPropertyGridPageState::DoExpand( wxPGProperty* p ) bool wxPropertyGridPageState::DoSelectProperty( wxPGProperty* p, unsigned int flags ) { - if ( this == m_pPropGrid->GetState() ) + if ( IsDisplayed() ) return m_pPropGrid->DoSelectProperty( p, flags ); DoSetSelection(p); @@ -1490,7 +1488,7 @@ void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList& list, wx { bool origFrozen = true; - if ( m_pPropGrid->GetState() == this ) + if ( IsDisplayed() ) { origFrozen = m_pPropGrid->IsFrozen(); if ( !origFrozen ) m_pPropGrid->Freeze(); @@ -1629,7 +1627,7 @@ void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList& list, wx { m_pPropGrid->Thaw(); - if ( this == m_pPropGrid->GetState() ) + if ( IsDisplayed() ) m_pPropGrid->RefreshEditor(); } @@ -1835,7 +1833,7 @@ void wxPropertyGridPageState::DoRemoveChildrenFromSelection(wxPGProperty* p, wxPGProperty* child = p->Item(i); if ( DoIsPropertySelected(child) ) { - if ( pg && pg->GetState() == this ) + if ( pg && IsDisplayed() ) { pg->DoRemoveFromSelection(child, selFlags); } @@ -1942,7 +1940,7 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete ) // Try to unselect property and its sub-properties. if ( DoIsPropertySelected(item) ) { - if ( pg && pg->GetState() == this ) + if ( pg && IsDisplayed() ) { pg->DoRemoveFromSelection(item, wxPG_SEL_DELETING|wxPG_SEL_NOVALIDATE);