LibreOffice Module sw (master) 1
scroll.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <scroll.hxx>
21
22#define SCROLL_LINE_SIZE 250
23
25 : ScrollAdaptor(pWin, bHoriz)
26 , m_bAuto(false)
27 , m_bVisible(false)
28 , m_bSizeSet(false)
29{
30 m_xScrollBar->show();
31
32 // No mirroring for horizontal scrollbars
33 if (bHoriz)
34 m_xScrollBar->set_direction(false);
35}
36
37// Will be called after a change of the document size
38// to refresh the range of the scrollbars.
39void SwScrollbar::DocSzChgd( const Size &rSize )
40{
41 m_aDocSz = rSize;
42 SetRange( Range( 0, m_bHori ? rSize.Width() : rSize.Height()) );
43 const tools::Long nVisSize = GetVisibleSize();
45 SetPageSize( nVisSize * 77 / 100 );
46}
47
48// Will be called after a change of the visible view section.
50{
51 tools::Long nThumb, nVisible;
52 if( m_bHori )
53 {
54 nThumb = rRect.Left();
55 nVisible = rRect.GetWidth();
56 }
57 else
58 {
59 nThumb = rRect.Top();
60 nVisible = rRect.GetHeight();
61 }
62
63 SetVisibleSize( nVisible );
65 SetThumbPos( nThumb );
66 if(m_bAuto)
67 AutoShow();
68}
69
71{
72 m_bVisible = bSet;
73 if( (!bSet || !m_bAuto) && IsUpdateMode() && m_bSizeSet)
74 {
75 ScrollAdaptor::Show(bSet);
76 }
77}
78
79void SwScrollbar::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
80{
81 ScrollAdaptor::SetPosSizePixel(rNewPos, rNewSize);
82 m_bSizeSet = true;
83 if(m_bVisible)
85}
86
87void SwScrollbar::SetAuto(bool bSet)
88{
89 if(m_bAuto != bSet)
90 {
91 m_bAuto = bSet;
92
93 // hide automatically - then show
94 if(!m_bAuto && m_bVisible && !ScrollAdaptor::IsVisible())
96 else if(m_bAuto)
97 AutoShow(); // or hide automatically
98 }
99}
100
102{
104 tools::Long nLen = GetRange().Len();
105 if (nVis >= nLen - 1)
106 {
107 if (ScrollAdaptor::IsVisible())
108 ScrollAdaptor::Show(false);
109 }
110 else if (!ScrollAdaptor::IsVisible())
111 {
112 ScrollAdaptor::Show();
113 }
114}
115
116/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Long Len() const
virtual void SetRange(const Range &rRange) override
virtual Range GetRange() const override
virtual void SetPageSize(tools::Long nNewSize) override
virtual tools::Long GetVisibleSize() const override
std::unique_ptr< weld::Scrollbar > m_xScrollBar
virtual void SetVisibleSize(tools::Long nNewSize) override
virtual void SetLineSize(tools::Long nNewSize) override
virtual void SetThumbPos(tools::Long nThumbPos) override
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void ViewPortChgd(const tools::Rectangle &rRectangle)
Definition: scroll.cxx:49
bool m_bAuto
Definition: scroll.hxx:26
bool m_bSizeSet
Definition: scroll.hxx:28
Size m_aDocSz
Definition: scroll.hxx:25
void ExtendedShow(bool bVisible=true)
Definition: scroll.cxx:70
void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize) override
Definition: scroll.cxx:79
bool m_bVisible
Definition: scroll.hxx:27
void DocSzChgd(const Size &rNewSize)
Definition: scroll.cxx:39
SwScrollbar(vcl::Window *pParent, bool bHori)
Definition: scroll.cxx:24
void SetAuto(bool bSet)
Definition: scroll.cxx:87
void AutoShow()
Definition: scroll.cxx:101
constexpr tools::Long GetWidth() const
constexpr tools::Long Top() const
constexpr tools::Long GetHeight() const
constexpr tools::Long Left() const
long Long
#define SCROLL_LINE_SIZE
Definition: scroll.cxx:22