bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / uiview / scroll.cxx
blob0bb2ee2756ab7ee29be3e82ab120b19f2e299a07
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 .
21 #include "swtypes.hxx"
22 #include "swrect.hxx"
23 #include "scroll.hxx"
25 #define SCROLL_LINE_SIZE 250
28 SwScrollbar::SwScrollbar( Window *pWin, sal_Bool bHoriz ) :
29 ScrollBar( pWin,
30 WinBits( WB_3DLOOK | WB_HIDE | ( bHoriz ? WB_HSCROLL : WB_VSCROLL) ) ),
31 bHori( bHoriz ),
32 bAuto( sal_False ),
33 bVisible(sal_False),
34 bSizeSet(sal_False)
36 // SSA: --- RTL --- no mirroring for horizontal scrollbars
37 if( bHoriz )
38 EnableRTL( sal_False );
42 SwScrollbar::~SwScrollbar() {}
44 /*------------------------------------------------------------------------
45 Beschreibung: wird nach einer Aenderung der Dokumentgroesse gerufen, um den
46 Range des Scrollbars neu einzustellen.
47 ------------------------------------------------------------------------*/
49 void SwScrollbar::DocSzChgd( const Size &rSize )
51 aDocSz = rSize;
52 SetRange( Range( 0, bHori ? rSize.Width() : rSize.Height()) );
53 const sal_uLong nVisSize = GetVisibleSize();
54 SetLineSize( SCROLL_LINE_SIZE );
55 SetPageSize( nVisSize * 77 / 100 );
58 /*------------------------------------------------------------------------
59 Beschreibung: wird nach einer Veraenderung des sichtbaren Ausschnittes
60 gerufen.
61 ------------------------------------------------------------------------*/
64 void SwScrollbar::ViewPortChgd( const Rectangle &rRect )
66 long nThumb, nVisible;
67 if( bHori )
69 nThumb = rRect.Left();
70 nVisible = rRect.GetWidth();
72 else
74 nThumb = rRect.Top();
75 nVisible = rRect.GetHeight();
78 SetVisibleSize( nVisible );
79 DocSzChgd(aDocSz);
80 SetThumbPos( nThumb );
81 if(bAuto)
82 AutoShow();
85 void SwScrollbar::ExtendedShow( sal_Bool bSet )
87 bVisible = bSet;
88 if( (!bSet || !bAuto) && IsUpdateMode() && bSizeSet)
89 ScrollBar::Show(bSet);
92 void SwScrollbar::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
94 ScrollBar::SetPosSizePixel(rNewPos, rNewSize);
95 bSizeSet = sal_True;
96 if(bVisible)
97 ExtendedShow();
101 void SwScrollbar::SetAuto(sal_Bool bSet)
103 if(bAuto != bSet)
105 bAuto = bSet;
107 // automatisch versteckt - dann anzeigen
108 if(!bAuto && bVisible && !ScrollBar::IsVisible())
109 ExtendedShow(sal_True);
110 else if(bAuto)
111 AutoShow(); // oder automatisch verstecken
115 void SwScrollbar::AutoShow()
117 long nVis = GetVisibleSize();
118 long nLen = GetRange().Len();
119 if( nVis >= nLen - 1)
121 if(ScrollBar::IsVisible())
122 ScrollBar::Show(sal_False);
124 else if ( !ScrollBar::IsVisible() )
126 ScrollBar::Show(sal_True);
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */