+ Refresh(true, &rect);
+}
+
+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 )
+ RefreshSelectedUnder(m_anchor);
+}
+
+void wxGenericTreeCtrl::RefreshSelectedUnder(wxGenericTreeItem *item)
+{
+ if (m_freezeCount)
+ return;
+
+ if ( item->IsSelected() )
+ RefreshLine(item);
+
+ const wxArrayGenericTreeItems& children = item->GetChildren();
+ size_t count = children.GetCount();
+ for ( size_t n = 0; n < count; n++ )
+ {
+ RefreshSelectedUnder(children[n]);
+ }
+}
+
+void wxGenericTreeCtrl::Freeze()
+{
+ m_freezeCount++;
+}
+
+void wxGenericTreeCtrl::Thaw()
+{
+ wxCHECK_RET( m_freezeCount > 0, _T("thawing unfrozen tree control?") );
+
+ if ( --m_freezeCount == 0 )
+ {
+ Refresh();
+ }
+}
+
+// ----------------------------------------------------------------------------
+// changing colours: we need to refresh the tree control
+// ----------------------------------------------------------------------------
+
+bool wxGenericTreeCtrl::SetBackgroundColour(const wxColour& colour)
+{
+ if ( !wxWindow::SetBackgroundColour(colour) )
+ return false;
+
+ Refresh();
+
+ return true;
+}
+
+bool wxGenericTreeCtrl::SetForegroundColour(const wxColour& colour)
+{
+ if ( !wxWindow::SetForegroundColour(colour) )
+ return false;
+
+ Refresh();
+
+ return true;
+}
+
+// Process the tooltip event, to speed up event processing.
+// Doesn't actually get a tooltip.
+void wxGenericTreeCtrl::OnGetToolTip( wxTreeEvent &event )
+{
+ event.Veto();
+}
+
+
+// NOTE: If using the wxListBox visual attributes works everywhere then this can
+// be removed, as well as the #else case below.
+#define _USE_VISATTR 0
+
+//static
+wxVisualAttributes
+#if _USE_VISATTR
+wxGenericTreeCtrl::GetClassDefaultAttributes(wxWindowVariant variant)
+#else
+wxGenericTreeCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+#endif
+{
+#if _USE_VISATTR
+ // Use the same color scheme as wxListBox
+ return wxListBox::GetClassDefaultAttributes(variant);
+#else
+ wxVisualAttributes attr;
+ attr.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
+ attr.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX);
+ attr.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
+ return attr;
+#endif
+}
+
+#if WXWIN_COMPATIBILITY_2_4
+
+int wxGenericTreeCtrl::GetItemSelectedImage(const wxTreeItemId& item) const
+{
+ return GetItemImage(item, wxTreeItemIcon_Selected);
+}
+
+void wxGenericTreeCtrl::SetItemSelectedImage(const wxTreeItemId& item, int image)
+{
+ SetItemImage(item, image, wxTreeItemIcon_Selected);
+}
+
+#endif // WXWIN_COMPATIBILITY_2_4
+
+void wxGenericTreeCtrl::DoDirtyProcessing()
+{
+ if (m_freezeCount)
+ return;
+
+ m_dirty = false;
+
+ CalculatePositions();
+ Refresh();
+ AdjustMyScrollbars();
+}
+
+wxSize wxGenericTreeCtrl::DoGetBestSize() const
+{
+ // make sure all positions are calculated as normally this only done during
+ // idle time but we need them for base class DoGetBestSize() to return the
+ // correct result
+ wxConstCast(this, wxGenericTreeCtrl)->CalculatePositions();
+
+ wxSize size = wxTreeCtrlBase::DoGetBestSize();
+
+ // there seems to be an implicit extra border around the items, although
+ // I'm not really sure where does it come from -- but without this, the
+ // scrollbars appear in a tree with default/best size
+ size.IncBy(4, 4);
+
+ // and the border has to be rounded up to a multiple of PIXELS_PER_UNIT or
+ // scrollbars still appear
+ const wxSize& borderSize = GetWindowBorderSize();
+
+ int dx = (size.x - borderSize.x) % PIXELS_PER_UNIT;
+ if ( dx )
+ size.x += PIXELS_PER_UNIT - dx;
+ int dy = (size.y - borderSize.y) % PIXELS_PER_UNIT;
+ if ( dy )
+ size.y += PIXELS_PER_UNIT - dy;
+
+ // we need to update the cache too as the base class cached its own value
+ CacheBestSize(size);
+
+ return size;