summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extras/source/glade/libreoffice-catalog.xml.in13
-rw-r--r--include/svtools/treelistbox.hxx5
-rw-r--r--svtools/source/contnr/treelistbox.cxx25
3 files changed, 40 insertions, 3 deletions
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index b291c1333b68..8f9b780a4048 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -388,7 +388,18 @@
icon-name="widget-gtk-treeview"/>
<glade-widget-class title="Tree List" name="svtlo-SvTreeListBox"
generic-name="Tree List" parent="GtkTreeView"
- icon-name="widget-gtk-treeview"/>
+ icon-name="widget-gtk-treeview">
+ <properties>
+ <property save="True" query="False" id="min-width-chars" default="-1" name="Minimum Width in Characters">
+ <parameter-spec>
+ <type>GParamInt</type>
+ <min>-1</min>
+ </parameter-spec>
+ <tooltip>The desired minimum width of the SvTreeListBox, in characters</tooltip>
+ </property>
+ </properties>
+ </glade-widget-class>
+
<glade-widget-class title="DD ListBox" name="swuilo-DDListBox"
generic-name="DD ListBox" parent="svtlo-SvTreeListBox"
icon-name="widget-gtk-treeview"/>
diff --git a/include/svtools/treelistbox.hxx b/include/svtools/treelistbox.hxx
index 699300f25497..404689a52b0e 100644
--- a/include/svtools/treelistbox.hxx
+++ b/include/svtools/treelistbox.hxx
@@ -238,6 +238,7 @@ class SVT_DLLPUBLIC SvTreeListBox
DragDropMode nOldDragMode;
SelectionMode eSelMode;
sal_Int8 nDragOptions;
+ sal_Int32 nMinWidthInChars;
SvTreeListEntry* pEdEntry;
SvLBoxItem* pEdItem;
@@ -501,6 +502,10 @@ public:
/** Enables, that one cell of a tablistbox entry can be focused */
void EnableCellFocus();
+ void set_min_width_in_chars(sal_Int32 nChars);
+
+ virtual bool set_property(const OString &rKey, const OString &rValue);
+
protected:
using SvListView::Expand;
using SvListView::Collapse;
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: */