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 .
21 #include "swtypes.hxx"
25 #define SCROLL_LINE_SIZE 250
28 SwScrollbar::SwScrollbar( Window
*pWin
, sal_Bool bHoriz
) :
30 WinBits( WB_3DLOOK
| WB_HIDE
| ( bHoriz
? WB_HSCROLL
: WB_VSCROLL
) ) ),
36 // SSA: --- RTL --- no mirroring for horizontal scrollbars
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
)
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
61 ------------------------------------------------------------------------*/
64 void SwScrollbar::ViewPortChgd( const Rectangle
&rRect
)
66 long nThumb
, nVisible
;
69 nThumb
= rRect
.Left();
70 nVisible
= rRect
.GetWidth();
75 nVisible
= rRect
.GetHeight();
78 SetVisibleSize( nVisible
);
80 SetThumbPos( nThumb
);
85 void SwScrollbar::ExtendedShow( sal_Bool 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
);
101 void SwScrollbar::SetAuto(sal_Bool bSet
)
107 // automatisch versteckt - dann anzeigen
108 if(!bAuto
&& bVisible
&& !ScrollBar::IsVisible())
109 ExtendedShow(sal_True
);
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: */