Kaydet (Commit) e9c52f55 authored tarafından Muhammet Kara's avatar Muhammet Kara

towards solving tdf#112323: Allow multiple separators in listboxes

Change-Id: I40e2d9faa4121ad99e28cbae0d8eea8e46bc1e9a
Reviewed-on: https://gerrit.libreoffice.org/53174Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMuhammet Kara <muhammet.kara@pardus.org.tr>
üst f1451fb7
...@@ -202,9 +202,22 @@ public: ...@@ -202,9 +202,22 @@ public:
sal_Int32 GetSavedValue() const { return mnSaveValue; } sal_Int32 GetSavedValue() const { return mnSaveValue; }
bool IsValueChangedFromSaved() const { return mnSaveValue != GetSelectedEntryPos(); } bool IsValueChangedFromSaved() const { return mnSaveValue != GetSelectedEntryPos(); }
/**
* Removes existing separators, and sets the position of the
* one and only separator.
*/
void SetSeparatorPos( sal_Int32 n ); 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; sal_Int32 GetSeparatorPos() const;
/**
* Adds a new separator at the given position n.
*/
void AddSeparator( sal_Int32 n );
bool IsTravelSelect() const; bool IsTravelSelect() const;
bool IsInDropDown() const; bool IsInDropDown() const;
void ToggleDropDown(); void ToggleDropDown();
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <vcl/floatwin.hxx> #include <vcl/floatwin.hxx>
#include <vcl/quickselectionengine.hxx> #include <vcl/quickselectionengine.hxx>
#include <set>
#include <vector> #include <vector>
#include <memory> #include <memory>
...@@ -182,7 +183,7 @@ private: ...@@ -182,7 +183,7 @@ private:
sal_Int32 mnCurrentPos; ///< Position (Focus) sal_Int32 mnCurrentPos; ///< Position (Focus)
sal_Int32 mnTrackingSaveSelection; ///< Selection before Tracking(); sal_Int32 mnTrackingSaveSelection; ///< Selection before Tracking();
sal_Int32 mnSeparatorPos; ///< Separator std::set< sal_Int32 > maSeparators; ///< Separator positions
sal_Int32 mnUserDrawEntry; sal_Int32 mnUserDrawEntry;
...@@ -289,8 +290,25 @@ public: ...@@ -289,8 +290,25 @@ public:
void AllowGrabFocus( bool b ) { mbGrabFocus = b; } void AllowGrabFocus( bool b ) { mbGrabFocus = b; }
bool IsGrabFocusAllowed() const { return mbGrabFocus; } 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; } void SetTravelSelect( bool bTravelSelect ) { mbTravelSelect = bTravelSelect; }
bool IsTravelSelect() const { return mbTravelSelect; } bool IsTravelSelect() const { return mbTravelSelect; }
...@@ -409,9 +427,22 @@ public: ...@@ -409,9 +427,22 @@ public:
bool ProcessKeyInput( const KeyEvent& rKEvt ) { return maLBWindow->ProcessKeyInput( rKEvt ); } bool ProcessKeyInput( const KeyEvent& rKEvt ) { return maLBWindow->ProcessKeyInput( rKEvt ); }
bool HandleWheelAsCursorTravel( const CommandEvent& rCEvt ); 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 ); } 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(); } 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 ); } void SetTopEntry( sal_Int32 nTop ) { maLBWindow->SetTopEntry( nTop ); }
sal_Int32 GetTopEntry() const { return maLBWindow->GetTopEntry(); } sal_Int32 GetTopEntry() const { return maLBWindow->GetTopEntry(); }
void ShowProminentEntry( sal_Int32 nPos ) { maLBWindow->ShowProminentEntry( nPos ); } void ShowProminentEntry( sal_Int32 nPos ) { maLBWindow->ShowProminentEntry( nPos ); }
......
...@@ -491,7 +491,6 @@ ImplListBoxWindow::ImplListBoxWindow( vcl::Window* pParent, WinBits nWinStyle ) ...@@ -491,7 +491,6 @@ ImplListBoxWindow::ImplListBoxWindow( vcl::Window* pParent, WinBits nWinStyle )
mnCurrentPos = LISTBOX_ENTRY_NOTFOUND; mnCurrentPos = LISTBOX_ENTRY_NOTFOUND;
mnTrackingSaveSelection = LISTBOX_ENTRY_NOTFOUND; mnTrackingSaveSelection = LISTBOX_ENTRY_NOTFOUND;
mnSeparatorPos = LISTBOX_ENTRY_NOTFOUND;
meProminentType = ProminentEntry::TOP; meProminentType = ProminentEntry::TOP;
SetLineColor(); SetLineColor();
...@@ -1825,13 +1824,12 @@ void ImplListBoxWindow::DrawEntry(vcl::RenderContext& rRenderContext, sal_Int32 ...@@ -1825,13 +1824,12 @@ void ImplListBoxWindow::DrawEntry(vcl::RenderContext& rRenderContext, sal_Int32
} }
} }
if ((mnSeparatorPos != LISTBOX_ENTRY_NOTFOUND) && if ( !maSeparators.empty() && ( isSeparator(nPos) || isSeparator(nPos-1) ) )
((nPos == mnSeparatorPos) || (nPos == mnSeparatorPos + 1)))
{ {
Color aOldLineColor(rRenderContext.GetLineColor()); Color aOldLineColor(rRenderContext.GetLineColor());
rRenderContext.SetLineColor((GetBackground().GetColor() != COL_LIGHTGRAY) ? COL_LIGHTGRAY : COL_GRAY); rRenderContext.SetLineColor((GetBackground().GetColor() != COL_LIGHTGRAY) ? COL_LIGHTGRAY : COL_GRAY);
Point aStartPos(0, nY); Point aStartPos(0, nY);
if (nPos == mnSeparatorPos) if (isSeparator(nPos))
aStartPos.AdjustY(pEntry->mnHeight - 1 ); aStartPos.AdjustY(pEntry->mnHeight - 1 );
Point aEndPos(aStartPos); Point aEndPos(aStartPos);
aEndPos.setX( GetOutputSizePixel().Width() ); aEndPos.setX( GetOutputSizePixel().Width() );
...@@ -2011,6 +2009,29 @@ void ImplListBoxWindow::ScrollHorz( long n ) ...@@ -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 Size ImplListBoxWindow::CalcSize(sal_Int32 nMaxLines) const
{ {
// FIXME: ListBoxEntryFlags::MultiLine // FIXME: ListBoxEntryFlags::MultiLine
......
...@@ -1380,6 +1380,11 @@ sal_Int32 ListBox::GetSeparatorPos() const ...@@ -1380,6 +1380,11 @@ sal_Int32 ListBox::GetSeparatorPos() const
return mpImplLB->GetSeparatorPos(); return mpImplLB->GetSeparatorPos();
} }
void ListBox::AddSeparator( sal_Int32 n )
{
mpImplLB->AddSeparator( n );
}
sal_uInt16 ListBox::GetDisplayLineCount() const sal_uInt16 ListBox::GetDisplayLineCount() const
{ {
return mpImplLB->GetDisplayLineCount(); return mpImplLB->GetDisplayLineCount();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment