Show tooltips for the too long items in generic wxTreeCtrl.
Show the full item text in a tooltip if the entire text can't be shown on screen. Closes #14667. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72505 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
f45f43cad0
commit
fcde720806
@ -552,6 +552,7 @@ All (GUI):
|
||||
- Add wxTextEntry::SelectNone() (troelsk).
|
||||
- Restore the original wxGrid col/row size when unhiding it (Michael Richards).
|
||||
- Fix text origin and extent computations in wxSVGFileDC (Neil Chittenden).
|
||||
- Show tooltips for the too long items in generic wxTreeCtrl (Steven Houchins).
|
||||
|
||||
wxGTK:
|
||||
|
||||
|
@ -3534,9 +3534,14 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event )
|
||||
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
|
||||
@ -4004,11 +4009,24 @@ bool wxGenericTreeCtrl::SetForegroundColour(const wxColour& colour)
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user