android: Update app-specific/MIME type icons
[LibreOffice.git] / svtools / source / control / scrolladaptor.cxx
blob6d01e9d414d78619be320e7253c1449843dcd414
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, "svt/ui/scrollbars.ui", "ScrollBars")
24 , m_xScrollBar(
25 m_xBuilder->weld_scrollbar(bHoriz ? OUString("horizontal") : OUString("vertical")))
26 , m_bHori(bHoriz)
28 m_xScrollBar->show();
29 SetSizePixel(GetOptimalSize());
32 void ScrollAdaptor::dispose()
34 m_xScrollBar.reset();
35 InterimItemWindow::dispose();
38 void ScrollAdaptor::SetRange(const Range& rRange)
40 m_xScrollBar->adjustment_set_lower(rRange.Min());
41 m_xScrollBar->adjustment_set_upper(rRange.Max());
44 Range ScrollAdaptor::GetRange() const
46 return Range(m_xScrollBar->adjustment_get_lower(), m_xScrollBar->adjustment_get_upper());
49 void ScrollAdaptor::SetRangeMin(tools::Long nNewRange)
51 m_xScrollBar->adjustment_set_lower(nNewRange);
54 tools::Long ScrollAdaptor::GetRangeMin() const { return m_xScrollBar->adjustment_get_lower(); }
56 void ScrollAdaptor::SetRangeMax(tools::Long nNewRange)
58 m_xScrollBar->adjustment_set_upper(nNewRange);
61 tools::Long ScrollAdaptor::GetRangeMax() const { return m_xScrollBar->adjustment_get_upper(); }
63 void ScrollAdaptor::SetLineSize(tools::Long nNewSize)
65 m_xScrollBar->adjustment_set_step_increment(nNewSize);
68 tools::Long ScrollAdaptor::GetLineSize() const
70 return m_xScrollBar->adjustment_get_step_increment();
73 void ScrollAdaptor::SetPageSize(tools::Long nNewSize)
75 m_xScrollBar->adjustment_set_page_increment(nNewSize);
78 tools::Long ScrollAdaptor::GetPageSize() const
80 return m_xScrollBar->adjustment_get_page_increment();
83 void ScrollAdaptor::SetVisibleSize(tools::Long nNewSize)
85 m_xScrollBar->adjustment_set_page_size(nNewSize);
88 tools::Long ScrollAdaptor::GetVisibleSize() const
90 return m_xScrollBar->adjustment_get_page_size();
93 void ScrollAdaptor::SetThumbPos(tools::Long nThumbPos)
95 m_xScrollBar->adjustment_set_value(nThumbPos);
98 tools::Long ScrollAdaptor::GetThumbPos() const { return m_xScrollBar->adjustment_get_value(); }
100 ScrollType ScrollAdaptor::GetScrollType() const { return m_xScrollBar->get_scroll_type(); }
102 void ScrollAdaptor::EnableRTL(bool bEnable) { m_xScrollBar->set_direction(bEnable); }
104 void ScrollAdaptor::SetScrollHdl(const Link<weld::Scrollbar&, void>& rLink)
106 m_aLink = rLink;
107 m_xScrollBar->connect_adjustment_changed(rLink);
110 void ScrollAdaptor::SetMouseReleaseHdl(const Link<const MouseEvent&, bool>& rLink)
112 m_xScrollBar->connect_mouse_release(rLink);
115 tools::Long ScrollAdaptor::DoScroll(tools::Long nNewPos)
117 const auto nOrig = m_xScrollBar->adjustment_get_value();
118 m_xScrollBar->adjustment_set_value(nNewPos);
119 m_aLink.Call(*m_xScrollBar);
120 return m_xScrollBar->adjustment_get_value() - nOrig;
123 void ScrollAdaptor::SetThickness(int nThickness) { m_xScrollBar->set_scroll_thickness(nThickness); }
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */