+ Refresh(true, &rect);
+}
+
+void wxGenericTreeCtrl::RefreshSelected()
+{
+ if (IsFrozen())
+ 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 (IsFrozen())
+ 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::DoThaw()
+{
+ wxTreeCtrlBase::DoThaw();
+
+ if ( m_dirty )
+ DoDirtyProcessing();
+ else
+ 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;
+}
+
+void wxGenericTreeCtrl::OnGetToolTip( wxTreeEvent &event )
+{
+#if wxUSE_TOOLTIPS
+ wxTreeItemId itemId = event.GetItem();
+ const wxGenericTreeItem* const pItem = (wxGenericTreeItem*)itemId.m_pItem;
+
+ // Check if the item fits into the client area:
+ if ( pItem->GetX() + pItem->GetWidth() > GetClientSize().x )
+ {
+ // If it doesn't, show its full text in the tooltip.
+ event.SetLabel(pItem->GetText());
+ }
+ else
+#endif // wxUSE_TOOLTIPS
+ {
+ // veto processing the event, nixing any tooltip
+ 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_LISTBOXTEXT);
+ attr.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX);
+ attr.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
+ return attr;
+#endif
+}
+
+void wxGenericTreeCtrl::DoDirtyProcessing()
+{
+ if (IsFrozen())
+ 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;