X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e822d1bd5fc4f3ac91fafd201d7519d091408dd2..3508c1432884472f0d24f0f98c0dc75ed35df297:/src/generic/treectlg.cpp?ds=sidebyside diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 391a1d635d..1e071880d4 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -985,11 +985,14 @@ void wxGenericTreeCtrl::Init() m_findTimer = NULL; m_dropEffectAboveItem = false; + + m_dndEffect = NoEffect; + m_dndEffectItem = NULL; m_lastOnSame = false; #if defined( __WXMAC__ ) -#if wxOSX_USE_CARBON +#if wxOSX_USE_ATSU_TEXT m_normalFont.MacCreateFromThemeFont( kThemeViewsFont ) ; #else m_normalFont.MacCreateFromUIFont( kCTFontViewsFontType ) ; @@ -2461,6 +2464,7 @@ int wxGenericTreeCtrl::GetLineHeight(wxGenericTreeItem *item) const void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) { item->SetFont(this, dc); + item->CalculateSize(this, dc); wxCoord text_h = item->GetTextHeight(); @@ -2638,6 +2642,40 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) // restore normal font dc.SetFont( m_normalFont ); + + if (item == m_dndEffectItem) + { + dc.SetPen( *wxBLACK_PEN ); + // DnD visual effects + switch (m_dndEffect) + { + case BorderEffect: + { + dc.SetBrush(*wxTRANSPARENT_BRUSH); + int w = item->GetWidth() + 2; + int h = total_h + 2; + dc.DrawRectangle( item->GetX() - 1, item->GetY() - 1, w, h); + break; + } + case AboveEffect: + { + int x = item->GetX(), + y = item->GetY(); + dc.DrawLine( x, y, x + item->GetWidth(), y); + break; + } + case BelowEffect: + { + int x = item->GetX(), + y = item->GetY(); + y += total_h - 1; + dc.DrawLine( x, y, x + item->GetWidth(), y); + break; + } + case NoEffect: + break; + } + } } void @@ -2859,7 +2897,7 @@ void wxGenericTreeCtrl::DrawDropEffect(wxGenericTreeItem *item) DrawLine(item, !m_dropEffectAboveItem ); } - SetCursor(wxCURSOR_BULLSEYE); + SetCursor(*wxSTANDARD_CURSOR); } else { @@ -2874,15 +2912,20 @@ void wxGenericTreeCtrl::DrawBorder(const wxTreeItemId &item) wxGenericTreeItem *i = (wxGenericTreeItem*) item.m_pItem; - wxClientDC dc(this); - PrepareDC( dc ); - dc.SetLogicalFunction(wxINVERT); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - - int w = i->GetWidth() + 2; - int h = GetLineHeight(i) + 2; - - dc.DrawRectangle( i->GetX() - 1, i->GetY() - 1, w, h); + if (m_dndEffect == NoEffect) + { + m_dndEffect = BorderEffect; + m_dndEffectItem = i; + } + else + { + m_dndEffect = NoEffect; + m_dndEffectItem = NULL; + } + + wxRect rect( i->GetX()-1, i->GetY()-1, i->GetWidth()+2, GetLineHeight(i)+2 ); + CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); + RefreshRect( rect ); } void wxGenericTreeCtrl::DrawLine(const wxTreeItemId &item, bool below) @@ -2891,18 +2934,23 @@ void wxGenericTreeCtrl::DrawLine(const wxTreeItemId &item, bool below) wxGenericTreeItem *i = (wxGenericTreeItem*) item.m_pItem; - wxClientDC dc(this); - PrepareDC( dc ); - dc.SetLogicalFunction(wxINVERT); - - int x = i->GetX(), - y = i->GetY(); - if ( below ) + if (m_dndEffect == NoEffect) + { + if (below) + m_dndEffect = BelowEffect; + else + m_dndEffect = AboveEffect; + m_dndEffectItem = i; + } + else { - y += GetLineHeight(i) - 1; + m_dndEffect = NoEffect; + m_dndEffectItem = NULL; } - - dc.DrawLine( x, y, x + i->GetWidth(), y); + + wxRect rect( i->GetX()-1, i->GetY()-1, i->GetWidth()+2, GetLineHeight(i)+2 ); + CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); + RefreshRect( rect ); } // ----------------------------------------------------------------------------- @@ -3933,7 +3981,7 @@ wxGenericTreeCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) return wxListBox::GetClassDefaultAttributes(variant); #else wxVisualAttributes attr; - attr.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); + attr.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXTEXT); attr.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX); attr.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); return attr;