fixes redraw bug which was leaving a horizontal strip under the tree item

after it was unselected (in wxGTK)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@158 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1998-06-29 16:23:41 +00:00
parent a5f81d8c07
commit 29d87bba53

View File

@@ -212,8 +212,7 @@ long wxGenericTreeItem::HitTest( const wxPoint& point, int &flags )
(point.x < m_xCross+5) && (point.x < m_xCross+5) &&
(point.y > m_yCross-5) && (point.y > m_yCross-5) &&
(point.y < m_yCross+5) && (point.y < m_yCross+5) &&
(m_hasChildren) (m_hasChildren))
)
{ {
flags = wxTREE_HITTEST_ONITEMBUTTON; flags = wxTREE_HITTEST_ONITEMBUTTON;
return m_itemId; return m_itemId;
@@ -739,11 +738,13 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxPaintDC &dc, int level,
if (IsExposed( 0, child->m_y-2, 10000, m_lineHeight+4 )) if (IsExposed( 0, child->m_y-2, 10000, m_lineHeight+4 ))
{ {
int startX,endX; int startX = horizX,
if ((node->Previous()) || (level != 0)) endX = horizX + 10;
startX = horizX; else startX = horizX-10;
if (child->HasChildren()) if (!(node->Previous()) && (level == 0))
endX = horizX+10; else endX = horizX+30; startX -= 10;
if (!child->HasChildren())
endX += 20;
dc.DrawLine( startX, y, endX, y ); dc.DrawLine( startX, y, endX, y );
if (child->HasChildren()) if (child->HasChildren())
@@ -760,26 +761,34 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxPaintDC &dc, int level,
if (child->HasHilight()) if (child->HasHilight())
{ {
dc.SetTextForeground( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) ); dc.SetTextForeground( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) );
#if 0 // VZ: this code leaves horizontal stripes when item is unselected
dc.SetBrush( *m_hilightBrush ); dc.SetBrush( *m_hilightBrush );
if (m_hasFocus) if (m_hasFocus)
dc.SetPen( wxBLACK_PEN ); dc.SetPen( wxBLACK_PEN );
else else
dc.SetPen( wxTRANSPARENT_PEN ); dc.SetPen( wxTRANSPARENT_PEN );
long tw = 0; long tw, th;
long th = 0;
dc.GetTextExtent( child->m_text, &tw, &th ); dc.GetTextExtent( child->m_text, &tw, &th );
dc.DrawRectangle( child->m_x-2, child->m_y-2, tw+4, th+4 ); dc.DrawRectangle( child->m_x-2, child->m_y-2, tw+4, th+4 );
}; #else
int modeOld = dc.GetBackgroundMode();
dc.SetTextBackground( *wxBLACK );
dc.SetBackgroundMode(wxSOLID);
#endif // 0
dc.DrawText( child->m_text, child->m_x, child->m_y ); dc.DrawText( child->m_text, child->m_x, child->m_y );
if (child->HasHilight()) #if 0 // VZ: same as above
{
dc.SetTextForeground( *wxBLACK );
dc.SetBrush( *wxWHITE_BRUSH );
dc.SetPen( *wxBLACK_PEN ); dc.SetPen( *wxBLACK_PEN );
}; #else
dc.SetBackgroundMode(modeOld);
dc.SetTextBackground( *wxWHITE );
dc.SetBrush( *wxWHITE_BRUSH );
#endif
dc.SetTextForeground( *wxBLACK );
}
else
dc.DrawText( child->m_text, child->m_x, child->m_y );
}; };
y += m_lineHeight; y += m_lineHeight;
@@ -837,7 +846,8 @@ void wxTreeCtrl::OnMouse( const wxMouseEvent &event )
int flag = 0; int flag = 0;
long id = HitTest( wxPoint(x,y), flag ); long id = HitTest( wxPoint(x,y), flag );
if (id == -1) return; if (id == -1)
return;
wxGenericTreeItem *item = FindItem( id ); wxGenericTreeItem *item = FindItem( id );
if (!item) return; if (!item) return;
@@ -857,7 +867,8 @@ void wxTreeCtrl::OnMouse( const wxMouseEvent &event )
m_current->SendSelected( this ); m_current->SendSelected( this );
}; };
if (event.LeftDClick()) m_current->SendKeyDown( this ); if (event.LeftDClick())
m_current->SendKeyDown( this );
if (flag == wxTREE_HITTEST_ONITEMBUTTON) if (flag == wxTREE_HITTEST_ONITEMBUTTON)
{ {
@@ -875,11 +886,13 @@ void wxTreeCtrl::CalculateLevel( wxGenericTreeItem *item, wxPaintDC &dc, int lev
wxGenericTreeItem *child = (wxGenericTreeItem *)node->Data(); wxGenericTreeItem *child = (wxGenericTreeItem *)node->Data();
dc.SetPen( m_dottedPen ); dc.SetPen( m_dottedPen );
int startX,endX; int startX = horizX,
if ((node->Previous()) || (level != 0)) endX = horizX + 10;
startX = horizX; else startX = horizX-10;
if (child->HasChildren()) if (!node->Previous() && (level == 0))
endX = horizX+10; else endX = horizX+30; startX -= 10;
if (!child->HasChildren())
endX += 20;
child->m_x = horizX+33; child->m_x = horizX+33;
child->m_y = y-m_lineHeight/3-2; child->m_y = y-m_lineHeight/3-2;
@@ -895,7 +908,8 @@ void wxTreeCtrl::CalculateLevel( wxGenericTreeItem *item, wxPaintDC &dc, int lev
void wxTreeCtrl::CalculatePositions(void) void wxTreeCtrl::CalculatePositions(void)
{ {
if (!m_anchor) return; if (!m_anchor)
return;
wxClientDC dc(this); wxClientDC dc(this);
PrepareDC( dc ); PrepareDC( dc );