Files
libreoffice/sw/source/ui/uiview/scroll.cxx

161 lines
4.6 KiB
C++
Raw Normal View History

2000-09-18 16:15:01 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 16:15:01 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 16:15:01 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 16:15:01 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 16:15:01 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 16:15:01 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 16:15:01 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 16:15:01 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
2000-09-18 16:15:01 +00:00
#include "swtypes.hxx"
#include "swrect.hxx"
#include "scroll.hxx"
#define SCROLL_LINE_SIZE 250
2000-09-18 16:15:01 +00:00
SwScrollbar::SwScrollbar( Window *pWin, BOOL bHoriz ) :
2000-09-18 16:15:01 +00:00
ScrollBar( pWin,
WinBits( WB_3DLOOK | WB_HIDE | ( bHoriz ? WB_HSCROLL : WB_VSCROLL) ) ),
bHori( bHoriz ),
bAuto( FALSE ),
bThumbEnabled( TRUE ),
bVisible(FALSE),
bSizeSet(FALSE)
{
// SSA: --- RTL --- no mirroring for horizontal scrollbars
if( bHoriz )
EnableRTL( FALSE );
2000-09-18 16:15:01 +00:00
}
SwScrollbar::~SwScrollbar() {}
/*------------------------------------------------------------------------
Beschreibung: wird nach einer Aenderung der Dokumentgroesse gerufen, um den
Range des Scrollbars neu einzustellen.
------------------------------------------------------------------------*/
void SwScrollbar::DocSzChgd( const Size &rSize )
{
aDocSz = rSize;
SetRange( Range( 0, bHori ? rSize.Width() : rSize.Height()) );
const ULONG nVisSize = GetVisibleSize();
SetLineSize( SCROLL_LINE_SIZE );
// SetLineSize( nVisSize * 10 / 100 );
2000-09-18 16:15:01 +00:00
SetPageSize( nVisSize * 77 / 100 );
}
/*------------------------------------------------------------------------
Beschreibung: wird nach einer Veraenderung des sichtbaren Ausschnittes
gerufen.
------------------------------------------------------------------------*/
void SwScrollbar::ViewPortChgd( const Rectangle &rRect )
{
long nThumb, nVisible;
if( bHori )
{
nThumb = rRect.Left();
nVisible = rRect.GetWidth();
}
else
{
nThumb = rRect.Top();
nVisible = rRect.GetHeight();
}
SetVisibleSize( nVisible );
DocSzChgd(aDocSz);
if ( bThumbEnabled )
SetThumbPos( nThumb );
if(bAuto)
AutoShow();
}
/*-----------------10/21/97 02:48pm-----------------
--------------------------------------------------*/
void SwScrollbar::ExtendedShow( BOOL bSet )
2000-09-18 16:15:01 +00:00
{
bVisible = bSet;
if( (!bSet || !bAuto) && IsUpdateMode() && bSizeSet)
2000-09-18 16:15:01 +00:00
ScrollBar::Show(bSet);
}
/*-----------------10/21/97 03:23pm-----------------
--------------------------------------------------*/
void SwScrollbar::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
{
ScrollBar::SetPosSizePixel(rNewPos, rNewSize);
bSizeSet = TRUE;
if(bVisible)
ExtendedShow();
2000-09-18 16:15:01 +00:00
}
/*-----------------14.04.98 11:38-------------------
--------------------------------------------------*/
void SwScrollbar::SetAuto(BOOL bSet)
{
if(bAuto != bSet)
{
bAuto = bSet;
// automatisch versteckt - dann anzeigen
if(!bAuto && bVisible && !ScrollBar::IsVisible())
ExtendedShow(TRUE);
2000-09-18 16:15:01 +00:00
else if(bAuto)
AutoShow(); // oder automatisch verstecken
}
}
/*-----------------14.04.98 11:43-------------------
--------------------------------------------------*/
void SwScrollbar::AutoShow()
{
long nVis = GetVisibleSize();
long nLen = GetRange().Len();
{
if( nVis >= nLen - 1)
{
if(ScrollBar::IsVisible())
ScrollBar::Show(FALSE);
2000-09-18 16:15:01 +00:00
}
else if ( !ScrollBar::IsVisible() &&
(!bHori || nVis) ) //Optimierung fuer Browser.
//Horizontaler Scrollbar per
//default aus.
{
ScrollBar::Show(TRUE);
2000-09-18 16:15:01 +00:00
}
}
}