[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - sc/uiconfig vcl/inc vcl/source
Caolán McNamara
caolanm at redhat.com
Mon Feb 25 07:58:15 PST 2013
sc/uiconfig/scalc/ui/sortoptionspage.ui | 1 +
vcl/inc/vcl/combobox.hxx | 4 ++++
vcl/inc/vcl/lstbox.hxx | 6 ++++++
vcl/inc/vcl/outdev.hxx | 1 +
vcl/source/control/combobox.cxx | 15 +++++++++++++++
vcl/source/control/lstbox.cxx | 28 ++++++++++++++++++++++++++++
vcl/source/gdi/outdev3.cxx | 5 +++++
vcl/source/window/window.cxx | 2 +-
8 files changed, 61 insertions(+), 1 deletion(-)
New commits:
commit e43b2fa55e244db36111a7cb0548f2ff5d2ae66a
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Feb 22 15:41:00 2013 +0000
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 at documentfoundation.org>
Tested-by: Fridrich Strba <fridrich at documentfoundation.org>
diff --git a/sc/uiconfig/scalc/ui/sortoptionspage.ui b/sc/uiconfig/scalc/ui/sortoptionspage.ui
index ded61ac..2f1eb10 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 72478c5..e6e2b92 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 a3a7dbb..813591d 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 ce1e7ec..5ab2e3e 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 389929c3..148f492 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 8675c5a..885b29c 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 fdb79f4..f7640f8 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 05d979a..30f7923 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.
More information about the Libreoffice-commits
mailing list