vcl/inc/vcl/combobox.hxx        |    1 +
 vcl/source/control/combobox.cxx |   27 +++++++++++++++++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)

New commits:
commit ab0efc3eb1c0b351bcaccd847cd66f986f95781e
Author: Caolán McNamara <caol...@redhat.com>
Date:   Sat Feb 4 12:57:37 2012 +0100

    Better optimal combobox width
    
    if dropdown button is wider than scrollbar than use that as
    the extra width over the edit widget

diff --git a/vcl/inc/vcl/combobox.hxx b/vcl/inc/vcl/combobox.hxx
index d44a595..85d4e20 100644
--- a/vcl/inc/vcl/combobox.hxx
+++ b/vcl/inc/vcl/combobox.hxx
@@ -78,6 +78,7 @@ protected:
     SAL_DLLPRIVATE WinBits  ImplInitStyle( WinBits nStyle );
     SAL_DLLPRIVATE void     ImplLoadRes( const ResId& rResId );
     SAL_DLLPRIVATE void     ImplCalcEditHeight();
+    SAL_DLLPRIVATE long     getMaxWidthScrollBarAndDownButton() const;
 
 protected:
                     ComboBox( WindowType nType );
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 97abfc1..a93dc67 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -1078,6 +1078,29 @@ Size ComboBox::GetOptimalSize(WindowSizeType eType) const
 
 // -----------------------------------------------------------------------
 
+long ComboBox::getMaxWidthScrollBarAndDownButton() const
+{
+    long nButtonDownWidth = 0;
+
+    Window *pBorder = GetWindow( WINDOW_BORDER );
+    ImplControlValue aControlValue;
+    Point aPoint;
+    Rectangle aContent, aBound;
+
+    // use the full extent of the control
+    Rectangle aArea( aPoint, pBorder->GetOutputSizePixel() );
+
+    if ( GetNativeControlRegion(CTRL_COMBOBOX, PART_BUTTON_DOWN,
+        aArea, 0, aControlValue, rtl::OUString(), aBound, aContent) )
+    {
+        nButtonDownWidth = aContent.getWidth();
+    }
+
+    long nScrollBarWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
+
+    return std::max(nScrollBarWidth, nButtonDownWidth);
+}
+
 Size ComboBox::CalcMinimumSize() const
 {
     Size aSz;
@@ -1090,7 +1113,7 @@ Size ComboBox::CalcMinimumSize() const
     {
         aSz.Height() = mpImplLB->CalcSize( 1 ).Height();
         aSz.Width() = mpImplLB->GetMaxEntryWidth();
-        aSz.Width() += GetSettings().GetStyleSettings().GetScrollBarSize();
+        aSz.Width() += getMaxWidthScrollBarAndDownButton();
     }
 
     aSz = CalcWindowSize( aSz );
@@ -1150,7 +1173,7 @@ Size ComboBox::CalcSize( sal_uInt16 nColumns, sal_uInt16 
nLines ) const
         aSz.Width() = aMinSz.Width();
 
     if ( IsDropDownBox() )
-        aSz.Width() += GetSettings().GetStyleSettings().GetScrollBarSize();
+        aSz.Width() += getMaxWidthScrollBarAndDownButton();
 
     if ( !IsDropDownBox() )
     {
_______________________________________________
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to