summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-07-02 11:53:27 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2024-07-03 08:19:15 +0200
commitaf9413cb4ad49c0b4854c08cc2804644220755ae (patch)
treed8003849d624bf489d362260b39ce58577bf57a7 /vcl
parent65013d5d0d5c5348d51b037fb6719fd25ddedda4 (diff)
tdf#161853 icon choice ctrl: Drop support for non-single selection modes
Since commit fd2ea8e03510c6a99ec8be6228b7422f6c5b182b Date: Wed Aug 19 14:59:33 2020 +0100 weld OApplicationSwapWindow , the `SvtIconChoiceCtrl` and its implementation class, `SvxIconChoiceCtrl_Impl`, is only used in `VerticalTabControl`. That one was explicitly enabling `SelectionMode::Single` in its ctor. Therefore, other modes are unused. Drop support for them altogether to simplify the implementation. This commit primarily drops `SvxIconChoiceCtrl_Impl::eSelectionMode` and uses thereof, and allows for further simplification in upcoming commits. Change-Id: I0acde664d695571e9058b9829ad02745a4abaad2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169872 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/control/imivctl.hxx6
-rw-r--r--vcl/source/control/imivctl1.cxx197
-rw-r--r--vcl/source/control/ivctrl.cxx6
3 files changed, 20 insertions, 189 deletions
diff --git a/vcl/source/control/imivctl.hxx b/vcl/source/control/imivctl.hxx
index 6f6030bab271..4c6729a7a19d 100644
--- a/vcl/source/control/imivctl.hxx
+++ b/vcl/source/control/imivctl.hxx
@@ -146,7 +146,6 @@ class SvxIconChoiceCtrl_Impl
LocalFocus aFocus; // Data for focusrect
::vcl::AccessibleFactoryAccess aAccFactory;
- SelectionMode eSelectionMode;
sal_Int32 nSelectionCount;
SvxIconChoiceCtrlPositionMode ePositionMode;
bool bBoundRectsDirty;
@@ -252,11 +251,6 @@ public:
SvxIconChoiceCtrl_Impl( SvtIconChoiceCtrl* pView, WinBits nWinStyle );
~SvxIconChoiceCtrl_Impl();
- void SetSelectionMode(SelectionMode eMode)
- {
- eSelectionMode = eMode;
- }
-
void Clear( bool bInCtor );
void SetStyle( WinBits nWinStyle );
WinBits GetStyle() const { return nWinBits; }
diff --git a/vcl/source/control/imivctl1.cxx b/vcl/source/control/imivctl1.cxx
index a21d1e83f690..9a76ef7d3e0f 100644
--- a/vcl/source/control/imivctl1.cxx
+++ b/vcl/source/control/imivctl1.cxx
@@ -66,7 +66,7 @@ SvxIconChoiceCtrl_Impl::SvxIconChoiceCtrl_Impl(
pCurHighlightFrame(nullptr), bHighlightFramePressed(false), pHead(nullptr), pCursor(nullptr),
pHdlEntry(nullptr),
pAnchor(nullptr),
- eSelectionMode(SelectionMode::Multiple), ePositionMode(SvxIconChoiceCtrlPositionMode::Free),
+ ePositionMode(SvxIconChoiceCtrlPositionMode::Free),
bUpdateMode(true)
{
SetStyle( nWinStyle );
@@ -245,8 +245,6 @@ void SvxIconChoiceCtrl_Impl::SetListPositions()
void SvxIconChoiceCtrl_Impl::SelectEntry( SvxIconChoiceCtrlEntry* pEntry, bool bSelect,
bool bAdd )
{
- if( eSelectionMode == SelectionMode::NONE )
- return;
if( !bAdd )
{
@@ -281,11 +279,9 @@ void SvxIconChoiceCtrl_Impl::SelectEntry( SvxIconChoiceCtrlEntry* pEntry, bool b
void SvxIconChoiceCtrl_Impl::EntrySelected(SvxIconChoiceCtrlEntry* pEntry, bool bSelect)
{
- // When using SingleSelection, make sure that the cursor is always placed
+ // make sure that the cursor is always placed
// over the (only) selected entry. (But only if a cursor exists.)
- if (bSelect && pCursor &&
- eSelectionMode == SelectionMode::Single &&
- pEntry != pCursor)
+ if (bSelect && pCursor && pEntry != pCursor)
{
SetCursor(pEntry);
}
@@ -594,7 +590,6 @@ bool SvxIconChoiceCtrl_Impl::MouseButtonDown( const MouseEvent& rMEvt)
{
bool bHandled = true;
bHighlightFramePressed = false;
- bool bGotFocus = (!pView->HasFocus() && !(nWinBits & WB_NOPOINTERFOCUS));
if( !(nWinBits & WB_NOPOINTERFOCUS) )
pView->GrabFocus();
@@ -606,68 +601,8 @@ bool SvxIconChoiceCtrl_Impl::MouseButtonDown( const MouseEvent& rMEvt)
if( pEntry )
MakeEntryVisible( pEntry, false );
- if( rMEvt.IsShift() && eSelectionMode != SelectionMode::Single )
- {
- if( pEntry )
- SetCursor_Impl( pCursor, pEntry, rMEvt.IsMod1(), rMEvt.IsShift() );
- return true;
- }
-
- if( pAnchor && (rMEvt.IsShift() || rMEvt.IsMod1())) // keyboard selection?
- {
- DBG_ASSERT(eSelectionMode != SelectionMode::Single,"Invalid selection mode");
- if( rMEvt.IsMod1() )
- nFlags |= IconChoiceFlags::AddMode;
-
- if( rMEvt.IsShift() )
- {
- tools::Rectangle aRect( GetEntryBoundRect( pAnchor ));
- if( pEntry )
- aRect.Union( GetEntryBoundRect( pEntry ) );
- else
- {
- tools::Rectangle aTempRect( aDocPos, Size(1,1));
- aRect.Union( aTempRect );
- }
- aCurSelectionRect = aRect;
- SelectRect(aRect, bool(nFlags & IconChoiceFlags::AddMode), aSelectedRectList);
- }
- else if( rMEvt.IsMod1() )
- {
- AddSelectedRect( aCurSelectionRect );
- pAnchor = nullptr;
- aCurSelectionRect.SetPos( aDocPos );
- }
-
- if( !pEntry && !(nWinBits & WB_NODRAGSELECTION))
- pView->StartTracking( StartTrackingFlags::ScrollRepeat );
- return true;
- }
- else
- {
- if( !pEntry )
- {
- if( eSelectionMode == SelectionMode::Multiple )
- {
- if( !rMEvt.IsMod1() ) // Ctrl
- {
- if( !bGotFocus )
- {
- SetNoSelection();
- ClearSelectedRectList();
- }
- }
- else
- nFlags |= IconChoiceFlags::AddMode;
- aCurSelectionRect.SetPos( aDocPos );
- pView->StartTracking( StartTrackingFlags::ScrollRepeat );
- }
- else
- bHandled = false;
- return bHandled;
- }
- }
- bool bSelected = pEntry->IsSelected();
+ if( !pEntry )
+ return false;
if( rMEvt.GetClicks() == 2 )
{
@@ -682,39 +617,11 @@ bool SvxIconChoiceCtrl_Impl::MouseButtonDown( const MouseEvent& rMEvt)
if( rMEvt.IsMod2() ) // Alt?
{
}
- else if( eSelectionMode == SelectionMode::Single )
+ else
{
DeselectAllBut( pEntry );
SetCursor( pEntry );
}
- else if( eSelectionMode == SelectionMode::NONE )
- {
- if( rMEvt.IsLeft() && (nWinBits & WB_HIGHLIGHTFRAME) )
- {
- pCurHighlightFrame = nullptr; // force repaint of frame
- bHighlightFramePressed = true;
- SetEntryHighlightFrame( pEntry, true );
- }
- }
- else
- {
- if( !rMEvt.GetModifier() && rMEvt.IsLeft() )
- {
- if( !bSelected )
- {
- DeselectAllBut( pEntry );
- SetCursor( pEntry );
- SelectEntry( pEntry, true, false );
- }
- else
- {
- // deselect only in the Up, if the Move happened via D&D!
- nFlags |= IconChoiceFlags::DownDeselect;
- }
- }
- else if( rMEvt.IsMod1() )
- nFlags |= IconChoiceFlags::DownCtrl;
- }
}
return bHandled;
}
@@ -793,20 +700,6 @@ void SvxIconChoiceCtrl_Impl::SetCursor_Impl( SvxIconChoiceCtrlEntry* pOldCursor,
if( !pNewCursor )
return;
- SvxIconChoiceCtrlEntry* pFilterEntry = nullptr;
- bool bDeselectAll = false;
- if( eSelectionMode != SelectionMode::Single )
- {
- if( !bMod1 && !bShift )
- bDeselectAll = true;
- else if( bShift && !bMod1 && !pAnchor )
- {
- bDeselectAll = true;
- pFilterEntry = pOldCursor;
- }
- }
- if( bDeselectAll )
- DeselectAllBut( pFilterEntry );
ShowCursor( false );
MakeEntryVisible( pNewCursor );
SetCursor( pNewCursor );
@@ -855,17 +748,6 @@ bool SvxIconChoiceCtrl_Impl::KeyInput( const KeyEvent& rKEvt )
return false;
bool bKeyUsed = true;
- bool bMod1 = rKEvt.GetKeyCode().IsMod1();
- bool bShift = rKEvt.GetKeyCode().IsShift();
-
- if( eSelectionMode == SelectionMode::Single || eSelectionMode == SelectionMode::NONE)
- {
- bShift = false;
- bMod1 = false;
- }
-
- if( bMod1 )
- nFlags |= IconChoiceFlags::AddMode;
SvxIconChoiceCtrlEntry* pNewCursor;
SvxIconChoiceCtrlEntry* pOldCursor = pCursor;
@@ -882,7 +764,7 @@ bool SvxIconChoiceCtrl_Impl::KeyInput( const KeyEvent& rKEvt )
pNewCursor = pImpCursor->GoUpDown(pCursor,false);
else
pNewCursor = pImpCursor->GoPageUpDown(pCursor,false);
- SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift );
+ SetCursor_Impl(pOldCursor, pNewCursor, false, false);
if( !pNewCursor )
{
tools::Rectangle aRect( GetEntryBoundRect( pCursor ) );
@@ -904,7 +786,7 @@ bool SvxIconChoiceCtrl_Impl::KeyInput( const KeyEvent& rKEvt )
pNewCursor=pImpCursor->GoUpDown( pCursor,true );
else
pNewCursor=pImpCursor->GoPageUpDown( pCursor,true );
- SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift );
+ SetCursor_Impl(pOldCursor, pNewCursor, false, false);
}
break;
@@ -912,7 +794,7 @@ bool SvxIconChoiceCtrl_Impl::KeyInput( const KeyEvent& rKEvt )
if( pCursor )
{
pNewCursor=pImpCursor->GoLeftRight(pCursor,true );
- SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift );
+ SetCursor_Impl(pOldCursor, pNewCursor, false, false);
}
break;
@@ -921,7 +803,7 @@ bool SvxIconChoiceCtrl_Impl::KeyInput( const KeyEvent& rKEvt )
{
MakeEntryVisible( pCursor );
pNewCursor = pImpCursor->GoLeftRight(pCursor,false );
- SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift );
+ SetCursor_Impl(pOldCursor, pNewCursor, false, false);
if( !pNewCursor )
{
tools::Rectangle aRect( GetEntryBoundRect(pCursor));
@@ -936,8 +818,6 @@ bool SvxIconChoiceCtrl_Impl::KeyInput( const KeyEvent& rKEvt )
break;
case KEY_F2:
- if( bMod1 || bShift )
- bKeyUsed = false;
break;
case KEY_F8:
@@ -953,23 +833,6 @@ bool SvxIconChoiceCtrl_Impl::KeyInput( const KeyEvent& rKEvt )
break;
case KEY_SPACE:
- if( pCursor && eSelectionMode != SelectionMode::Single )
- {
- if( !bMod1 )
- {
- //SelectAll( false );
- SetNoSelection();
- ClearSelectedRectList();
-
- // click Icon with spacebar
- SetEntryHighlightFrame( GetCurEntry(), true );
- pView->ClickIcon();
- pHdlEntry = pCurHighlightFrame;
- pCurHighlightFrame=nullptr;
- }
- else
- ToggleSelection( pCursor );
- }
break;
#ifdef DBG_UTIL
@@ -990,30 +853,23 @@ bool SvxIconChoiceCtrl_Impl::KeyInput( const KeyEvent& rKEvt )
case KEY_ADD:
case KEY_DIVIDE :
case KEY_A:
- if( bMod1 && (eSelectionMode != SelectionMode::Single))
- SelectAll();
- else
bKeyUsed = false;
break;
case KEY_SUBTRACT:
case KEY_COMMA :
- if( bMod1 )
- SetNoSelection();
- else
- bKeyUsed = false;
+ bKeyUsed = false;
break;
case KEY_RETURN:
- if( !bMod1 )
- bKeyUsed = false;
+ bKeyUsed = false;
break;
case KEY_END:
if( pCursor )
{
pNewCursor = maEntries.back().get();
- SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift );
+ SetCursor_Impl(pOldCursor, pNewCursor, false, false);
}
break;
@@ -1021,7 +877,7 @@ bool SvxIconChoiceCtrl_Impl::KeyInput( const KeyEvent& rKEvt )
if( pCursor )
{
pNewCursor = maEntries[ 0 ].get();
- SetCursor_Impl( pOldCursor, pNewCursor, bMod1, bShift );
+ SetCursor_Impl(pOldCursor, pNewCursor, false, false);
}
break;
@@ -1378,21 +1234,16 @@ void SvxIconChoiceCtrl_Impl::PaintItem(const tools::Rectangle& rRect,
void SvxIconChoiceCtrl_Impl::PaintEntry(SvxIconChoiceCtrlEntry* pEntry, const Point& rPos, vcl::RenderContext& rRenderContext)
{
- bool bSelected = false;
-
- if (eSelectionMode != SelectionMode::NONE)
- bSelected = pEntry->IsSelected();
+ bool bSelected = pEntry->IsSelected();
rRenderContext.Push(vcl::PushFlags::FONT | vcl::PushFlags::TEXTCOLOR);
tools::Rectangle aTextRect(CalcTextRect(pEntry, &rPos));
tools::Rectangle aBmpRect(CalcBmpRect(pEntry, &rPos));
- bool bShowSelection = (bSelected && (eSelectionMode != SelectionMode::NONE));
-
bool bActiveSelection = (0 != (nWinBits & WB_NOHIDESELECTION)) || pView->HasFocus();
- if (bShowSelection)
+ if (bSelected)
{
const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings();
vcl::Font aNewFont(rRenderContext.GetFont());
@@ -1436,7 +1287,7 @@ void SvxIconChoiceCtrl_Impl::PaintEntry(SvxIconChoiceCtrlEntry* pEntry, const Po
PaintEmphasis(aTextRect, bSelected, rRenderContext);
- if ( bShowSelection )
+ if (bSelected)
vcl::RenderTools::DrawSelectionBackground(rRenderContext, *pView, CalcFocusRect(pEntry),
bActiveSelection ? 1 : 2, false, true, false);
@@ -1742,8 +1593,7 @@ void SvxIconChoiceCtrl_Impl::SetCursor( SvxIconChoiceCtrlEntry* pEntry )
{
if( pEntry == pCursor )
{
- if( pCursor && eSelectionMode == SelectionMode::Single &&
- !pCursor->IsSelected() )
+ if (pCursor && !pCursor->IsSelected())
SelectEntry( pCursor, true );
return;
}
@@ -1753,15 +1603,13 @@ void SvxIconChoiceCtrl_Impl::SetCursor( SvxIconChoiceCtrlEntry* pEntry )
if( pOldCursor )
{
pOldCursor->ClearFlags( SvxIconViewFlags::FOCUSED );
- if( eSelectionMode == SelectionMode::Single )
- SelectEntry( pOldCursor, false ); // deselect old cursor
+ SelectEntry(pOldCursor, false); // deselect old cursor
}
if( pCursor )
{
ToTop( pCursor );
pCursor->SetFlags( SvxIconViewFlags::FOCUSED );
- if( eSelectionMode == SelectionMode::Single )
- SelectEntry( pCursor, true );
+ SelectEntry(pCursor, true);
ShowCursor( true );
}
}
@@ -2505,11 +2353,6 @@ SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::GetFirstSelectedEntry() const
if( !GetSelectionCount() )
return nullptr;
- if( (nWinBits & WB_HIGHLIGHTFRAME) && (eSelectionMode == SelectionMode::NONE) )
- {
- return pCurHighlightFrame;
- }
-
size_t nCount = maEntries.size();
if( !pHead )
{
diff --git a/vcl/source/control/ivctrl.cxx b/vcl/source/control/ivctrl.cxx
index 61fa316bd796..4fa8b92997a9 100644
--- a/vcl/source/control/ivctrl.cxx
+++ b/vcl/source/control/ivctrl.cxx
@@ -91,11 +91,6 @@ SvtIconChoiceCtrl::SvtIconChoiceCtrl( vcl::Window* pParent, WinBits nWinStyle )
_pImpl->SetPositionMode( SvxIconChoiceCtrlPositionMode::AutoArrange );
}
-void SvtIconChoiceCtrl::SetSelectionMode(SelectionMode eMode)
-{
- _pImpl->SetSelectionMode(eMode);
-}
-
SvtIconChoiceCtrl::~SvtIconChoiceCtrl()
{
disposeOnce();
@@ -422,7 +417,6 @@ VerticalTabControl::VerticalTabControl(vcl::Window* pParent, bool bWithIcons)
{
SetStyle(GetStyle() | WB_DIALOGCONTROL);
SetType(WindowType::VERTICALTABCONTROL);
- m_xChooser->SetSelectionMode(SelectionMode::Single);
m_xChooser->SetClickHdl(LINK(this, VerticalTabControl, ChosePageHdl_Impl));
m_xChooser->set_width_request(150);
m_xChooser->set_height_request(400);