From: Vadim Zeitlin Date: Sun, 6 Feb 2011 01:00:48 +0000 (+0000) Subject: Use Explorer style for wxTreeCtrl with wxTR_TWIST_BUTTONS in wxMSW. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e615d356fc99ae4508c2a83cd18ba905497c09b9?ds=sidebyside Use Explorer style for wxTreeCtrl with wxTR_TWIST_BUTTONS in wxMSW. The tree control style used by Explorer uses rotating triangles instead of the standard "+/-" buttons and so seems to correspond relatively well to this style. And this provides a possibility to have a more standard-looking tree controls in wxWidgets programs. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66850 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/interface/wx/treectrl.h b/interface/wx/treectrl.h index d41d5d4336..6b3513650b 100644 --- a/interface/wx/treectrl.h +++ b/interface/wx/treectrl.h @@ -29,6 +29,14 @@ For convenience to document that no buttons are to be drawn. @style{wxTR_HAS_BUTTONS} Use this style to show + and - buttons to the left of parent items. + @style{wxTR_TWIST_BUTTONS} + Selects alternative style of @c +/@c - buttons and shows rotating + ("twisting") arrows instead. Currently this style is only implemented + under Microsoft Windows Vista and later Windows versions and is ignored + under the other platforms. Notice that under Vista this style results + in the same appearance as used by the tree control in Explorer and + other built-in programs and so using it may be preferable to the + default style. @style{wxTR_NO_LINES} Use this style to hide vertical level connectors. @style{wxTR_FULL_ROW_HIGHLIGHT} diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 4fd9657d16..326e154469 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -42,6 +42,7 @@ #include "wx/imaglist.h" #include "wx/msw/dragimag.h" +#include "wx/msw/uxtheme.h" // macros to hide the cast ugliness // -------------------------------- @@ -741,6 +742,20 @@ bool wxTreeCtrl::Create(wxWindow *parent, wxSetCCUnicodeFormat(GetHwnd()); + if ( m_windowStyle & wxTR_TWIST_BUTTONS ) + { + // Under Vista and later Explorer uses rotating ("twist") buttons + // instead of the default "+/-" ones so apply its theme to the tree + // control to implement this style. + if ( wxGetWinVersion() >= wxWinVersion_Vista ) + { + if ( wxUxThemeEngine *theme = wxUxThemeEngine::GetIfActive() ) + { + theme->SetWindowTheme(GetHwnd(), L"EXPLORER", NULL); + } + } + } + return true; }