X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5391f772be01cefca80affdc87afbfb894b2976b..3372145d9daa42f680fc5aab7eb00e82d587c5a0:/src/generic/treectrl.cpp?ds=inline diff --git a/src/generic/treectrl.cpp b/src/generic/treectrl.cpp index db95ab3abe..3dd2b16562 100644 --- a/src/generic/treectrl.cpp +++ b/src/generic/treectrl.cpp @@ -1196,11 +1196,16 @@ void wxTreeCtrl::ScrollTo(const wxTreeItemId &item) { if (!item.IsOk()) return; + // We have to call this here because the label in + // question might just have been added and no screen + // update taken place. + if (m_dirty) wxYield(); + wxGenericTreeItem *gitem = item.m_pItem; // now scroll to the item int item_y = gitem->GetY(); - + int start_x = 0; int start_y = 0; ViewStart( &start_x, &start_y ); @@ -1339,10 +1344,10 @@ void wxTreeCtrl::AdjustMyScrollbars() int wxTreeCtrl::GetLineHeight(wxGenericTreeItem *item) const { - if (GetWindowStyleFlag() & wxTR_HAS_VARIABLE_ROW_HEIGHT) - return item->GetHeight(); - else - return m_lineHeight; + if (GetWindowStyleFlag() & wxTR_HAS_VARIABLE_ROW_HEIGHT) + return item->GetHeight(); + else + return m_lineHeight; } void wxTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) @@ -1778,6 +1783,11 @@ void wxTreeCtrl::OnChar( wxKeyEvent &event ) wxTreeItemId wxTreeCtrl::HitTest(const wxPoint& point, int& flags) { + // We have to call this here because the label in + // question might just have been added and no screen + // update taken place. + if (m_dirty) wxYield(); + wxClientDC dc(this); PrepareDC(dc); long x = dc.DeviceToLogicalX( (long)point.x ); @@ -1808,6 +1818,11 @@ void wxTreeCtrl::Edit( const wxTreeItemId& item ) GetEventHandler()->ProcessEvent( te ); if (!te.IsAllowed()) return; + + // We have to call this here because the label in + // question might just have been added and no screen + // update taken place. + if (m_dirty) wxYield(); wxString s = m_currentEdit->GetText(); int x = m_currentEdit->GetX(); @@ -1860,8 +1875,6 @@ void wxTreeCtrl::OnRenameAccept() void wxTreeCtrl::OnMouse( wxMouseEvent &event ) { - if (!event.LeftIsDown()) m_dragCount = 0; - if ( !(event.LeftUp() || event.LeftDClick() || event.Dragging()) ) return; if ( !m_anchor ) return; @@ -1875,25 +1888,30 @@ void wxTreeCtrl::OnMouse( wxMouseEvent &event ) wxGenericTreeItem *item = m_anchor->HitTest( wxPoint(x,y), this, flags); bool onButton = flags & wxTREE_HITTEST_ONITEMBUTTON; - if (item == NULL) return; /* we hit the blank area */ - if (event.Dragging()) { - if (m_dragCount == 2) /* small drag latency (3?) */ - { - m_dragCount = 0; - - wxTreeEvent nevent(wxEVT_COMMAND_TREE_BEGIN_DRAG, GetId()); - nevent.m_item = m_current; - nevent.SetEventObject(this); - GetEventHandler()->ProcessEvent(nevent); - } - else - { - m_dragCount++; - } - return; + if (m_dragCount == 0) + m_dragStart = wxPoint(x,y); + + m_dragCount++; + + if (m_dragCount != 3) return; + + int command = wxEVT_COMMAND_TREE_BEGIN_DRAG; + if (event.RightIsDown()) command = wxEVT_COMMAND_TREE_BEGIN_RDRAG; + + wxTreeEvent nevent( command, GetId() ); + nevent.m_item = m_current; + nevent.SetEventObject(this); + GetEventHandler()->ProcessEvent(nevent); + return; } + else + { + m_dragCount = 0; + } + + if (item == NULL) return; /* we hit the blank area */ if (event.LeftUp() && (item == m_current) && (flags & wxTREE_HITTEST_ONITEMLABEL) &&