]> git.saurik.com Git - wxWidgets.git/commitdiff
Show tooltips for the too long items in generic wxTreeCtrl.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 18 Sep 2012 22:45:15 +0000 (22:45 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 18 Sep 2012 22:45:15 +0000 (22:45 +0000)
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

docs/changes.txt
src/generic/treectlg.cpp

index 20aa862f3cef610ba395b0a91ffdc1fe0e0a7c7a..c848a7672778503846ffea7c2197c1a53b881baa 100644 (file)
@@ -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:
 
index b11fd4b44960459d66effc35b0a57b817b805b0d..51347f51e57995367ac9a366564e24450b45e384 100644 (file)
@@ -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();
+    }
 }