summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-09-17 12:34:53 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-09-17 11:42:12 +0000
commiteae6c400109c91237ea5e7890f8d950ee0e52cbb (patch)
treeae2eb34195a96b37a5b99dc229da51e5bf195c1f /svtools
parent4af723397ec041f006ffce57f6347e669076e167 (diff)
add a min-width-chars property to SvTreeListBox
Change-Id: If6213ab630222d0d9483beea602ea9d54be2396c Reviewed-on: https://gerrit.libreoffice.org/5971 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/contnr/treelistbox.cxx25
1 files changed, 23 insertions, 2 deletions
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index b942469aef6f..ec2960850fe6 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -401,7 +401,8 @@ SvTreeListBox::SvTreeListBox(Window* pParent, WinBits nWinStyle) :
DragSourceHelper(this),
mpImpl(new SvTreeListBoxImpl(*this)),
mbContextBmpExpanded(false),
- eSelMode(NO_SELECTION)
+ eSelMode(NO_SELECTION),
+ nMinWidthInChars(0)
{
DBG_CTOR(SvTreeListBox,0);
nDragOptions = DND_ACTION_COPYMOVE | DND_ACTION_LINK;
@@ -430,7 +431,8 @@ SvTreeListBox::SvTreeListBox(Window* pParent, const ResId& rResId) :
DragSourceHelper(this),
mpImpl(new SvTreeListBoxImpl(*this)),
mbContextBmpExpanded(false),
- eSelMode(NO_SELECTION)
+ eSelMode(NO_SELECTION),
+ nMinWidthInChars(0)
{
DBG_CTOR(SvTreeListBox,0);
pTargetEntry = 0;
@@ -3454,6 +3456,8 @@ Size SvTreeListBox::GetOptimalSize() const
aRet.Width() += rStyleSettings.GetBorderSize() * 2;
aRet.Height() += rStyleSettings.GetBorderSize() * 2;
}
+ long nMinWidth = nMinWidthInChars * approximate_char_width();
+ aRet.Width() = std::max(aRet.Width(), nMinWidth);
return aRet;
}
@@ -3983,4 +3987,21 @@ void SvTreeListBox::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& /*r
{
}
+void SvTreeListBox::set_min_width_in_chars(sal_Int32 nChars)
+{
+ nMinWidthInChars = nChars;
+ queue_resize();
+}
+
+bool SvTreeListBox::set_property(const OString &rKey, const OString &rValue)
+{
+ if (rKey == "min-width-chars")
+ {
+ set_min_width_in_chars(rValue.toInt32());
+ }
+ else
+ return Control::set_property(rKey, rValue);
+ return true;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */