X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c8fce1a43c78a54eefcbe4fad2048d3f6ee09855..cfeff6f71c716a19a9651b176dce26534c4da216:/src/generic/treectlg.cpp diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 01cd41e868..24dec8e4cb 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -40,6 +40,10 @@ #include "wx/renderer.h" +#ifdef __WXMAC__ + #include "wx/mac/private.h" +#endif + // ----------------------------------------------------------------------------- // array types // ----------------------------------------------------------------------------- @@ -677,7 +681,7 @@ BEGIN_EVENT_TABLE(wxGenericTreeCtrl,wxScrolledWindow) EVT_TREE_ITEM_GETTOOLTIP(-1, wxGenericTreeCtrl::OnGetToolTip) END_EVENT_TABLE() -#if !defined(__WXMSW__) || defined(__WIN16__) || defined(__WXUNIVERSAL__) +#if !defined(__WXMSW__) || defined(__WXUNIVERSAL__) /* * wxTreeCtrl has to be a real class or we have problems with * the run-time information. @@ -730,11 +734,17 @@ void wxGenericTreeCtrl::Init() m_textCtrl = NULL; m_renameTimer = NULL; + m_freezeCount = 0; + m_findTimer = NULL; m_lastOnSame = FALSE; +#if defined( __WXMAC__ ) && __WXMAC_CARBON__ + m_normalFont.MacCreateThemeFont( kThemeViewsFont ) ; +#else m_normalFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); +#endif m_boldFont = wxFont(m_normalFont.GetPointSize(), m_normalFont.GetFamily(), m_normalFont.GetStyle(), @@ -826,7 +836,9 @@ void wxGenericTreeCtrl::SetSpacing(unsigned int spacing) m_dirty = TRUE; } -size_t wxGenericTreeCtrl::GetChildrenCount(const wxTreeItemId& item, bool recursively) +size_t +wxGenericTreeCtrl::GetChildrenCount(const wxTreeItemId& item, + bool recursively) const { wxCHECK_MSG( item.IsOk(), 0u, wxT("invalid tree item") ); @@ -1898,8 +1910,12 @@ void wxGenericTreeCtrl::ScrollTo(const wxTreeItemId &item) // We have to call this here because the label in // question might just have been added and no screen // update taken place. - if (m_dirty) wxYieldIfNeeded(); - + if (m_dirty) +#if defined( __WXMSW__ ) || defined(__WXMAC__) + Update(); +#else + wxYieldIfNeeded(); +#endif wxGenericTreeItem *gitem = (wxGenericTreeItem*) item.m_pItem; // now scroll to the item @@ -2831,7 +2847,11 @@ void wxGenericTreeCtrl::Edit( const wxTreeItemId& item ) // question might just have been added and no screen // update taken place. if ( m_dirty ) +#if defined( __WXMSW__ ) || defined(__WXMAC__) + Update(); +#else wxYieldIfNeeded(); +#endif m_textCtrl = new wxTreeTextCtrl(this, itemEdit); @@ -2888,7 +2908,9 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) int flags = 0; wxGenericTreeItem *thisItem = m_anchor->HitTest(pt, this, flags, 0); wxGenericTreeItem *underMouse = thisItem; +#if wxUSE_TOOLTIPS bool underMouseChanged = (underMouse != m_underMouse) ; +#endif // wxUSE_TOOLTIPS if ((underMouse) && (flags & wxTREE_HITTEST_ONITEMBUTTON) && @@ -3016,7 +3038,11 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) // highlight the current drop target if any DrawDropEffect(m_dropTarget); +#if defined( __WXMSW__ ) || defined(__WXMAC__) + Update(); +#else wxYieldIfNeeded(); +#endif } } else if ( (event.LeftUp() || event.RightUp()) && m_isDragging ) @@ -3047,7 +3073,11 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) SetCursor(m_oldCursor); +#if defined( __WXMSW__ ) || defined(__WXMAC__) + Update(); +#else wxYieldIfNeeded(); +#endif } else { @@ -3193,7 +3223,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(); @@ -3304,6 +3335,7 @@ void wxGenericTreeCtrl::CalculatePositions() void wxGenericTreeCtrl::RefreshSubtree(wxGenericTreeItem *item) { if (m_dirty) return; + if (m_freezeCount) return; wxSize client = GetClientSize(); @@ -3320,6 +3352,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); @@ -3331,6 +3364,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 ) @@ -3339,6 +3374,8 @@ void wxGenericTreeCtrl::RefreshSelected() void wxGenericTreeCtrl::RefreshSelectedUnder(wxGenericTreeItem *item) { + if (m_freezeCount) return; + if ( item->IsSelected() ) RefreshLine(item); @@ -3350,6 +3387,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 // ---------------------------------------------------------------------------- @@ -3359,6 +3411,8 @@ bool wxGenericTreeCtrl::SetBackgroundColour(const wxColour& colour) if ( !wxWindow::SetBackgroundColour(colour) ) return FALSE; + if (m_freezeCount) return TRUE; + Refresh(); return TRUE; @@ -3369,6 +3423,8 @@ bool wxGenericTreeCtrl::SetForegroundColour(const wxColour& colour) if ( !wxWindow::SetForegroundColour(colour) ) return FALSE; + if (m_freezeCount) return TRUE; + Refresh(); return TRUE;