From fb730c32b48e49e2688f3db3b5164cb248daad7f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 17 Jan 2014 18:56:13 +0000 Subject: [PATCH] Override Do{Freeze,Thaw}() instead of {Freeze,Thaw}() in wxPropGrid code. {Freeze,Thaw}() themselves are not virtual any more, so overriding them doesn't really work and it is unnecessary to reimplement the reference counting already done by the base class anyhow, so override the DoXXX() versions instead. Closes #15877. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75640 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/propgrid/manager.h | 12 ++----- include/wx/propgrid/propgrid.h | 15 ++------- src/propgrid/manager.cpp | 8 ++--- src/propgrid/propgrid.cpp | 50 +++++++++++------------------- src/propgrid/propgridpagestate.cpp | 2 +- 5 files changed, 28 insertions(+), 59 deletions(-) diff --git a/include/wx/propgrid/manager.h b/include/wx/propgrid/manager.h index 833254bcc6..ce4aca0f90 100644 --- a/include/wx/propgrid/manager.h +++ b/include/wx/propgrid/manager.h @@ -483,12 +483,6 @@ public: */ bool IsAnyModified() const; - /** - Returns true if updating is frozen (ie Freeze() called but not yet - Thaw() ). - */ - bool IsFrozen() const { return m_pPropGrid->m_frozen > 0; } - /** Returns true if any property on given page has been modified by the user. @@ -635,9 +629,6 @@ public: // void SetId( wxWindowID winid ); - - virtual void Freeze(); - virtual void Thaw(); virtual void SetExtraStyle ( long exStyle ); virtual bool SetFont ( const wxFont& font ); virtual void SetWindowStyleFlag ( long style ); @@ -646,6 +637,9 @@ public: protected: virtual wxSize DoGetBestSize() const; + virtual void DoFreeze(); + virtual void DoThaw(); + // // Event handlers // diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index 45cdf1c395..f7f2f1368b 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -1073,12 +1073,6 @@ public: /** Returns true if any property has been modified by the user. */ bool IsAnyModified() const { return (m_pState->m_anyModified>0); } - /** - Returns true if updating is frozen (ie Freeze() called but not yet - Thaw() ). - */ - bool IsFrozen() const { return (m_frozen>0)?true:false; } - /** It is recommended that you call this function any time your code causes wxPropertyGrid's top-level parent to change. wxPropertyGrid's OnIdle() @@ -1559,8 +1553,6 @@ public: { return (m_iFlags & flag) ? true : false; } void SetInternalFlag( long flag ) { m_iFlags |= flag; } void ClearInternalFlag( long flag ) { m_iFlags &= ~(flag); } - void IncFrozen() { m_frozen++; } - void DecFrozen() { m_frozen--; } void OnComboItemPaint( const wxPGComboBox* pCb, int item, @@ -1778,12 +1770,12 @@ public: virtual void Refresh( bool eraseBackground = true, const wxRect *rect = (const wxRect *) NULL ); virtual bool SetFont( const wxFont& font ); - virtual void Freeze(); virtual void SetExtraStyle( long exStyle ); - virtual void Thaw(); virtual bool Reparent( wxWindowBase *newParent ); protected: + virtual void DoThaw(); + virtual wxSize DoGetBestSize() const; #ifndef wxPG_ICON_WIDTH @@ -1934,9 +1926,6 @@ protected: /** 1 if m_latsCaption is also the bottommost caption. */ //unsigned char m_lastCaptionBottomnest; - /** Set to 1 when graphics frozen. */ - unsigned char m_frozen; - unsigned char m_vspacing; // Used to track when Alt/Ctrl+Key was consumed. diff --git a/src/propgrid/manager.cpp b/src/propgrid/manager.cpp index ed0f5108fd..0a9fcd19a0 100644 --- a/src/propgrid/manager.cpp +++ b/src/propgrid/manager.cpp @@ -679,17 +679,17 @@ void wxPropertyGridManager::SetExtraStyle( long exStyle ) // ----------------------------------------------------------------------- -void wxPropertyGridManager::Freeze() +void wxPropertyGridManager::DoFreeze() { m_pPropGrid->Freeze(); - wxWindow::Freeze(); + wxWindow::DoFreeze(); } // ----------------------------------------------------------------------- -void wxPropertyGridManager::Thaw() +void wxPropertyGridManager::DoThaw() { - wxWindow::Thaw(); + wxWindow::DoThaw(); m_pPropGrid->Thaw(); } diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 58724127ff..1f0ea10349 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -373,7 +373,6 @@ void wxPropertyGrid::Init1() AddActionTrigger( wxPG_ACTION_PRESS_BUTTON, WXK_F4 ); m_coloursCustomized = 0; - m_frozen = 0; m_doubleBuffer = NULL; @@ -607,7 +606,7 @@ void wxPropertyGrid::SetWindowStyleFlag( long style ) // // Autosort enabled // - if ( !m_frozen ) + if ( !IsFrozen() ) PrepareAfterItemsAdded(); else m_pState->m_itemsAdded = 1; @@ -648,24 +647,11 @@ void wxPropertyGrid::SetWindowStyleFlag( long style ) // ----------------------------------------------------------------------- -void wxPropertyGrid::Freeze() +void wxPropertyGrid::DoThaw() { - if ( !m_frozen ) + if ( !IsFrozen() ) { - wxControl::Freeze(); - } - m_frozen++; -} - -// ----------------------------------------------------------------------- - -void wxPropertyGrid::Thaw() -{ - m_frozen--; - - if ( !m_frozen ) - { - wxControl::Thaw(); + wxControl::DoThaw(); RecalculateVirtualSize(); Refresh(); @@ -1920,7 +1906,7 @@ void wxPropertyGrid::DrawItems( wxDC& dc, unsigned int bottomItemY, const wxRect* itemsRect ) { - if ( m_frozen || + if ( IsFrozen() || m_height < 1 || bottomItemY < topItemY || !m_pState ) @@ -2028,7 +2014,7 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc, if ( !lastItem ) lastItem = GetLastItem( wxPG_ITERATE_VISIBLE ); - if ( m_frozen || m_height < 1 || firstItem == NULL ) + if ( IsFrozen() || m_height < 1 || firstItem == NULL ) return itemsRect->y; wxCHECK_MSG( !m_pState->m_itemsAdded, itemsRect->y, @@ -2554,7 +2540,7 @@ wxRect wxPropertyGrid::GetPropertyRect( const wxPGProperty* p1, const wxPGProper void wxPropertyGrid::DrawItems( const wxPGProperty* p1, const wxPGProperty* p2 ) { - if ( m_frozen ) + if ( IsFrozen() ) return; if ( m_pState->m_itemsAdded ) @@ -2592,7 +2578,7 @@ void wxPropertyGrid::RefreshProperty( wxPGProperty* p ) void wxPropertyGrid::DrawItemAndValueRelated( wxPGProperty* p ) { - if ( m_frozen ) + if ( IsFrozen() ) return; // Draw item, children, and parent too, if it is not category @@ -2618,7 +2604,7 @@ void wxPropertyGrid::DrawItemAndChildren( wxPGProperty* p ) return; // do not draw a single item if multiple pending - if ( m_pState->m_itemsAdded || m_frozen ) + if ( m_pState->m_itemsAdded || IsFrozen() ) return; // Update child control. @@ -2662,7 +2648,7 @@ void wxPropertyGrid::Clear() RecalculateVirtualSize(); // Need to clear some area at the end - if ( !m_frozen ) + if ( !IsFrozen() ) RefreshRect(wxRect(0, 0, m_width, m_height)); } @@ -2691,7 +2677,7 @@ bool wxPropertyGrid::EnableCategories( bool enable ) if ( !m_pState->EnableCategories(enable) ) return false; - if ( !m_frozen ) + if ( !IsFrozen() ) { if ( m_windowStyle & wxPG_AUTO_SORT ) { @@ -2763,7 +2749,7 @@ void wxPropertyGrid::SwitchState( wxPropertyGridPageState* pNewState ) // This should refresh as well. EnableCategories( orig_mode?false:true ); } - else if ( !m_frozen ) + else if ( !IsFrozen() ) { // Refresh, if not frozen. m_pState->PrepareAfterItemsAdded(); @@ -4029,7 +4015,7 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags ) wxWindow* primaryCtrl = NULL; // If we are frozen, then just set the values. - if ( m_frozen ) + if ( IsFrozen() ) { m_iFlags &= ~(wxPG_FL_ABNORMAL_EDITOR); m_editorFocused = 0; @@ -4341,7 +4327,7 @@ bool wxPropertyGrid::UnfocusEditor() { wxPGProperty* selected = GetSelection(); - if ( !selected || !m_wndEditor || m_frozen ) + if ( !selected || !m_wndEditor || IsFrozen() ) return true; if ( !CommitChangesFromEditor(0) ) @@ -4463,7 +4449,7 @@ bool wxPropertyGrid::DoExpand( wxPGProperty* p, bool sendEvents ) bool wxPropertyGrid::DoHideProperty( wxPGProperty* p, bool hide, int flags ) { - if ( m_frozen ) + if ( IsFrozen() ) return m_pState->DoHideProperty(p, hide, flags); wxArrayPGProperty selection = m_pState->m_selection; // Must use a copy @@ -4497,7 +4483,7 @@ void wxPropertyGrid::RecalculateVirtualSize( int forceXPos ) // Don't check for !HasInternalFlag(wxPG_FL_INITIALIZED) here. Otherwise // virtual size calculation may go wrong. if ( HasInternalFlag(wxPG_FL_RECALCULATING_VIRTUAL_SIZE) || - m_frozen || + IsFrozen() || !m_pState ) return; @@ -4614,7 +4600,7 @@ void wxPropertyGrid::OnResize( wxSizeEvent& event ) m_pState->OnClientWidthChange( width, event.GetSize().x - m_ncWidth, true ); m_ncWidth = event.GetSize().x; - if ( !m_frozen ) + if ( !IsFrozen() ) { if ( m_pState->m_itemsAdded ) PrepareAfterItemsAdded(); @@ -5544,7 +5530,7 @@ void wxPropertyGrid::HandleKeyEvent( wxKeyEvent &event, bool fromChild ) // Handles key event when editor control is not focused. // - wxCHECK2(!m_frozen, return); + wxCHECK2(!IsFrozen(), return); // Travelsal between items, collapsing/expanding, etc. wxPGProperty* selected = GetSelection(); diff --git a/src/propgrid/propgridpagestate.cpp b/src/propgrid/propgridpagestate.cpp index b178b1b46c..dc7426f2f8 100644 --- a/src/propgrid/propgridpagestate.cpp +++ b/src/propgrid/propgridpagestate.cpp @@ -1494,7 +1494,7 @@ void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList& list, wx if ( m_pPropGrid->GetState() == this ) { - origFrozen = m_pPropGrid->m_frozen; + origFrozen = m_pPropGrid->IsFrozen(); if ( !origFrozen ) m_pPropGrid->Freeze(); }