Files
libreoffice/svtools/source/brwbox/datwin.cxx

751 lines
21 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patch contributed by: Jurgen Schmidt remove onlineregistration with dependencies http://svn.apache.org/viewvc?view=revision&revision=1240245 imported patch package_eventlistener.patch http://svn.apache.org/viewvc?view=revision&revision=1172103 Patch contributed by Pedro Giffuni Accept Google Chrome OS fonts as equivalent to MS fonts. http://svn.apache.org/viewvc?view=revision&revision=1233155 http://svn.apache.org/viewvc?view=revision&revision=1233408 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i114600#: remove forbidden characters from list of unencoded characters http://svn.apache.org/viewvc?view=revision&revision=1172370 Patches contributed by Oliver Rainer-Wittman some clean up in JPEGReader due to memory constraints http://svn.apache.org/viewvc?view=revision&revision=1299729 119114 - method <UpdateDialog::addSpecificError(..)> - create entry with correct type http://svn.apache.org/viewvc?view=revision&revision=1305265 Patches contributed by Ariel Constenla-Haile i118707 - make toolbar control's popup window grab focus http://svn.apache.org/viewvc?view=revision&revision=1225846 Patches contributed by Herbert Duerr #i118662# remove usage of BerkeleyDB in desktop module http://svn.apache.org/viewvc?view=revision&revision=1213171 minor cleanups in dp_persmap.* http://svn.apache.org/viewvc?view=revision&revision=1215064 flush early to prevent problem with extension manager not cleaning up its objects http://svn.apache.org/viewvc?view=revision&revision=1228147 i118726 do not flush *pmap file while reading it http://svn.apache.org/viewvc?view=revision&revision=1230614 #i119048# migrate BDB extension entries using a simple heuristic http://svn.apache.org/viewvc?view=revision&revision=1300972 #i119048# handle edge cases when importing BDB hash files http://svn.apache.org/viewvc?view=revision&revision=1301428 #i119113# fix of-by-one when importing BDB files http://svn.apache.org/viewvc?view=revision&revision=1305420 restore our encryption settings, icon themes, and dictionaries. removed wrapper hacks, kill obsolete bundled extension blob / pre-registration handling, remove duplicated quickstart code. remove OS/2 conditionals.
2012-11-15 17:28:16 +00:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 16:07:07 +00:00
2000-09-18 16:07:07 +00:00
#include "datwin.hxx"
#include <o3tl/numeric.hxx>
2000-09-18 16:07:07 +00:00
#include <vcl/svapp.hxx>
#include <vcl/help.hxx>
#include <vcl/image.hxx>
#include <vcl/settings.hxx>
#include <rtl/string.hxx>
2000-09-18 16:07:07 +00:00
#include <tools/debug.hxx>
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 );
rDev.DrawRect( aRect );
if( rDev.GetOutDevType() == OUTDEV_WINDOW )
{
vcl::Window *pWin = static_cast<vcl::Window*>( &rDev );
if( bPressed )
pWin->DrawSelectionBackground( aRect, 0, true, false, false );
}
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.isEmpty() )
2000-09-18 16:07:07 +00:00
{
OUString aVal = rDev.GetEllipsisString(aText,aInnerRect.GetWidth() - 2*MIN_COLUMNWIDTH);
vcl::Font aFont( rDev.GetFont() );
bool bOldTransp = aFont.IsTransparent();
2000-09-18 16:07:07 +00:00
if ( !bOldTransp )
{
aFont.SetTransparent( true );
2000-09-18 16:07:07 +00:00
rDev.SetFont( aFont );
}
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 );
// restore settings
2000-09-18 16:07:07 +00:00
if ( !bOldTransp )
{
aFont.SetTransparent(false);
2000-09-18 16:07:07 +00:00
rDev.SetFont( aFont );
}
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 );
}
BrowserColumn::BrowserColumn( sal_uInt16 nItemId, const class Image &rImage,
const OUString& rTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom )
2000-09-18 16:07:07 +00:00
: _nId( nItemId ),
_nWidth( nWidthPixel ),
_aImage( rImage ),
_aTitle( rTitle ),
_bFrozen( false )
2000-09-18 16:07:07 +00:00
{
double n = (double)_nWidth;
n *= (double)rCurrentZoom.GetDenominator();
if (!rCurrentZoom.GetNumerator())
throw o3tl::divide_by_zero();
n /= (double)rCurrentZoom.GetNumerator();
2000-09-18 16:07:07 +00:00
_nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
}
BrowserColumn::~BrowserColumn()
{
}
void BrowserColumn::SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom)
2000-09-18 16:07:07 +00:00
{
_nWidth = nNewWidthPixel;
double n = (double)_nWidth;
n *= (double)rCurrentZoom.GetDenominator();
if (!rCurrentZoom.GetNumerator())
throw o3tl::divide_by_zero();
n /= (double)rCurrentZoom.GetNumerator();
2000-09-18 16:07:07 +00:00
_nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
}
void BrowserColumn::Draw( BrowseBox& rBox, OutputDevice& rDev, const Point& rPos, bool bCurs )
2000-09-18 16:07:07 +00:00
{
if ( _nId == 0 )
{
// paint handle column
ButtonFrame( rPos, Size( Width()-1, rBox.GetDataRowHeight()-1 ),
"", false, bCurs, false ).Draw( rDev );
2000-09-18 16:07:07 +00:00
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 );
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();
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 ) ),
GetId(),
BrowseBox::BrowserColumnAccess() );
2000-09-18 16:07:07 +00:00
}
}
2000-09-18 16:07:07 +00:00
void BrowserColumn::ZoomChanged(const Fraction& rNewZoom)
2000-09-18 16:07:07 +00:00
{
double n = (double)_nOriginalWidth;
n *= (double)rNewZoom.GetNumerator();
n /= (double)rNewZoom.GetDenominator();
2000-09-18 16:07:07 +00:00
_nWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
}
2000-09-18 16:07:07 +00:00
BrowserDataWin::BrowserDataWin( BrowseBox* pParent )
:Control( pParent, WinBits(WB_CLIPCHILDREN) )
,DragSourceHelper( this )
,DropTargetHelper( this )
,pHeaderBar( 0 )
,pEventWin( pParent )
,pCornerWin( 0 )
,bInDtor( false )
,bInPaint( false )
,bInCommand( false )
,bNoScrollBack( false )
,bNoHScroll( false )
,bNoVScroll( false )
,bAutoHScroll(false)
,bAutoVScroll(false)
,bUpdateMode( true )
,bAutoSizeLastCol(false)
,bResizeOnPaint( false )
,bUpdateOnUnlock( false )
,bInUpdateScrollbars( false )
,bHadRecursion( false )
,bOwnDataChangedHdl( false )
,bCallingDropCallback( false )
,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 );
}
2000-09-18 16:07:07 +00:00
BrowserDataWin::~BrowserDataWin()
{
bInDtor = true;
for ( size_t i = 0, n = aInvalidRegion.size(); i < n; ++i )
delete aInvalidRegion[ i ];
aInvalidRegion.clear();
2000-09-18 16:07:07 +00:00
}
2000-09-18 16:07:07 +00:00
void BrowserDataWin::LeaveUpdateLock()
{
if ( !--nUpdateLock )
{
DoOutstandingInvalidations();
if (bUpdateOnUnlock )
{
Control::Update();
bUpdateOnUnlock = false;
2000-09-18 16:07:07 +00:00
}
}
}
void InitSettings_Impl( vcl::Window *pWin,
bool bFont, bool bForeground, bool bBackground )
2000-09-18 16:07:07 +00:00
{
const StyleSettings& rStyleSettings =
pWin->GetSettings().GetStyleSettings();
if ( bFont )
{
vcl::Font aFont = rStyleSettings.GetFieldFont();
2000-09-18 16:07:07 +00:00
if ( pWin->IsControlFont() )
aFont.Merge( pWin->GetControlFont() );
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() );
}
}
2000-09-18 16:07:07 +00:00
void BrowserDataWin::Update()
{
if ( !nUpdateLock )
Control::Update();
else
bUpdateOnUnlock = true;
2000-09-18 16:07:07 +00:00
}
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 )
{
InitSettings_Impl( this, true, true, true );
2000-09-18 16:07:07 +00:00
Invalidate();
InitSettings_Impl( GetParent(), true, true, true );
2000-09-18 16:07:07 +00:00
GetParent()->Invalidate();
GetParent()->Resize();
2000-09-18 16:07:07 +00:00
}
}
else
Control::DataChanged( rDCEvt );
}
2000-09-18 16:07:07 +00:00
void BrowserDataWin::Paint( const Rectangle& rRect )
{
if ( !nUpdateLock && GetUpdateMode() )
{
if ( bInPaint )
{
aInvalidRegion.push_back( new Rectangle( rRect ) );
return;
}
bInPaint = true;
2000-09-18 16:07:07 +00:00
( (BrowseBox*) GetParent() )->PaintData( *this, rRect );
bInPaint = false;
DoOutstandingInvalidations();
2000-09-18 16:07:07 +00:00
}
else
aInvalidRegion.push_back( new Rectangle( rRect ) );
2000-09-18 16:07:07 +00:00
}
2000-09-18 16:07:07 +00:00
BrowseEvent BrowserDataWin::CreateBrowseEvent( const Point& rPosPixel )
{
BrowseBox *pBox = GetParent();
// seek to row under mouse
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;
size_t nCol;
2000-09-18 16:07:07 +00:00
for ( nCol = 0;
nCol < pBox->pCols->size() && nColX < GetSizePixel().Width();
2000-09-18 16:07:07 +00:00
++nCol )
if ( (*pBox->pCols)[ nCol ]->IsFrozen() || nCol >= pBox->nFirstCol )
2000-09-18 16:07:07 +00:00
{
nColX += (*pBox->pCols)[ nCol ]->Width();
2000-09-18 16:07:07 +00:00
if ( nMouseX < nColX )
break;
}
sal_uInt16 nColId = BROWSER_INVALIDID;
if ( nCol < pBox->pCols->size() )
nColId = (*pBox->pCols)[ nCol ]->GetId();
2000-09-18 16:07:07 +00:00
// compute the field rectangle and field relative MouseEvent
Rectangle aFieldRect;
if ( nCol < pBox->pCols->size() )
2000-09-18 16:07:07 +00:00
{
nColX -= (*pBox->pCols)[ nCol ]->Width();
2000-09-18 16:07:07 +00:00
aFieldRect = Rectangle(
Point( nColX, nRelRow * pBox->GetDataRowHeight() ),
Size( (*pBox->pCols)[ nCol ]->Width(),
2000-09-18 16:07:07 +00:00
pBox->GetDataRowHeight() ) );
}
// assemble and return the BrowseEvent
return BrowseEvent( this, nRow, nCol, nColId, aFieldRect );
}
sal_Int8 BrowserDataWin::AcceptDrop( const AcceptDropEvent& _rEvt )
{
bCallingDropCallback = true;
sal_Int8 nReturn = GetParent()->AcceptDrop( BrowserAcceptDropEvent( this, _rEvt ) );
bCallingDropCallback = false;
return nReturn;
}
sal_Int8 BrowserDataWin::ExecuteDrop( const ExecuteDropEvent& _rEvt )
{
bCallingDropCallback = true;
sal_Int8 nReturn = GetParent()->ExecuteDrop( BrowserExecuteDropEvent( this, _rEvt ) );
bCallingDropCallback = false;
return nReturn;
}
2001-03-27 10:47:48 +00:00
void BrowserDataWin::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel )
{
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 )
{
// scroll mouse event?
2000-09-18 16:07:07 +00:00
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() );
long nRow = pBox->GetRowAtYPosPixel( aEventPos.Y(), false);
MouseEvent aMouseEvt( aEventPos, 1, MouseEventModifiers::SELECT, MOUSE_LEFT );
2000-09-18 16:07:07 +00:00
if ( COMMAND_CONTEXTMENU == rEvt.GetCommand() && rEvt.IsMouseEvent() &&
nRow < pBox->GetRowCount() && !pBox->IsRowSelected(nRow) )
{
bInCommand = true;
2000-09-18 16:07:07 +00:00
MouseButtonDown( aMouseEvt );
if( bInDtor )
2000-09-18 16:07:07 +00:00
return;
MouseButtonUp( aMouseEvt );
if( bInDtor )
2000-09-18 16:07:07 +00:00
return;
bInCommand = false;
2000-09-18 16:07:07 +00:00
}
aEventPos.Y() += GetParent()->GetTitleHeight();
CommandEvent aEvt( aEventPos, rEvt.GetCommand(),
rEvt.IsMouseEvent(), rEvt.GetData() );
bInCommand = true;
2000-09-18 16:07:07 +00:00
GetParent()->Command( aEvt );
if( bInDtor )
2000-09-18 16:07:07 +00:00
return;
bInCommand = false;
2000-09-18 16:07:07 +00:00
if ( COMMAND_STARTDRAG == rEvt.GetCommand() )
MouseButtonUp( aMouseEvt );
Control::Command( rEvt );
}
2000-09-18 16:07:07 +00:00
bool BrowserDataWin::ImplRowDividerHitTest( const BrowserMouseEvent& _rEvent )
{
if ( ! ( GetParent()->IsInteractiveRowHeightEnabled()
&& ( _rEvent.GetRow() >= 0 )
&& ( _rEvent.GetRow() < GetParent()->GetRowCount() )
&& ( _rEvent.GetColumnId() == BrowseBox::HandleColumnId )
)
)
return false;
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() );
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 ) );
}
2000-09-18 16:07:07 +00:00
void BrowserDataWin::MouseMove( const MouseEvent& rEvt )
{
// avoid pseudo MouseMoves
2000-09-18 16:07:07 +00:00
Point aNewPos = OutputToScreenPixel( rEvt.GetPosPixel() );
if ( ( aNewPos == aLastMousePos ) )
2000-09-18 16:07:07 +00:00
return;
aLastMousePos = aNewPos;
// transform to a BrowseEvent
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();
}
2000-09-18 16:07:07 +00:00
IMPL_LINK_NOARG_INLINE_START(BrowserDataWin, RepeatedMouseMove)
2000-09-18 16:07:07 +00:00
{
GetParent()->MouseMove( BrowserMouseEvent( this, aRepeatEvt ) );
return 0;
}
IMPL_LINK_NOARG_INLINE_END(BrowserDataWin, RepeatedMouseMove)
2000-09-18 16:07:07 +00:00
2000-09-18 16:07:07 +00:00
void BrowserDataWin::MouseButtonUp( const MouseEvent& rEvt )
{
// avoid pseudo MouseMoves
2000-09-18 16:07:07 +00:00
Point aNewPos = OutputToScreenPixel( rEvt.GetPosPixel() );
aLastMousePos = aNewPos;
// simulate a move to the current position
2000-09-18 16:07:07 +00:00
MouseMove( rEvt );
// actual button up handling
2000-09-18 16:07:07 +00:00
ReleaseMouse();
if ( aMouseTimer.IsActive() )
aMouseTimer.Stop();
GetParent()->MouseButtonUp( BrowserMouseEvent( this, rEvt ) );
}
2000-09-18 16:07:07 +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;
GetParent()->bRowDividerDrag = true;
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();
GetParent()->bRowDividerDrag = false;
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 );
}
2000-09-18 16:07:07 +00:00
void BrowserDataWin::RequestHelp( const HelpEvent& rHEvt )
{
pEventWin = this;
GetParent()->RequestHelp( rHEvt );
pEventWin = GetParent();
}
2000-09-18 16:07:07 +00:00
BrowseEvent::BrowseEvent( vcl::Window* pWindow,
long nAbsRow, sal_uInt16 nColumn, sal_uInt16 nColumnId,
2000-09-18 16:07:07 +00:00
const Rectangle& rRect ):
pWin(pWindow),
nRow(nAbsRow),
aRect(rRect),
2000-09-18 16:07:07 +00:00
nCol(nColumn),
nColId(nColumnId)
2000-09-18 16:07:07 +00:00
{
}
BrowserMouseEvent::BrowserMouseEvent( BrowserDataWin *pWindow,
2000-09-18 16:07:07 +00:00
const MouseEvent& rEvt ):
MouseEvent(rEvt),
BrowseEvent( pWindow->CreateBrowseEvent( rEvt.GetPosPixel() ) )
2000-09-18 16:07:07 +00:00
{
}
2000-09-18 16:07:07 +00:00
BrowserMouseEvent::BrowserMouseEvent( vcl::Window *pWindow, const MouseEvent& rEvt,
long nAbsRow, sal_uInt16 nColumn, sal_uInt16 nColumnId,
2000-09-18 16:07:07 +00:00
const Rectangle& rRect ):
MouseEvent(rEvt),
BrowseEvent( pWindow, nAbsRow, nColumn, nColumnId, rRect )
2000-09-18 16:07:07 +00:00
{
}
BrowserAcceptDropEvent::BrowserAcceptDropEvent( BrowserDataWin *pWindow, const AcceptDropEvent& rEvt )
:AcceptDropEvent(rEvt)
,BrowseEvent( pWindow->CreateBrowseEvent( rEvt.maPosPixel ) )
{
}
BrowserExecuteDropEvent::BrowserExecuteDropEvent( BrowserDataWin *pWindow, const ExecuteDropEvent& rEvt )
:ExecuteDropEvent(rEvt)
,BrowseEvent( pWindow->CreateBrowseEvent( rEvt.maPosPixel ) )
{
}
2000-09-18 16:07:07 +00:00
void BrowserDataWin::SetUpdateMode( bool bMode )
2000-09-18 16:07:07 +00:00
{
DBG_ASSERT( !bUpdateMode || aInvalidRegion.empty(), "invalid region not empty" );
if ( (bool) bMode == bUpdateMode )
2000-09-18 16:07:07 +00:00
return;
bUpdateMode = bMode;
if ( bMode )
DoOutstandingInvalidations();
}
2000-09-18 16:07:07 +00:00
void BrowserDataWin::DoOutstandingInvalidations()
{
for ( size_t i = 0, n = aInvalidRegion.size(); i < n; ++i ) {
Control::Invalidate( *aInvalidRegion[ i ] );
delete aInvalidRegion[ i ];
2000-09-18 16:07:07 +00:00
}
aInvalidRegion.clear();
2000-09-18 16:07:07 +00:00
}
2000-09-18 16:07:07 +00:00
void BrowserDataWin::Invalidate( sal_uInt16 nFlags )
2000-09-18 16:07:07 +00:00
{
if ( !GetUpdateMode() )
{
for ( size_t i = 0, n = aInvalidRegion.size(); i < n; ++i )
delete aInvalidRegion[ i ];
aInvalidRegion.clear();
aInvalidRegion.push_back( new Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) );
2000-09-18 16:07:07 +00:00
}
else
Window::Invalidate( nFlags );
2000-09-18 16:07:07 +00:00
}
2000-09-18 16:07:07 +00:00
void BrowserDataWin::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags )
2000-09-18 16:07:07 +00:00
{
if ( !GetUpdateMode() )
aInvalidRegion.push_back( new Rectangle( rRect ) );
2000-09-18 16:07:07 +00:00
else
Window::Invalidate( rRect, nFlags );
2000-09-18 16:07:07 +00:00
}
2000-09-18 16:07:07 +00:00
void BrowserScrollBar::Tracking( const TrackingEvent& rTEvt )
{
sal_uLong nPos = GetThumbPos();
2000-09-18 16:07:07 +00:00
if ( nPos != _nLastPos )
{
OUString aTip( OUString::number(nPos) );
aTip += "/";
if ( !_pDataWin->GetRealRowCount().isEmpty() )
2000-09-18 16:07:07 +00:00
aTip += _pDataWin->GetRealRowCount();
else
aTip += OUString::number(GetRangeMax());
2000-09-18 16:07:07 +00:00
Rectangle aRect( GetPointerPosPixel(), Size( GetTextHeight(), GetTextWidth( aTip ) ) );
if ( _nTip )
Help::UpdateTip( _nTip, this, aRect, aTip );
else
_nTip = Help::ShowTip( this, aRect, aTip );
2000-09-18 16:07:07 +00:00
_nLastPos = nPos;
}
ScrollBar::Tracking( rTEvt );
}
2000-09-18 16:07:07 +00:00
void BrowserScrollBar::EndScroll()
{
if ( _nTip )
Help::HideTip( _nTip );
_nTip = 0;
ScrollBar::EndScroll();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */