From e1983ab58804a0e32ab2d832ded0349af1cc0476 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 30 Mar 2004 17:10:30 +0000 Subject: [PATCH] implemented Freeze/Thaw() (patch 922156) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26499 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 4 ++-- include/wx/generic/treectlg.h | 4 ++++ src/generic/treectlg.cpp | 30 +++++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 781c4b1824..51b8a4d090 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -89,8 +89,8 @@ All (GUI): - wxHtmlWindow now delays image scaling until rendering, resulting in much better display of scaled images -- Added UpdateSize to wxSplitterWindow to allow layout - while hidden +- Added UpdateSize to wxSplitterWindow to allow layout while hidden +- implemented Freeze/Thaw() for wxGenericTreeCtrl (Kevin Hock) wxMSW: diff --git a/include/wx/generic/treectlg.h b/include/wx/generic/treectlg.h index db05419223..2aba6baa10 100644 --- a/include/wx/generic/treectlg.h +++ b/include/wx/generic/treectlg.h @@ -378,6 +378,9 @@ public: virtual bool SetBackgroundColour(const wxColour& colour); virtual bool SetForegroundColour(const wxColour& colour); + virtual void Freeze(); + virtual void Thaw(); + // callbacks void OnPaint( wxPaintEvent &event ); void OnSetFocus( wxFocusEvent &event ); @@ -419,6 +422,7 @@ protected: *m_imageListState, *m_imageListButtons; + int m_freezeCount; int m_dragCount; wxPoint m_dragStart; wxGenericTreeItem *m_dropTarget; diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 97c309222a..69637e09c0 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -734,6 +734,8 @@ void wxGenericTreeCtrl::Init() m_textCtrl = NULL; m_renameTimer = NULL; + m_freezeCount = 0; + m_findTimer = NULL; m_lastOnSame = FALSE; @@ -3219,7 +3221,8 @@ void wxGenericTreeCtrl::OnInternalIdle() * we actually redraw the tree when everything is over */ if (!m_dirty) return; - + if (m_freezeCount) return; + m_dirty = FALSE; CalculatePositions(); @@ -3330,6 +3333,7 @@ void wxGenericTreeCtrl::CalculatePositions() void wxGenericTreeCtrl::RefreshSubtree(wxGenericTreeItem *item) { if (m_dirty) return; + if (m_freezeCount) return; wxSize client = GetClientSize(); @@ -3346,6 +3350,7 @@ void wxGenericTreeCtrl::RefreshSubtree(wxGenericTreeItem *item) void wxGenericTreeCtrl::RefreshLine( wxGenericTreeItem *item ) { if (m_dirty) return; + if (m_freezeCount) return; wxRect rect; CalcScrolledPosition(0, item->GetY(), NULL, &rect.y); @@ -3357,6 +3362,8 @@ void wxGenericTreeCtrl::RefreshLine( wxGenericTreeItem *item ) void wxGenericTreeCtrl::RefreshSelected() { + if (m_freezeCount) return; + // TODO: this is awfully inefficient, we should keep the list of all // selected items internally, should be much faster if ( m_anchor ) @@ -3365,6 +3372,8 @@ void wxGenericTreeCtrl::RefreshSelected() void wxGenericTreeCtrl::RefreshSelectedUnder(wxGenericTreeItem *item) { + if (m_freezeCount) return; + if ( item->IsSelected() ) RefreshLine(item); @@ -3376,6 +3385,21 @@ void wxGenericTreeCtrl::RefreshSelectedUnder(wxGenericTreeItem *item) } } +void wxGenericTreeCtrl::Freeze() +{ + m_freezeCount++; +} + +void wxGenericTreeCtrl::Thaw() +{ + wxCHECK_RET( m_freezeCount > 0, _T("thawing unfrozen tree control?") ); + + if ( !--m_freezeCount ) + { + Refresh(); + } +} + // ---------------------------------------------------------------------------- // changing colours: we need to refresh the tree control // ---------------------------------------------------------------------------- @@ -3385,6 +3409,8 @@ bool wxGenericTreeCtrl::SetBackgroundColour(const wxColour& colour) if ( !wxWindow::SetBackgroundColour(colour) ) return FALSE; + if (m_freezeCount) return TRUE; + Refresh(); return TRUE; @@ -3395,6 +3421,8 @@ bool wxGenericTreeCtrl::SetForegroundColour(const wxColour& colour) if ( !wxWindow::SetForegroundColour(colour) ) return FALSE; + if (m_freezeCount) return TRUE; + Refresh(); return TRUE; -- 2.45.2