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>
This commit is contained 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"/>
|
||||
|
@@ -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;
|
||||
|
@@ -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: */
|
||||
|
Reference in New Issue
Block a user