merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / uiview / scroll.cxx
blob0196d9283dee36952e0cd37b386c9b9299978a42
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: scroll.cxx,v $
10 * $Revision: 1.10 $
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"
37 #include "swrect.hxx"
38 #include "scroll.hxx"
40 #define SCROLL_LINE_SIZE 250
43 SwScrollbar::SwScrollbar( Window *pWin, BOOL bHoriz ) :
44 ScrollBar( pWin,
45 WinBits( WB_3DLOOK | WB_HIDE | ( bHoriz ? WB_HSCROLL : WB_VSCROLL) ) ),
46 bHori( bHoriz ),
47 bAuto( FALSE ),
48 bThumbEnabled( TRUE ),
49 bVisible(FALSE),
50 bSizeSet(FALSE)
52 // SSA: --- RTL --- no mirroring for horizontal scrollbars
53 if( bHoriz )
54 EnableRTL( FALSE );
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 )
67 aDocSz = 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
77 gerufen.
78 ------------------------------------------------------------------------*/
81 void SwScrollbar::ViewPortChgd( const Rectangle &rRect )
83 long nThumb, nVisible;
84 if( bHori )
86 nThumb = rRect.Left();
87 nVisible = rRect.GetWidth();
89 else
91 nThumb = rRect.Top();
92 nVisible = rRect.GetHeight();
95 SetVisibleSize( nVisible );
96 DocSzChgd(aDocSz);
97 if ( bThumbEnabled )
98 SetThumbPos( nThumb );
99 if(bAuto)
100 AutoShow();
103 /*-----------------10/21/97 02:48pm-----------------
105 --------------------------------------------------*/
106 void SwScrollbar::ExtendedShow( BOOL bSet )
108 bVisible = 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);
119 bSizeSet = TRUE;
120 if(bVisible)
121 ExtendedShow();
126 /*-----------------14.04.98 11:38-------------------
128 --------------------------------------------------*/
129 void SwScrollbar::SetAuto(BOOL bSet)
131 if(bAuto != bSet)
133 bAuto = bSet;
135 // automatisch versteckt - dann anzeigen
136 if(!bAuto && bVisible && !ScrollBar::IsVisible())
137 ExtendedShow(TRUE);
138 else if(bAuto)
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
158 //default aus.
160 ScrollBar::Show(TRUE);