Set the mouse pos for the drag events, add support for the tooltip event
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32561 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -543,6 +543,7 @@ protected:
|
|||||||
// // the common part of all ctors
|
// // the common part of all ctors
|
||||||
// void Init();
|
// void Init();
|
||||||
|
|
||||||
|
void OnGetToolTip( wxTreeEvent &event );
|
||||||
void OnSize(wxSizeEvent& event);
|
void OnSize(wxSizeEvent& event);
|
||||||
void CalculateAndSetHeaderHeight();
|
void CalculateAndSetHeaderHeight();
|
||||||
void DoHeaderLayout();
|
void DoHeaderLayout();
|
||||||
|
@@ -4133,6 +4133,9 @@ void wxTreeListMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
int flags = 0;
|
int flags = 0;
|
||||||
wxTreeListItem *item = m_anchor->HitTest(pt, this, flags, 0);
|
wxTreeListItem *item = m_anchor->HitTest(pt, this, flags, 0);
|
||||||
wxTreeListItem *underMouse = item;
|
wxTreeListItem *underMouse = item;
|
||||||
|
#if wxUSE_TOOLTIPS
|
||||||
|
bool underMouseChanged = (underMouse != m_underMouse) ;
|
||||||
|
#endif // wxUSE_TOOLTIPS
|
||||||
|
|
||||||
if (underMouse && (flags & wxTREE_HITTEST_ONITEMBUTTON) &&
|
if (underMouse && (flags & wxTREE_HITTEST_ONITEMBUTTON) &&
|
||||||
!event.LeftIsDown() && !m_isDragging &&
|
!event.LeftIsDown() && !m_isDragging &&
|
||||||
@@ -4159,6 +4162,25 @@ void wxTreeListMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
RefreshLine( m_underMouse );
|
RefreshLine( m_underMouse );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_TOOLTIPS
|
||||||
|
// Determines what item we are hovering over and need a tooltip for
|
||||||
|
wxTreeItemId hoverItem = item;
|
||||||
|
|
||||||
|
// We do not want a tooltip if we are dragging, or if the rename timer is running
|
||||||
|
if (underMouseChanged && hoverItem.IsOk() && !m_isDragging && (!m_renameTimer || !m_renameTimer->IsRunning()))
|
||||||
|
{
|
||||||
|
// Ask the tree control what tooltip (if any) should be shown
|
||||||
|
wxTreeEvent hevent(wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP, GetId());
|
||||||
|
hevent.SetItem(hoverItem);
|
||||||
|
hevent.SetEventObject(this);
|
||||||
|
|
||||||
|
if ( GetEventHandler()->ProcessEvent(hevent) && hevent.IsAllowed() )
|
||||||
|
{
|
||||||
|
SetToolTip(hevent.GetLabel());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// we process left mouse up event (enables in-place edit), right down
|
// we process left mouse up event (enables in-place edit), right down
|
||||||
// (pass to the user code), left dbl click (activate item) and
|
// (pass to the user code), left dbl click (activate item) and
|
||||||
// dragging/moving events for items drag-and-drop
|
// dragging/moving events for items drag-and-drop
|
||||||
@@ -4203,6 +4225,7 @@ void wxTreeListMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
wxTreeEvent nevent( command,/*ALB*/ m_owner->GetId() );
|
wxTreeEvent nevent( command,/*ALB*/ m_owner->GetId() );
|
||||||
nevent.SetItem( (long) m_current);
|
nevent.SetItem( (long) m_current);
|
||||||
nevent.SetEventObject(/*this*/m_owner); // ALB
|
nevent.SetEventObject(/*this*/m_owner); // ALB
|
||||||
|
nevent.SetPoint(pt);
|
||||||
|
|
||||||
// by default the dragging is not supported, the user code must
|
// by default the dragging is not supported, the user code must
|
||||||
// explicitly allow the event for it to take place
|
// explicitly allow the event for it to take place
|
||||||
@@ -4610,6 +4633,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxTreeListCtrl, wxControl);
|
|||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxTreeListCtrl, wxControl)
|
BEGIN_EVENT_TABLE(wxTreeListCtrl, wxControl)
|
||||||
EVT_SIZE(wxTreeListCtrl::OnSize)
|
EVT_SIZE(wxTreeListCtrl::OnSize)
|
||||||
|
EVT_TREE_ITEM_GETTOOLTIP(wxID_ANY, wxTreeListCtrl::OnGetToolTip)
|
||||||
END_EVENT_TABLE();
|
END_EVENT_TABLE();
|
||||||
|
|
||||||
bool wxTreeListCtrl::Create(wxWindow *parent, wxWindowID id,
|
bool wxTreeListCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||||
@@ -5088,3 +5112,11 @@ wxSize wxTreeListCtrl::DoGetBestSize() const
|
|||||||
// something is better than nothing...
|
// something is better than nothing...
|
||||||
return wxSize(100,80);
|
return wxSize(100,80);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Process the tooltip event, to speed up event processing.
|
||||||
|
// Doesn't actually get a tooltip.
|
||||||
|
void wxTreeListCtrl::OnGetToolTip( wxTreeEvent &event )
|
||||||
|
{
|
||||||
|
event.Veto();
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user