From 89e1f57475a0cdc0161eca37eeae611b60b7dd63 Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Thu, 27 May 2010 15:02:42 +0000 Subject: [PATCH] Disable Vista/Win7-style wxComboCtrl rendering in wx2.8 by default (define wxUSE_COMBOCTRL_VISTA_RENDERING=1 to enable it), as it may cause subtle drawing bugs with custom wxComboCtrls git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@64411 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 2 -- src/msw/combo.cpp | 26 ++++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index fce0405753..fd4347b09d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -98,8 +98,6 @@ All (GUI): wxMSW: -- Backported improved wxOwnerDrawnComboBox and wxComboCtrl appearance under - Windows Vista/7. - wxOwnerDrawnComboBox and wxComboCtrl with wxCB_READONLY window style now have more native-like focus indicator rendering. diff --git a/src/msw/combo.cpp b/src/msw/combo.cpp index 221b2840fa..25f8f6cf69 100644 --- a/src/msw/combo.cpp +++ b/src/msw/combo.cpp @@ -43,6 +43,16 @@ #include "wx/msw/uxtheme.h" #endif +// +// Define wxUSE_COMBOCTRL_VISTA_RENDERING as 1 to have read-only wxComboCtrl +// and wxOwnerDrawnComboBox appear much nicer on Win Vista/7. Disabled by +// default as this may cause some subtle rendering bugs with custom +// wxComboCtrls. +// +#ifndef wxUSE_COMBOCTRL_VISTA_RENDERING + #define wxUSE_COMBOCTRL_VISTA_RENDERING 0 +#endif + // Change to #if 1 to include tmschema.h for easier testing of theme // parameters. #if 0 @@ -514,7 +524,11 @@ void wxComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) #if wxUSE_UXTHEME if ( hTheme ) { + #if wxUSE_COMBOCTRL_VISTA_RENDERING const bool useVistaComboBox = ::wxGetWinVersion() >= wxWinVersion_Vista; + #else + const bool useVistaComboBox = false; + #endif RECT rFull; wxCopyRectToRECT(borderRect, rFull); @@ -554,12 +568,17 @@ void wxComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) int comboBoxPart = 0; // For XP, use the 'default' part RECT* rUseForBg = &rBorder; - bool drawFullButton = false; int bgState = butState; - const bool isFocused = (FindFocus() == GetMainWindowOfCompositeControl()) ? true : false; + + #if wxUSE_COMBOCTRL_VISTA_RENDERING + bool drawFullButton = false; if ( useVistaComboBox ) { + const bool isFocused = + (FindFocus() == GetMainWindowOfCompositeControl()) ? + true : false; + // FIXME: Either SetBackgroundColour or GetBackgroundColour // doesn't work under Vista, so here's a temporary // workaround. @@ -591,6 +610,7 @@ void wxComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) bgState = CBB_NORMAL; } } + #endif // // Draw parent's background, if necessary @@ -627,6 +647,7 @@ void wxComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) int butPart = CP_DROPDOWNBUTTON; + #if wxUSE_COMBOCTRL_VISTA_RENDERING if ( useVistaComboBox ) { if ( drawFullButton ) @@ -644,6 +665,7 @@ void wxComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) butPart = CP_DROPDOWNBUTTONLEFT; } + #endif theme->DrawThemeBackground( hTheme, hDc, butPart, butState, &rButton, NULL ); } else if ( useVistaComboBox &&