From 233058c7abe360926b8e905de1a49884e2035130 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Fri, 4 Aug 2000 15:23:28 +0000 Subject: [PATCH] Generic tree control fixes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7933 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/treectlg.h | 29 ++++++++++++++++++++++++++++- include/wx/treectrl.h | 2 ++ samples/treectrl/treectrl.cpp | 2 +- src/generic/treectlg.cpp | 20 +++++++++++++++++--- 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/include/wx/generic/treectlg.h b/include/wx/generic/treectlg.h index 4d48f81cde..6b661d238b 100644 --- a/include/wx/generic/treectlg.h +++ b/include/wx/generic/treectlg.h @@ -13,7 +13,7 @@ #define _GENERIC_TREECTRL_H_ #ifdef __GNUG__ - #pragma interface "treectrg.h" + #pragma interface "treectlg.h" #endif #include "wx/defs.h" @@ -394,5 +394,32 @@ private: DECLARE_DYNAMIC_CLASS(wxGenericTreeCtrl) }; +#if !defined(__WXMSW__) || defined(__WIN16__) +/* + * wxTreeCtrl has to be a real class or we have problems with + * the run-time information. + */ + +class WXDLLEXPORT wxTreeCtrl: public wxGenericTreeCtrl +{ +public: + DECLARE_DYNAMIC_CLASS(wxTreeCtrl) + + wxTreeCtrl() {} + + wxTreeCtrl(wxWindow *parent, wxWindowID id = -1, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT, + const wxValidator &validator = wxDefaultValidator, + const wxString& name = wxTreeCtrlNameStr) + { + Create(parent, id, pos, size, style, validator, name); + } + +}; + +#endif + #endif // _GENERIC_TREECTRL_H_ diff --git a/include/wx/treectrl.h b/include/wx/treectrl.h index b30804c1e8..1a2cc60c1c 100644 --- a/include/wx/treectrl.h +++ b/include/wx/treectrl.h @@ -27,10 +27,12 @@ #include "wx/generic/treectlg.h" #endif +/* #if !defined(__WXMSW__) #define wxTreeCtrl wxGenericTreeCtrl #define sm_classwxTreeCtrl sm_classwxGenericTreeCtrl #endif +*/ #endif // _WX_TREECTRL_H_BASE_ diff --git a/samples/treectrl/treectrl.cpp b/samples/treectrl/treectrl.cpp index cb30f162d0..e04b74f314 100644 --- a/samples/treectrl/treectrl.cpp +++ b/samples/treectrl/treectrl.cpp @@ -215,7 +215,7 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h) m_treeCtrl = new MyTreeCtrl(this, TreeTest_Ctrl, wxDefaultPosition, wxDefaultSize, - wxTR_HAS_BUTTONS | + wxTR_HAS_BUTTONS | // wxTR_NO_LINES | wxTR_EDIT_LABELS | #ifndef NO_VARIABLE_HEIGHT wxTR_HAS_VARIABLE_ROW_HEIGHT | diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 4f5cd24802..3e1dcb049b 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -580,6 +580,15 @@ BEGIN_EVENT_TABLE(wxGenericTreeCtrl,wxScrolledWindow) EVT_IDLE (wxGenericTreeCtrl::OnIdle) END_EVENT_TABLE() +#if !defined(__WXMSW__) || defined(__WIN16__) +/* + * wxTreeCtrl has to be a real class or we have problems with + * the run-time information. + */ + +IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxGenericTreeCtrl) +#endif + // ----------------------------------------------------------------------------- // construction/destruction // ----------------------------------------------------------------------------- @@ -1687,6 +1696,8 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level int exposed_x = dc.LogicalToDeviceX( 0 ); int exposed_y = dc.LogicalToDeviceY( item->GetY() ); + bool drawLines = ((GetWindowStyle() & wxTR_NO_LINES) == 0); + if (IsExposed( exposed_x, exposed_y, 10000, GetLineHeight(item) )) // 10000 = very much { int startX = horizX; @@ -1695,11 +1706,13 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level // if (!item->HasChildren()) endX += (m_indent+5); if (!item->HasChildren()) endX += 20; - dc.DrawLine( startX, y, endX, y ); + if (drawLines) + dc.DrawLine( startX, y, endX, y ); if (item->HasPlus()) { - dc.DrawLine( horizX+(m_indent+5), y, horizX+(m_indent+15), y ); + 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 ); @@ -1766,7 +1779,8 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level if (count > 0) { semiOldY+=GetLineHeight(children[--n])/2; - dc.DrawLine( horizX+m_indent, oldY+5, horizX+m_indent, semiOldY ); + if (drawLines) + dc.DrawLine( horizX+m_indent, oldY+5, horizX+m_indent, semiOldY ); } } } -- 2.45.2