2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 18:46:55 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 18:46:55 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 18:46:55 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 18:46:55 +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:07:07 +00:00
|
|
|
*
|
2008-04-10 18:46:55 +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:07:07 +00:00
|
|
|
*
|
2008-04-10 18:46:55 +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:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 13:18:52 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_svtools.hxx"
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "datwin.hxx"
|
|
|
|
|
2004-06-16 09:05:18 +00:00
|
|
|
#ifndef GCC
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#ifndef _APP_HXX //autogen
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _HELP_HXX
|
|
|
|
#include <vcl/help.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _IMAGE_HXX
|
|
|
|
#include <vcl/image.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
|
2006-06-19 19:40:06 +00:00
|
|
|
DECLARE_LIST( BrowserColumns, BrowserColumn* )
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
//===================================================================
|
|
|
|
void ButtonFrame::Draw( OutputDevice& rDev )
|
|
|
|
{
|
|
|
|
Color aOldFillColor = rDev.GetFillColor();
|
|
|
|
Color aOldLineColor = rDev.GetLineColor();
|
|
|
|
|
|
|
|
const StyleSettings &rSettings = rDev.GetSettings().GetStyleSettings();
|
|
|
|
Color aColLight( rSettings.GetLightColor() );
|
|
|
|
Color aColShadow( rSettings.GetShadowColor() );
|
|
|
|
Color aColFace( rSettings.GetFaceColor() );
|
|
|
|
|
|
|
|
rDev.SetLineColor( aColFace );
|
|
|
|
rDev.SetFillColor( aColFace );
|
2005-01-07 08:20:59 +00:00
|
|
|
rDev.DrawRect( aRect );
|
|
|
|
|
|
|
|
if( rDev.GetOutDevType() == OUTDEV_WINDOW )
|
|
|
|
{
|
|
|
|
Window *pWin = (Window*) &rDev;
|
|
|
|
if( bPressed )
|
2010-11-05 10:31:15 +08:00
|
|
|
pWin->DrawSelectionBackground( aRect, 0, sal_True, sal_False, sal_False );
|
2005-01-07 08:20:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rDev.SetLineColor( bPressed ? aColShadow : aColLight );
|
|
|
|
rDev.DrawLine( aRect.TopLeft(), Point( aRect.Right(), aRect.Top() ) );
|
|
|
|
rDev.DrawLine( aRect.TopLeft(), Point( aRect.Left(), aRect.Bottom() - 1 ) );
|
|
|
|
rDev.SetLineColor( bPressed ? aColLight : aColShadow );
|
|
|
|
rDev.DrawLine( aRect.BottomRight(), Point( aRect.Right(), aRect.Top() ) );
|
|
|
|
rDev.DrawLine( aRect.BottomRight(), Point( aRect.Left(), aRect.Bottom() ) );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( aText.Len() )
|
|
|
|
{
|
2002-08-21 05:23:43 +00:00
|
|
|
String aVal = rDev.GetEllipsisString(aText,aInnerRect.GetWidth() - 2*MIN_COLUMNWIDTH);
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
Font aFont( rDev.GetFont() );
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool bOldTransp = aFont.IsTransparent();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !bOldTransp )
|
|
|
|
{
|
2010-11-05 10:31:15 +08:00
|
|
|
aFont.SetTransparent( sal_True );
|
2000-09-18 16:07:07 +00:00
|
|
|
rDev.SetFont( aFont );
|
|
|
|
}
|
|
|
|
|
2001-03-08 13:20:02 +00:00
|
|
|
Color aOldColor = rDev.GetTextColor();
|
|
|
|
if (m_bDrawDisabled)
|
|
|
|
rDev.SetTextColor(rSettings.GetDisableColor());
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
rDev.DrawText( Point(
|
|
|
|
( aInnerRect.Left() + aInnerRect.Right() ) / 2 - ( rDev.GetTextWidth(aVal) / 2 ),
|
|
|
|
aInnerRect.Top() ), aVal );
|
|
|
|
|
2001-03-08 13:20:02 +00:00
|
|
|
// restore settings
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !bOldTransp )
|
|
|
|
{
|
2010-11-05 10:31:15 +08:00
|
|
|
aFont.SetTransparent(sal_False);
|
2000-09-18 16:07:07 +00:00
|
|
|
rDev.SetFont( aFont );
|
|
|
|
}
|
2001-03-08 13:20:02 +00:00
|
|
|
if (m_bDrawDisabled)
|
|
|
|
rDev.SetTextColor(aOldColor);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( bCurs )
|
|
|
|
{
|
|
|
|
rDev.SetLineColor( Color( COL_BLACK ) );
|
|
|
|
rDev.SetFillColor();
|
|
|
|
rDev.DrawRect( Rectangle(
|
|
|
|
Point( aRect.Left(), aRect.Top() ), Point( aRect.Right(), aRect.Bottom() ) ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
rDev.SetLineColor( aOldLineColor );
|
|
|
|
rDev.SetFillColor( aOldFillColor );
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
BrowserColumn::BrowserColumn( sal_uInt16 nItemId, const class Image &rImage,
|
|
|
|
const String& rTitle, sal_uIntPtr nWidthPixel, const Fraction& rCurrentZoom,
|
2000-09-18 16:07:07 +00:00
|
|
|
HeaderBarItemBits nFlags )
|
|
|
|
: _nId( nItemId ),
|
|
|
|
_nWidth( nWidthPixel ),
|
|
|
|
_aImage( rImage ),
|
|
|
|
_aTitle( rTitle ),
|
2010-11-05 10:31:15 +08:00
|
|
|
_bFrozen( sal_False ),
|
2000-09-18 16:07:07 +00:00
|
|
|
_nFlags( nFlags )
|
|
|
|
{
|
|
|
|
double n = (double)_nWidth;
|
|
|
|
n *= (double)rCurrentZoom.GetDenominator();
|
|
|
|
n /= (double)rCurrentZoom.GetNumerator();
|
|
|
|
_nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
|
|
|
|
}
|
|
|
|
|
2006-06-19 19:40:06 +00:00
|
|
|
BrowserColumn::~BrowserColumn()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
void BrowserColumn::SetWidth(sal_uIntPtr nNewWidthPixel, const Fraction& rCurrentZoom)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
_nWidth = nNewWidthPixel;
|
|
|
|
double n = (double)_nWidth;
|
|
|
|
n *= (double)rCurrentZoom.GetDenominator();
|
|
|
|
n /= (double)rCurrentZoom.GetNumerator();
|
|
|
|
_nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
void BrowserColumn::Draw( BrowseBox& rBox, OutputDevice& rDev, const Point& rPos, sal_Bool bCurs )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( _nId == 0 )
|
|
|
|
{
|
|
|
|
// paint handle column
|
|
|
|
ButtonFrame( rPos, Size( Width()-1, rBox.GetDataRowHeight()-1 ),
|
2010-11-05 10:31:15 +08:00
|
|
|
String(), sal_False, bCurs,
|
2000-09-18 16:07:07 +00:00
|
|
|
0 != (BROWSER_COLUMN_TITLEABBREVATION&_nFlags) ).Draw( rDev );
|
|
|
|
Color aOldLineColor = rDev.GetLineColor();
|
|
|
|
rDev.SetLineColor( Color( COL_BLACK ) );
|
|
|
|
rDev.DrawLine(
|
|
|
|
Point( rPos.X(), rPos.Y()+rBox.GetDataRowHeight()-1 ),
|
|
|
|
Point( rPos.X() + Width() - 1, rPos.Y()+rBox.GetDataRowHeight()-1 ) );
|
|
|
|
rDev.DrawLine(
|
|
|
|
Point( rPos.X() + Width() - 1, rPos.Y() ),
|
|
|
|
Point( rPos.X() + Width() - 1, rPos.Y()+rBox.GetDataRowHeight()-1 ) );
|
|
|
|
rDev.SetLineColor( aOldLineColor );
|
|
|
|
|
2006-06-19 19:40:06 +00:00
|
|
|
rBox.DoPaintField( rDev,
|
|
|
|
Rectangle(
|
|
|
|
Point( rPos.X() + 2, rPos.Y() + 2 ),
|
|
|
|
Size( Width()-1, rBox.GetDataRowHeight()-1 ) ),
|
|
|
|
GetId(),
|
|
|
|
BrowseBox::BrowserColumnAccess() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// paint data column
|
|
|
|
long nWidth = Width() == LONG_MAX ? rBox.GetDataWindow().GetSizePixel().Width() : Width();
|
|
|
|
|
2006-06-19 19:40:06 +00:00
|
|
|
rBox.DoPaintField( rDev,
|
2000-09-18 16:07:07 +00:00
|
|
|
Rectangle(
|
|
|
|
Point( rPos.X() + MIN_COLUMNWIDTH, rPos.Y() ),
|
|
|
|
Size( nWidth-2*MIN_COLUMNWIDTH, rBox.GetDataRowHeight()-1 ) ),
|
2006-06-19 19:40:06 +00:00
|
|
|
GetId(),
|
|
|
|
BrowseBox::BrowserColumnAccess() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
|
|
|
void BrowserColumn::ZoomChanged(const Fraction& rNewZoom)
|
|
|
|
{
|
|
|
|
double n = (double)_nOriginalWidth;
|
|
|
|
n *= (double)rNewZoom.GetNumerator();
|
|
|
|
n /= (double)rNewZoom.GetDenominator();
|
|
|
|
|
|
|
|
_nWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
2004-10-22 11:32:34 +00:00
|
|
|
BrowserDataWin::BrowserDataWin( BrowseBox* pParent )
|
|
|
|
:Control( pParent, WinBits(WB_CLIPCHILDREN) )
|
|
|
|
,DragSourceHelper( this )
|
|
|
|
,DropTargetHelper( this )
|
|
|
|
,pHeaderBar( 0 )
|
|
|
|
,pEventWin( pParent )
|
|
|
|
,pCornerWin( 0 )
|
|
|
|
,pDtorNotify( 0 )
|
2010-11-05 10:31:15 +08:00
|
|
|
,bInPaint( sal_False )
|
|
|
|
,bInCommand( sal_False )
|
|
|
|
,bNoScrollBack( sal_False )
|
|
|
|
,bNoHScroll( sal_False )
|
|
|
|
,bNoVScroll( sal_False )
|
|
|
|
,bUpdateMode( sal_True )
|
|
|
|
,bResizeOnPaint( sal_False )
|
|
|
|
,bUpdateOnUnlock( sal_False )
|
|
|
|
,bInUpdateScrollbars( sal_False )
|
|
|
|
,bHadRecursion( sal_False )
|
|
|
|
,bOwnDataChangedHdl( sal_False )
|
|
|
|
,bCallingDropCallback( sal_False )
|
2004-10-22 11:32:34 +00:00
|
|
|
,nUpdateLock( 0 )
|
|
|
|
,nCursorHidden( 0 )
|
|
|
|
,m_nDragRowDividerLimit( 0 )
|
|
|
|
,m_nDragRowDividerOffset( 0 )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
aMouseTimer.SetTimeoutHdl( LINK( this, BrowserDataWin, RepeatedMouseMove ) );
|
|
|
|
aMouseTimer.SetTimeout( 100 );
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
BrowserDataWin::~BrowserDataWin()
|
|
|
|
{
|
|
|
|
if( pDtorNotify )
|
2010-11-05 10:31:15 +08:00
|
|
|
*pDtorNotify = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
void BrowserDataWin::LeaveUpdateLock()
|
|
|
|
{
|
|
|
|
if ( !--nUpdateLock )
|
|
|
|
{
|
|
|
|
DoOutstandingInvalidations();
|
|
|
|
if (bUpdateOnUnlock )
|
|
|
|
{
|
|
|
|
Control::Update();
|
2010-11-05 10:31:15 +08:00
|
|
|
bUpdateOnUnlock = sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
void InitSettings_Impl( Window *pWin,
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
const StyleSettings& rStyleSettings =
|
|
|
|
pWin->GetSettings().GetStyleSettings();
|
|
|
|
|
|
|
|
if ( bFont )
|
|
|
|
{
|
2008-06-25 10:49:12 +00:00
|
|
|
Font aFont = rStyleSettings.GetFieldFont();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pWin->IsControlFont() )
|
|
|
|
aFont.Merge( pWin->GetControlFont() );
|
2008-06-25 10:49:12 +00:00
|
|
|
pWin->SetZoomedPointFont( aFont );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( bFont || bForeground )
|
|
|
|
{
|
|
|
|
Color aTextColor = rStyleSettings.GetWindowTextColor();
|
|
|
|
if ( pWin->IsControlForeground() )
|
|
|
|
aTextColor = pWin->GetControlForeground();
|
|
|
|
pWin->SetTextColor( aTextColor );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bBackground )
|
|
|
|
{
|
|
|
|
if( pWin->IsControlBackground() )
|
|
|
|
pWin->SetBackground( pWin->GetControlBackground() );
|
|
|
|
else
|
|
|
|
pWin->SetBackground( rStyleSettings.GetWindowColor() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
void BrowserDataWin::Update()
|
|
|
|
{
|
|
|
|
if ( !nUpdateLock )
|
|
|
|
Control::Update();
|
|
|
|
else
|
2010-11-05 10:31:15 +08:00
|
|
|
bUpdateOnUnlock = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
void BrowserDataWin::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
|
|
|
|
(rDCEvt.GetFlags() & SETTINGS_STYLE) )
|
|
|
|
{
|
|
|
|
if( !bOwnDataChangedHdl )
|
|
|
|
{
|
2010-11-05 10:31:15 +08:00
|
|
|
InitSettings_Impl( this, sal_True, sal_True, sal_True );
|
2000-09-18 16:07:07 +00:00
|
|
|
Invalidate();
|
2010-11-05 10:31:15 +08:00
|
|
|
InitSettings_Impl( GetParent(), sal_True, sal_True, sal_True );
|
2000-09-18 16:07:07 +00:00
|
|
|
GetParent()->Invalidate();
|
2000-10-23 13:37:31 +00:00
|
|
|
GetParent()->Resize();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Control::DataChanged( rDCEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
void BrowserDataWin::Paint( const Rectangle& rRect )
|
|
|
|
{
|
|
|
|
if ( !nUpdateLock && GetUpdateMode() )
|
|
|
|
{
|
2004-11-17 14:02:06 +00:00
|
|
|
if ( bInPaint )
|
|
|
|
{
|
|
|
|
aInvalidRegion.Insert( new Rectangle( rRect ) );
|
|
|
|
return;
|
|
|
|
}
|
2010-11-05 10:31:15 +08:00
|
|
|
bInPaint = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
( (BrowseBox*) GetParent() )->PaintData( *this, rRect );
|
2010-11-05 10:31:15 +08:00
|
|
|
bInPaint = sal_False;
|
2004-11-17 14:02:06 +00:00
|
|
|
DoOutstandingInvalidations();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
aInvalidRegion.Insert( new Rectangle( rRect ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
|
|
|
BrowseEvent BrowserDataWin::CreateBrowseEvent( const Point& rPosPixel )
|
|
|
|
{
|
|
|
|
BrowseBox *pBox = GetParent();
|
|
|
|
|
|
|
|
// seek to row under mouse
|
2006-10-12 14:06:25 +00:00
|
|
|
long nRelRow = rPosPixel.Y() < 0
|
2000-09-18 16:07:07 +00:00
|
|
|
? -1
|
|
|
|
: rPosPixel.Y() / pBox->GetDataRowHeight();
|
|
|
|
long nRow = nRelRow < 0 ? -1 : nRelRow + pBox->nTopRow;
|
|
|
|
|
|
|
|
// find column under mouse
|
|
|
|
long nMouseX = rPosPixel.X();
|
|
|
|
long nColX = 0;
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uInt16 nCol;
|
2000-09-18 16:07:07 +00:00
|
|
|
for ( nCol = 0;
|
|
|
|
nCol < pBox->pCols->Count() && nColX < GetSizePixel().Width();
|
|
|
|
++nCol )
|
|
|
|
if ( pBox->pCols->GetObject(nCol)->IsFrozen() || nCol >= pBox->nFirstCol )
|
|
|
|
{
|
|
|
|
nColX += pBox->pCols->GetObject(nCol)->Width();
|
|
|
|
if ( nMouseX < nColX )
|
|
|
|
break;
|
|
|
|
}
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uInt16 nColId = BROWSER_INVALIDID;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nCol < pBox->pCols->Count() )
|
|
|
|
nColId = pBox->pCols->GetObject(nCol)->GetId();
|
|
|
|
|
|
|
|
// compute the field rectangle and field relative MouseEvent
|
|
|
|
Rectangle aFieldRect;
|
|
|
|
if ( nCol < pBox->pCols->Count() )
|
|
|
|
{
|
|
|
|
nColX -= pBox->pCols->GetObject(nCol)->Width();
|
|
|
|
aFieldRect = Rectangle(
|
|
|
|
Point( nColX, nRelRow * pBox->GetDataRowHeight() ),
|
|
|
|
Size( pBox->pCols->GetObject(nCol)->Width(),
|
|
|
|
pBox->GetDataRowHeight() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// assemble and return the BrowseEvent
|
|
|
|
return BrowseEvent( this, nRow, nCol, nColId, aFieldRect );
|
|
|
|
}
|
|
|
|
|
2001-03-30 12:01:06 +00:00
|
|
|
//-------------------------------------------------------------------
|
|
|
|
sal_Int8 BrowserDataWin::AcceptDrop( const AcceptDropEvent& _rEvt )
|
|
|
|
{
|
|
|
|
bCallingDropCallback = sal_True;
|
|
|
|
sal_Int8 nReturn = DND_ACTION_NONE;
|
|
|
|
nReturn = GetParent()->AcceptDrop( BrowserAcceptDropEvent( this, _rEvt ) );
|
|
|
|
bCallingDropCallback = sal_False;
|
|
|
|
return nReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
sal_Int8 BrowserDataWin::ExecuteDrop( const ExecuteDropEvent& _rEvt )
|
|
|
|
{
|
|
|
|
bCallingDropCallback = sal_True;
|
|
|
|
sal_Int8 nReturn = DND_ACTION_NONE;
|
2002-04-09 06:27:17 +00:00
|
|
|
nReturn = GetParent()->ExecuteDrop( BrowserExecuteDropEvent( this, _rEvt ) );
|
2001-03-30 12:01:06 +00:00
|
|
|
bCallingDropCallback = sal_False;
|
|
|
|
return nReturn;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
//-------------------------------------------------------------------
|
2001-03-27 10:47:48 +00:00
|
|
|
void BrowserDataWin::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel )
|
|
|
|
{
|
2004-05-10 12:20:31 +00:00
|
|
|
if ( !GetParent()->bRowDividerDrag )
|
|
|
|
{
|
|
|
|
Point aEventPos( _rPosPixel );
|
|
|
|
aEventPos.Y() += GetParent()->GetTitleHeight();
|
|
|
|
GetParent()->StartDrag( _nAction, aEventPos );
|
|
|
|
}
|
2001-03-27 10:47:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
2000-09-18 16:07:07 +00:00
|
|
|
void BrowserDataWin::Command( const CommandEvent& rEvt )
|
|
|
|
{
|
|
|
|
// Scrollmaus-Event?
|
|
|
|
BrowseBox *pBox = GetParent();
|
|
|
|
if ( ( (rEvt.GetCommand() == COMMAND_WHEEL) ||
|
|
|
|
(rEvt.GetCommand() == COMMAND_STARTAUTOSCROLL) ||
|
|
|
|
(rEvt.GetCommand() == COMMAND_AUTOSCROLL) ) &&
|
|
|
|
( HandleScrollCommand( rEvt, &pBox->aHScroll, pBox->pVScroll ) ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Point aEventPos( rEvt.GetMousePosPixel() );
|
2010-11-05 10:31:15 +08:00
|
|
|
long nRow = pBox->GetRowAtYPosPixel( aEventPos.Y(), sal_False);
|
2000-09-18 16:07:07 +00:00
|
|
|
MouseEvent aMouseEvt( aEventPos, 1, MOUSE_SELECT, MOUSE_LEFT );
|
|
|
|
if ( COMMAND_CONTEXTMENU == rEvt.GetCommand() && rEvt.IsMouseEvent() &&
|
|
|
|
nRow < pBox->GetRowCount() && !pBox->IsRowSelected(nRow) )
|
|
|
|
{
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool bDeleted = sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
pDtorNotify = &bDeleted;
|
2010-11-05 10:31:15 +08:00
|
|
|
bInCommand = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
MouseButtonDown( aMouseEvt );
|
|
|
|
if( bDeleted )
|
|
|
|
return;
|
|
|
|
MouseButtonUp( aMouseEvt );
|
|
|
|
if( bDeleted )
|
|
|
|
return;
|
|
|
|
pDtorNotify = 0;
|
2010-11-05 10:31:15 +08:00
|
|
|
bInCommand = sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aEventPos.Y() += GetParent()->GetTitleHeight();
|
|
|
|
CommandEvent aEvt( aEventPos, rEvt.GetCommand(),
|
|
|
|
rEvt.IsMouseEvent(), rEvt.GetData() );
|
2010-11-05 10:31:15 +08:00
|
|
|
bInCommand = sal_True;
|
|
|
|
sal_Bool bDeleted = sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
pDtorNotify = &bDeleted;
|
|
|
|
GetParent()->Command( aEvt );
|
|
|
|
if( bDeleted )
|
|
|
|
return;
|
|
|
|
pDtorNotify = 0;
|
2010-11-05 10:31:15 +08:00
|
|
|
bInCommand = sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( COMMAND_STARTDRAG == rEvt.GetCommand() )
|
|
|
|
MouseButtonUp( aMouseEvt );
|
|
|
|
|
|
|
|
Control::Command( rEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_Bool BrowserDataWin::ImplRowDividerHitTest( const BrowserMouseEvent& _rEvent )
|
2004-05-10 12:20:31 +00:00
|
|
|
{
|
|
|
|
if ( ! ( GetParent()->IsInteractiveRowHeightEnabled()
|
|
|
|
&& ( _rEvent.GetRow() >= 0 )
|
|
|
|
&& ( _rEvent.GetRow() < GetParent()->GetRowCount() )
|
|
|
|
&& ( _rEvent.GetColumnId() == 0 )
|
|
|
|
)
|
|
|
|
)
|
2010-11-05 10:31:15 +08:00
|
|
|
return sal_False;
|
2004-05-10 12:20:31 +00:00
|
|
|
|
|
|
|
long nDividerDistance = GetParent()->GetDataRowHeight() - ( _rEvent.GetPosPixel().Y() % GetParent()->GetDataRowHeight() );
|
|
|
|
return ( nDividerDistance <= 4 );
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void BrowserDataWin::MouseButtonDown( const MouseEvent& rEvt )
|
|
|
|
{
|
|
|
|
aLastMousePos = OutputToScreenPixel( rEvt.GetPosPixel() );
|
2004-05-10 12:20:31 +00:00
|
|
|
|
|
|
|
BrowserMouseEvent aBrowserEvent( this, rEvt );
|
|
|
|
if ( ( aBrowserEvent.GetClicks() == 1 ) && ImplRowDividerHitTest( aBrowserEvent ) )
|
|
|
|
{
|
|
|
|
StartRowDividerDrag( aBrowserEvent.GetPosPixel() );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
GetParent()->MouseButtonDown( BrowserMouseEvent( this, rEvt ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
|
|
|
void BrowserDataWin::MouseMove( const MouseEvent& rEvt )
|
|
|
|
{
|
|
|
|
// Pseudo MouseMoves verhindern
|
|
|
|
Point aNewPos = OutputToScreenPixel( rEvt.GetPosPixel() );
|
2004-05-10 12:20:31 +00:00
|
|
|
if ( ( aNewPos == aLastMousePos ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
return;
|
|
|
|
aLastMousePos = aNewPos;
|
|
|
|
|
|
|
|
// transform to a BrowseEvent
|
2004-05-10 12:20:31 +00:00
|
|
|
BrowserMouseEvent aBrowserEvent( this, rEvt );
|
|
|
|
GetParent()->MouseMove( aBrowserEvent );
|
|
|
|
|
|
|
|
// pointer shape
|
|
|
|
PointerStyle ePointerStyle = POINTER_ARROW;
|
|
|
|
if ( ImplRowDividerHitTest( aBrowserEvent ) )
|
|
|
|
ePointerStyle = POINTER_VSIZEBAR;
|
|
|
|
SetPointer( Pointer( ePointerStyle ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// dragging out of the visible area?
|
|
|
|
if ( rEvt.IsLeft() &&
|
|
|
|
( rEvt.GetPosPixel().Y() > GetSizePixel().Height() ||
|
|
|
|
rEvt.GetPosPixel().Y() < 0 ) )
|
|
|
|
{
|
|
|
|
// repeat the event
|
|
|
|
aRepeatEvt = rEvt;
|
|
|
|
aMouseTimer.Start();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
// killing old repeat-event
|
|
|
|
if ( aMouseTimer.IsActive() )
|
|
|
|
aMouseTimer.Stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
2006-06-19 19:40:06 +00:00
|
|
|
IMPL_LINK_INLINE_START( BrowserDataWin, RepeatedMouseMove, void *, EMPTYARG )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
GetParent()->MouseMove( BrowserMouseEvent( this, aRepeatEvt ) );
|
|
|
|
return 0;
|
|
|
|
}
|
2006-06-19 19:40:06 +00:00
|
|
|
IMPL_LINK_INLINE_END( BrowserDataWin, RepeatedMouseMove, void *, EMPTYARG )
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
|
|
|
void BrowserDataWin::MouseButtonUp( const MouseEvent& rEvt )
|
|
|
|
{
|
|
|
|
// Pseudo MouseMoves verhindern
|
|
|
|
Point aNewPos = OutputToScreenPixel( rEvt.GetPosPixel() );
|
|
|
|
aLastMousePos = aNewPos;
|
|
|
|
|
|
|
|
// Move an die aktuelle Position simulieren
|
|
|
|
MouseMove( rEvt );
|
|
|
|
|
|
|
|
// eigentliches Up-Handling
|
|
|
|
ReleaseMouse();
|
|
|
|
if ( aMouseTimer.IsActive() )
|
|
|
|
aMouseTimer.Stop();
|
|
|
|
GetParent()->MouseButtonUp( BrowserMouseEvent( this, rEvt ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
2004-05-10 12:20:31 +00:00
|
|
|
void BrowserDataWin::StartRowDividerDrag( const Point& _rStartPos )
|
|
|
|
{
|
|
|
|
long nDataRowHeight = GetParent()->GetDataRowHeight();
|
|
|
|
// the exact separation pos of the two rows
|
|
|
|
long nDragRowDividerCurrentPos = _rStartPos.Y();
|
|
|
|
if ( ( nDragRowDividerCurrentPos % nDataRowHeight ) > nDataRowHeight / 2 )
|
|
|
|
nDragRowDividerCurrentPos += nDataRowHeight;
|
|
|
|
nDragRowDividerCurrentPos /= nDataRowHeight;
|
|
|
|
nDragRowDividerCurrentPos *= nDataRowHeight;
|
|
|
|
|
|
|
|
m_nDragRowDividerOffset = nDragRowDividerCurrentPos - _rStartPos.Y();
|
|
|
|
|
|
|
|
m_nDragRowDividerLimit = nDragRowDividerCurrentPos - nDataRowHeight;
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
GetParent()->bRowDividerDrag = sal_True;
|
2004-05-10 12:20:31 +00:00
|
|
|
GetParent()->ImplStartTracking();
|
|
|
|
|
|
|
|
Rectangle aDragSplitRect( 0, m_nDragRowDividerLimit, GetOutputSizePixel().Width(), nDragRowDividerCurrentPos );
|
|
|
|
ShowTracking( aDragSplitRect, SHOWTRACK_SMALL );
|
|
|
|
|
|
|
|
StartTracking();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
|
|
|
void BrowserDataWin::Tracking( const TrackingEvent& rTEvt )
|
|
|
|
{
|
|
|
|
if ( !GetParent()->bRowDividerDrag )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
|
|
|
|
// stop resizing at our bottom line
|
|
|
|
if ( aMousePos.Y() > GetOutputSizePixel().Height() )
|
|
|
|
aMousePos.Y() = GetOutputSizePixel().Height();
|
|
|
|
|
|
|
|
if ( rTEvt.IsTrackingEnded() )
|
|
|
|
{
|
|
|
|
HideTracking();
|
2010-11-05 10:31:15 +08:00
|
|
|
GetParent()->bRowDividerDrag = sal_False;
|
2004-05-10 12:20:31 +00:00
|
|
|
GetParent()->ImplEndTracking();
|
|
|
|
|
|
|
|
if ( !rTEvt.IsTrackingCanceled() )
|
|
|
|
{
|
|
|
|
long nNewRowHeight = aMousePos.Y() + m_nDragRowDividerOffset - m_nDragRowDividerLimit;
|
|
|
|
|
|
|
|
// care for minimum row height
|
|
|
|
if ( nNewRowHeight < GetParent()->QueryMinimumRowHeight() )
|
|
|
|
nNewRowHeight = GetParent()->QueryMinimumRowHeight();
|
|
|
|
|
|
|
|
GetParent()->SetDataRowHeight( nNewRowHeight );
|
|
|
|
GetParent()->RowHeightChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GetParent()->ImplTracking();
|
|
|
|
|
|
|
|
long nDragRowDividerCurrentPos = aMousePos.Y() + m_nDragRowDividerOffset;
|
|
|
|
|
|
|
|
// care for minimum row height
|
|
|
|
if ( nDragRowDividerCurrentPos < m_nDragRowDividerLimit + GetParent()->QueryMinimumRowHeight() )
|
|
|
|
nDragRowDividerCurrentPos = m_nDragRowDividerLimit + GetParent()->QueryMinimumRowHeight();
|
|
|
|
|
|
|
|
Rectangle aDragSplitRect( 0, m_nDragRowDividerLimit, GetOutputSizePixel().Width(), nDragRowDividerCurrentPos );
|
|
|
|
ShowTracking( aDragSplitRect, SHOWTRACK_SMALL );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void BrowserDataWin::KeyInput( const KeyEvent& rEvt )
|
|
|
|
{
|
|
|
|
// pass to parent window
|
|
|
|
if ( !GetParent()->ProcessKey( rEvt ) )
|
|
|
|
Control::KeyInput( rEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
|
|
|
void BrowserDataWin::RequestHelp( const HelpEvent& rHEvt )
|
|
|
|
{
|
|
|
|
pEventWin = this;
|
|
|
|
GetParent()->RequestHelp( rHEvt );
|
|
|
|
pEventWin = GetParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
//===================================================================
|
|
|
|
|
|
|
|
BrowseEvent::BrowseEvent( Window* pWindow,
|
2010-11-05 10:31:15 +08:00
|
|
|
long nAbsRow, sal_uInt16 nColumn, sal_uInt16 nColumnId,
|
2000-09-18 16:07:07 +00:00
|
|
|
const Rectangle& rRect ):
|
|
|
|
pWin(pWindow),
|
|
|
|
nRow(nAbsRow),
|
2004-06-16 09:05:18 +00:00
|
|
|
aRect(rRect),
|
2000-09-18 16:07:07 +00:00
|
|
|
nCol(nColumn),
|
2004-06-16 09:05:18 +00:00
|
|
|
nColId(nColumnId)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//===================================================================
|
2006-06-19 19:40:06 +00:00
|
|
|
BrowserMouseEvent::BrowserMouseEvent( BrowserDataWin *pWindow,
|
2000-09-18 16:07:07 +00:00
|
|
|
const MouseEvent& rEvt ):
|
|
|
|
MouseEvent(rEvt),
|
2006-06-19 19:40:06 +00:00
|
|
|
BrowseEvent( pWindow->CreateBrowseEvent( rEvt.GetPosPixel() ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
2006-06-19 19:40:06 +00:00
|
|
|
BrowserMouseEvent::BrowserMouseEvent( Window *pWindow, const MouseEvent& rEvt,
|
2010-11-05 10:31:15 +08:00
|
|
|
long nAbsRow, sal_uInt16 nColumn, sal_uInt16 nColumnId,
|
2000-09-18 16:07:07 +00:00
|
|
|
const Rectangle& rRect ):
|
|
|
|
MouseEvent(rEvt),
|
2006-06-19 19:40:06 +00:00
|
|
|
BrowseEvent( pWindow, nAbsRow, nColumn, nColumnId, rRect )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-03-30 12:01:06 +00:00
|
|
|
//===================================================================
|
|
|
|
|
2006-06-19 19:40:06 +00:00
|
|
|
BrowserAcceptDropEvent::BrowserAcceptDropEvent( BrowserDataWin *pWindow, const AcceptDropEvent& rEvt )
|
2001-03-30 12:01:06 +00:00
|
|
|
:AcceptDropEvent(rEvt)
|
2006-06-19 19:40:06 +00:00
|
|
|
,BrowseEvent( pWindow->CreateBrowseEvent( rEvt.maPosPixel ) )
|
2001-03-30 12:01:06 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//===================================================================
|
|
|
|
|
2006-06-19 19:40:06 +00:00
|
|
|
BrowserExecuteDropEvent::BrowserExecuteDropEvent( BrowserDataWin *pWindow, const ExecuteDropEvent& rEvt )
|
2001-03-30 12:01:06 +00:00
|
|
|
:ExecuteDropEvent(rEvt)
|
2006-06-19 19:40:06 +00:00
|
|
|
,BrowseEvent( pWindow->CreateBrowseEvent( rEvt.maPosPixel ) )
|
2001-03-30 12:01:06 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//===================================================================
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
void BrowserDataWin::SetUpdateMode( sal_Bool bMode )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT( !bUpdateMode || aInvalidRegion.Count() == 0,
|
|
|
|
"invalid region not empty" );
|
|
|
|
if ( bMode == bUpdateMode )
|
|
|
|
return;
|
|
|
|
|
|
|
|
bUpdateMode = bMode;
|
|
|
|
if ( bMode )
|
|
|
|
DoOutstandingInvalidations();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
void BrowserDataWin::DoOutstandingInvalidations()
|
|
|
|
{
|
|
|
|
for ( Rectangle* pRect = aInvalidRegion.First();
|
|
|
|
pRect;
|
|
|
|
pRect = aInvalidRegion.Next() )
|
|
|
|
{
|
2006-06-19 19:40:06 +00:00
|
|
|
Control::Invalidate( *pRect );
|
2000-09-18 16:07:07 +00:00
|
|
|
delete pRect;
|
|
|
|
}
|
|
|
|
aInvalidRegion.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
void BrowserDataWin::Invalidate( sal_uInt16 nFlags )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( !GetUpdateMode() )
|
|
|
|
{
|
|
|
|
for ( Rectangle* pRect = aInvalidRegion.First();
|
|
|
|
pRect;
|
|
|
|
pRect = aInvalidRegion.Next() )
|
|
|
|
delete pRect;
|
|
|
|
aInvalidRegion.Clear();
|
2006-06-19 19:40:06 +00:00
|
|
|
aInvalidRegion.Insert( new Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
2006-06-19 19:40:06 +00:00
|
|
|
Window::Invalidate( nFlags );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
2010-11-05 10:31:15 +08:00
|
|
|
void BrowserDataWin::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( !GetUpdateMode() )
|
|
|
|
aInvalidRegion.Insert( new Rectangle( rRect ) );
|
|
|
|
else
|
2006-06-19 19:40:06 +00:00
|
|
|
Window::Invalidate( rRect, nFlags );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===================================================================
|
|
|
|
|
|
|
|
void BrowserScrollBar::Tracking( const TrackingEvent& rTEvt )
|
|
|
|
{
|
2010-11-05 10:31:15 +08:00
|
|
|
sal_uIntPtr nPos = GetThumbPos();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nPos != _nLastPos )
|
|
|
|
{
|
|
|
|
if ( _nTip )
|
|
|
|
Help::HideTip( _nTip );
|
|
|
|
|
|
|
|
String aTip( String::CreateFromInt32(nPos) );
|
|
|
|
aTip += '/';
|
|
|
|
if ( _pDataWin->GetRealRowCount().Len() )
|
|
|
|
aTip += _pDataWin->GetRealRowCount();
|
|
|
|
else
|
|
|
|
aTip += String::CreateFromInt32(GetRangeMax());
|
|
|
|
Rectangle aRect( GetPointerPosPixel(), Size( GetTextHeight(), GetTextWidth( aTip ) ) );
|
|
|
|
_nTip = Help::ShowTip( this, aRect, aTip );
|
|
|
|
_nLastPos = nPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollBar::Tracking( rTEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
|
|
|
void BrowserScrollBar::EndScroll()
|
|
|
|
{
|
|
|
|
if ( _nTip )
|
|
|
|
Help::HideTip( _nTip );
|
|
|
|
_nTip = 0;
|
|
|
|
ScrollBar::EndScroll();
|
|
|
|
}
|
|
|
|
|
|
|
|
|