X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/87b3708781255019ea1731dce40d699217f1b675..6bb81c8e1ae2f7a0acc2535ebdfa776512cfe26f:/src/msw/combo.cpp diff --git a/src/msw/combo.cpp b/src/msw/combo.cpp index 996728d4c4..1e59def4d8 100644 --- a/src/msw/combo.cpp +++ b/src/msw/combo.cpp @@ -187,7 +187,7 @@ bool wxComboCtrl::Create(wxWindow *parent, pos, size, style | wxFULL_REPAINT_ON_RESIZE, - wxDefaultValidator, + validator, name) ) return false; @@ -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, validator ); + 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 ) @@ -730,6 +736,7 @@ void wxComboCtrl::DoTimerEvent() { bool stopTimer = false; + wxWindow* win = GetPopupWindow(); wxWindow* popup = GetPopupControl()->GetControl(); // Popup was hidden before it was fully shown? @@ -741,7 +748,6 @@ void wxComboCtrl::DoTimerEvent() { wxLongLong t = ::wxGetLocalTimeMillis(); const wxRect& rect = m_animRect; - wxWindow* win = GetPopupWindow(); int pos = (int) (t-m_animStart).GetLo(); if ( pos < COMBOBOX_ANIMATION_DURATION ) @@ -759,8 +765,10 @@ void wxComboCtrl::DoTimerEvent() } else { - popup->Move( 0, -y ); + // Note that apparently Move() should be called after + // SetSize() to reduce (or even eliminate) animation garbage win->SetSize( rect.x, rect.y, rect.width, h ); + popup->Move( 0, -y ); } } else @@ -771,9 +779,13 @@ void wxComboCtrl::DoTimerEvent() if ( stopTimer ) { - popup->Move( 0, 0 ); m_animTimer.Stop(); DoShowPopup( m_animRect, m_animFlags ); + popup->Move( 0, 0 ); + + // Do a one final refresh to clean up the rare cases of animation + // garbage + win->Refresh(); } } #endif