[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/source

Muhammet Kara muhammet.kara at pardus.org.tr
Fri Apr 20 18:53:22 UTC 2018


 include/vcl/lstbox.hxx             |   13 +++++++++++++
 vcl/inc/listbox.hxx                |   37 ++++++++++++++++++++++++++++++++++---
 vcl/source/control/imp_listbox.cxx |   29 +++++++++++++++++++++++++----
 vcl/source/control/listbox.cxx     |    5 +++++
 4 files changed, 77 insertions(+), 7 deletions(-)

New commits:
commit e9c52f55f0cc7155d6883e4d2abf14f1638b03b3
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date:   Thu Apr 19 21:36:08 2018 +0300

    towards solving tdf#112323: Allow multiple separators in listboxes
    
    Change-Id: I40e2d9faa4121ad99e28cbae0d8eea8e46bc1e9a
    Reviewed-on: https://gerrit.libreoffice.org/53174
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Muhammet Kara <muhammet.kara at pardus.org.tr>

diff --git a/include/vcl/lstbox.hxx b/include/vcl/lstbox.hxx
index 5c8c6d29938e..62ad36283adc 100644
--- a/include/vcl/lstbox.hxx
+++ b/include/vcl/lstbox.hxx
@@ -202,9 +202,22 @@ public:
     sal_Int32           GetSavedValue() const { return mnSaveValue; }
     bool                IsValueChangedFromSaved() const { return mnSaveValue != GetSelectedEntryPos(); }
 
+    /**
+     * Removes existing separators, and sets the position of the
+     * one and only separator.
+     */
     void                SetSeparatorPos( sal_Int32 n );
+    /**
+     * Gets the position of the separator which was added first.
+     * Returns LISTBOX_ENTRY_NOTFOUND if there is no separator.
+     */
     sal_Int32           GetSeparatorPos() const;
 
+    /**
+     * Adds a new separator at the given position n.
+     */
+    void                AddSeparator( sal_Int32 n );
+
     bool                IsTravelSelect() const;
     bool                IsInDropDown() const;
     void                ToggleDropDown();
diff --git a/vcl/inc/listbox.hxx b/vcl/inc/listbox.hxx
index cea25b5cfeb0..313ff8cbd047 100644
--- a/vcl/inc/listbox.hxx
+++ b/vcl/inc/listbox.hxx
@@ -24,6 +24,7 @@
 #include <vcl/floatwin.hxx>
 #include <vcl/quickselectionengine.hxx>
 
+#include <set>
 #include <vector>
 #include <memory>
 
@@ -182,7 +183,7 @@ private:
     sal_Int32       mnCurrentPos;    ///< Position (Focus)
     sal_Int32       mnTrackingSaveSelection; ///< Selection before Tracking();
 
-    sal_Int32       mnSeparatorPos; ///< Separator
+    std::set< sal_Int32 > maSeparators; ///< Separator positions
 
     sal_Int32       mnUserDrawEntry;
 
@@ -289,8 +290,25 @@ public:
     void            AllowGrabFocus( bool b )        { mbGrabFocus = b; }
     bool            IsGrabFocusAllowed() const      { return mbGrabFocus; }
 
-    void            SetSeparatorPos( sal_Int32  n )     { mnSeparatorPos = n; }
-    sal_Int32       GetSeparatorPos() const         { return mnSeparatorPos; }
+    /**
+     * Removes existing separators, and sets the position of the
+     * one and only separator.
+     */
+    void            SetSeparatorPos( sal_Int32  n );
+    /**
+     * Gets the position of the separator which was added first.
+     * Returns LISTBOX_ENTRY_NOTFOUND if there is no separator.
+     */
+    sal_Int32       GetSeparatorPos() const;
+
+    /**
+     * Adds a new separator at the given position n.
+     */
+    void            AddSeparator( sal_Int32 n )     { maSeparators.insert( n ); }
+    /**
+     * Checks if the given number n is an element of the separator positions set.
+     */
+    bool            isSeparator( const sal_Int32 &n ) const;
 
     void            SetTravelSelect( bool bTravelSelect ) { mbTravelSelect = bTravelSelect; }
     bool            IsTravelSelect() const          { return mbTravelSelect; }
@@ -409,9 +427,22 @@ public:
     bool            ProcessKeyInput( const KeyEvent& rKEvt )    { return maLBWindow->ProcessKeyInput( rKEvt ); }
     bool            HandleWheelAsCursorTravel( const CommandEvent& rCEvt );
 
+    /**
+     * Removes existing separators, and sets the position of the
+     * one and only separator.
+     */
     void            SetSeparatorPos( sal_Int32  n )     { maLBWindow->SetSeparatorPos( n ); }
+    /**
+     * Gets the position of the separator which was added first.
+     * Returns LISTBOX_ENTRY_NOTFOUND if there is no separator.
+     */
     sal_Int32       GetSeparatorPos() const         { return maLBWindow->GetSeparatorPos(); }
 
+    /**
+     * Adds a new separator at the given position n.
+     */
+    void            AddSeparator( sal_Int32 n )     { maLBWindow->AddSeparator( n ); }
+
     void            SetTopEntry( sal_Int32  nTop )      { maLBWindow->SetTopEntry( nTop ); }
     sal_Int32       GetTopEntry() const             { return maLBWindow->GetTopEntry(); }
     void            ShowProminentEntry( sal_Int32  nPos ) { maLBWindow->ShowProminentEntry( nPos ); }
diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx
index 171b75afd151..7dbabad9934a 100644
--- a/vcl/source/control/imp_listbox.cxx
+++ b/vcl/source/control/imp_listbox.cxx
@@ -491,7 +491,6 @@ ImplListBoxWindow::ImplListBoxWindow( vcl::Window* pParent, WinBits nWinStyle )
 
     mnCurrentPos            = LISTBOX_ENTRY_NOTFOUND;
     mnTrackingSaveSelection = LISTBOX_ENTRY_NOTFOUND;
-    mnSeparatorPos          = LISTBOX_ENTRY_NOTFOUND;
     meProminentType         = ProminentEntry::TOP;
 
     SetLineColor();
@@ -1825,13 +1824,12 @@ void ImplListBoxWindow::DrawEntry(vcl::RenderContext& rRenderContext, sal_Int32
         }
     }
 
