wxTreeCtrl Mac look
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10357 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -54,7 +54,7 @@ public:
|
|||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
long style = wxTR_MAC_BUTTONS | wxTR_NO_LINES,
|
long style = wxTR_MAC_BUTTONS | wxTR_NO_LINES | wxTR_ROW_LINES,
|
||||||
#else
|
#else
|
||||||
long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
|
long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
|
||||||
#endif
|
#endif
|
||||||
@@ -71,7 +71,7 @@ public:
|
|||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
long style = wxTR_MAC_BUTTONS | wxTR_NO_LINES,
|
long style = wxTR_MAC_BUTTONS | wxTR_NO_LINES | wxTR_ROW_LINES,
|
||||||
#else
|
#else
|
||||||
long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
|
long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1788,15 +1788,22 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
|
|||||||
dc.SetBrush(wxBrush(colBg, wxSOLID));
|
dc.SetBrush(wxBrush(colBg, wxSOLID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int offset = 0;
|
||||||
|
if (HasFlag(wxTR_ROW_LINES)) offset = 1;
|
||||||
|
|
||||||
if (item->IsSelected() && image != NO_IMAGE)
|
if (item->IsSelected() && image != NO_IMAGE)
|
||||||
{
|
{
|
||||||
// If it's selected, and there's an image, then we should
|
// If it's selected, and there's an image, then we should
|
||||||
// take care to leave the area under the image painted in the
|
// take care to leave the area under the image painted in the
|
||||||
// background colour.
|
// 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
|
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 )
|
if ( image != NO_IMAGE )
|
||||||
{
|
{
|
||||||
@@ -1821,27 +1828,26 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
|
|||||||
// Now y stands for the top of the item, whereas it used to stand for middle !
|
// 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 )
|
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 );
|
item->SetY( y );
|
||||||
|
|
||||||
int oldY = y;
|
int oldY = y;
|
||||||
y+=GetLineHeight(item)/2;
|
y+=GetLineHeight(item)/2;
|
||||||
|
|
||||||
item->SetCross( horizX+m_indent, y );
|
item->SetCross( x, y );
|
||||||
|
|
||||||
int exposed_x = dc.LogicalToDeviceX( 0 );
|
int exposed_x = dc.LogicalToDeviceX( 0 );
|
||||||
int exposed_y = dc.LogicalToDeviceY( item->GetY() );
|
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
|
if (IsExposed( exposed_x, exposed_y, 10000, GetLineHeight(item) )) // 10000 = very much
|
||||||
{
|
{
|
||||||
int startX = horizX;
|
int startX = x - m_indent;
|
||||||
int endX = horizX + (m_indent-5);
|
int endX = x-5;
|
||||||
|
|
||||||
// if (!item->HasChildren()) endX += (m_indent+5);
|
|
||||||
if (!item->HasChildren()) endX += 20;
|
if (!item->HasChildren()) endX += 20;
|
||||||
|
|
||||||
if (HasFlag( wxTR_MAC_BUTTONS ))
|
if (HasFlag( wxTR_MAC_BUTTONS ))
|
||||||
@@ -1852,7 +1858,6 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
|
|||||||
dc.SetBrush( *m_hilightBrush );
|
dc.SetBrush( *m_hilightBrush );
|
||||||
|
|
||||||
wxPoint button[3];
|
wxPoint button[3];
|
||||||
int x = horizX + m_indent;
|
|
||||||
|
|
||||||
if (item->IsExpanded())
|
if (item->IsExpanded())
|
||||||
{
|
{
|
||||||
@@ -1885,15 +1890,15 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
|
|||||||
if (item->HasPlus())
|
if (item->HasPlus())
|
||||||
{
|
{
|
||||||
if (drawLines)
|
if (drawLines)
|
||||||
dc.DrawLine( horizX+(m_indent+5), y, horizX+(m_indent+15), y );
|
dc.DrawLine( x+5, y, x+15, y );
|
||||||
dc.SetPen( *wxGREY_PEN );
|
dc.SetPen( *wxGREY_PEN );
|
||||||
dc.SetBrush( *wxWHITE_BRUSH );
|
dc.SetBrush( *wxWHITE_BRUSH );
|
||||||
dc.DrawRectangle( horizX+(m_indent-5), y-4, 11, 9 );
|
dc.DrawRectangle( x-5, y-4, 11, 9 );
|
||||||
|
|
||||||
dc.SetPen( *wxBLACK_PEN );
|
dc.SetPen( *wxBLACK_PEN );
|
||||||
dc.DrawLine( horizX+(m_indent-2), y, horizX+(m_indent+3), y );
|
dc.DrawLine( x-2, y, x+3, y );
|
||||||
if (!item->IsExpanded())
|
if (!item->IsExpanded())
|
||||||
dc.DrawLine( horizX+m_indent, y-2, horizX+m_indent, y+3 );
|
dc.DrawLine( x, y-2, x, y+3 );
|
||||||
dc.SetPen( m_dottedPen );
|
dc.SetPen( m_dottedPen );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1925,6 +1930,13 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
|
|||||||
// draw
|
// draw
|
||||||
PaintItem(item, dc);
|
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
|
// restore DC objects
|
||||||
dc.SetBrush( *wxWHITE_BRUSH );
|
dc.SetBrush( *wxWHITE_BRUSH );
|
||||||
dc.SetPen( m_dottedPen );
|
dc.SetPen( m_dottedPen );
|
||||||
@@ -1953,7 +1965,7 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
|
|||||||
{
|
{
|
||||||
semiOldY+=GetLineHeight(children[--n])/2;
|
semiOldY+=GetLineHeight(children[--n])/2;
|
||||||
if (drawLines)
|
if (drawLines)
|
||||||
dc.DrawLine( horizX+m_indent, oldY+5, horizX+m_indent, semiOldY );
|
dc.DrawLine( x, oldY+5, x, semiOldY );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user