X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/df74fdeafdf63821d9740dda8f52415421729700..5b8f917c3007b1776f55cba6b71843b83d412bf3:/src/generic/treectlg.cpp diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 24dec8e4cb..4a83697fd7 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -788,12 +788,16 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent, SetValidator( validator ); #endif - SetForegroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT) ); - SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX) ); + wxVisualAttributes attr = GetDefaultAttributes(); + SetDefaultForegroundColour( attr.colFg ); + SetDefaultBackgroundColour( attr.colBg ); + SetDefaultFont(attr.font); // m_dottedPen = wxPen( "grey", 0, wxDOT ); too slow under XFree86 m_dottedPen = wxPen( wxT("grey"), 0, 0 ); + SetBestSize(size); + return TRUE; } @@ -1874,6 +1878,8 @@ size_t wxGenericTreeCtrl::GetSelections(wxArrayTreeItemIds &array) const void wxGenericTreeCtrl::EnsureVisible(const wxTreeItemId& item) { + wxCHECK_RET( item.IsOk(), wxT("invalid tree item") ); + if (!item.IsOk()) return; wxGenericTreeItem *gitem = (wxGenericTreeItem*) item.m_pItem; @@ -2478,7 +2484,7 @@ void wxGenericTreeCtrl::DrawLine(const wxTreeItemId &item, bool below) } // ----------------------------------------------------------------------------- -// wxWindows callbacks +// wxWidgets callbacks // ----------------------------------------------------------------------------- void wxGenericTreeCtrl::OnPaint( wxPaintEvent &WXUNUSED(event) ) @@ -3437,4 +3443,33 @@ void wxGenericTreeCtrl::OnGetToolTip( wxTreeEvent &event ) event.Veto(); } + +// NOTE: If using the wxListBox visual attributes works everywhere then this can +// be removed, as well as the #else case below. +#define _USE_VISATTR 0 + +#if _USE_VISATTR +#include "wx/listbox.h" +#endif + +//static +wxVisualAttributes +#if _USE_VISATTR +wxGenericTreeCtrl::GetClassDefaultAttributes(wxWindowVariant variant) +#else +wxGenericTreeCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) +#endif +{ +#if _USE_VISATTR + // Use the same color scheme as wxListBox + return wxListBox::GetClassDefaultAttributes(variant); +#else + wxVisualAttributes attr; + attr.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); + attr.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX); + attr.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + return attr; +#endif +} + #endif // wxUSE_TREECTRL