summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@pardus.org.tr>2018-04-19 21:36:08 +0300
committerMuhammet Kara <muhammet.kara@pardus.org.tr>2018-04-20 20:52:35 +0200
commite9c52f55f0cc7155d6883e4d2abf14f1638b03b3 (patch)
tree4daa3ba03e39cde571f1220dfa231d430b5c7ec5 /vcl
parentf1451fb7742bba9da298027e3ab79390acb196d9 (diff)
towards solving tdf#112323: Allow multiple separators in listboxes
Change-Id: I40e2d9faa4121ad99e28cbae0d8eea8e46bc1e9a Reviewed-on: https://gerrit.libreoffice.org/53174 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Muhammet Kara <muhammet.kara@pardus.org.tr>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/listbox.hxx37
-rw-r--r--vcl/source/control/imp_listbox.cxx29
-rw-r--r--vcl/source/control/listbox.cxx5
3 files changed, 64 insertions, 7 deletions
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();