1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #define SCROLL_LINE_SIZE 250
24 SwScrollbar::SwScrollbar(vcl::Window
*pWin
, bool bHoriz
)
25 : ScrollAdaptor(pWin
, bHoriz
)
32 // No mirroring for horizontal scrollbars
34 m_xScrollBar
->set_direction(false);
37 // Will be called after a change of the document size
38 // to refresh the range of the scrollbars.
39 void SwScrollbar::DocSzChgd( const Size
&rSize
)
42 SetRange( Range( 0, m_bHori
? rSize
.Width() : rSize
.Height()) );
43 const tools::Long nVisSize
= GetVisibleSize();
44 SetLineSize( SCROLL_LINE_SIZE
);
45 SetPageSize( nVisSize
* 77 / 100 );
48 // Will be called after a change of the visible view section.
49 void SwScrollbar::ViewPortChgd( const tools::Rectangle
&rRect
)
51 tools::Long nThumb
, nVisible
;
54 nThumb
= rRect
.Left();
55 nVisible
= rRect
.GetWidth();
60 nVisible
= rRect
.GetHeight();
63 SetVisibleSize( nVisible
);
65 SetThumbPos( nThumb
);
70 void SwScrollbar::ExtendedShow( bool bSet
)
73 if( (!bSet
|| !m_bAuto
) && IsUpdateMode() && m_bSizeSet
)
75 ScrollAdaptor::Show(bSet
);
79 void SwScrollbar::SetPosSizePixel( const Point
& rNewPos
, const Size
& rNewSize
)
81 ScrollAdaptor::SetPosSizePixel(rNewPos
, rNewSize
);
87 void SwScrollbar::SetAuto(bool bSet
)
93 // hide automatically - then show
94 if(!m_bAuto
&& m_bVisible
&& !ScrollAdaptor::IsVisible())
97 AutoShow(); // or hide automatically
101 void SwScrollbar::AutoShow()
103 tools::Long nVis
= GetVisibleSize();
104 tools::Long nLen
= GetRange().Len();
105 if (nVis
>= nLen
- 1)
107 if (ScrollAdaptor::IsVisible())
108 ScrollAdaptor::Show(false);
110 else if (!ScrollAdaptor::IsVisible())
112 ScrollAdaptor::Show();
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */