// update the control before scrolling it
if (m_dirty)
-#if defined( __WXMSW__ ) || defined(__WXMAC__)
+ {
+#if defined( __WXMSW__ )
+ Update();
+#elif defined(__WXMAC__)
Update();
+ DoDirtyProcessing();
#else
DoDirtyProcessing();
#endif
-
+ }
+
wxGenericTreeItem *gitem = (wxGenericTreeItem*) item.m_pItem;
int itemY = gitem->GetY();
{
// need to scroll up by enough to show this item fully
itemY += itemHeight - clientHeight;
+#ifdef __WXOSX__
+ // because itemY below will be divided by PIXELS_PER_UNIT it may
+ // be rounded down, with the result of the item still only being
+ // partially visible, so make sure we are rounding up
+ itemY += PIXELS_PER_UNIT-1;
+#endif
}
else if ( itemY > start_y*PIXELS_PER_UNIT )
{
yOrigin = abs(yOrigin);
GetClientSize(&width, &height);
- // Move end points to the begining/end of the view?
+ // Move end points to the beginning/end of the view?
if (y_mid < yOrigin)
y_mid = yOrigin;
if (oldY > yOrigin + height)
wxTreeEvent
hevent(wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP, this, hoverItem);
- if ( GetEventHandler()->ProcessEvent(hevent) && hevent.IsAllowed() )
+ if ( GetEventHandler()->ProcessEvent(hevent) )
{
- SetToolTip(hevent.m_label);
+ // If the user permitted the tooltip change, update it, otherwise
+ // remove any old tooltip we might have.
+ if ( hevent.IsAllowed() )
+ SetToolTip(hevent.m_label);
+ else
+ SetToolTip(NULL);
}
}
#endif
return true;
}
-// Process the tooltip event, to speed up event processing.
-// Doesn't actually get a tooltip.
void wxGenericTreeCtrl::OnGetToolTip( wxTreeEvent &event )
{
- event.Veto();
+#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();
+ }
}