cui/source/options/optaboutconfig.cxx   |    1 
 include/svtools/treelistbox.hxx         |    4 +++
 include/svtools/treelistentry.hxx       |    4 +++
 include/vcl/settings.hxx                |    6 ++++
 svtools/source/contnr/treelistbox.cxx   |   41 ++++++++++++++++++++++++++++++++
 svtools/source/contnr/treelistentry.cxx |    2 +
 vcl/source/app/settings.cxx             |   32 ++++++++++++++++++++++++
 7 files changed, 90 insertions(+)

New commits:
commit 0ada00bd9b4f10861d37b8802564a2ace7385aa2
Author: Palenik Mihály <palenik.mih...@gmail.com>
Date:   Sat Sep 27 21:16:01 2014 +0200

    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.mehrbr...@gmail.com>
    Tested-by: Samuel Mehrbrodt <s.mehrbr...@gmail.com>

diff --git a/cui/source/options/optaboutconfig.cxx 
b/cui/source/options/optaboutconfig.cxx
index d16723e..7b3c0d6 100644
--- a/cui/source/options/optaboutconfig.cxx
+++ b/cui/source/options/optaboutconfig.cxx
@@ -157,6 +157,7 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage( vcl::Window* 
pParent/*, const SfxI
     aTabs[4] = aTabs[3] + fWidth * 8;
 
     m_pPrefBox->SetTabs(aTabs, MAP_PIXEL);
+    m_pPrefBox->SetAlternatingRow( true );
 }
 
 void CuiAboutConfigTabPage::InsertEntry(const OUString& rProp, const OUString& 
rStatus, const OUString& rType, const OUString& rValue)
diff --git a/include/svtools/treelistbox.hxx b/include/svtools/treelistbox.hxx
index ac8a281..f54f324 100644
--- a/include/svtools/treelistbox.hxx
+++ b/include/svtools/treelistbox.hxx
@@ -236,6 +236,7 @@ class SVT_DLLPUBLIC SvTreeListBox
     sal_uInt16      nLastSelTab;
     long mnCheckboxItemWidth;
     bool mbContextBmpExpanded;
+    bool mbAlternatingRowColor;
 
     SvTreeListEntry*    pHdlEntry;
     SvLBoxItem*     pHdlItem;
@@ -778,6 +779,9 @@ public:
     long getPreferredDimensions(std::vector<long> &rWidths) const;
 
     virtual Size GetOptimalSize() const SAL_OVERRIDE;
+
+    void SetAlternatingRow( const bool bEnable );
+    bool IsRowAlternating() const { return mbAlternatingRowColor; }
 };
 
 #define SV_LBOX_DD_FORMAT "SV_LBOX_DD_FORMAT"
diff --git a/include/svtools/treelistentry.hxx 
b/include/svtools/treelistentry.hxx
index 71ff072..2692bec 100644
--- a/include/svtools/treelistentry.hxx
+++ b/include/svtools/treelistentry.hxx
@@ -56,6 +56,7 @@ class SVT_DLLPUBLIC SvTreeListEntry
     bool                bIsMarked;
     void*               pUserData;
     sal_uInt16          nEntryFlags;
+    Color               maBackColor;
 
 private:
     void ClearChildren();
@@ -101,6 +102,9 @@ public:
 
     bool GetIsMarked() const { return bIsMarked; }
     void SetMarked( bool IsMarked ) { bIsMarked = IsMarked; }
+
+    void SetBackColor( const Color& aColor ) { maBackColor = aColor; }
+    Color GetBackColor() const { return maBackColor; }
 };
 
 #endif
diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx
index fb16ee3..bb454a3 100644
--- a/include/vcl/settings.hxx
+++ b/include/vcl/settings.hxx
@@ -358,6 +358,12 @@ public:
     void                            SetInactiveTabColor( const Color& rColor );
     const Color&                    GetInactiveTabColor() const;
 
+    void                            SetAlternatingRowColor( const Color& 
rColor );
+    const Color&                    GetAlternatingRowColor() const;
+
+    void                            SetAlternatingRowColor2( const Color& 
rColor );
+    const Color&                    GetAlternatingRowColor2() const;
+
     void                            SetHighContrastMode(bool bHighContrast );
     bool                            GetHighContrastMode() const;
 
diff --git a/svtools/source/contnr/treelistbox.cxx 
b/svtools/source/contnr/treelistbox.cxx
index c0ed007..c7d610c 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 559a60f..c4c9220 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)
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index a4fb97e..0c358eb 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -89,6 +89,8 @@ struct ImplStyleData
     Color                           maActiveColor;
     Color                           maActiveColor2;
     Color                           maActiveTextColor;
+    Color                           maAlternatingRowColor;
+    Color                           maAlternatingRowColor2;
     Color                           maButtonTextColor;
     Color                           maButtonRolloverTextColor;
     Color                           maCheckedColor;
@@ -561,6 +563,8 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) :
     maActiveColor( rData.maActiveColor ),
     maActiveColor2( rData.maActiveColor2 ),
     maActiveTextColor( rData.maActiveTextColor ),
+    maAlternatingRowColor( rData.maAlternatingRowColor ),
+    maAlternatingRowColor2( rData.maAlternatingRowColor2 ),
     maButtonTextColor( rData.maButtonTextColor ),
     maButtonRolloverTextColor( rData.maButtonRolloverTextColor ),
     maCheckedColor( rData.maCheckedColor ),
@@ -741,6 +745,8 @@ void ImplStyleData::SetStandardStyles()
     maVisitedLinkColor          = Color( 0x00, 0x00, 0xCC );
     maHighlightLinkColor        = Color( COL_LIGHTBLUE );
     maFontColor                 = Color( COL_BLACK );
+    maAlternatingRowColor       = Color( COL_WHITE );
+    maAlternatingRowColor2      = Color( 0xEE, 0xEE, 0xEE );
 
     mnBorderSize                = 1;
     mnTitleHeight               = 18;
@@ -1384,6 +1390,32 @@ StyleSettings::GetInactiveTabColor() const
 }
 
 void
+StyleSettings::SetAlternatingRowColor( const Color& rColor )
+{
+    CopyData();
+    mpData->maAlternatingRowColor = rColor;
+}
+
+const Color&
+StyleSettings::GetAlternatingRowColor() const
+{
+    return mpData->maAlternatingRowColor;
+}
+
+void
+StyleSettings::SetAlternatingRowColor2( const Color& rColor )
+{
+    CopyData();
+    mpData->maAlternatingRowColor2 = rColor;
+}
+
+const Color&
+StyleSettings::GetAlternatingRowColor2() const
+{
+    return mpData->maAlternatingRowColor2;
+}
+
+void
 StyleSettings::SetUseSystemUIFonts( bool bUseSystemUIFonts )
 {
     CopyData();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to