diff options
-rw-r--r-- | cui/source/options/optaboutconfig.cxx | 3 | ||||
-rw-r--r-- | include/svtools/treelistbox.hxx | 1 | ||||
-rw-r--r-- | svtools/source/contnr/treelistbox.cxx | 51 |
3 files changed, 29 insertions, 26 deletions
diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx index 811976c83ef9..165e9e932fa6 100644 --- a/cui/source/options/optaboutconfig.cxx +++ b/cui/source/options/optaboutconfig.cxx @@ -179,6 +179,7 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage( vcl::Window* pParent/*, const SfxI util::SearchFlags::REG_NOT_ENDOFLINE); m_pPrefBox->SetTabs(aTabs, MAP_PIXEL); + m_pPrefBox->SetAlternatingRowColors( true ); } CuiAboutConfigTabPage::~CuiAboutConfigTabPage() @@ -479,7 +480,6 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces InsertEntry(sPath, sPath.copy(index+1), seqItems[i], sType, sValue, pParentEntry, !bLoadAll); } } - m_pPrefBox->SetAlternatingRowColors( true ); } Reference< XNameAccess > CuiAboutConfigTabPage::getConfigAccess( const OUString& sNodePath, bool bUpdate ) @@ -863,7 +863,6 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, SearchHdl_Impl) m_pPrefBox->SortByCol(sortedCol, sortMode == SortAscending); m_pPrefBox->SetUpdateMode( true ); - m_pPrefBox->SetAlternatingRowColors( true ); return 0; } diff --git a/include/svtools/treelistbox.hxx b/include/svtools/treelistbox.hxx index 1c89cec84750..9ec23e4653ac 100644 --- a/include/svtools/treelistbox.hxx +++ b/include/svtools/treelistbox.hxx @@ -267,6 +267,7 @@ class SVT_DLLPUBLIC SvTreeListBox long mnCheckboxItemWidth; bool mbContextBmpExpanded; bool mbAlternatingRowColors; + bool mbUpdateAlternatingRows; SvTreeListEntry* pHdlEntry; SvLBoxItem* pHdlItem; 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(); } |