summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorPalenik Mihály <palenik.mihaly@gmail.com>2014-09-27 21:16:01 +0200
committerSamuel Mehrbrodt <s.mehrbrodt@gmail.com>2014-09-30 21:00:59 +0000
commit0ada00bd9b4f10861d37b8802564a2ace7385aa2 (patch)
treefe0320f39561af45c0ba7fa9dfd8094d31de0b81 /svtools
parent9bb04da4bb18342a107bb843d8054e178d97ae28 (diff)
Improve SvTreeListBox class
It is possible to set alternating rows. Expert Configuration dialog use it. Change-Id: Ie43a87ca05be73fdb345fa4866f31c2c36b7cdf1 Reviewed-on: https://gerrit.libreoffice.org/11663 Reviewed-by: Samuel Mehrbrodt <s.mehrbrodt@gmail.com> Tested-by: Samuel Mehrbrodt <s.mehrbrodt@gmail.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/contnr/treelistbox.cxx41
-rw-r--r--svtools/source/contnr/treelistentry.cxx2
2 files changed, 43 insertions, 0 deletions
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index c0ed007fc611..c7d610c04daf 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -380,6 +380,7 @@ SvTreeListBox::SvTreeListBox(vcl::Window* pParent, WinBits nWinStyle) :
DragSourceHelper(this),
mpImpl(new SvTreeListBoxImpl(*this)),
mbContextBmpExpanded(false),
+ mbAlternatingRowColor(false),
eSelMode(NO_SELECTION),
nMinWidthInChars(0)
{
@@ -409,6 +410,7 @@ SvTreeListBox::SvTreeListBox(vcl::Window* pParent, const ResId& rResId) :
DragSourceHelper(this),
mpImpl(new SvTreeListBoxImpl(*this)),
mbContextBmpExpanded(false),
+ mbAlternatingRowColor(false),
eSelMode(NO_SELECTION),
nMinWidthInChars(0)
{
@@ -468,12 +470,30 @@ IMPL_LINK_INLINE_END( SvTreeListBox, CloneHdl_Impl, SvTreeListEntry*, pEntry )
sal_uLong SvTreeListBox::Insert( SvTreeListEntry* pEntry, SvTreeListEntry* pParent, sal_uLong nPos )
{
sal_uLong nInsPos = pModel->Insert( pEntry, pParent, nPos );
+ if(mbAlternatingRowColor)
+ {
+ if(nPos == TREELIST_APPEND)
+ pEntry->SetBackColor( Prev(pEntry) && Prev(pEntry)->GetBackColor() == GetSettings().GetStyleSettings().GetAlternatingRowColor() ?
+ GetSettings().GetStyleSettings().GetAlternatingRowColor2() :
+ GetSettings().GetStyleSettings().GetAlternatingRowColor() );
+ else
+ SetAlternatingRow( true );
+ }
return nInsPos;
}
sal_uLong SvTreeListBox::Insert( SvTreeListEntry* pEntry,sal_uLong nRootPos )
{
sal_uLong nInsPos = pModel->Insert( pEntry, nRootPos );
+ if(mbAlternatingRowColor)
+ {
+ if(nRootPos == TREELIST_APPEND)
+ pEntry->SetBackColor( Prev(pEntry) && Prev(pEntry)->GetBackColor() == GetSettings().GetStyleSettings().GetAlternatingRowColor() ?
+ GetSettings().GetStyleSettings().GetAlternatingRowColor2() :
+ GetSettings().GetStyleSettings().GetAlternatingRowColor() );
+ else
+ SetAlternatingRow( true );
+ }
return nInsPos;
}
@@ -3002,6 +3022,8 @@ long SvTreeListBox::PaintEntry1(SvTreeListEntry* pEntry,long nLine,sal_uInt16 nT
SetTextColor( aBackupTextColor );
Control::SetFont( aBackupFont );
}
+ else
+ aWallpaper.SetColor( pEntry->GetBackColor() );
}
// draw background
@@ -3388,6 +3410,25 @@ Size SvTreeListBox::GetOptimalSize() const
return aRet;
}
+void SvTreeListBox::SetAlternatingRow( bool bEnable )
+{
+ mbAlternatingRowColor = bEnable;
+ if( mbAlternatingRowColor )
+ {
+ SvTreeListEntry* pEntry = pModel->First();
+ for(size_t i = 0; pEntry; ++i)
+ {
+ pEntry->SetBackColor( i % 2 == 0 ? GetSettings().GetStyleSettings().GetAlternatingRowColor() : GetSettings().GetStyleSettings().GetAlternatingRowColor2());
+ pEntry = pModel->Next(pEntry);
+ }
+ }
+ else
+ for(SvTreeListEntry* pEntry = pModel->First(); pEntry; pEntry = pModel->Next(pEntry))
+ pEntry->SetBackColor( GetSettings().GetStyleSettings().GetFieldColor() );
+
+ pImp->UpdateAll();
+}
+
SvLBoxItem* SvTreeListBox::GetItem(SvTreeListEntry* pEntry,long nX,SvLBoxTab** ppTab)
{
return GetItem_Impl( pEntry, nX, ppTab, 0 );
diff --git a/svtools/source/contnr/treelistentry.cxx b/svtools/source/contnr/treelistentry.cxx
index 559a60f2b25d..c4c9220895eb 100644
--- a/svtools/source/contnr/treelistentry.cxx
+++ b/svtools/source/contnr/treelistentry.cxx
@@ -54,6 +54,7 @@ SvTreeListEntry::SvTreeListEntry()
, bIsMarked(false)
, pUserData(NULL)
, nEntryFlags(0)
+ , maBackColor(Color(COL_WHITE))
{
}
@@ -64,6 +65,7 @@ SvTreeListEntry::SvTreeListEntry(const SvTreeListEntry& r)
, bIsMarked(r.bIsMarked)
, pUserData(r.pUserData)
, nEntryFlags(r.nEntryFlags)
+ , maBackColor(Color(COL_WHITE))
{
SvTreeListEntries::const_iterator it = r.maChildren.begin(), itEnd = r.maChildren.end();
for (; it != itEnd; ++it)