diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-08-05 15:20:03 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-08-06 13:08:46 +0200 |
commit | 6d9ee6444d07bac64b9744b1c9fc7a2519e62965 (patch) | |
tree | 3c70419bc1b754967aa46ab24d645f3fb5227604 /sc | |
parent | 800551502416d3d80c8d14a53335dad5190290a4 (diff) |
tdf#117388 use native scrollbar under gtk in calc data view browser
Change-Id: Ia0ab035473da7b5b64e18876bb81e25fd63effda
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137877
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/inc/datatableview.hxx | 10 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/datatableview.cxx | 43 |
2 files changed, 28 insertions, 25 deletions
diff --git a/sc/source/ui/inc/datatableview.hxx b/sc/source/ui/inc/datatableview.hxx index 8eaac9084bbe..fa7be381d3c9 100644 --- a/sc/source/ui/inc/datatableview.hxx +++ b/sc/source/ui/inc/datatableview.hxx @@ -20,6 +20,7 @@ #pragma once #include <com/sun/star/awt/XWindow.hpp> +#include <svtools/scrolladaptor.hxx> #include <vcl/ctrl.hxx> #include <vcl/scrbar.hxx> #include <types.hxx> @@ -79,15 +80,18 @@ class ScDataTableView : public Control VclPtr<ScrollBarBox> mpTopLeft; VclPtr<ScDataTableColView> mpColView; VclPtr<ScDataTableRowView> mpRowView; - VclPtr<ScrollBar> mpVScroll; - VclPtr<ScrollBar> mpHScroll; + VclPtr<ScrollAdaptor> mpVScroll; + VclPtr<ScrollAdaptor> mpHScroll; + + sal_uInt16 mnScrollBarSize; SCROW mnFirstVisibleRow; SCCOL mnFirstVisibleCol; std::unique_ptr<MouseEvent> mpMouseEvent; - DECL_LINK(ScrollHdl, ScrollBar*, void); + DECL_LINK(VertScrollHdl, weld::Scrollbar&, void); + DECL_LINK(HorzScrollHdl, weld::Scrollbar&, void); public: ScDataTableView(const css::uno::Reference<css::awt::XWindow>& rParent, diff --git a/sc/source/ui/miscdlgs/datatableview.cxx b/sc/source/ui/miscdlgs/datatableview.cxx index d74df0e81fe4..70fe3dde756e 100644 --- a/sc/source/ui/miscdlgs/datatableview.cxx +++ b/sc/source/ui/miscdlgs/datatableview.cxx @@ -36,7 +36,6 @@ constexpr double nPPTY = 0.06666; constexpr sal_uInt16 nRowHeaderWidth = 100; constexpr sal_uInt16 nColHeaderHeight = 20; -constexpr sal_uInt16 nScrollBarSize = 10; ScDataTableColView::ScDataTableColView(vcl::Window* pParent, ScDocument* pDoc, SelectionEngine* pSelectionEngine): ScHeaderControl(pParent, pSelectionEngine, pDoc->MaxCol()+1, false, nullptr), @@ -136,8 +135,9 @@ ScDataTableView::ScDataTableView(const css::uno::Reference<css::awt::XWindow> &r mpTopLeft(VclPtr<ScrollBarBox>::Create(this, WB_SIZEABLE)), mpColView(VclPtr<ScDataTableColView>::Create(this, mpDoc.get(), mpSelectionEngine.get())), mpRowView(VclPtr<ScDataTableRowView>::Create(this, mpDoc.get(), mpSelectionEngine.get())), - mpVScroll(VclPtr<ScrollBar>::Create(this, WinBits(WB_VSCROLL | WB_DRAG))), - mpHScroll(VclPtr<ScrollBar>::Create(this, WinBits(WB_HSCROLL | WB_DRAG))), + mpVScroll(VclPtr<ScrollAdaptor>::Create(this, false)), + mpHScroll(VclPtr<ScrollAdaptor>::Create(this, true)), + mnScrollBarSize(mpVScroll->GetSizePixel().Width()), mnFirstVisibleRow(0), mnFirstVisibleCol(0) { @@ -147,11 +147,11 @@ ScDataTableView::ScDataTableView(const css::uno::Reference<css::awt::XWindow> &r mpVScroll->SetRangeMin(0); mpVScroll->SetRangeMax(100); - mpVScroll->SetEndScrollHdl(LINK(this, ScDataTableView, ScrollHdl)); + mpVScroll->SetScrollHdl(LINK(this, ScDataTableView, VertScrollHdl)); mpHScroll->SetRangeMin(0); mpHScroll->SetRangeMax(50); - mpHScroll->SetEndScrollHdl(LINK(this, ScDataTableView, ScrollHdl)); + mpHScroll->SetScrollHdl(LINK(this, ScDataTableView, HorzScrollHdl)); mpTopLeft->Show(); mpColView->Show(); @@ -250,17 +250,17 @@ void ScDataTableView::Resize() { Size aSize = GetSizePixel(); mpTopLeft->setPosSizePixel(0, 0, nRowHeaderWidth, nColHeaderHeight); - mpColView->setPosSizePixel(nRowHeaderWidth, 0, aSize.Width() - nScrollBarSize, nColHeaderHeight); + mpColView->setPosSizePixel(nRowHeaderWidth, 0, aSize.Width() - mnScrollBarSize, nColHeaderHeight); mpRowView->setPosSizePixel(0, nColHeaderHeight, nRowHeaderWidth, aSize.Height()); - mpVScroll->setPosSizePixel(aSize.Width() - nScrollBarSize, nColHeaderHeight, nScrollBarSize, aSize.Height() - nColHeaderHeight - nScrollBarSize); - mpHScroll->setPosSizePixel(nRowHeaderWidth, aSize.Height() - nScrollBarSize, aSize.Width() - nRowHeaderWidth - nScrollBarSize, nScrollBarSize); + mpVScroll->setPosSizePixel(aSize.Width() - mnScrollBarSize, nColHeaderHeight, mnScrollBarSize, aSize.Height() - nColHeaderHeight - mnScrollBarSize); + mpHScroll->setPosSizePixel(nRowHeaderWidth, aSize.Height() - mnScrollBarSize, aSize.Width() - nRowHeaderWidth - mnScrollBarSize, mnScrollBarSize); } void ScDataTableView::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRectangle) { Size aSize = GetSizePixel(); - SCCOL nMaxVisibleCol = findColFromPos(aSize.Width() - nScrollBarSize, mpDoc.get(), mnFirstVisibleCol); + SCCOL nMaxVisibleCol = findColFromPos(aSize.Width() - mnScrollBarSize, mpDoc.get(), mnFirstVisibleCol); SCROW nMaxVisibleRow = findRowFromPos(aSize.Height(), mpDoc.get(), mnFirstVisibleRow); ScTableInfo aTableInfo; @@ -300,20 +300,19 @@ void ScDataTableView::getRowRange(SCROW& rStartCol, SCROW& rEndCol) const rEndCol = static_cast<SCROW>(aEnd); } -IMPL_LINK(ScDataTableView, ScrollHdl, ScrollBar*, pScrollBar, void) +IMPL_LINK_NOARG(ScDataTableView, VertScrollHdl, weld::Scrollbar&, void) { - if (pScrollBar == mpVScroll.get()) - { - mnFirstVisibleRow = pScrollBar->GetThumbPos(); - pScrollBar->SetRangeMax(std::min(mpDoc->MaxRow(), static_cast<SCROW>(mnFirstVisibleRow + 100))); - mpRowView->SetPos(mnFirstVisibleRow); - } - else - { - mnFirstVisibleCol = pScrollBar->GetThumbPos(); - pScrollBar->SetRangeMax(std::min(mpDoc->MaxCol(), static_cast<SCCOL>(mnFirstVisibleCol + 50))); - mpColView->SetPos(mnFirstVisibleCol); - } + mnFirstVisibleRow = mpVScroll->GetThumbPos(); + mpVScroll->SetRangeMax(std::min(mpDoc->MaxRow(), static_cast<SCROW>(mnFirstVisibleRow + 100))); + mpRowView->SetPos(mnFirstVisibleRow); + Invalidate(); +} + +IMPL_LINK_NOARG(ScDataTableView, HorzScrollHdl, weld::Scrollbar&, void) +{ + mnFirstVisibleCol = mpHScroll->GetThumbPos(); + mpHScroll->SetRangeMax(std::min(mpDoc->MaxCol(), static_cast<SCCOL>(mnFirstVisibleCol + 50))); + mpColView->SetPos(mnFirstVisibleCol); Invalidate(); } |