[Libreoffice-commits] .: Branch 'libreoffice-3-3' - vcl/source

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Nov 19 15:17:39 PST 2010


 vcl/source/control/combobox.cxx |    2 +-
 vcl/source/control/ilstbox.cxx  |   12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

New commits:
commit b44cfbbf6ed9bc53310dcb37507f534800572fb5
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Fri Nov 19 18:12:56 2010 -0500

    Allow the dropdown list of a combo box to be scrollable. (fdo#31710)
    
    This change makes the dropdown list of a combo box control to be
    horizontally scrollable in case the longest text in the list box
    is wider than the maximum allowed width of the dropdown list.
    
    Also, previously the dropdown list would become wider than the
    desktop width when the longest text exceeded the desktop width.
    This change caps the max width of the dropdown list to be the width
    of the desktop width.

diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 329f88e..178974d 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -213,7 +213,7 @@ void ComboBox::ImplInit( Window* pParent, WinBits nStyle )
     Window* pLBParent = this;
     if ( mpFloatWin )
         pLBParent = mpFloatWin;
-    mpImplLB = new ImplListBox( pLBParent, nListStyle|WB_SIMPLEMODE );
+    mpImplLB = new ImplListBox( pLBParent, nListStyle|WB_SIMPLEMODE|WB_AUTOHSCROLL );
     mpImplLB->SetPosPixel( Point() );
     mpImplLB->SetSelectHdl( LINK( this, ComboBox, ImplSelectHdl ) );
     mpImplLB->SetCancelHdl( LINK( this, ComboBox, ImplCancelHdl ) );
diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx
index 78f535e..5c8f422 100644
--- a/vcl/source/control/ilstbox.cxx
+++ b/vcl/source/control/ilstbox.cxx
@@ -3147,6 +3147,11 @@ Size ImplListBoxFloatingWindow::CalcFloatSize()
             long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
             aFloatSz.Width() += nSBWidth;
         }
+
+        long nDesktopWidth = GetDesktopRectPixel().getWidth();
+        if (aFloatSz.Width() > nDesktopWidth)
+            // Don't exceed the desktop width.
+            aFloatSz.Width() = nDesktopWidth;
     }
 
     if ( aFloatSz.Height() > nMaxHeight )
@@ -3173,6 +3178,13 @@ Size ImplListBoxFloatingWindow::CalcFloatSize()
         aFloatSz.Height() = nInnerHeight + nTop + nBottom;
     }
 
+    if (aFloatSz.Width() < aSz.Width())
+    {
+        // The max width of list box entries exceeds the window width.
+        // Account for the scroll bar height.
+        long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
+        aFloatSz.Height() += nSBWidth;
+    }
     return aFloatSz;
 }
 


More information about the Libreoffice-commits mailing list