diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-02-22 15:41:00 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-02-22 16:56:01 +0000 |
commit | 7c760f34a00462d5904d0e2eed4132761c2e51c5 (patch) | |
tree | db69cca6e1a7d816d527df706dff4d87321e7178 /vcl | |
parent | 393609f3f702bf5cf34e1495f32e78b75e3d5f17 (diff) |
Resolves: fdo#60764 sort options can grow too wide to fit on screen
Change-Id: Id3aed9ef251f61710b43ceda1a28c6895e91872f
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/vcl/combobox.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/vcl/lstbox.hxx | 4 | ||||
-rw-r--r-- | vcl/source/control/combobox.cxx | 17 | ||||
-rw-r--r-- | vcl/source/control/lstbox.cxx | 21 |
4 files changed, 46 insertions, 0 deletions
diff --git a/vcl/inc/vcl/combobox.hxx b/vcl/inc/vcl/combobox.hxx index 33a4382d5cbf..1a73983167e4 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 694f45c882b5..74dc854b8f44 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; @@ -219,6 +220,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); + virtual bool set_property(const rtl::OString &rKey, const rtl::OString &rValue); }; diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 673001d46de9..e74d024e9ac6 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; } // ----------------------------------------------------------------------- @@ -1063,6 +1064,13 @@ Size ComboBox::CalcMinimumSize() const aSz.Height() = Edit::CalcMinimumSizeForText(GetText()).Height(); aSz.Width() = mpImplLB->GetMaxEntryWidth(); + if (m_nMaxWidthChars != -1) + { + //MAP_APPFONT == 1/8th avg char + long nMaxWidth = LogicToPixel(Size(m_nMaxWidthChars * 8, 0), + MapMode(MAP_APPFONT)).Width(); + aSz.Width() = std::min(aSz.Width(), nMaxWidth); + } aSz.Width() += getMaxWidthScrollBarAndDownButton(); ComboBoxBounds aBounds(calcComboBoxDropDownComponentBounds( Size(0xFFFF, 0xFFFF), Size(0xFFFF, 0xFFFF))); @@ -1541,4 +1549,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 beb216d12c07..d87c1b3e4729 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -98,6 +98,7 @@ void ListBox::ImplInitListBoxData() mbDDAutoSize = sal_True; mnSaveValue = LISTBOX_ENTRY_NOTFOUND; mnLineCount = 0; + m_nMaxWidthChars = -1; } // ----------------------------------------------------------------------- @@ -1344,6 +1345,15 @@ Size ListBox::CalcSubEditSize() const aSz.Height() = mpImplLB->CalcSize( 1 ).Height(); // size to maxmimum entry width aSz.Width() = mpImplLB->GetMaxEntryWidth(); + + if (m_nMaxWidthChars != -1) + { + //MAP_APPFONT == 1/8th avg char + long nMaxWidth = LogicToPixel(Size(m_nMaxWidthChars * 8, 0), + MapMode(MAP_APPFONT)).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(); @@ -1552,10 +1562,21 @@ 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; |