Tried to make wxTreeCtrl on Mac look more Maccy. Part I.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10346 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1146,6 +1146,8 @@ enum wxStretch
|
|||||||
#define wxTR_EXTENDED 0x0040
|
#define wxTR_EXTENDED 0x0040
|
||||||
#define wxTR_HAS_VARIABLE_ROW_HEIGHT 0x0080
|
#define wxTR_HAS_VARIABLE_ROW_HEIGHT 0x0080
|
||||||
#define wxTR_NO_LINES 0x0100
|
#define wxTR_NO_LINES 0x0100
|
||||||
|
#define wxTR_MAC_BUTTONS 0x0200
|
||||||
|
#define wxTR_ROW_LINES 0x0400
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wxListCtrl flags
|
* wxListCtrl flags
|
||||||
|
@@ -53,7 +53,11 @@ public:
|
|||||||
wxGenericTreeCtrl(wxWindow *parent, wxWindowID id = -1,
|
wxGenericTreeCtrl(wxWindow *parent, wxWindowID id = -1,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
long style = wxTR_MAC_BUTTONS | wxTR_NO_LINES,
|
||||||
|
#else
|
||||||
long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
|
long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
|
||||||
|
#endif
|
||||||
const wxValidator &validator = wxDefaultValidator,
|
const wxValidator &validator = wxDefaultValidator,
|
||||||
const wxString& name = wxTreeCtrlNameStr)
|
const wxString& name = wxTreeCtrlNameStr)
|
||||||
{
|
{
|
||||||
@@ -66,7 +70,11 @@ public:
|
|||||||
bool Create(wxWindow *parent, wxWindowID id = -1,
|
bool Create(wxWindow *parent, wxWindowID id = -1,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
long style = wxTR_MAC_BUTTONS | wxTR_NO_LINES,
|
||||||
|
#else
|
||||||
long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
|
long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
|
||||||
|
#endif
|
||||||
const wxValidator &validator = wxDefaultValidator,
|
const wxValidator &validator = wxDefaultValidator,
|
||||||
const wxString& name = wxTreeCtrlNameStr);
|
const wxString& name = wxTreeCtrlNameStr);
|
||||||
|
|
||||||
|
@@ -218,14 +218,14 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
|
|||||||
|
|
||||||
m_treeCtrl = new MyTreeCtrl(this, TreeTest_Ctrl,
|
m_treeCtrl = new MyTreeCtrl(this, TreeTest_Ctrl,
|
||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
wxTR_HAS_BUTTONS | // wxTR_NO_LINES |
|
wxTR_MAC_BUTTONS | wxTR_NO_LINES |
|
||||||
wxTR_EDIT_LABELS |
|
wxTR_EDIT_LABELS |
|
||||||
#ifndef NO_VARIABLE_HEIGHT
|
#ifndef NO_VARIABLE_HEIGHT
|
||||||
wxTR_HAS_VARIABLE_ROW_HEIGHT |
|
wxTR_HAS_VARIABLE_ROW_HEIGHT |
|
||||||
#endif
|
#endif
|
||||||
wxSUNKEN_BORDER);
|
wxSUNKEN_BORDER);
|
||||||
|
|
||||||
m_treeCtrl->SetBackgroundColour(wxColour(204, 205, 79));
|
// m_treeCtrl->SetBackgroundColour( *wxLIGHT_GREY );
|
||||||
|
|
||||||
m_textCtrl = new wxTextCtrl(this, -1, "",
|
m_textCtrl = new wxTextCtrl(this, -1, "",
|
||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
|
@@ -663,7 +663,10 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
SetValidator( validator );
|
SetValidator( validator );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __WXMAC__
|
||||||
SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX ) );
|
SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
// m_dottedPen = wxPen( "grey", 0, wxDOT ); too slow under XFree86
|
// m_dottedPen = wxPen( "grey", 0, wxDOT ); too slow under XFree86
|
||||||
m_dottedPen = wxPen( "grey", 0, 0 );
|
m_dottedPen = wxPen( "grey", 0, 0 );
|
||||||
|
|
||||||
@@ -1841,6 +1844,41 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
|
|||||||
// if (!item->HasChildren()) endX += (m_indent+5);
|
// if (!item->HasChildren()) endX += (m_indent+5);
|
||||||
if (!item->HasChildren()) endX += 20;
|
if (!item->HasChildren()) endX += 20;
|
||||||
|
|
||||||
|
if (HasFlag( wxTR_MAC_BUTTONS ))
|
||||||
|
{
|
||||||
|
if (item->HasPlus())
|
||||||
|
{
|
||||||
|
dc.SetPen( *wxBLACK_PEN );
|
||||||
|
dc.SetBrush( *m_hilightBrush );
|
||||||
|
|
||||||
|
wxPoint button[3];
|
||||||
|
int x = horizX + m_indent;
|
||||||
|
|
||||||
|
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)
|
if (drawLines)
|
||||||
dc.DrawLine( startX, y, endX, y );
|
dc.DrawLine( startX, y, endX, y );
|
||||||
|
|
||||||
@@ -1856,9 +1894,9 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
|
|||||||
dc.DrawLine( horizX+(m_indent-2), y, horizX+(m_indent+3), y );
|
dc.DrawLine( horizX+(m_indent-2), y, horizX+(m_indent+3), y );
|
||||||
if (!item->IsExpanded())
|
if (!item->IsExpanded())
|
||||||
dc.DrawLine( horizX+m_indent, y-2, horizX+m_indent, y+3 );
|
dc.DrawLine( horizX+m_indent, y-2, horizX+m_indent, y+3 );
|
||||||
|
|
||||||
dc.SetPen( m_dottedPen );
|
dc.SetPen( m_dottedPen );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wxPen *pen = wxTRANSPARENT_PEN;
|
wxPen *pen = wxTRANSPARENT_PEN;
|
||||||
wxColour colText;
|
wxColour colText;
|
||||||
|
Reference in New Issue
Block a user