-    if ((mnSeparatorPos != LISTBOX_ENTRY_NOTFOUND) &&
-        ((nPos == mnSeparatorPos) || (nPos == mnSeparatorPos + 1)))
+    if ( !maSeparators.empty() && ( isSeparator(nPos) || isSeparator(nPos-1) ) )
     {
         Color aOldLineColor(rRenderContext.GetLineColor());
         rRenderContext.SetLineColor((GetBackground().GetColor() != COL_LIGHTGRAY) ? COL_LIGHTGRAY : COL_GRAY);
         Point aStartPos(0, nY);
-        if (nPos == mnSeparatorPos)
+        if (isSeparator(nPos))
             aStartPos.AdjustY(pEntry->mnHeight - 1 );
         Point aEndPos(aStartPos);
         aEndPos.setX( GetOutputSizePixel().Width() );
@@ -2011,6 +2009,29 @@ void ImplListBoxWindow::ScrollHorz( long n )
     }
 }
 
+void ImplListBoxWindow::SetSeparatorPos( sal_Int32 n )
+{
+    maSeparators.clear();
+
+    if ( n != LISTBOX_ENTRY_NOTFOUND )
+    {
+        maSeparators.insert( n );
+    }
+}
+
+sal_Int32 ImplListBoxWindow::GetSeparatorPos() const
+{
+    if (!maSeparators.empty())
+        return *(maSeparators.begin());
+    else
+        return LISTBOX_ENTRY_NOTFOUND;
+}
+
+bool ImplListBoxWindow::isSeparator( const sal_Int32 &n) const
+{
+    return maSeparators.find(n) != maSeparators.end();
+}
+
 Size ImplListBoxWindow::CalcSize(sal_Int32 nMaxLines) const
 {
     // FIXME: ListBoxEntryFlags::MultiLine
diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx
index ef945a087659..1d8e256e80e2 100644
--- a/vcl/source/control/listbox.cxx
+++ b/vcl/source/control/listbox.cxx
@@ -1380,6 +1380,11 @@ sal_Int32 ListBox::GetSeparatorPos() const
     return mpImplLB->GetSeparatorPos();
 }
 
+void ListBox::AddSeparator( sal_Int32 n )
+{
+    mpImplLB->AddSeparator( n );
+}
+
 sal_uInt16 ListBox::GetDisplayLineCount() const
 {
     return mpImplLB->GetDisplayLineCount();


More information about the Libreoffice-commits mailing list