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.
This commit is contained in:
Artur Wieczorek
2019-05-12 10:41:49 +02:00
parent e73183743a
commit 8e726db667

View File

@@ -276,7 +276,7 @@ void wxPropertyGridPageState::InitNonCatMode()
void wxPropertyGridPageState::DoClear() void wxPropertyGridPageState::DoClear()
{ {
if ( m_pPropGrid && m_pPropGrid->GetState() == this ) if ( m_pPropGrid && IsDisplayed() )
{ {
m_pPropGrid->ClearSelection(false); 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); pg->SendEvent(wxEVT_PG_COLS_RESIZED, (wxPGProperty*)NULL);
} }
@@ -642,7 +642,7 @@ bool wxPropertyGridPageState::EnableCategories( bool enable )
VirtualHeightChanged(); VirtualHeightChanged();
if ( m_pPropGrid->GetState() == this ) if ( IsDisplayed() )
m_pPropGrid->RecalculateVirtualSize(); m_pPropGrid->RecalculateVirtualSize();
return true; return true;
@@ -994,7 +994,7 @@ wxSize wxPropertyGridPageState::DoFitColumns( bool WXUNUSED(allowGridResize) )
m_fSplitterX = (double) firstSplitterX; m_fSplitterX = (double) firstSplitterX;
// Don't allow initial splitter auto-positioning after this. // Don't allow initial splitter auto-positioning after this.
if ( pg->GetState() == this ) if ( IsDisplayed() )
{ {
pg->SetSplitterPosition(firstSplitterX, false); pg->SetSplitterPosition(firstSplitterX, false);
pg->Refresh(); pg->Refresh();
@@ -1072,7 +1072,7 @@ void wxPropertyGridPageState::CheckColumnWidths( int widthChange )
m_width = colsWidth; m_width = colsWidth;
// If width changed, recalculate virtual size // If width changed, recalculate virtual size
if ( pg->GetState() == this ) if ( IsDisplayed() )
pg->RecalculateVirtualSize(); pg->RecalculateVirtualSize();
} }
@@ -1167,7 +1167,7 @@ void wxPropertyGridPageState::SetColumnCount( int colCount )
m_colWidths.resize(colCount, wxPG_DRAG_MARGIN); m_colWidths.resize(colCount, wxPG_DRAG_MARGIN);
m_columnProportions.resize(colCount, 1); m_columnProportions.resize(colCount, 1);
if ( m_pPropGrid->GetState() == this ) if ( IsDisplayed() )
m_pPropGrid->RecalculateVirtualSize(); m_pPropGrid->RecalculateVirtualSize();
else else
CheckColumnWidths(); CheckColumnWidths();
@@ -1280,8 +1280,7 @@ bool wxPropertyGridPageState::DoSetPropertyValueString( wxPGProperty* p, const w
if ( res ) if ( res )
{ {
p->SetValue(variant); p->SetValue(variant);
if ( p == m_pPropGrid->GetSelection() && if ( p == m_pPropGrid->GetSelection() && IsDisplayed() )
this == m_pPropGrid->GetState() )
m_pPropGrid->RefreshEditor(); m_pPropGrid->RefreshEditor();
} }
@@ -1297,8 +1296,7 @@ bool wxPropertyGridPageState::DoSetPropertyValue( wxPGProperty* p, wxVariant& va
if ( p ) if ( p )
{ {
p->SetValue(value); p->SetValue(value);
if ( p == m_pPropGrid->GetSelection() && if ( p == m_pPropGrid->GetSelection() && IsDisplayed() )
this == m_pPropGrid->GetState() )
m_pPropGrid->RefreshEditor(); m_pPropGrid->RefreshEditor();
return true; return true;
@@ -1338,7 +1336,7 @@ void wxPropertyGridPageState::DoRemoveFromSelection( wxPGProperty* prop )
if ( m_selection[i] == prop ) if ( m_selection[i] == prop )
{ {
wxPropertyGrid* pg = m_pPropGrid; 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 // If first item (i.e. one with the active editor) was
// deselected, then we need to take some extra measures. // 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 ) bool wxPropertyGridPageState::DoSelectProperty( wxPGProperty* p, unsigned int flags )
{ {
if ( this == m_pPropGrid->GetState() ) if ( IsDisplayed() )
return m_pPropGrid->DoSelectProperty( p, flags ); return m_pPropGrid->DoSelectProperty( p, flags );
DoSetSelection(p); DoSetSelection(p);
@@ -1490,7 +1488,7 @@ void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList& list, wx
{ {
bool origFrozen = true; bool origFrozen = true;
if ( m_pPropGrid->GetState() == this ) if ( IsDisplayed() )
{ {
origFrozen = m_pPropGrid->IsFrozen(); origFrozen = m_pPropGrid->IsFrozen();
if ( !origFrozen ) m_pPropGrid->Freeze(); if ( !origFrozen ) m_pPropGrid->Freeze();
@@ -1629,7 +1627,7 @@ void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList& list, wx
{ {
m_pPropGrid->Thaw(); m_pPropGrid->Thaw();
if ( this == m_pPropGrid->GetState() ) if ( IsDisplayed() )
m_pPropGrid->RefreshEditor(); m_pPropGrid->RefreshEditor();
} }
@@ -1835,7 +1833,7 @@ void wxPropertyGridPageState::DoRemoveChildrenFromSelection(wxPGProperty* p,
wxPGProperty* child = p->Item(i); wxPGProperty* child = p->Item(i);
if ( DoIsPropertySelected(child) ) if ( DoIsPropertySelected(child) )
{ {
if ( pg && pg->GetState() == this ) if ( pg && IsDisplayed() )
{ {
pg->DoRemoveFromSelection(child, selFlags); pg->DoRemoveFromSelection(child, selFlags);
} }
@@ -1942,7 +1940,7 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
// Try to unselect property and its sub-properties. // Try to unselect property and its sub-properties.
if ( DoIsPropertySelected(item) ) if ( DoIsPropertySelected(item) )
{ {
if ( pg && pg->GetState() == this ) if ( pg && IsDisplayed() )
{ {
pg->DoRemoveFromSelection(item, pg->DoRemoveFromSelection(item,
wxPG_SEL_DELETING|wxPG_SEL_NOVALIDATE); wxPG_SEL_DELETING|wxPG_SEL_NOVALIDATE);