From: Włodzimierz Skiba Date: Tue, 30 May 2006 09:17:45 +0000 (+0000) Subject: [ 1494561 ] wxComboCtrl vertical size fix. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a9e8bf2dd9bccb38eb39fba955125aaf23d6f500?ds=inline [ 1494561 ] wxComboCtrl vertical size fix. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39472 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/combo.h b/include/wx/combo.h index c821f1e328..8c15a099c6 100644 --- a/include/wx/combo.h +++ b/include/wx/combo.h @@ -379,7 +379,6 @@ protected: void DestroyPopup(); // override the base class virtuals involved in geometry calculations - virtual void DoMoveWindow(int x, int y, int width, int height); virtual wxSize DoGetBestSize() const; // ensures there is atleast the default popup diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp index a614127e2a..bca191234f 100644 --- a/src/common/combocmn.cpp +++ b/src/common/combocmn.cpp @@ -716,6 +716,16 @@ bool wxComboCtrlBase::Create(wxWindow *parent, OnThemeChange(); m_absIndent = GetNativeTextIndent(); + m_iFlags |= wxCC_IFLAG_CREATED; + + // If x and y indicate valid size, wxSizeEvent won't be + // emitted automatically, so we need to add artifical one. + if ( size.x > 0 && size.y > 0 ) + { + wxSizeEvent evt(size,GetId()); + GetEventHandler()->AddPendingEvent(evt); + } + return true; } @@ -828,15 +838,31 @@ void wxComboCtrlBase::CalculateAreas( int btnWidth ) if ( butWidth <= 0 ) return; + int butHeight = sz.y - btnBorder*2; + // Adjust button width if ( m_btnWid < 0 ) butWidth += m_btnWid; else if ( m_btnWid > 0 ) butWidth = m_btnWid; + else + { + // Adjust button width to match aspect ratio + // (but only if control is smaller than best size). + int bestHeight = GetBestSize().y; + int height = GetSize().y; - int butHeight = sz.y; - - butHeight -= btnBorder*2; + if ( height < bestHeight ) + { + // Make very small buttons square, as it makes + // them accommodate arrow image better and still + // looks decent. + if ( height > 18 ) + butWidth = (height*butWidth)/bestHeight; + else + butWidth = butHeight; + } + } // Adjust button height if ( m_btnHei < 0 ) @@ -987,14 +1013,6 @@ wxSize wxComboCtrlBase::DoGetBestSize() const return ret; } -void wxComboCtrlBase::DoMoveWindow(int x, int y, int width, int height) -{ - // SetSize is called last in create, so it marks the end of creation - m_iFlags |= wxCC_IFLAG_CREATED; - - wxControl::DoMoveWindow(x, y, width, height); -} - void wxComboCtrlBase::OnSizeEvent( wxSizeEvent& event ) { if ( !IsCreated() )