diff options
author | Mihály Palenik <palenik.mihaly@gmail.com> | 2015-07-23 09:50:09 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-07-24 13:47:48 +0000 |
commit | af162f1c37e8c909386e72e5d8b4ff6bccfd529b (patch) | |
tree | 231653817f1d77a57e59e710c0f1bc3b2522a548 /svtools | |
parent | 738cf411e9315d17c7eb8be47ded643a00dfe5c5 (diff) |
Fix alternating rows in SvTreeListBox
Alternating rows in SvTreeListBox is not work correctly when insert, expand
or collapse. Now is work properly and set in Expert Configuration dialog.
Change-Id: I58b53ae59fa7f8d9de769342a0e1bad55de18f20
Reviewed-on: https://gerrit.libreoffice.org/17310
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.cxx | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx index c7207d4eebbe..b33c31cabefe 100644 --- a/svtools/source/contnr/treelistbox.cxx +++ b/svtools/source/contnr/treelistbox.cxx @@ -381,6 +381,7 @@ SvTreeListBox::SvTreeListBox(vcl::Window* pParent, WinBits nWinStyle) : mpImpl(new SvTreeListBoxImpl(*this)), mbContextBmpExpanded(false), mbAlternatingRowColors(false), + mbUpdateAlternatingRows(false), eSelMode(NO_SELECTION), nMinWidthInChars(0) { @@ -411,6 +412,7 @@ SvTreeListBox::SvTreeListBox(vcl::Window* pParent, const ResId& rResId) : mpImpl(new SvTreeListBoxImpl(*this)), mbContextBmpExpanded(false), mbAlternatingRowColors(false), + mbUpdateAlternatingRows(false), eSelMode(NO_SELECTION), nMinWidthInChars(0) { @@ -471,16 +473,7 @@ sal_uLong SvTreeListBox::Insert( SvTreeListEntry* pEntry, SvTreeListEntry* pPare { sal_uLong nInsPos = pModel->Insert( pEntry, pParent, nPos ); pEntry->SetBackColor( GetBackground().GetColor() ); - if(mbAlternatingRowColors) - { - if(nPos == TREELIST_APPEND) - { - if(Prev(pEntry) && Prev(pEntry)->GetBackColor() == GetBackground().GetColor()) - pEntry->SetBackColor( GetSettings().GetStyleSettings().GetAlternatingRowColor() ); - } - else - SetAlternatingRowColors( true ); - } + SetAlternatingRowColors( mbAlternatingRowColors ); return nInsPos; } @@ -488,16 +481,7 @@ sal_uLong SvTreeListBox::Insert( SvTreeListEntry* pEntry,sal_uLong nRootPos ) { sal_uLong nInsPos = pModel->Insert( pEntry, nRootPos ); pEntry->SetBackColor( GetBackground().GetColor() ); - if(mbAlternatingRowColors) - { - if(nRootPos == TREELIST_APPEND) - { - if(Prev(pEntry) && Prev(pEntry)->GetBackColor() == GetBackground().GetColor()) - pEntry->SetBackColor( GetSettings().GetStyleSettings().GetAlternatingRowColor() ); - } - else - SetAlternatingRowColors( true ); - } + SetAlternatingRowColors( mbAlternatingRowColors ); return nInsPos; } @@ -2372,6 +2356,7 @@ bool SvTreeListBox::Expand( SvTreeListEntry* pParent ) pImp->EntryExpanded( pParent ); pHdlEntry = pParent; ExpandedHdl(); + SetAlternatingRowColors( mbAlternatingRowColors ); } nFlags = pParent->GetFlags(); nFlags &= ~SvTLEntryFlags::NO_NODEBMP; @@ -2409,6 +2394,7 @@ bool SvTreeListBox::Collapse( SvTreeListEntry* pParent ) pImp->EntryCollapsed( pParent ); pHdlEntry = pParent; ExpandedHdl(); + SetAlternatingRowColors( mbAlternatingRowColors ); } // #i92103# @@ -2590,6 +2576,8 @@ void SvTreeListBox::MouseMove( const MouseEvent& rMEvt ) void SvTreeListBox::SetUpdateMode( bool bUpdate ) { pImp->SetUpdateMode( bUpdate ); + mbUpdateAlternatingRows = bUpdate; + SetAlternatingRowColors( mbAlternatingRowColors ); } void SvTreeListBox::SetSpaceBetweenEntries( short nOffsLogic ) @@ -3393,20 +3381,35 @@ Size SvTreeListBox::GetOptimalSize() const void SvTreeListBox::SetAlternatingRowColors( bool bEnable ) { - mbAlternatingRowColors = bEnable; - if( mbAlternatingRowColors ) + if( !mbUpdateAlternatingRows ) + { + mbAlternatingRowColors = bEnable; + return; + } + + if( bEnable ) { SvTreeListEntry* pEntry = pModel->First(); for(size_t i = 0; pEntry; ++i) { pEntry->SetBackColor( i % 2 == 0 ? GetBackground().GetColor() : GetSettings().GetStyleSettings().GetAlternatingRowColor()); - pEntry = pModel->Next(pEntry); + SvTreeListEntry *pNextEntry = nullptr; + if( IsExpanded( pEntry ) ) + pNextEntry = pModel->FirstChild( pEntry ); + else + pNextEntry = pModel->NextSibling( pEntry ); + + if( !pNextEntry ) + pEntry = pModel->Next( pEntry ); + else + pEntry = pNextEntry; } } - else + else if( mbAlternatingRowColors ) for(SvTreeListEntry* pEntry = pModel->First(); pEntry; pEntry = pModel->Next(pEntry)) pEntry->SetBackColor( GetBackground().GetColor() ); + mbAlternatingRowColors = bEnable; pImp->UpdateAll(); } |