2000-09-18 16:15:01 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 20:47:02 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 20:47:02 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 20:47:02 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 20:47:02 +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
|
|
|
*
|
2008-04-10 20:47:02 +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
|
|
|
*
|
2008-04-10 20:47:02 +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
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 22:22:50 +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"
|
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
#define SCROLL_LINE_SIZE 250
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2007-09-27 11:35:36 +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)
|
|
|
|
{
|
2002-09-17 08:43:17 +00:00
|
|
|
// 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();
|
2003-03-27 14:45:43 +00:00
|
|
|
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-----------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
2007-09-27 11:35:36 +00:00
|
|
|
void SwScrollbar::ExtendedShow( BOOL bSet )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
bVisible = bSet;
|
2003-03-27 14:45:43 +00:00
|
|
|
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)
|
2007-09-27 11:35:36 +00:00
|
|
|
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())
|
2007-09-27 11:35:36 +00:00
|
|
|
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)
|
|
|
|
{
|
2002-06-28 11:11:19 +00:00
|
|
|
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.
|
|
|
|
{
|
2002-06-28 11:11:19 +00:00
|
|
|
ScrollBar::Show(TRUE);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|