From 9cb80f3fa331228864ebc13188a0168da36a4998 Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Tue, 22 Mar 2011 09:56:40 +0000 Subject: [PATCH] To have better support for themed and custom backgrounds for wxMSW wxComboCtrl, use WS_EX_COMPOSITED and wxBG_STYLE_ERASE instead of custom double-buffering (when made possible by the OS version) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67276 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/combo.h | 2 ++ src/msw/combo.cpp | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/wx/msw/combo.h b/include/wx/msw/combo.h index c5b2768..f30bc1a 100644 --- a/include/wx/msw/combo.h +++ b/include/wx/msw/combo.h @@ -94,6 +94,8 @@ protected: void OnPaintEvent( wxPaintEvent& event ); void OnMouseEvent( wxMouseEvent& event ); + virtual bool HasTransparentBackground() { return IsDoubleBuffered(); } + private: void Init(); diff --git a/src/msw/combo.cpp b/src/msw/combo.cpp index b85366b..1e59def 100644 --- a/src/msw/combo.cpp +++ b/src/msw/combo.cpp @@ -202,15 +202,18 @@ bool wxComboCtrl::Create(wxWindow *parent, if ( style & wxCC_STD_BUTTON ) m_iFlags |= wxCC_POPUP_ON_MOUSE_UP; + // Prepare background for double-buffering or better background theme + // support, whichever is possible. + SetDoubleBuffered(true); + if ( !IsDoubleBuffered() ) + SetBackgroundStyle( wxBG_STYLE_PAINT ); + // Create textctrl, if necessary CreateTextCtrl( wxNO_BORDER ); // Add keyboard input handlers for main control and textctrl InstallInputHandlers(); - // Prepare background for double-buffering - SetBackgroundStyle( wxBG_STYLE_CUSTOM ); - // SetInitialSize should be called last SetInitialSize(size); @@ -434,7 +437,8 @@ void wxComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) // TODO: Convert drawing in this function to Windows API Code wxSize sz = GetClientSize(); - wxAutoBufferedPaintDC dc(this); + wxDC* dcPtr = wxAutoBufferedPaintDCFactory(this); + wxDC& dc = *dcPtr; const wxRect& rectButton = m_btnArea; wxRect rectTextField = m_tcArea; @@ -640,6 +644,8 @@ void wxComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) else wxComboPopup::DefaultPaintComboControl(this,dc,rectTextField); } + + delete dcPtr; } void wxComboCtrl::OnMouseEvent( wxMouseEvent& event ) -- 2.7.4