X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ce17501854573f9c95cc04e6eb344d3a3912f7c0..b4626104e5a68430c5c7c4f3a0b79425be9945e8:/src/generic/treectlg.cpp diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 25d04b0dee..bdd3003ec1 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -475,7 +475,7 @@ void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &event ) // We must finish regardless of success, otherwise we'll get // focus problems: Finish(); - + if ( !AcceptChanges() ) m_owner->OnRenameCancelled( m_itemEdited ); } @@ -1931,7 +1931,7 @@ void wxGenericTreeCtrl::SelectItem(const wxTreeItemId& itemId, bool select) { if ( select ) { - DoSelectItem(itemId); + DoSelectItem(itemId, !HasFlag(wxTR_MULTIPLE)); } else // deselect { @@ -2255,6 +2255,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) } int total_h = GetLineHeight(item); + bool drawItemBackground = false; if ( item->IsSelected() ) { @@ -2272,14 +2273,20 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) #else dc.SetBrush(*(m_hasFocus ? m_hilightBrush : m_hilightUnfocusedBrush)); #endif + drawItemBackground = true; } else { wxColour colBg; if ( attr && attr->HasBackgroundColour() ) + { + drawItemBackground = true; colBg = attr->GetBackgroundColour(); + } else + { colBg = m_backgroundColour; + } dc.SetBrush(wxBrush(colBg, wxSOLID)); } @@ -2303,7 +2310,10 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) dc.DrawRectangle( item->GetX() + image_w - 2, item->GetY()+offset, item->GetWidth() - image_w + 2, total_h-offset ); } - else + // On GTK+ 2, drawing a 'normal' background is wrong for themes that + // don't allow backgrounds to be customized. Not drawing the background, + // except for custom item backgrounds, works for both kinds of theme. + else if (drawItemBackground) { dc.DrawRectangle( item->GetX()-2, item->GetY()+offset, item->GetWidth()+2, total_h-offset ); @@ -2685,8 +2695,15 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event ) case WXK_MENU: { + // Use the item's bounding rectangle to determine position for the event + wxRect ItemRect; + GetBoundingRect(m_current, ItemRect, true); + wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_MENU, GetId() ); event.m_item = m_current; + // Use the left edge, vertical middle + event.m_pointDrag = wxPoint(ItemRect.GetX(), + ItemRect.GetY() + ItemRect.GetHeight() / 2); event.SetEventObject( this ); GetEventHandler()->ProcessEvent( event ); break; @@ -3218,12 +3235,20 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event ) nevent.m_pointDrag = CalcScrolledPosition(pt); nevent.SetEventObject(this); event.Skip(!GetEventHandler()->ProcessEvent(nevent)); + + // Consistent with MSW (for now), send the ITEM_MENU *after* + // the RIGHT_CLICK event. TODO: This behavior may change. + wxTreeEvent nevent2(wxEVT_COMMAND_TREE_ITEM_MENU, GetId()); + nevent2.m_item = item; + nevent2.m_pointDrag = CalcScrolledPosition(pt); + nevent2.SetEventObject(this); + GetEventHandler()->ProcessEvent(nevent2); } else if ( event.LeftUp() ) { // this facilitates multiple-item drag-and-drop - if (item && HasFlag(wxTR_MULTIPLE)) + if ( /* item && */ HasFlag(wxTR_MULTIPLE)) { wxArrayTreeItemIds selections; size_t count = GetSelections(selections);