[Libreoffice-commits] core.git: extras/source include/svtools svtools/source
Caolán McNamara
caolanm at redhat.com
Tue Sep 17 04:42:31 PDT 2013
extras/source/glade/libreoffice-catalog.xml.in | 13 ++++++++++++-
include/svtools/treelistbox.hxx | 5 +++++
svtools/source/contnr/treelistbox.cxx | 25 +++++++++++++++++++++++--
3 files changed, 40 insertions(+), 3 deletions(-)
New commits:
commit eae6c400109c91237ea5e7890f8d950ee0e52cbb
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Sep 17 12:34:53 2013 +0100
add a min-width-chars property to SvTreeListBox
Change-Id: If6213ab630222d0d9483beea602ea9d54be2396c
Reviewed-on: https://gerrit.libreoffice.org/5971
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index b291c13..8f9b780 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 699300f..404689a 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 b942469..ec29608 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: */
More information about the Libreoffice-commits
mailing list