1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: scroll.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
36 #include "swtypes.hxx"
40 #define SCROLL_LINE_SIZE 250
43 SwScrollbar::SwScrollbar( Window
*pWin
, BOOL bHoriz
) :
45 WinBits( WB_3DLOOK
| WB_HIDE
| ( bHoriz
? WB_HSCROLL
: WB_VSCROLL
) ) ),
48 bThumbEnabled( TRUE
),
52 // SSA: --- RTL --- no mirroring for horizontal scrollbars
58 SwScrollbar::~SwScrollbar() {}
60 /*------------------------------------------------------------------------
61 Beschreibung: wird nach einer Aenderung der Dokumentgroesse gerufen, um den
62 Range des Scrollbars neu einzustellen.
63 ------------------------------------------------------------------------*/
65 void SwScrollbar::DocSzChgd( const Size
&rSize
)
68 SetRange( Range( 0, bHori
? rSize
.Width() : rSize
.Height()) );
69 const ULONG nVisSize
= GetVisibleSize();
70 SetLineSize( SCROLL_LINE_SIZE
);
71 // SetLineSize( nVisSize * 10 / 100 );
72 SetPageSize( nVisSize
* 77 / 100 );
75 /*------------------------------------------------------------------------
76 Beschreibung: wird nach einer Veraenderung des sichtbaren Ausschnittes
78 ------------------------------------------------------------------------*/
81 void SwScrollbar::ViewPortChgd( const Rectangle
&rRect
)
83 long nThumb
, nVisible
;
86 nThumb
= rRect
.Left();
87 nVisible
= rRect
.GetWidth();
92 nVisible
= rRect
.GetHeight();
95 SetVisibleSize( nVisible
);
98 SetThumbPos( nThumb
);
103 /*-----------------10/21/97 02:48pm-----------------
105 --------------------------------------------------*/
106 void SwScrollbar::ExtendedShow( BOOL bSet
)
109 if( (!bSet
|| !bAuto
) && IsUpdateMode() && bSizeSet
)
110 ScrollBar::Show(bSet
);
113 /*-----------------10/21/97 03:23pm-----------------
115 --------------------------------------------------*/
116 void SwScrollbar::SetPosSizePixel( const Point
& rNewPos
, const Size
& rNewSize
)
118 ScrollBar::SetPosSizePixel(rNewPos
, rNewSize
);
126 /*-----------------14.04.98 11:38-------------------
128 --------------------------------------------------*/
129 void SwScrollbar::SetAuto(BOOL bSet
)
135 // automatisch versteckt - dann anzeigen
136 if(!bAuto
&& bVisible
&& !ScrollBar::IsVisible())
139 AutoShow(); // oder automatisch verstecken
142 /*-----------------14.04.98 11:43-------------------
144 --------------------------------------------------*/
145 void SwScrollbar::AutoShow()
147 long nVis
= GetVisibleSize();
148 long nLen
= GetRange().Len();
150 if( nVis
>= nLen
- 1)
152 if(ScrollBar::IsVisible())
153 ScrollBar::Show(FALSE
);
155 else if ( !ScrollBar::IsVisible() &&
156 (!bHori
|| nVis
) ) //Optimierung fuer Browser.
157 //Horizontaler Scrollbar per
160 ScrollBar::Show(TRUE
);