tdf#117388 use native scrollbar under gtk in writer
with the motivation that for gtk4 theming for vcl scrollbar isn't
available, so it looks super yuck but this should also support the
long-press scrolling thing under gtk3 as a side effect.
Change-Id: Iada5a66087d5aa982f9213d7ec0a05f6177f4e66
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137750
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/include/vcl/scrbar.hxx b/include/vcl/scrbar.hxx
index 240a1c7..dd8f309 100644
--- a/include/vcl/scrbar.hxx
+++ b/include/vcl/scrbar.hxx
@@ -22,11 +22,13 @@
#include <vcl/dllapi.h>
#include <vcl/ctrl.hxx>
#include <vcl/scrollable.hxx>
#include <memory>
struct ImplScrollBarData;
class VCL_DLLPUBLIC ScrollBar : public Control
, public Scrollable
{
private:
tools::Rectangle maBtn1Rect;
@@ -97,27 +99,29 @@ public:
void Scroll();
virtual void EndScroll();
tools::Long DoScroll( tools::Long nNewPos );
tools::Long DoScrollAction( ScrollType eScrollType );
tools::Long DoScroll( tools::Long nNewPos ) override;
tools::Long DoScrollAction( ScrollType eScrollType );
void EnableDrag() { mbFullDrag = true; }
void SetRangeMin( tools::Long nNewRange );
tools::Long GetRangeMin() const { return mnMinRange; }
void SetRangeMax( tools::Long nNewRange );
tools::Long GetRangeMax() const { return mnMaxRange; }
void SetRange( const Range& rRange );
Range GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); }
void SetThumbPos( tools::Long nThumbPos );
tools::Long GetThumbPos() const { return mnThumbPos; }
void SetLineSize( tools::Long nNewSize ) { mnLineSize = nNewSize; }
tools::Long GetLineSize() const { return mnLineSize; }
void SetPageSize( tools::Long nNewSize ) { mnPageSize = nNewSize; }
tools::Long GetPageSize() const { return mnPageSize; }
void SetVisibleSize( tools::Long nNewSize );
tools::Long GetVisibleSize() const { return mnVisibleSize; }
void SetRangeMin( tools::Long nNewRange ) override;
tools::Long GetRangeMin() const override { return mnMinRange; }
void SetRangeMax( tools::Long nNewRange ) override;
tools::Long GetRangeMax() const override { return mnMaxRange; }
void SetRange( const Range& rRange ) override;
Range GetRange() const override { return Range( GetRangeMin(), GetRangeMax() ); }
void SetThumbPos( tools::Long nThumbPos ) override;
tools::Long GetThumbPos() const override { return mnThumbPos; }
void SetLineSize( tools::Long nNewSize ) override { mnLineSize = nNewSize; }
tools::Long GetLineSize() const override { return mnLineSize; }
void SetPageSize( tools::Long nNewSize ) override { mnPageSize = nNewSize; }
tools::Long GetPageSize() const override { return mnPageSize; }
void SetVisibleSize( tools::Long nNewSize ) override;
tools::Long GetVisibleSize() const override { return mnVisibleSize; }
tools::Long GetDelta() const { return mnDelta; }
bool Inactive() const override;
tools::Long GetDelta() const { return mnDelta; }
ScrollType GetType() const { return meScrollType; }
void SetScrollHdl( const Link<ScrollBar*,void>& rLink ) { maScrollHdl = rLink; }
diff --git a/include/vcl/scrollable.hxx b/include/vcl/scrollable.hxx
new file mode 100644
index 0000000..7544fe9
--- /dev/null
+++ b/include/vcl/scrollable.hxx
@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <tools/long.hxx>
#include <vcl/dllapi.h>
class VCL_DLLPUBLIC Scrollable
{
public:
virtual tools::Long DoScroll(tools::Long nNewPos) = 0;
virtual void SetRangeMin(tools::Long nNewRange) = 0;
virtual tools::Long GetRangeMin() const = 0;
virtual void SetRangeMax(tools::Long nNewRange) = 0;
virtual tools::Long GetRangeMax() const = 0;
virtual void SetRange(const Range& rRange) = 0;
virtual Range GetRange() const = 0;
virtual void SetThumbPos(tools::Long nThumbPos) = 0;
virtual tools::Long GetThumbPos() const = 0;
virtual void SetLineSize(tools::Long nNewSize) = 0;
virtual tools::Long GetLineSize() const = 0;
virtual void SetPageSize(tools::Long nNewSize) = 0;
virtual tools::Long GetPageSize() const = 0;
virtual void SetVisibleSize(tools::Long nNewSize) = 0;
virtual tools::Long GetVisibleSize() const = 0;
virtual bool Inactive() const = 0;
virtual ~Scrollable() {}
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 1c3f19a..c886ba2 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -2510,7 +2510,9 @@ public:
virtual void adjustment_set_upper(int upper) = 0;
virtual int adjustment_get_page_size() const = 0;
virtual void adjustment_set_page_size(int size) = 0;
virtual int adjustment_get_page_increment() const = 0;
virtual void adjustment_set_page_increment(int size) = 0;
virtual int adjustment_get_step_increment() const = 0;
virtual void adjustment_set_step_increment(int size) = 0;
virtual int adjustment_get_lower() const = 0;
virtual void adjustment_set_lower(int upper) = 0;
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 51324a2..2494f88 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -43,6 +43,7 @@ struct SystemParentData;
class ImplBorderWindow;
class Timer;
class DockingManager;
class Scrollable;
class ScrollBar;
class FixedText;
class MouseEvent;
@@ -687,7 +688,7 @@ private:
SAL_DLLPRIVATE void ImplCallActivateListeners(vcl::Window*);
SAL_DLLPRIVATE void ImplCallDeactivateListeners(vcl::Window*);
SAL_DLLPRIVATE static void ImplHandleScroll(ScrollBar* pHScrl, double nX, ScrollBar* pVScrl, double nY);
SAL_DLLPRIVATE static void ImplHandleScroll(Scrollable* pHScrl, double nX, Scrollable* pVScrl, double nY);
SAL_DLLPRIVATE tools::Rectangle ImplOutputToUnmirroredAbsoluteScreenPixel( const tools::Rectangle& rRect ) const;
SAL_DLLPRIVATE tools::Rectangle ImplUnmirroredAbsoluteScreenToOutputPixel( const tools::Rectangle& rRect ) const;
@@ -1086,8 +1087,8 @@ public:
void EndAutoScroll();
bool HandleScrollCommand( const CommandEvent& rCmd,
ScrollBar* pHScrl,
ScrollBar* pVScrl );
Scrollable* pHScrl,
Scrollable* pVScrl );
virtual const SystemEnvData* GetSystemData() const;
diff --git a/svtools/source/table/tabledatawindow.cxx b/svtools/source/table/tabledatawindow.cxx
index 06e6902..701b9ea 100644
--- a/svtools/source/table/tabledatawindow.cxx
+++ b/svtools/source/table/tabledatawindow.cxx
@@ -24,6 +24,7 @@
#include "tablegeometry.hxx"
#include <vcl/help.hxx>
#include <vcl/scrbar.hxx>
#include <vcl/settings.hxx>
#include <vcl/commandevent.hxx>
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index f4e003e..43543e9 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -282,6 +282,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
sw/uiconfig/swriter/ui/pageheaderpanel \
sw/uiconfig/swriter/ui/pagefooterpanel \
sw/uiconfig/swriter/ui/poseditbox \
sw/uiconfig/swriter/ui/scrollbars \
sw/uiconfig/swriter/ui/sidebarwrap \
sw/uiconfig/swriter/ui/sidebarstylepresets \
sw/uiconfig/swriter/ui/sidebartableedit \
diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx
index 422da7f..fe45f38 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -72,6 +72,7 @@ enum class SelectionType : sal_Int32;
namespace com::sun::star::view { class XSelectionSupplier; }
namespace sfx2 { class FileDialogHelper; }
namespace sw::mark { class IFieldmark; }
namespace weld { class Scrollbar; }
const tools::Long nLeftOfst = -370;
const tools::Long nScrollX = 30;
@@ -298,8 +299,9 @@ class SW_DLLPUBLIC SwView: public SfxViewShell
SAL_DLLPRIVATE void PhyPageDown();
SAL_DLLPRIVATE void CreateScrollbar( bool bHori );
DECL_DLLPRIVATE_LINK( ScrollHdl, ScrollBar*, void );
DECL_DLLPRIVATE_LINK( EndScrollHdl, ScrollBar*, void );
DECL_DLLPRIVATE_LINK(HoriScrollHdl, weld::Scrollbar&, void);
DECL_DLLPRIVATE_LINK(VertScrollHdl, weld::Scrollbar&, void);
SAL_DLLPRIVATE void EndScrollHdl(weld::Scrollbar& rScrollbar, bool bHorizontal);
SAL_DLLPRIVATE bool UpdateScrollbars();
DECL_DLLPRIVATE_LINK( WindowChildEventListener, VclWindowEvent&, void );
SAL_DLLPRIVATE void CalcVisArea( const Size &rPixelSz );
diff --git a/sw/source/uibase/inc/pview.hxx b/sw/source/uibase/inc/pview.hxx
index 2252c87..bc78b3c 100644
--- a/sw/source/uibase/inc/pview.hxx
+++ b/sw/source/uibase/inc/pview.hxx
@@ -194,8 +194,10 @@ class SW_DLLPUBLIC SwPagePreview final : public SfxViewShell
SAL_DLLPRIVATE Point AlignToPixel(const Point& rPt) const;
SAL_DLLPRIVATE void CreateScrollbar( bool bHori);
DECL_DLLPRIVATE_LINK(ScrollHdl, ScrollBar*, void);
DECL_DLLPRIVATE_LINK(EndScrollHdl, ScrollBar*, void);
DECL_DLLPRIVATE_LINK(HoriScrollHdl, weld::Scrollbar&, void);
DECL_DLLPRIVATE_LINK(VertScrollHdl, weld::Scrollbar&, void);
SAL_DLLPRIVATE void ScrollHdl(weld::Scrollbar&, bool bHorizontal);
SAL_DLLPRIVATE void EndScrollHdl(weld::Scrollbar&, bool bHorizontal);
SAL_DLLPRIVATE bool ChgPage( int eMvMode, bool bUpdateScrollbar = true );
SAL_DLLPRIVATE virtual SfxPrinter* GetPrinter( bool bCreate = false ) override;
diff --git a/sw/source/uibase/inc/scroll.hxx b/sw/source/uibase/inc/scroll.hxx
index 3fb1988..f473d02 100644
--- a/sw/source/uibase/inc/scroll.hxx
+++ b/sw/source/uibase/inc/scroll.hxx
@@ -18,15 +18,19 @@
*/
#pragma once
#include <vcl/scrbar.hxx>
#include <vcl/InterimItemWindow.hxx>
#include <vcl/scrollable.hxx>
class SwScrollbar final : public ScrollBar
class SwScrollbar final : public InterimItemWindow
, public Scrollable
{
Size m_aDocSz;
bool m_bHori :1; // horizontal = true, otherwise vertical
bool m_bAuto :1; // for scrolling mode
bool m_bVisible :1; // show/hide should only set this flag
bool m_bSizeSet :1; // was the size already set?
std::unique_ptr<weld::Scrollbar> m_xScrollBar;
Link<weld::Scrollbar&, void> m_aLink;
void AutoShow();
@@ -36,7 +40,7 @@ class SwScrollbar final : public ScrollBar
public:
void ExtendedShow( bool bVisible = true );
void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) override;
bool IsVisible(bool bReal) const { return bReal ? ScrollBar::IsVisible() : m_bVisible; }
bool IsVisible(bool bReal) const { return bReal ? InterimItemWindow::IsVisible() : m_bVisible; }
// changing of document size
void DocSzChgd(const Size &rNewSize);
@@ -48,8 +52,38 @@ public:
void SetAuto(bool bSet);
bool IsAuto() const { return m_bAuto;}
virtual void SetRange(const Range& rRange) override;
virtual Range GetRange() const override;
virtual void SetRangeMin(tools::Long nNewRange) override;
virtual tools::Long GetRangeMin() const override;
virtual void SetRangeMax(tools::Long nNewRange) override;
virtual tools::Long GetRangeMax() const override;
virtual void SetLineSize(tools::Long nNewSize) override;
virtual tools::Long GetLineSize() const override;
virtual void SetPageSize(tools::Long nNewSize) override;
virtual tools::Long GetPageSize() const override;
virtual void SetVisibleSize(tools::Long nNewSize) override;
virtual tools::Long GetVisibleSize() const override;
virtual void SetThumbPos(tools::Long nThumbPos) override;
virtual tools::Long GetThumbPos() const override;
void SetScrollHdl(const Link<weld::Scrollbar&, void>& rLink);
virtual tools::Long DoScroll(tools::Long nNewPos) override;
virtual bool Inactive() const override
{
return !m_xScrollBar->get_sensitive();
}
SwScrollbar(vcl::Window *pParent, bool bHori );
virtual ~SwScrollbar() override;
virtual void dispose() override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/uiview/pview.cxx b/sw/source/uibase/uiview/pview.cxx
index ffe1e0d..e10174c 100644
--- a/sw/source/uibase/uiview/pview.cxx
+++ b/sw/source/uibase/uiview/pview.cxx
@@ -22,6 +22,7 @@
#include <sfx2/objface.hxx>
#include <vcl/help.hxx>
#include <vcl/commandevent.hxx>
#include <vcl/scrbar.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
#include <vcl/syswin.hxx>
@@ -1240,14 +1241,14 @@ void SwPagePreview::CreateScrollbar( bool bHori )
VclPtr<SwScrollbar>& ppScrollbar = bHori ? m_pHScrollbar : m_pVScrollbar;
assert(!ppScrollbar); //check beforehand!
ppScrollbar = VclPtr<SwScrollbar>::Create( pMDI, bHori );
ScrollDocSzChg();
ppScrollbar->EnableDrag();
ppScrollbar->SetEndScrollHdl( LINK( this, SwPagePreview, EndScrollHdl ));
ppScrollbar->SetScrollHdl( LINK( this, SwPagePreview, ScrollHdl ));
if (bHori)
ppScrollbar->SetScrollHdl( LINK( this, SwPagePreview, HoriScrollHdl ));
else
ppScrollbar->SetScrollHdl( LINK( this, SwPagePreview, VertScrollHdl ));
InvalidateBorder();
ppScrollbar->ExtendedShow();
@@ -1386,56 +1387,65 @@ void SwPagePreview::SetVisArea( const tools::Rectangle &rRect )
m_pViewWin->Invalidate();
}
IMPL_LINK( SwPagePreview, ScrollHdl, ScrollBar *, p, void )
IMPL_LINK(SwPagePreview, HoriScrollHdl, weld::Scrollbar&, rScrollbar, void)
{
SwScrollbar* pScrollbar = static_cast<SwScrollbar*>(p);
ScrollHdl(rScrollbar, true);
}
IMPL_LINK(SwPagePreview, VertScrollHdl, weld::Scrollbar&, rScrollbar, void)
{
ScrollHdl(rScrollbar, false);
}
void SwPagePreview::ScrollHdl(weld::Scrollbar& rScrollbar, bool bHori)
{
if(!GetViewShell())
return;
if( !pScrollbar->IsHoriScroll() &&
pScrollbar->GetType() == ScrollType::Drag &&
if( !bHori &&
rScrollbar.get_scroll_type() == ScrollType::Drag &&
Help::IsQuickHelpEnabled() &&
GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow())
{
// Scroll how many pages??
OUString sStateStr(m_sPageStr);
tools::Long nThmbPos = pScrollbar->GetThumbPos();
tools::Long nThmbPos = rScrollbar.adjustment_get_value();
if( 1 == m_pViewWin->GetCol() || !nThmbPos )
++nThmbPos;
sStateStr += OUString::number( nThmbPos );
Point aPos = pScrollbar->GetParent()->OutputToScreenPixel(
pScrollbar->GetPosPixel());
aPos.setY( pScrollbar->OutputToScreenPixel(pScrollbar->GetPointerPosPixel()).Y() );
Point aPos = m_pVScrollbar->GetParent()->OutputToScreenPixel(
m_pVScrollbar->GetPosPixel());
aPos.setY( m_pVScrollbar->OutputToScreenPixel(m_pVScrollbar->GetPointerPosPixel()).Y() );
tools::Rectangle aRect;
aRect.SetLeft( aPos.X() -8 );
aRect.SetRight( aRect.Left() );
aRect.SetTop( aPos.Y() );
aRect.SetBottom( aRect.Top() );
Help::ShowQuickHelp(pScrollbar, aRect, sStateStr,
Help::ShowQuickHelp(m_pVScrollbar, aRect, sStateStr,
QuickHelpFlags::Right|QuickHelpFlags::VCenter);
}
else
EndScrollHdl( pScrollbar );
EndScrollHdl(rScrollbar, bHori);
}
IMPL_LINK( SwPagePreview, EndScrollHdl, ScrollBar *, p, void )
void SwPagePreview::EndScrollHdl(weld::Scrollbar& rScrollbar, bool bHori)
{
SwScrollbar* pScrollbar = static_cast<SwScrollbar*>(p);
if(!GetViewShell())
return;
// boolean to avoid unnecessary invalidation of the window.
bool bInvalidateWin = true;
if( !pScrollbar->IsHoriScroll() ) // scroll vertically
if (!bHori) // scroll vertically
{
if ( Help::IsQuickHelpEnabled() )
Help::ShowQuickHelp(pScrollbar, tools::Rectangle(), OUString());
Help::ShowQuickHelp(m_pVScrollbar, tools::Rectangle(), OUString());
if ( GetViewShell()->PagePreviewLayout()->DoesPreviewLayoutRowsFitIntoWindow() )
{
// Scroll how many pages ??
const sal_uInt16 nThmbPos = o3tl::narrowing<sal_uInt16>(pScrollbar->GetThumbPos());
const sal_uInt16 nThmbPos = o3tl::narrowing<sal_uInt16>(rScrollbar.adjustment_get_value());
// adjust to new preview functionality
if( nThmbPos != m_pViewWin->SelectedPage() )
{
@@ -1486,13 +1496,13 @@ IMPL_LINK( SwPagePreview, EndScrollHdl, ScrollBar *, p, void )
}
else
{
tools::Long nThmbPos = pScrollbar->GetThumbPos();
tools::Long nThmbPos = rScrollbar.adjustment_get_value();
m_pViewWin->Scroll(0, nThmbPos - m_pViewWin->GetPaintedPreviewDocRect().Top());
}
}
else
{
tools::Long nThmbPos = pScrollbar->GetThumbPos();
tools::Long nThmbPos = rScrollbar.adjustment_get_value();
m_pViewWin->Scroll(nThmbPos - m_pViewWin->GetPaintedPreviewDocRect().Left(), 0);
}
// additional invalidate page status.
diff --git a/sw/source/uibase/uiview/scroll.cxx b/sw/source/uibase/uiview/scroll.cxx
index a277a597..39c714c 100644
--- a/sw/source/uibase/uiview/scroll.cxx
+++ b/sw/source/uibase/uiview/scroll.cxx
@@ -21,24 +21,29 @@
#define SCROLL_LINE_SIZE 250
SwScrollbar::SwScrollbar( vcl::Window *pWin, bool bHoriz ) :
ScrollBar( pWin,
WinBits( WB_3DLOOK | WB_HIDE | ( bHoriz ? WB_HSCROLL : WB_VSCROLL) ) ),
m_bHori( bHoriz ),
m_bAuto( false ),
m_bVisible(false),
m_bSizeSet(false)
SwScrollbar::SwScrollbar(vcl::Window *pWin, bool bHoriz)
: InterimItemWindow(pWin, "modules/swriter/ui/scrollbars.ui", "ScrollBars")
, m_bHori(bHoriz)
, m_bAuto(false)
, m_bVisible(false)
, m_bSizeSet(false)
, m_xScrollBar(m_xBuilder->weld_scrollbar(bHoriz ? "horizontal" : "vertical"))
{
m_xScrollBar->show();
// No mirroring for horizontal scrollbars
if( bHoriz )
EnableRTL( false );
if (bHoriz)
m_xScrollBar->set_direction(false);
}
SwScrollbar::~SwScrollbar() {}
void SwScrollbar::dispose()
{
m_xScrollBar.reset();
InterimItemWindow::dispose();
}
// Will be called after a change of the document size
// to refresh the range of the scrollbars.
void SwScrollbar::DocSzChgd( const Size &rSize )
{
m_aDocSz = rSize;
@@ -49,7 +54,6 @@ void SwScrollbar::DocSzChgd( const Size &rSize )
}
// Will be called after a change of the visible view section.
void SwScrollbar::ViewPortChgd( const tools::Rectangle &rRect )
{
tools::Long nThumb, nVisible;
@@ -75,16 +79,17 @@ void SwScrollbar::ExtendedShow( bool bSet )
{
m_bVisible = bSet;
if( (!bSet || !m_bAuto) && IsUpdateMode() && m_bSizeSet)
ScrollBar::Show(bSet);
{
InterimItemWindow::Show(bSet);
}
}
void SwScrollbar::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
{
ScrollBar::SetPosSizePixel(rNewPos, rNewSize);
InterimItemWindow::SetPosSizePixel(rNewPos, rNewSize);
m_bSizeSet = true;
if(m_bVisible)
ExtendedShow();
}
void SwScrollbar::SetAuto(bool bSet)
@@ -94,7 +99,7 @@ void SwScrollbar::SetAuto(bool bSet)
m_bAuto = bSet;
// hide automatically - then show
if(!m_bAuto && m_bVisible && !ScrollBar::IsVisible())
if(!m_bAuto && m_bVisible && !InterimItemWindow::IsVisible())
ExtendedShow();
else if(m_bAuto)
AutoShow(); // or hide automatically
@@ -107,13 +112,99 @@ void SwScrollbar::AutoShow()
tools::Long nLen = GetRange().Len();
if( nVis >= nLen - 1)
{
if(ScrollBar::IsVisible())
ScrollBar::Show(false);
if(InterimItemWindow::IsVisible())
InterimItemWindow::Show(false);
}
else if ( !ScrollBar::IsVisible() )
else if ( !InterimItemWindow::IsVisible() )
{
ScrollBar::Show();
InterimItemWindow::Show();
}
}
void SwScrollbar::SetRange(const Range& rRange)
{
m_xScrollBar->adjustment_set_lower(rRange.Min());
m_xScrollBar->adjustment_set_upper(rRange.Max());
}
Range SwScrollbar::GetRange() const
{
return Range(m_xScrollBar->adjustment_get_lower(),
m_xScrollBar->adjustment_get_upper());
}
void SwScrollbar::SetRangeMin(tools::Long nNewRange)
{
m_xScrollBar->adjustment_set_lower(nNewRange);
}
tools::Long SwScrollbar::GetRangeMin() const
{
return m_xScrollBar->adjustment_get_lower();
}
void SwScrollbar::SetRangeMax(tools::Long nNewRange)
{
m_xScrollBar->adjustment_set_upper(nNewRange);
}
tools::Long SwScrollbar::GetRangeMax() const
{
return m_xScrollBar->adjustment_get_upper();
}
void SwScrollbar::SetLineSize(tools::Long nNewSize)
{
m_xScrollBar->adjustment_set_step_increment(nNewSize);
}
tools::Long SwScrollbar::GetLineSize() const
{
return m_xScrollBar->adjustment_get_step_increment();
}
void SwScrollbar::SetPageSize(tools::Long nNewSize)
{
m_xScrollBar->adjustment_set_page_increment(nNewSize);
}
tools::Long SwScrollbar::GetPageSize() const
{
return m_xScrollBar->adjustment_get_page_increment();
}
void SwScrollbar::SetVisibleSize(tools::Long nNewSize)
{
m_xScrollBar->adjustment_set_page_size(nNewSize);
}
tools::Long SwScrollbar::GetVisibleSize() const
{
return m_xScrollBar->adjustment_get_page_size();
}
void SwScrollbar::SetThumbPos(tools::Long nThumbPos)
{
m_xScrollBar->adjustment_set_value(nThumbPos);
}
tools::Long SwScrollbar::GetThumbPos() const
{
return m_xScrollBar->adjustment_get_value();
}
void SwScrollbar::SetScrollHdl(const Link<weld::Scrollbar&, void>& rLink)
{
m_aLink = rLink;
m_xScrollBar->connect_adjustment_changed(rLink);
}
tools::Long SwScrollbar::DoScroll(tools::Long nNewPos)
{
const auto nOrig = m_xScrollBar->adjustment_get_value();
m_xScrollBar->adjustment_set_value(nNewPos);
m_aLink.Call(*m_xScrollBar);
return m_xScrollBar->adjustment_get_value() - nOrig;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 0e83cf6..0fe4fc8 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -32,6 +32,7 @@
#include <officecfg/Office/Common.hxx>
#include <vcl/graph.hxx>
#include <vcl/inputctx.hxx>
#include <vcl/scrbar.hxx>
#include <svl/eitem.hxx>
#include <unotools/configmgr.hxx>
#include <unotools/lingucfg.hxx>
diff --git a/sw/source/uibase/uiview/viewmdi.cxx b/sw/source/uibase/uiview/viewmdi.cxx
index fee7f5c..b7c1810 100644
--- a/sw/source/uibase/uiview/viewmdi.cxx
+++ b/sw/source/uibase/uiview/viewmdi.cxx
@@ -307,12 +307,9 @@ void SwView::CreateScrollbar( bool bHori )
ppScrollbar = VclPtr<SwScrollbar>::Create( pMDI, bHori );
UpdateScrollbars();
if(bHori)
ppScrollbar->SetScrollHdl( LINK( this, SwView, EndScrollHdl ));
ppScrollbar->SetScrollHdl( LINK( this, SwView, HoriScrollHdl ));
else
ppScrollbar->SetScrollHdl( LINK( this, SwView, ScrollHdl ));
ppScrollbar->SetEndScrollHdl( LINK( this, SwView, EndScrollHdl ));
ppScrollbar->EnableDrag();
ppScrollbar->SetScrollHdl( LINK( this, SwView, VertScrollHdl ));
if(GetWindow())
InvalidateBorder();
diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx
index f249638..ed3adf8 100644
--- a/sw/source/uibase/uiview/viewport.cxx
+++ b/sw/source/uibase/uiview/viewport.cxx
@@ -74,16 +74,16 @@ static tools::Long GetLeftMargin( SwView const &rView )
static void lcl_GetPos(SwView const * pView,
Point& rPos,
SwScrollbar const * pScrollbar,
const weld::Scrollbar& rScrollbar,
bool bHori,
bool bBorder)
{
SwWrtShell &rSh = pView->GetWrtShell();
const Size aDocSz( rSh.GetDocSize() );
const tools::Long lBorder = bBorder ? DOCUMENTBORDER : DOCUMENTBORDER * 2;
const bool bHori = pScrollbar->IsHoriScroll();
const tools::Long lPos = pScrollbar->GetThumbPos() + (bBorder ? DOCUMENTBORDER : 0);
const tools::Long lPos = rScrollbar.adjustment_get_value() + (bBorder ? DOCUMENTBORDER : 0);
tools::Long lDelta = lPos - (bHori ? rSh.VisArea().Pos().X() : rSh.VisArea().Pos().Y());
@@ -669,30 +669,28 @@ bool SwView::PageDownCursor(bool bSelect)
}
// Handler of the scrollbars
IMPL_LINK( SwView, ScrollHdl, ScrollBar *, p, void )
IMPL_LINK(SwView, VertScrollHdl, weld::Scrollbar&, rScrollbar, void)
{
SwScrollbar* pScrollbar = static_cast<SwScrollbar*>(p);
if ( GetWrtShell().ActionPend() )
return;
if ( pScrollbar->GetType() == ScrollType::Drag )
if (rScrollbar.get_scroll_type() == ScrollType::Drag)
m_pWrtShell->EnableSmooth( false );
if(!m_pWrtShell->GetViewOptions()->getBrowseMode() &&
pScrollbar->GetType() == ScrollType::Drag)
if (!m_pWrtShell->GetViewOptions()->getBrowseMode() &&
rScrollbar.get_scroll_type() == ScrollType::Drag)
{
// Here comment out again if it is not desired to scroll together:
// The end scrollhandler invalidate the FN_STAT_PAGE,
// so we don't must do it again.
EndScrollHdl(pScrollbar);
EndScrollHdl(rScrollbar, false);
if ( !m_bWheelScrollInProgress && Help::IsQuickHelpEnabled() &&
m_pWrtShell->GetViewOptions()->IsShowScrollBarTips())
{
Point aPos( m_aVisArea.TopLeft() );
lcl_GetPos(this, aPos, pScrollbar, IsDocumentBorder());
lcl_GetPos(this, aPos, rScrollbar, false, IsDocumentBorder());
sal_uInt16 nPhNum = 1;
sal_uInt16 nVirtNum = 1;
@@ -711,10 +709,10 @@ IMPL_LINK( SwView, ScrollHdl, ScrollBar *, p, void )
if( !nPgNum || nPgNum != nPhNum )
{
tools::Rectangle aRect;
aRect.SetLeft( pScrollbar->GetParent()->OutputToScreenPixel(
pScrollbar->GetPosPixel() ).X() -8 );
aRect.SetTop( pScrollbar->OutputToScreenPixel(
pScrollbar->GetPointerPosPixel() ).Y() );
aRect.SetLeft( m_pVScrollbar->GetParent()->OutputToScreenPixel(
m_pVScrollbar->GetPosPixel() ).X() -8 );
aRect.SetTop( m_pVScrollbar->OutputToScreenPixel(
m_pVScrollbar->GetPointerPosPixel() ).Y() );
aRect.SetRight( aRect.Left() );
aRect.SetBottom( aRect.Top() );
@@ -731,7 +729,7 @@ IMPL_LINK( SwView, ScrollHdl, ScrollBar *, p, void )
sPageStr = sPageStr.replace(0x0a, ' ');
}
Help::ShowQuickHelp( pScrollbar, aRect, sPageStr,
Help::ShowQuickHelp(m_pVScrollbar, aRect, sPageStr,
QuickHelpFlags::Right|QuickHelpFlags::VCenter);
}
nPgNum = nPhNum;
@@ -740,28 +738,26 @@ IMPL_LINK( SwView, ScrollHdl, ScrollBar *, p, void )
}
}
else
EndScrollHdl(pScrollbar);
EndScrollHdl(rScrollbar, false);
if ( pScrollbar->GetType() == ScrollType::Drag )
if (rScrollbar.get_scroll_type() == ScrollType::Drag)
m_pWrtShell->EnableSmooth( true );
}
// Handler of the scrollbars
IMPL_LINK( SwView, EndScrollHdl, ScrollBar *, p, void )
void SwView::EndScrollHdl(weld::Scrollbar& rScrollbar, bool bHorizontal)
{
SwScrollbar* pScrollbar = static_cast<SwScrollbar*>(p);
if ( GetWrtShell().ActionPend() )
return;
if(nPgNum)
{
nPgNum = 0;
Help::ShowQuickHelp(pScrollbar, tools::Rectangle(), OUString());
Help::ShowQuickHelp(bHorizontal ? m_pHScrollbar : m_pVScrollbar, tools::Rectangle(), OUString());
}
Point aPos( m_aVisArea.TopLeft() );
bool bBorder = IsDocumentBorder();
lcl_GetPos(this, aPos, pScrollbar, bBorder);
lcl_GetPos(this, aPos, rScrollbar, bHorizontal, bBorder);
if ( bBorder && aPos == m_aVisArea.TopLeft() )
UpdateScrollbars();
else
@@ -770,6 +766,11 @@ IMPL_LINK( SwView, EndScrollHdl, ScrollBar *, p, void )
GetViewFrame()->GetBindings().Update(FN_STAT_PAGE);
}
IMPL_LINK(SwView, HoriScrollHdl, weld::Scrollbar&, rScrollBar, void)
{
EndScrollHdl(rScrollBar, true);
}
// Calculates the size of the m_aVisArea in dependency of the size of
// EditWin on the screen.
diff --git a/sw/uiconfig/swriter/ui/scrollbars.ui b/sw/uiconfig/swriter/ui/scrollbars.ui
new file mode 100644
index 0000000..c448d3f
--- /dev/null
+++ b/sw/uiconfig/swriter/ui/scrollbars.ui
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface domain="sw">
<requires lib="gtk+" version="3.20"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">100</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment2">
<property name="upper">100</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkBox" id="ScrollBars">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrollbar" id="vertical">
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="adjustment">adjustment1</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrollbar" id="horizontal">
<property name="can-focus">False</property>
<property name="adjustment">adjustment2</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</interface>
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 3f35337..1cc12d4 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -2494,7 +2494,6 @@ class SalInstanceScrollbar : public SalInstanceWidget, public virtual weld::Scro
{
private:
VclPtr<ScrollBar> m_xScrollBar;
Link<ScrollBar*, void> m_aOrigScrollHdl;
DECL_LINK(ScrollHdl, ScrollBar*, void);
@@ -2503,8 +2502,8 @@ public:
: SalInstanceWidget(pScrollbar, pBuilder, bTakeOwnership)
, m_xScrollBar(pScrollbar)
{
m_aOrigScrollHdl = m_xScrollBar->GetScrollHdl();
m_xScrollBar->SetScrollHdl(LINK(this, SalInstanceScrollbar, ScrollHdl));
m_xScrollBar->EnableDrag();
}
virtual void adjustment_configure(int value, int lower, int upper, int step_increment,
@@ -2520,11 +2519,7 @@ public:
virtual int adjustment_get_value() const override { return m_xScrollBar->GetThumbPos(); }
virtual void adjustment_set_value(int value) override
{
m_xScrollBar->SetThumbPos(value);
m_aOrigScrollHdl.Call(m_xScrollBar.get());
}
virtual void adjustment_set_value(int value) override { m_xScrollBar->SetThumbPos(value); }
virtual int adjustment_get_upper() const override { return m_xScrollBar->GetRangeMax(); }
@@ -2536,32 +2531,33 @@ public:
virtual int adjustment_get_page_size() const override { return m_xScrollBar->GetVisibleSize(); }
virtual void adjustment_set_page_size(int size) override
virtual void adjustment_set_page_size(int size) override { m_xScrollBar->SetVisibleSize(size); }
virtual int adjustment_get_page_increment() const override
{
return m_xScrollBar->SetVisibleSize(size);
return m_xScrollBar->GetPageSize();
}
virtual void adjustment_set_page_increment(int size) override
{
return m_xScrollBar->SetPageSize(size);
m_xScrollBar->SetPageSize(size);
}
virtual int adjustment_get_step_increment() const override
{
return m_xScrollBar->GetLineSize();
}
virtual void adjustment_set_step_increment(int size) override
{
return m_xScrollBar->SetLineSize(size);
m_xScrollBar->SetLineSize(size);
}
virtual ScrollType get_scroll_type() const override { return m_xScrollBar->GetType(); }
virtual ~SalInstanceScrollbar() override { m_xScrollBar->SetScrollHdl(m_aOrigScrollHdl); }
};
}
IMPL_LINK_NOARG(SalInstanceScrollbar, ScrollHdl, ScrollBar*, void)
{
signal_adjustment_changed();
m_aOrigScrollHdl.Call(m_xScrollBar.get());
}
IMPL_LINK_NOARG(SalInstanceScrollbar, ScrollHdl, ScrollBar*, void) { signal_adjustment_changed(); }
SalInstanceNotebook::SalInstanceNotebook(TabControl* pNotebook, SalInstanceBuilder* pBuilder,
bool bTakeOwnership)
diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx
index 79fb1d4..2994fa0 100644
--- a/vcl/source/control/scrbar.cxx
+++ b/vcl/source/control/scrbar.cxx
@@ -1419,6 +1419,11 @@ Size ScrollBar::getCurrentCalcSize() const
return aCtrlRegion.GetSize();
}
bool ScrollBar::Inactive() const
{
return !IsEnabled() || !IsInputEnabled() || IsInModalMode();
}
void ScrollBarBox::ImplInit(vcl::Window* pParent, WinBits nStyle)
{
Window::ImplInit( pParent, nStyle, nullptr );
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index c20dc47..6c99b81 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -30,6 +30,7 @@
#include <vcl/layout.hxx>
#include <vcl/timer.hxx>
#include <vcl/window.hxx>
#include <vcl/scrollable.hxx>
#include <vcl/scrbar.hxx>
#include <vcl/dockwin.hxx>
#include <vcl/settings.hxx>
@@ -597,9 +598,9 @@ tools::Long Window::GetDrawPixel( OutputDevice const * pDev, tools::Long nPixels
return nP;
}
static void lcl_HandleScrollHelper( ScrollBar* pScrl, double nN, bool isMultiplyByLineSize )
static void lcl_HandleScrollHelper( Scrollable* pScrl, double nN, bool isMultiplyByLineSize )
{
if ( !pScrl || !nN || !pScrl->IsEnabled() || !pScrl->IsInputEnabled() || pScrl->IsInModalMode() )
if (!pScrl || !nN || pScrl->Inactive())
return;
tools::Long nNewPos = pScrl->GetThumbPos();
@@ -625,7 +626,7 @@ static void lcl_HandleScrollHelper( ScrollBar* pScrl, double nN, bool isMultiply
}
bool Window::HandleScrollCommand( const CommandEvent& rCmd,
ScrollBar* pHScrl, ScrollBar* pVScrl )
Scrollable* pHScrl, Scrollable* pVScrl )
{
bool bRet = false;
@@ -639,13 +640,13 @@ bool Window::HandleScrollCommand( const CommandEvent& rCmd,
if ( pHScrl )
{
if ( (pHScrl->GetVisibleSize() < pHScrl->GetRangeMax()) &&
pHScrl->IsEnabled() && pHScrl->IsInputEnabled() && ! pHScrl->IsInModalMode() )
!pHScrl->Inactive() )
nFlags |= StartAutoScrollFlags::Horz;
}
if ( pVScrl )
{
if ( (pVScrl->GetVisibleSize() < pVScrl->GetRangeMax()) &&
pVScrl->IsEnabled() && pVScrl->IsInputEnabled() && ! pVScrl->IsInModalMode() )
!pVScrl->Inactive() )
nFlags |= StartAutoScrollFlags::Vert;
}
@@ -811,8 +812,8 @@ bool Window::HandleScrollCommand( const CommandEvent& rCmd,
// horizontal or vertical scroll bar. nY is correspondingly either
// the horizontal or vertical scroll amount.
void Window::ImplHandleScroll( ScrollBar* pHScrl, double nX,
ScrollBar* pVScrl, double nY )
void Window::ImplHandleScroll( Scrollable* pHScrl, double nX,
Scrollable* pVScrl, double nY )
{
lcl_HandleScrollHelper( pHScrl, nX, true );
lcl_HandleScrollHelper( pVScrl, nY, true );
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 57e76f4..8778a6b 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -8488,11 +8488,21 @@ public:
gtk_adjustment_set_page_size(m_pAdjustment, size);
}
virtual int adjustment_get_page_increment() const override
{
return gtk_adjustment_get_page_increment(m_pAdjustment);
}
virtual void adjustment_set_page_increment(int size) override
{
gtk_adjustment_set_page_increment(m_pAdjustment, size);
}
virtual int adjustment_get_step_increment() const override
{
return gtk_adjustment_get_step_increment(m_pAdjustment);
}
virtual void adjustment_set_step_increment(int size) override
{
gtk_adjustment_set_step_increment(m_pAdjustment, size);