tdf#117388 use native scrollbar under gtk in calc document
Change-Id: I436067b4f2b463fe9a5d6789cf96f906891757bd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137810
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/include/svtools/scrolladaptor.hxx b/include/svtools/scrolladaptor.hxx
index 8e94d3e..1214b2c 100644
--- a/include/svtools/scrolladaptor.hxx
+++ b/include/svtools/scrolladaptor.hxx
@@ -58,6 +58,10 @@ public:
// what is it
bool IsHoriScroll() const { return m_bHori; }
ScrollType GetScrollType() const;
virtual void EnableRTL(bool bEnable = true) override;
virtual tools::Long DoScroll(tools::Long nNewPos) override;
virtual bool Inactive() const override { return !m_xScrollBar->get_sensitive(); }
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 81151f1..97c6e96 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -22,6 +22,7 @@
#include <array>
#include <memory>
#include <svtools/scrolladaptor.hxx>
#include <vcl/scrbar.hxx>
#include <vcl/help.hxx>
@@ -147,10 +148,10 @@ private:
VclPtr<ScTabSplitter> pHSplitter;
VclPtr<ScTabSplitter> pVSplitter;
VclPtr<ScTabControl> pTabControl;
VclPtr<ScrollBar> aVScrollTop;
VclPtr<ScrollBar> aVScrollBottom; // initially visible
VclPtr<ScrollBar> aHScrollLeft; // initially visible
VclPtr<ScrollBar> aHScrollRight;
VclPtr<ScrollAdaptor> aVScrollTop;
VclPtr<ScrollAdaptor> aVScrollBottom; // initially visible
VclPtr<ScrollAdaptor> aHScrollLeft; // initially visible
VclPtr<ScrollAdaptor> aHScrollRight;
VclPtr<ScCornerButton> aCornerButton;
VclPtr<ScCornerButton> aTopButton;
VclPtr<ScrollBarBox> aScrollBarBox;
@@ -219,9 +220,12 @@ private:
void DoAddWin( ScGridWindow* pWin );
void InitScrollBar( ScrollBar& rScrollBar, tools::Long nMaxVal );
DECL_LINK(ScrollHdl, ScrollBar*, void );
DECL_LINK(EndScrollHdl, ScrollBar*, void );
void InitScrollBar(ScrollAdaptor& rScrollBar, tools::Long nMaxVal, const Link<weld::Scrollbar&, void>& rLink);
DECL_LINK(HScrollLeftHdl, weld::Scrollbar&, void );
DECL_LINK(HScrollRightHdl, weld::Scrollbar&, void );
DECL_LINK(VScrollTopHdl, weld::Scrollbar&, void );
DECL_LINK(VScrollBottomHdl, weld::Scrollbar&, void );
void ScrollHdl(ScrollAdaptor* rScrollBar);
DECL_LINK(SplitHdl, Splitter*, void);
void DoHSplit(tools::Long nSplitPos);
@@ -231,8 +235,8 @@ private:
void UpdateVarZoom();
static void SetScrollBar( ScrollBar& rScroll, tools::Long nRangeMax, tools::Long nVisible, tools::Long nPos, bool bLayoutRTL );
static tools::Long GetScrollBarPos( const ScrollBar& rScroll );
static void SetScrollBar( ScrollAdaptor& rScroll, tools::Long nRangeMax, tools::Long nVisible, tools::Long nPos, bool bLayoutRTL );
static tools::Long GetScrollBarPos( const ScrollAdaptor& rScroll );
void GetAreaMoveEndPosition(SCCOL nMovX, SCROW nMovY, ScFollowMode eMode,
SCCOL& rAreaX, SCROW& rAreaY, ScFollowMode& rMode);
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index c737317..45764e6 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -176,10 +176,10 @@ ScTabView::ScTabView( vcl::Window* pParent, ScDocShell& rDocSh, ScTabViewShell*
aViewData( rDocSh, pViewShell ),
aFunctionSet( &aViewData ),
aHdrFunc( &aViewData ),
aVScrollTop( VclPtr<ScrollBar>::Create( pFrameWin, WinBits( WB_VSCROLL | WB_DRAG ) ) ),
aVScrollBottom( VclPtr<ScrollBar>::Create( pFrameWin, WinBits( WB_VSCROLL | WB_DRAG ) ) ),
aHScrollLeft( VclPtr<ScrollBar>::Create( pFrameWin, WinBits( WB_HSCROLL | WB_DRAG ) ) ),
aHScrollRight( VclPtr<ScrollBar>::Create( pFrameWin, WinBits( WB_HSCROLL | WB_DRAG ) ) ),
aVScrollTop( VclPtr<ScrollAdaptor>::Create( pFrameWin, false ) ),
aVScrollBottom( VclPtr<ScrollAdaptor>::Create( pFrameWin, false ) ),
aHScrollLeft( VclPtr<ScrollAdaptor>::Create( pFrameWin, true ) ),
aHScrollRight( VclPtr<ScrollAdaptor>::Create( pFrameWin, true ) ),
aCornerButton( VclPtr<ScCornerButton>::Create( pFrameWin, &aViewData ) ),
aTopButton( VclPtr<ScCornerButton>::Create( pFrameWin, &aViewData ) ),
aScrollBarBox( VclPtr<ScrollBarBox>::Create( pFrameWin, WB_SIZEABLE ) ),
@@ -221,21 +221,19 @@ ScTabView::ScTabView( vcl::Window* pParent, ScDocShell& rDocSh, ScTabViewShell*
Init();
}
void ScTabView::InitScrollBar( ScrollBar& rScrollBar, tools::Long nMaxVal )
void ScTabView::InitScrollBar(ScrollAdaptor& rScrollBar, tools::Long nMaxVal, const Link<weld::Scrollbar&, void>& rLink)
{
rScrollBar.SetRange( Range( 0, nMaxVal ) );
rScrollBar.SetLineSize( 1 );
rScrollBar.SetPageSize( 1 ); // is queried separately
rScrollBar.SetVisibleSize( 10 ); // is reset by Resize
rScrollBar.SetScrollHdl( LINK(this, ScTabView, ScrollHdl) );
rScrollBar.SetEndScrollHdl( LINK(this, ScTabView, EndScrollHdl) );
rScrollBar.SetScrollHdl(rLink);
rScrollBar.EnableRTL( aViewData.GetDocument().IsLayoutRTL( aViewData.GetTabNo() ) );
}
// Scroll-Timer
void ScTabView::SetTimer( ScGridWindow* pWin, const MouseEvent& rMEvt )
{
pTimerWindow = pWin;
@@ -989,24 +987,35 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos )
{
ScHSplitPos eHPos = WhichH(ePos);
ScVSplitPos eVPos = WhichV(ePos);
ScrollBar* pHScroll = ( eHPos == SC_SPLIT_LEFT ) ? aHScrollLeft.get() : aHScrollRight.get();
ScrollBar* pVScroll = ( eVPos == SC_SPLIT_TOP ) ? aVScrollTop.get() : aVScrollBottom.get();
ScrollAdaptor* pHScroll = ( eHPos == SC_SPLIT_LEFT ) ? aHScrollLeft.get() : aHScrollRight.get();
ScrollAdaptor* pVScroll = ( eVPos == SC_SPLIT_TOP ) ? aVScrollTop.get() : aVScrollBottom.get();
if ( pGridWin[ePos] )
bDone = pGridWin[ePos]->HandleScrollCommand( rCEvt, pHScroll, pVScroll );
}
return bDone;
}
IMPL_LINK_NOARG(ScTabView, EndScrollHdl, ScrollBar*, void)
IMPL_LINK_NOARG(ScTabView, HScrollLeftHdl, weld::Scrollbar&, void)
{
if ( bDragging )
{
UpdateScrollBars();
bDragging = false;
}
ScrollHdl(aHScrollLeft.get());
}
IMPL_LINK( ScTabView, ScrollHdl, ScrollBar*, pScroll, void )
IMPL_LINK_NOARG(ScTabView, HScrollRightHdl, weld::Scrollbar&, void)
{
ScrollHdl(aHScrollRight.get());
}
IMPL_LINK_NOARG(ScTabView, VScrollTopHdl, weld::Scrollbar&, void)
{
ScrollHdl(aVScrollTop.get());
}
IMPL_LINK_NOARG(ScTabView, VScrollBottomHdl, weld::Scrollbar&, void)
{
ScrollHdl(aVScrollBottom.get());
}
void ScTabView::ScrollHdl(ScrollAdaptor* pScroll)
{
bool bHoriz = ( pScroll == aHScrollLeft.get() || pScroll == aHScrollRight.get() );
tools::Long nViewPos;
@@ -1019,7 +1028,7 @@ IMPL_LINK( ScTabView, ScrollHdl, ScrollBar*, pScroll, void )
bool bLayoutRTL = aViewData.GetDocument().IsLayoutRTL( aViewData.GetTabNo() );
ScrollType eType = pScroll->GetType();
ScrollType eType = pScroll->GetScrollType();
if ( eType == ScrollType::Drag )
{
if (!bDragging)
@@ -1085,6 +1094,8 @@ IMPL_LINK( ScTabView, ScrollHdl, ScrollBar*, pScroll, void )
Help::ShowQuickHelp(pScroll->GetParent(), aRect, aHelpStr, nAlign);
}
}
else
bDragging = false;
tools::Long nDelta(0);
switch ( eType )
diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx
index 5238947..345ae93 100644
--- a/sc/source/ui/view/tabview4.cxx
+++ b/sc/source/ui/view/tabview4.cxx
@@ -340,7 +340,7 @@ void ScTabView::InitRefMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScRefType eT
}
}
void ScTabView::SetScrollBar( ScrollBar& rScroll, tools::Long nRangeMax, tools::Long nVisible, tools::Long nPos, bool bLayoutRTL )
void ScTabView::SetScrollBar( ScrollAdaptor& rScroll, tools::Long nRangeMax, tools::Long nVisible, tools::Long nPos, bool bLayoutRTL )
{
if ( nVisible == 0 )
nVisible = 1; // #i59893# don't use visible size 0
@@ -352,14 +352,13 @@ void ScTabView::SetScrollBar( ScrollBar& rScroll, tools::Long nRangeMax, tools::
rScroll.EnableRTL( bLayoutRTL );
}
tools::Long ScTabView::GetScrollBarPos( const ScrollBar& rScroll )
tools::Long ScTabView::GetScrollBarPos( const ScrollAdaptor& rScroll )
{
return rScroll.GetThumbPos();
}
// UpdateScrollBars - set visible area and scroll width of scroll bars
static tools::Long lcl_UpdateBar( ScrollBar& rScroll, SCCOLROW nSize ) // Size = (complete) cells
static tools::Long lcl_UpdateBar( ScrollAdaptor& rScroll, SCCOLROW nSize ) // Size = (complete) cells
{
tools::Long nOldPos;
tools::Long nNewPos;
diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx
index 6db05da..20c52ea 100644
--- a/sc/source/ui/view/tabview5.cxx
+++ b/sc/source/ui/view/tabview5.cxx
@@ -107,10 +107,10 @@ void ScTabView::Init()
explicitly because the parent frame window is already RTL disabled. */
pTabControl->EnableRTL( AllSettings::GetLayoutRTL() );
InitScrollBar( *aHScrollLeft, aViewData.GetDocument().MaxCol()+1 );
InitScrollBar( *aHScrollRight, aViewData.GetDocument().MaxCol()+1 );
InitScrollBar( *aVScrollTop, aViewData.GetDocument().MaxRow()+1 );
InitScrollBar( *aVScrollBottom, aViewData.GetDocument().MaxRow()+1 );
InitScrollBar( *aHScrollLeft, aViewData.GetDocument().MaxCol()+1, LINK(this, ScTabView, HScrollLeftHdl) );
InitScrollBar( *aHScrollRight, aViewData.GetDocument().MaxCol()+1, LINK(this, ScTabView, HScrollRightHdl) );
InitScrollBar( *aVScrollTop, aViewData.GetDocument().MaxRow()+1, LINK(this, ScTabView, VScrollTopHdl) );
InitScrollBar( *aVScrollBottom, aViewData.GetDocument().MaxRow()+1, LINK(this, ScTabView, VScrollBottomHdl) );
/* #i97900# scrollbars remain in correct RTL mode, needed mirroring etc.
is now handled correctly at the respective places. */
diff --git a/svtools/source/control/scrolladaptor.cxx b/svtools/source/control/scrolladaptor.cxx
index ebf9d9d..492adf4 100644
--- a/svtools/source/control/scrolladaptor.cxx
+++ b/svtools/source/control/scrolladaptor.cxx
@@ -95,6 +95,10 @@ void ScrollAdaptor::SetThumbPos(tools::Long nThumbPos)
tools::Long ScrollAdaptor::GetThumbPos() const { return m_xScrollBar->adjustment_get_value(); }
ScrollType ScrollAdaptor::GetScrollType() const { return m_xScrollBar->get_scroll_type(); }
void ScrollAdaptor::EnableRTL(bool bEnable) { m_xScrollBar->set_direction(bEnable); }
void ScrollAdaptor::SetScrollHdl(const Link<weld::Scrollbar&, void>& rLink)
{
m_aLink = rLink;