]> git.saurik.com Git - wxWidgets.git/commitdiff
[ 1494561 ] wxComboCtrl vertical size fix.
authorWłodzimierz Skiba <abx@abx.art.pl>
Tue, 30 May 2006 09:17:45 +0000 (09:17 +0000)
committerWłodzimierz Skiba <abx@abx.art.pl>
Tue, 30 May 2006 09:17:45 +0000 (09:17 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39472 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/combo.h
src/common/combocmn.cpp

index c821f1e328a4bf28239fbe9884d03e985c0f51ce..8c15a099c6ab7eae99e6a471e366c885310663b3 100644 (file)
@@ -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
index a614127e2a9e90769151f19f2083f712f9ee4c3b..bca191234fdeedbe60c2bb0eb40e67db91198653 100644 (file)
@@ -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() )