summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-02-22 15:41:00 +0000
committerFridrich Strba <fridrich@documentfoundation.org>2013-02-25 15:57:56 +0000
commite43b2fa55e244db36111a7cb0548f2ff5d2ae66a (patch)
treee5844fae94eb76a2ad5a3c545229846b9b4f2d44
parent8518173f0b8dc73eece82be959e65dba2768d33c (diff)
Resolves: fdo#60764 sort options can grow too wide to fit on screen
(cherry picked from commit 7c760f34a00462d5904d0e2eed4132761c2e51c5) Conflicts: sc/uiconfig/scalc/ui/sortoptionspage.ui vcl/inc/vcl/lstbox.hxx vcl/source/control/lstbox.cxx Change-Id: Id3aed9ef251f61710b43ceda1a28c6895e91872f Reviewed-on: https://gerrit.libreoffice.org/2392 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
-rw-r--r--sc/uiconfig/scalc/ui/sortoptionspage.ui1
-rw-r--r--vcl/inc/vcl/combobox.hxx4
-rw-r--r--vcl/inc/vcl/lstbox.hxx6
-rw-r--r--vcl/inc/vcl/outdev.hxx1
-rw-r--r--vcl/source/control/combobox.cxx15
-rw-r--r--vcl/source/control/lstbox.cxx28
-rw-r--r--vcl/source/gdi/outdev3.cxx5
-rw-r--r--vcl/source/window/window.cxx2
8 files changed, 61 insertions, 1 deletions
diff --git a/sc/uiconfig/scalc/ui/sortoptionspage.ui b/sc/uiconfig/scalc/ui/sortoptionspage.ui
index ded61ac0dd24..2f1eb1016cb2 100644
--- a/sc/uiconfig/scalc/ui/sortoptionspage.ui
+++ b/sc/uiconfig/scalc/ui/sortoptionspage.ui
@@ -159,6 +159,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">20</property>
+ <property name="max_width_chars">65</property>
</object>
<packing>
<property name="left_attach">0</property>
diff --git a/vcl/inc/vcl/combobox.hxx b/vcl/inc/vcl/combobox.hxx
index 72478c59a713..e6e2b92e67fc 100644
--- a/vcl/inc/vcl/combobox.hxx
+++ b/vcl/inc/vcl/combobox.hxx
@@ -47,6 +47,7 @@ private:
sal_Bool mbDDAutoSize : 1;
sal_Bool mbSyntheticModify : 1;
sal_Bool mbMatchCase : 1;
+ sal_Int32 m_nMaxWidthChars;
Link maSelectHdl;
Link maDoubleClickHdl;
@@ -214,6 +215,9 @@ public:
*/
using Control::GetIndexForPoint;
long GetIndexForPoint( const Point& rPoint, sal_uInt16& rPos ) const;
+
+ sal_Int32 getMaxWidthChars() const { return m_nMaxWidthChars; }
+ void setMaxWidthChars(sal_Int32 nWidth);
};
#endif // _COMBOBOX_HXX
diff --git a/vcl/inc/vcl/lstbox.hxx b/vcl/inc/vcl/lstbox.hxx
index a3a7dbb5cda4..813591d18ce8 100644
--- a/vcl/inc/vcl/lstbox.hxx
+++ b/vcl/inc/vcl/lstbox.hxx
@@ -44,6 +44,7 @@ private:
sal_uInt16 mnDDHeight;
sal_uInt16 mnSaveValue;
sal_Bool mbDDAutoSize;
+ sal_Int32 m_nMaxWidthChars;
Link maSelectHdl;
Link maDoubleClickHdl;
sal_uInt16 mnLineCount;
@@ -218,6 +219,11 @@ public:
using Control::GetIndexForPoint;
long GetIndexForPoint( const Point& rPoint, sal_uInt16& rPos ) const;
virtual void take_properties(Window &rOther);
+
+ sal_Int32 getMaxWidthChars() const { return m_nMaxWidthChars; }
+ void setMaxWidthChars(sal_Int32 nWidth);
+
+ virtual bool set_property(const rtl::OString &rKey, const rtl::OString &rValue);
};
// ----------------
diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx
index ce1e7ec55cca..5ab2e3e7ef53 100644
--- a/vcl/inc/vcl/outdev.hxx
+++ b/vcl/inc/vcl/outdev.hxx
@@ -580,6 +580,7 @@ public:
xub_StrLen nLen = STRING_LEN ) const;
/// Height where any character of the current font fits; in logic coordinates.
long GetTextHeight() const;
+ float approximate_char_width() const;
void DrawTextArray( const Point& rStartPt, const XubString& rStr,
const sal_Int32* pDXAry = NULL,
xub_StrLen nIndex = 0,
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 389929c34b53..148f49200d3e 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -110,6 +110,7 @@ void ComboBox::ImplInitComboBoxData()
mbSyntheticModify = sal_False;
mbMatchCase = sal_False;
mcMultiSep = ';';
+ m_nMaxWidthChars = -1;
}
// -----------------------------------------------------------------------
@@ -1068,6 +1069,11 @@ Size ComboBox::CalcMinimumSize() const
aSz.Height() = Edit::CalcMinimumSizeForText(GetText()).Height();
aSz.Width() = mpImplLB->GetMaxEntryWidth();
+ if (m_nMaxWidthChars != -1)
+ {
+ long nMaxWidth = m_nMaxWidthChars * approximate_char_width();
+ aSz.Width() = std::min(aSz.Width(), nMaxWidth);
+ }
aSz.Width() += getMaxWidthScrollBarAndDownButton();
ComboBoxBounds aBounds(calcComboBoxDropDownComponentBounds(
Size(0xFFFF, 0xFFFF), Size(0xFFFF, 0xFFFF)));
@@ -1546,4 +1552,13 @@ ComboBox::ComboBoxBounds ComboBox::calcComboBoxDropDownComponentBounds(const Siz
return aBounds;
}
+void ComboBox::setMaxWidthChars(sal_Int32 nWidth)
+{
+ if (nWidth != m_nMaxWidthChars)
+ {
+ m_nMaxWidthChars = nWidth;
+ queue_resize();
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx
index 8675c5a050dc..885b29c1a590 100644
--- a/vcl/source/control/lstbox.cxx
+++ b/vcl/source/control/lstbox.cxx
@@ -123,6 +123,7 @@ void ListBox::ImplInitListBoxData()
mbDDAutoSize = sal_True;
mnSaveValue = LISTBOX_ENTRY_NOTFOUND;
mnLineCount = 0;
+ m_nMaxWidthChars = -1;
}
// -----------------------------------------------------------------------
@@ -1321,6 +1322,13 @@ Size ListBox::CalcMinimumSize() const
aSz.Height() += 4; // add a space between entry and border
// size to maxmimum entry width and add a little breathing space
aSz.Width() = mpImplLB->GetMaxEntryWidth() + 4;
+
+ if (m_nMaxWidthChars != -1)
+ {
+ long nMaxWidth = m_nMaxWidthChars * approximate_char_width();
+ aSz.Width() = std::min(aSz.Width(), nMaxWidth);
+ }
+
// do not create ultrathin ListBoxes, it doesn't look good
if( aSz.Width() < GetSettings().GetStyleSettings().GetScrollBarSize() )
aSz.Width() = GetSettings().GetStyleSettings().GetScrollBarSize();
@@ -1565,6 +1573,26 @@ const Wallpaper& ListBox::GetDisplayBackground() const
return mpImplLB->GetDisplayBackground();
}
+void ListBox::setMaxWidthChars(sal_Int32 nWidth)
+{
+ if (nWidth != m_nMaxWidthChars)
+ {
+ m_nMaxWidthChars = nWidth;
+ queue_resize();
+ }
+}
+
+bool ListBox::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
+{
+ if (rKey == "active")
+ SelectEntryPos(rValue.toInt32());
+ else if (rKey == "max-width-chars")
+ setMaxWidthChars(rValue.toInt32());
+ else
+ return Control::set_property(rKey, rValue);
+ return true;
+}
+
// =======================================================================
MultiListBox::MultiListBox( Window* pParent, WinBits nStyle ) :
ListBox( WINDOW_MULTILISTBOX )
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index fdb79f45706c..f7640f8ba204 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -5758,6 +5758,11 @@ long OutputDevice::GetTextHeight() const
return nHeight;
}
+float OutputDevice::approximate_char_width() const
+{
+ return GetTextWidth(rtl::OUString("aemnnxEM")) / 8.0;
+}
+
// -----------------------------------------------------------------------
void OutputDevice::DrawTextArray( const Point& rStartPt, const String& rStr,
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 05d979a98f72..30f792334a03 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -209,7 +209,7 @@ void Window::ImplInitAppFontData( Window* pWindow )
{
ImplSVData* pSVData = ImplGetSVData();
long nTextHeight = pWindow->GetTextHeight();
- long nTextWidth = pWindow->GetTextWidth(rtl::OUString("aemnnxEM"));
+ long nTextWidth = pWindow->approximate_char_width() * 8;
long nSymHeight = nTextHeight*4;
// Make the basis wider if the font is too narrow
// such that the dialog looks symmetrical and does not become too narrow.