X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/33ac7e6f01acbac1cff0ad400d8ea7f0bfd0a62f..87df17a11b0017d31c09f767bd921abb27193bee:/src/generic/treectlg.cpp diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 4669cdca44..468dd926e6 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -664,6 +664,7 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent, wxWindowID id, #endif SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX ) ); + // m_dottedPen = wxPen( "grey", 0, wxDOT ); too slow under XFree86 m_dottedPen = wxPen( "grey", 0, 0 ); @@ -841,15 +842,15 @@ bool wxGenericTreeCtrl::IsVisible(const wxTreeItemId& item) const { wxCHECK_MSG( item.IsOk(), FALSE, wxT("invalid tree item") ); - // An item is only visible if it's not a descendant of a collapsed item + // An item is only visible if it's not a descendant of a collapsed item wxGenericTreeItem *pItem = (wxGenericTreeItem*) item.m_pItem; - wxGenericTreeItem* parent = pItem->GetParent(); - while (parent) - { - if (!parent->IsExpanded()) - return FALSE; - parent = parent->GetParent(); - } + wxGenericTreeItem* parent = pItem->GetParent(); + while (parent) + { + if (!parent->IsExpanded()) + return FALSE; + parent = parent->GetParent(); + } int startX, startY; GetViewStart(& startX, & startY); @@ -859,8 +860,8 @@ bool wxGenericTreeCtrl::IsVisible(const wxTreeItemId& item) const wxRect rect; if (!GetBoundingRect(item, rect)) return FALSE; - if (rect.GetWidth() == 0 || rect.GetHeight() == 0) - return FALSE; + if (rect.GetWidth() == 0 || rect.GetHeight() == 0) + return FALSE; if (rect.GetBottom() < 0 || rect.GetTop() > clientSize.y) return FALSE; if (rect.GetRight() < 0 || rect.GetLeft() > clientSize.x) @@ -1039,10 +1040,10 @@ wxTreeItemId wxGenericTreeCtrl::GetNextVisible(const wxTreeItemId& item) const wxTreeItemId id = item; while (id.IsOk()) { - id = GetNext(id); + id = GetNext(id); - if (id.IsOk() && IsVisible(id)) - return id; + if (id.IsOk() && IsVisible(id)) + return id; } return wxTreeItemId(); } @@ -1785,15 +1786,22 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) dc.SetBrush(wxBrush(colBg, wxSOLID)); } + int offset = 0; + if (HasFlag(wxTR_ROW_LINES)) offset = 1; + if (item->IsSelected() && image != NO_IMAGE) { // If it's selected, and there's an image, then we should // take care to leave the area under the image painted in the // background colour. - dc.DrawRectangle( item->GetX() + image_w - 2, item->GetY(), item->GetWidth() - image_w + 2, total_h ); + dc.DrawRectangle( item->GetX() + image_w - 2, item->GetY()+offset, + item->GetWidth() - image_w + 2, total_h-offset ); } else - dc.DrawRectangle( item->GetX()-2, item->GetY(), item->GetWidth()+2, total_h ); + { + dc.DrawRectangle( item->GetX()-2, item->GetY()+offset, + item->GetWidth()+2, total_h-offset ); + } if ( image != NO_IMAGE ) { @@ -1818,46 +1826,79 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) // Now y stands for the top of the item, whereas it used to stand for middle ! void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level, int &y ) { - int horizX = level*m_indent; + int x = (level+1)*m_indent; - item->SetX( horizX+m_indent+m_spacing ); + item->SetX( x+m_spacing ); item->SetY( y ); int oldY = y; y+=GetLineHeight(item)/2; - item->SetCross( horizX+m_indent, y ); + item->SetCross( x, y ); int exposed_x = dc.LogicalToDeviceX( 0 ); int exposed_y = dc.LogicalToDeviceY( item->GetY() ); - bool drawLines = ((GetWindowStyle() & wxTR_NO_LINES) == 0); + bool drawLines = (!HasFlag(wxTR_NO_LINES) && !HasFlag(wxTR_MAC_BUTTONS)); if (IsExposed( exposed_x, exposed_y, 10000, GetLineHeight(item) )) // 10000 = very much { - int startX = horizX; - int endX = horizX + (m_indent-5); + int startX = x - m_indent; + int endX = x-5; -// if (!item->HasChildren()) endX += (m_indent+5); if (!item->HasChildren()) endX += 20; - - if (drawLines) - dc.DrawLine( startX, y, endX, y ); - - if (item->HasPlus()) + + if (HasFlag( wxTR_MAC_BUTTONS )) + { + if (item->HasPlus()) + { + dc.SetPen( *wxBLACK_PEN ); + dc.SetBrush( *m_hilightBrush ); + + wxPoint button[3]; + + if (item->IsExpanded()) + { + button[0].x = x-5; + button[0].y = y-2; + button[1].x = x+5; + button[1].y = y-2; + button[2].x = x; + button[2].y = y+3; + } + else + { + button[0].y = y-5; + button[0].x = x-2; + button[1].y = y+5; + button[1].x = x-2; + button[2].y = y; + button[2].x = x+3; + } + dc.DrawPolygon( 3, button ); + + dc.SetPen( m_dottedPen ); + } + } + else { if (drawLines) - dc.DrawLine( horizX+(m_indent+5), y, horizX+(m_indent+15), y ); - dc.SetPen( *wxGREY_PEN ); - dc.SetBrush( *wxWHITE_BRUSH ); - dc.DrawRectangle( horizX+(m_indent-5), y-4, 11, 9 ); - - dc.SetPen( *wxBLACK_PEN ); - dc.DrawLine( horizX+(m_indent-2), y, horizX+(m_indent+3), y ); - if (!item->IsExpanded()) - dc.DrawLine( horizX+m_indent, y-2, horizX+m_indent, y+3 ); + dc.DrawLine( startX, y, endX, y ); - dc.SetPen( m_dottedPen ); + if (item->HasPlus()) + { + if (drawLines) + dc.DrawLine( x+5, y, x+15, y ); + dc.SetPen( *wxGREY_PEN ); + dc.SetBrush( *wxWHITE_BRUSH ); + dc.DrawRectangle( x-5, y-4, 11, 9 ); + + dc.SetPen( *wxBLACK_PEN ); + dc.DrawLine( x-2, y, x+3, y ); + if (!item->IsExpanded()) + dc.DrawLine( x, y-2, x, y+3 ); + dc.SetPen( m_dottedPen ); + } } wxPen *pen = wxTRANSPARENT_PEN; @@ -1887,6 +1928,13 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level // draw PaintItem(item, dc); + if (HasFlag( wxTR_ROW_LINES )) + { + dc.SetPen( *wxWHITE_PEN ); + dc.DrawLine( 0, oldY, 10000, oldY ); + dc.DrawLine( 0, oldY + GetLineHeight(item), 10000, oldY + GetLineHeight(item) ); + } + // restore DC objects dc.SetBrush( *wxWHITE_BRUSH ); dc.SetPen( m_dottedPen ); @@ -1915,7 +1963,7 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level { semiOldY+=GetLineHeight(children[--n])/2; if (drawLines) - dc.DrawLine( horizX+m_indent, oldY+5, horizX+m_indent, semiOldY ); + dc.DrawLine( x, oldY+5, x, semiOldY ); } } } @@ -2262,10 +2310,10 @@ bool wxGenericTreeCtrl::GetBoundingRect(const wxTreeItemId& item, GetViewStart(& startX, & startY); rect.x = i->GetX() - startX*PIXELS_PER_UNIT; - rect.y = i->GetY() - startY*PIXELS_PER_UNIT; + rect.y = i->GetY() - startY*PIXELS_PER_UNIT; rect.width = i->GetWidth(); - //rect.height = i->GetHeight(); - rect.height = GetLineHeight(i); + //rect.height = i->GetHeight(); + rect.height = GetLineHeight(i); return TRUE; }