related tdf#162786: Add cacert.pem
[LibreOffice.git] / svtools / source / control / scrolladaptor.cxx
blob2904682541499f2ade4bdc572fe3b13fbb3f60ca
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svtools/scrolladaptor.hxx>
22 ScrollAdaptor::ScrollAdaptor(vcl::Window* pWin, bool bHoriz)
23 : InterimItemWindow(pWin, u"svt/ui/scrollbars.ui"_ustr, u"ScrollBars"_ustr)
24 , m_xScrollBar(m_xBuilder->weld_scrollbar(bHoriz ? u"horizontal"_ustr : u"vertical"_ustr))
25 , m_bHori(bHoriz)
27 // tdf#160844 we don't want scrollbars to be a default target for Ctrl+F6, etc
28 SetStyle(GetStyle() & ~WB_TABSTOP);
29 m_xScrollBar->show();
30 SetSizePixel(GetOptimalSize());
33 void ScrollAdaptor::dispose()
35 m_xScrollBar.reset();
36 InterimItemWindow::dispose();
39 void ScrollAdaptor::SetRange(const Range& rRange)
41 m_xScrollBar->adjustment_set_lower(rRange.Min());
42 m_xScrollBar->adjustment_set_upper(rRange.Max());
45 Range ScrollAdaptor::GetRange() const
47 return Range(m_xScrollBar->adjustment_get_lower(), m_xScrollBar->adjustment_get_upper());
50 void ScrollAdaptor::SetRangeMin(tools::Long nNewRange)
52 m_xScrollBar->adjustment_set_lower(nNewRange);
55 tools::Long ScrollAdaptor::GetRangeMin() const { return m_xScrollBar->adjustment_get_lower(); }
57 void ScrollAdaptor::SetRangeMax(tools::Long nNewRange)
59 m_xScrollBar->adjustment_set_upper(nNewRange);
62 tools::Long ScrollAdaptor::GetRangeMax() const { return m_xScrollBar->adjustment_get_upper(); }
64 void ScrollAdaptor::SetLineSize(tools::Long nNewSize)
66 m_xScrollBar->adjustment_set_step_increment(nNewSize);
69 tools::Long ScrollAdaptor::GetLineSize() const
71 return m_xScrollBar->adjustment_get_step_increment();
74 void ScrollAdaptor::SetPageSize(tools::Long nNewSize)
76 m_xScrollBar->adjustment_set_page_increment(nNewSize);
79 tools::Long ScrollAdaptor::GetPageSize() const
81 return m_xScrollBar->adjustment_get_page_increment();
84 void ScrollAdaptor::SetVisibleSize(tools::Long nNewSize)
86 m_xScrollBar->adjustment_set_page_size(nNewSize);
89 tools::Long ScrollAdaptor::GetVisibleSize() const
91 return m_xScrollBar->adjustment_get_page_size();
94 void ScrollAdaptor::SetThumbPos(tools::Long nThumbPos)
96 m_xScrollBar->adjustment_set_value(nThumbPos);
99 tools::Long ScrollAdaptor::GetThumbPos() const { return m_xScrollBar->adjustment_get_value(); }
101 ScrollType ScrollAdaptor::GetScrollType() const { return m_xScrollBar->get_scroll_type(); }
103 void ScrollAdaptor::EnableRTL(bool bEnable) { m_xScrollBar->set_direction(bEnable); }
105 void ScrollAdaptor::SetScrollHdl(const Link<weld::Scrollbar&, void>& rLink)
107 m_aLink = rLink;
108 m_xScrollBar->connect_adjustment_changed(rLink);
111 void ScrollAdaptor::SetMouseReleaseHdl(const Link<const MouseEvent&, bool>& rLink)
113 m_xScrollBar->connect_mouse_release(rLink);
116 tools::Long ScrollAdaptor::DoScroll(tools::Long nNewPos)
118 const auto nOrig = m_xScrollBar->adjustment_get_value();
119 m_xScrollBar->adjustment_set_value(nNewPos);
120 m_aLink.Call(*m_xScrollBar);
121 return m_xScrollBar->adjustment_get_value() - nOrig;
124 void ScrollAdaptor::SetThickness(int nThickness) { m_xScrollBar->set_scroll_thickness(nThickness); }
126 void ScrollAdaptor::SetSwapArrows(bool bSwap) { m_xScrollBar->set_scroll_swap_arrows(bSwap); }
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */