bump product version to 4.1.6.2
[LibreOffice.git] / svtools / source / brwbox / datwin.cxx
blob29ae1b53c574fa6c0d5a1bb7966d2375c4527770
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "datwin.hxx"
23 #include <vcl/svapp.hxx>
25 #include <vcl/help.hxx>
26 #include <vcl/image.hxx>
28 #include <tools/debug.hxx>
30 //===================================================================
31 void ButtonFrame::Draw( OutputDevice& rDev )
33 Color aOldFillColor = rDev.GetFillColor();
34 Color aOldLineColor = rDev.GetLineColor();
36 const StyleSettings &rSettings = rDev.GetSettings().GetStyleSettings();
37 Color aColLight( rSettings.GetLightColor() );
38 Color aColShadow( rSettings.GetShadowColor() );
39 Color aColFace( rSettings.GetFaceColor() );
41 rDev.SetLineColor( aColFace );
42 rDev.SetFillColor( aColFace );
43 rDev.DrawRect( aRect );
45 if( rDev.GetOutDevType() == OUTDEV_WINDOW )
47 Window *pWin = (Window*) &rDev;
48 if( bPressed )
49 pWin->DrawSelectionBackground( aRect, 0, sal_True, sal_False, sal_False );
51 else
53 rDev.SetLineColor( bPressed ? aColShadow : aColLight );
54 rDev.DrawLine( aRect.TopLeft(), Point( aRect.Right(), aRect.Top() ) );
55 rDev.DrawLine( aRect.TopLeft(), Point( aRect.Left(), aRect.Bottom() - 1 ) );
56 rDev.SetLineColor( bPressed ? aColLight : aColShadow );
57 rDev.DrawLine( aRect.BottomRight(), Point( aRect.Right(), aRect.Top() ) );
58 rDev.DrawLine( aRect.BottomRight(), Point( aRect.Left(), aRect.Bottom() ) );
61 if ( aText.Len() )
63 OUString aVal = rDev.GetEllipsisString(aText,aInnerRect.GetWidth() - 2*MIN_COLUMNWIDTH);
65 Font aFont( rDev.GetFont() );
66 sal_Bool bOldTransp = aFont.IsTransparent();
67 if ( !bOldTransp )
69 aFont.SetTransparent( sal_True );
70 rDev.SetFont( aFont );
73 Color aOldColor = rDev.GetTextColor();
74 if (m_bDrawDisabled)
75 rDev.SetTextColor(rSettings.GetDisableColor());
77 rDev.DrawText( Point(
78 ( aInnerRect.Left() + aInnerRect.Right() ) / 2 - ( rDev.GetTextWidth(aVal) / 2 ),
79 aInnerRect.Top() ), aVal );
81 // restore settings
82 if ( !bOldTransp )
84 aFont.SetTransparent(sal_False);
85 rDev.SetFont( aFont );
87 if (m_bDrawDisabled)
88 rDev.SetTextColor(aOldColor);
91 if ( bCurs )
93 rDev.SetLineColor( Color( COL_BLACK ) );
94 rDev.SetFillColor();
95 rDev.DrawRect( Rectangle(
96 Point( aRect.Left(), aRect.Top() ), Point( aRect.Right(), aRect.Bottom() ) ) );
99 rDev.SetLineColor( aOldLineColor );
100 rDev.SetFillColor( aOldFillColor );
103 //-------------------------------------------------------------------
105 BrowserColumn::BrowserColumn( sal_uInt16 nItemId, const class Image &rImage,
106 const String& rTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom )
107 : _nId( nItemId ),
108 _nWidth( nWidthPixel ),
109 _aImage( rImage ),
110 _aTitle( rTitle ),
111 _bFrozen( sal_False )
113 double n = (double)_nWidth;
114 n *= (double)rCurrentZoom.GetDenominator();
115 n /= (double)rCurrentZoom.GetNumerator();
116 _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
119 BrowserColumn::~BrowserColumn()
123 //-------------------------------------------------------------------
125 void BrowserColumn::SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom)
127 _nWidth = nNewWidthPixel;
128 double n = (double)_nWidth;
129 n *= (double)rCurrentZoom.GetDenominator();
130 n /= (double)rCurrentZoom.GetNumerator();
131 _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
134 //-------------------------------------------------------------------
136 void BrowserColumn::Draw( BrowseBox& rBox, OutputDevice& rDev, const Point& rPos, sal_Bool bCurs )
138 if ( _nId == 0 )
140 // paint handle column
141 ButtonFrame( rPos, Size( Width()-1, rBox.GetDataRowHeight()-1 ),
142 String(), sal_False, bCurs, false ).Draw( rDev );
143 Color aOldLineColor = rDev.GetLineColor();
144 rDev.SetLineColor( Color( COL_BLACK ) );
145 rDev.DrawLine(
146 Point( rPos.X(), rPos.Y()+rBox.GetDataRowHeight()-1 ),
147 Point( rPos.X() + Width() - 1, rPos.Y()+rBox.GetDataRowHeight()-1 ) );
148 rDev.DrawLine(
149 Point( rPos.X() + Width() - 1, rPos.Y() ),
150 Point( rPos.X() + Width() - 1, rPos.Y()+rBox.GetDataRowHeight()-1 ) );
151 rDev.SetLineColor( aOldLineColor );
153 rBox.DoPaintField( rDev,
154 Rectangle(
155 Point( rPos.X() + 2, rPos.Y() + 2 ),
156 Size( Width()-1, rBox.GetDataRowHeight()-1 ) ),
157 GetId(),
158 BrowseBox::BrowserColumnAccess() );
160 else
162 // paint data column
163 long nWidth = Width() == LONG_MAX ? rBox.GetDataWindow().GetSizePixel().Width() : Width();
165 rBox.DoPaintField( rDev,
166 Rectangle(
167 Point( rPos.X() + MIN_COLUMNWIDTH, rPos.Y() ),
168 Size( nWidth-2*MIN_COLUMNWIDTH, rBox.GetDataRowHeight()-1 ) ),
169 GetId(),
170 BrowseBox::BrowserColumnAccess() );
174 //-------------------------------------------------------------------
176 void BrowserColumn::ZoomChanged(const Fraction& rNewZoom)
178 double n = (double)_nOriginalWidth;
179 n *= (double)rNewZoom.GetNumerator();
180 n /= (double)rNewZoom.GetDenominator();
182 _nWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
185 //-------------------------------------------------------------------
187 BrowserDataWin::BrowserDataWin( BrowseBox* pParent )
188 :Control( pParent, WinBits(WB_CLIPCHILDREN) )
189 ,DragSourceHelper( this )
190 ,DropTargetHelper( this )
191 ,pHeaderBar( 0 )
192 ,pEventWin( pParent )
193 ,pCornerWin( 0 )
194 ,pDtorNotify( 0 )
195 ,bInPaint( sal_False )
196 ,bInCommand( sal_False )
197 ,bNoScrollBack( sal_False )
198 ,bNoHScroll( sal_False )
199 ,bNoVScroll( sal_False )
200 ,bUpdateMode( sal_True )
201 ,bResizeOnPaint( sal_False )
202 ,bUpdateOnUnlock( sal_False )
203 ,bInUpdateScrollbars( sal_False )
204 ,bHadRecursion( sal_False )
205 ,bOwnDataChangedHdl( sal_False )
206 ,bCallingDropCallback( sal_False )
207 ,nUpdateLock( 0 )
208 ,nCursorHidden( 0 )
209 ,m_nDragRowDividerLimit( 0 )
210 ,m_nDragRowDividerOffset( 0 )
212 aMouseTimer.SetTimeoutHdl( LINK( this, BrowserDataWin, RepeatedMouseMove ) );
213 aMouseTimer.SetTimeout( 100 );
216 //-------------------------------------------------------------------
217 BrowserDataWin::~BrowserDataWin()
219 if( pDtorNotify )
220 *pDtorNotify = sal_True;
222 for ( size_t i = 0, n = aInvalidRegion.size(); i < n; ++i )
223 delete aInvalidRegion[ i ];
224 aInvalidRegion.clear();
227 //-------------------------------------------------------------------
228 void BrowserDataWin::LeaveUpdateLock()
230 if ( !--nUpdateLock )
232 DoOutstandingInvalidations();
233 if (bUpdateOnUnlock )
235 Control::Update();
236 bUpdateOnUnlock = sal_False;
241 //-------------------------------------------------------------------
242 void InitSettings_Impl( Window *pWin,
243 sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
245 const StyleSettings& rStyleSettings =
246 pWin->GetSettings().GetStyleSettings();
248 if ( bFont )
250 Font aFont = rStyleSettings.GetFieldFont();
251 if ( pWin->IsControlFont() )
252 aFont.Merge( pWin->GetControlFont() );
253 pWin->SetZoomedPointFont( aFont );
256 if ( bFont || bForeground )
258 Color aTextColor = rStyleSettings.GetWindowTextColor();
259 if ( pWin->IsControlForeground() )
260 aTextColor = pWin->GetControlForeground();
261 pWin->SetTextColor( aTextColor );
264 if ( bBackground )
266 if( pWin->IsControlBackground() )
267 pWin->SetBackground( pWin->GetControlBackground() );
268 else
269 pWin->SetBackground( rStyleSettings.GetWindowColor() );
273 //-------------------------------------------------------------------
274 void BrowserDataWin::Update()
276 if ( !nUpdateLock )
277 Control::Update();
278 else
279 bUpdateOnUnlock = sal_True;
282 //-------------------------------------------------------------------
283 void BrowserDataWin::DataChanged( const DataChangedEvent& rDCEvt )
285 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
286 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
288 if( !bOwnDataChangedHdl )
290 InitSettings_Impl( this, sal_True, sal_True, sal_True );
291 Invalidate();
292 InitSettings_Impl( GetParent(), sal_True, sal_True, sal_True );
293 GetParent()->Invalidate();
294 GetParent()->Resize();
297 else
298 Control::DataChanged( rDCEvt );
301 //-------------------------------------------------------------------
302 void BrowserDataWin::Paint( const Rectangle& rRect )
304 if ( !nUpdateLock && GetUpdateMode() )
306 if ( bInPaint )
308 aInvalidRegion.push_back( new Rectangle( rRect ) );
309 return;
311 bInPaint = sal_True;
312 ( (BrowseBox*) GetParent() )->PaintData( *this, rRect );
313 bInPaint = sal_False;
314 DoOutstandingInvalidations();
316 else
317 aInvalidRegion.push_back( new Rectangle( rRect ) );
320 //-------------------------------------------------------------------
322 BrowseEvent BrowserDataWin::CreateBrowseEvent( const Point& rPosPixel )
324 BrowseBox *pBox = GetParent();
326 // seek to row under mouse
327 long nRelRow = rPosPixel.Y() < 0
328 ? -1
329 : rPosPixel.Y() / pBox->GetDataRowHeight();
330 long nRow = nRelRow < 0 ? -1 : nRelRow + pBox->nTopRow;
332 // find column under mouse
333 long nMouseX = rPosPixel.X();
334 long nColX = 0;
335 size_t nCol;
336 for ( nCol = 0;
337 nCol < pBox->pCols->size() && nColX < GetSizePixel().Width();
338 ++nCol )
339 if ( (*pBox->pCols)[ nCol ]->IsFrozen() || nCol >= pBox->nFirstCol )
341 nColX += (*pBox->pCols)[ nCol ]->Width();
342 if ( nMouseX < nColX )
343 break;
345 sal_uInt16 nColId = BROWSER_INVALIDID;
346 if ( nCol < pBox->pCols->size() )
347 nColId = (*pBox->pCols)[ nCol ]->GetId();
349 // compute the field rectangle and field relative MouseEvent
350 Rectangle aFieldRect;
351 if ( nCol < pBox->pCols->size() )
353 nColX -= (*pBox->pCols)[ nCol ]->Width();
354 aFieldRect = Rectangle(
355 Point( nColX, nRelRow * pBox->GetDataRowHeight() ),
356 Size( (*pBox->pCols)[ nCol ]->Width(),
357 pBox->GetDataRowHeight() ) );
360 // assemble and return the BrowseEvent
361 return BrowseEvent( this, nRow, nCol, nColId, aFieldRect );
364 //-------------------------------------------------------------------
365 sal_Int8 BrowserDataWin::AcceptDrop( const AcceptDropEvent& _rEvt )
367 bCallingDropCallback = sal_True;
368 sal_Int8 nReturn = GetParent()->AcceptDrop( BrowserAcceptDropEvent( this, _rEvt ) );
369 bCallingDropCallback = sal_False;
370 return nReturn;
373 //-------------------------------------------------------------------
374 sal_Int8 BrowserDataWin::ExecuteDrop( const ExecuteDropEvent& _rEvt )
376 bCallingDropCallback = sal_True;
377 sal_Int8 nReturn = GetParent()->ExecuteDrop( BrowserExecuteDropEvent( this, _rEvt ) );
378 bCallingDropCallback = sal_False;
379 return nReturn;
382 //-------------------------------------------------------------------
383 void BrowserDataWin::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel )
385 if ( !GetParent()->bRowDividerDrag )
387 Point aEventPos( _rPosPixel );
388 aEventPos.Y() += GetParent()->GetTitleHeight();
389 GetParent()->StartDrag( _nAction, aEventPos );
393 //-------------------------------------------------------------------
394 void BrowserDataWin::Command( const CommandEvent& rEvt )
396 // scroll mouse event?
397 BrowseBox *pBox = GetParent();
398 if ( ( (rEvt.GetCommand() == COMMAND_WHEEL) ||
399 (rEvt.GetCommand() == COMMAND_STARTAUTOSCROLL) ||
400 (rEvt.GetCommand() == COMMAND_AUTOSCROLL) ) &&
401 ( HandleScrollCommand( rEvt, &pBox->aHScroll, pBox->pVScroll ) ) )
402 return;
404 Point aEventPos( rEvt.GetMousePosPixel() );
405 long nRow = pBox->GetRowAtYPosPixel( aEventPos.Y(), sal_False);
406 MouseEvent aMouseEvt( aEventPos, 1, MOUSE_SELECT, MOUSE_LEFT );
407 if ( COMMAND_CONTEXTMENU == rEvt.GetCommand() && rEvt.IsMouseEvent() &&
408 nRow < pBox->GetRowCount() && !pBox->IsRowSelected(nRow) )
410 sal_Bool bDeleted = sal_False;
411 pDtorNotify = &bDeleted;
412 bInCommand = sal_True;
413 MouseButtonDown( aMouseEvt );
414 if( bDeleted )
415 return;
416 MouseButtonUp( aMouseEvt );
417 if( bDeleted )
418 return;
419 pDtorNotify = 0;
420 bInCommand = sal_False;
423 aEventPos.Y() += GetParent()->GetTitleHeight();
424 CommandEvent aEvt( aEventPos, rEvt.GetCommand(),
425 rEvt.IsMouseEvent(), rEvt.GetData() );
426 bInCommand = sal_True;
427 sal_Bool bDeleted = sal_False;
428 pDtorNotify = &bDeleted;
429 GetParent()->Command( aEvt );
430 if( bDeleted )
431 return;
432 pDtorNotify = 0;
433 bInCommand = sal_False;
435 if ( COMMAND_STARTDRAG == rEvt.GetCommand() )
436 MouseButtonUp( aMouseEvt );
438 Control::Command( rEvt );
441 //-------------------------------------------------------------------
443 sal_Bool BrowserDataWin::ImplRowDividerHitTest( const BrowserMouseEvent& _rEvent )
445 if ( ! ( GetParent()->IsInteractiveRowHeightEnabled()
446 && ( _rEvent.GetRow() >= 0 )
447 && ( _rEvent.GetRow() < GetParent()->GetRowCount() )
448 && ( _rEvent.GetColumnId() == BrowseBox::HandleColumnId )
451 return sal_False;
453 long nDividerDistance = GetParent()->GetDataRowHeight() - ( _rEvent.GetPosPixel().Y() % GetParent()->GetDataRowHeight() );
454 return ( nDividerDistance <= 4 );
457 //-------------------------------------------------------------------
459 void BrowserDataWin::MouseButtonDown( const MouseEvent& rEvt )
461 aLastMousePos = OutputToScreenPixel( rEvt.GetPosPixel() );
463 BrowserMouseEvent aBrowserEvent( this, rEvt );
464 if ( ( aBrowserEvent.GetClicks() == 1 ) && ImplRowDividerHitTest( aBrowserEvent ) )
466 StartRowDividerDrag( aBrowserEvent.GetPosPixel() );
467 return;
470 GetParent()->MouseButtonDown( BrowserMouseEvent( this, rEvt ) );
473 //-------------------------------------------------------------------
475 void BrowserDataWin::MouseMove( const MouseEvent& rEvt )
477 // avoid pseudo MouseMoves
478 Point aNewPos = OutputToScreenPixel( rEvt.GetPosPixel() );
479 if ( ( aNewPos == aLastMousePos ) )
480 return;
481 aLastMousePos = aNewPos;
483 // transform to a BrowseEvent
484 BrowserMouseEvent aBrowserEvent( this, rEvt );
485 GetParent()->MouseMove( aBrowserEvent );
487 // pointer shape
488 PointerStyle ePointerStyle = POINTER_ARROW;
489 if ( ImplRowDividerHitTest( aBrowserEvent ) )
490 ePointerStyle = POINTER_VSIZEBAR;
491 SetPointer( Pointer( ePointerStyle ) );
493 // dragging out of the visible area?
494 if ( rEvt.IsLeft() &&
495 ( rEvt.GetPosPixel().Y() > GetSizePixel().Height() ||
496 rEvt.GetPosPixel().Y() < 0 ) )
498 // repeat the event
499 aRepeatEvt = rEvt;
500 aMouseTimer.Start();
502 else
503 // killing old repeat-event
504 if ( aMouseTimer.IsActive() )
505 aMouseTimer.Stop();
508 //-------------------------------------------------------------------
510 IMPL_LINK_NOARG_INLINE_START(BrowserDataWin, RepeatedMouseMove)
512 GetParent()->MouseMove( BrowserMouseEvent( this, aRepeatEvt ) );
513 return 0;
515 IMPL_LINK_NOARG_INLINE_END(BrowserDataWin, RepeatedMouseMove)
517 //-------------------------------------------------------------------
519 void BrowserDataWin::MouseButtonUp( const MouseEvent& rEvt )
521 // avoid pseudo MouseMoves
522 Point aNewPos = OutputToScreenPixel( rEvt.GetPosPixel() );
523 aLastMousePos = aNewPos;
525 // simulate a move to the current position
526 MouseMove( rEvt );
528 // actual button up handling
529 ReleaseMouse();
530 if ( aMouseTimer.IsActive() )
531 aMouseTimer.Stop();
532 GetParent()->MouseButtonUp( BrowserMouseEvent( this, rEvt ) );
535 //-------------------------------------------------------------------
537 void BrowserDataWin::StartRowDividerDrag( const Point& _rStartPos )
539 long nDataRowHeight = GetParent()->GetDataRowHeight();
540 // the exact separation pos of the two rows
541 long nDragRowDividerCurrentPos = _rStartPos.Y();
542 if ( ( nDragRowDividerCurrentPos % nDataRowHeight ) > nDataRowHeight / 2 )
543 nDragRowDividerCurrentPos += nDataRowHeight;
544 nDragRowDividerCurrentPos /= nDataRowHeight;
545 nDragRowDividerCurrentPos *= nDataRowHeight;
547 m_nDragRowDividerOffset = nDragRowDividerCurrentPos - _rStartPos.Y();
549 m_nDragRowDividerLimit = nDragRowDividerCurrentPos - nDataRowHeight;
551 GetParent()->bRowDividerDrag = sal_True;
552 GetParent()->ImplStartTracking();
554 Rectangle aDragSplitRect( 0, m_nDragRowDividerLimit, GetOutputSizePixel().Width(), nDragRowDividerCurrentPos );
555 ShowTracking( aDragSplitRect, SHOWTRACK_SMALL );
557 StartTracking();
560 //-------------------------------------------------------------------
562 void BrowserDataWin::Tracking( const TrackingEvent& rTEvt )
564 if ( !GetParent()->bRowDividerDrag )
565 return;
567 Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
568 // stop resizing at our bottom line
569 if ( aMousePos.Y() > GetOutputSizePixel().Height() )
570 aMousePos.Y() = GetOutputSizePixel().Height();
572 if ( rTEvt.IsTrackingEnded() )
574 HideTracking();
575 GetParent()->bRowDividerDrag = sal_False;
576 GetParent()->ImplEndTracking();
578 if ( !rTEvt.IsTrackingCanceled() )
580 long nNewRowHeight = aMousePos.Y() + m_nDragRowDividerOffset - m_nDragRowDividerLimit;
582 // care for minimum row height
583 if ( nNewRowHeight < GetParent()->QueryMinimumRowHeight() )
584 nNewRowHeight = GetParent()->QueryMinimumRowHeight();
586 GetParent()->SetDataRowHeight( nNewRowHeight );
587 GetParent()->RowHeightChanged();
590 else
592 GetParent()->ImplTracking();
594 long nDragRowDividerCurrentPos = aMousePos.Y() + m_nDragRowDividerOffset;
596 // care for minimum row height
597 if ( nDragRowDividerCurrentPos < m_nDragRowDividerLimit + GetParent()->QueryMinimumRowHeight() )
598 nDragRowDividerCurrentPos = m_nDragRowDividerLimit + GetParent()->QueryMinimumRowHeight();
600 Rectangle aDragSplitRect( 0, m_nDragRowDividerLimit, GetOutputSizePixel().Width(), nDragRowDividerCurrentPos );
601 ShowTracking( aDragSplitRect, SHOWTRACK_SMALL );
605 //-------------------------------------------------------------------
607 void BrowserDataWin::KeyInput( const KeyEvent& rEvt )
609 // pass to parent window
610 if ( !GetParent()->ProcessKey( rEvt ) )
611 Control::KeyInput( rEvt );
614 //-------------------------------------------------------------------
616 void BrowserDataWin::RequestHelp( const HelpEvent& rHEvt )
618 pEventWin = this;
619 GetParent()->RequestHelp( rHEvt );
620 pEventWin = GetParent();
623 //===================================================================
625 BrowseEvent::BrowseEvent( Window* pWindow,
626 long nAbsRow, sal_uInt16 nColumn, sal_uInt16 nColumnId,
627 const Rectangle& rRect ):
628 pWin(pWindow),
629 nRow(nAbsRow),
630 aRect(rRect),
631 nCol(nColumn),
632 nColId(nColumnId)
636 //===================================================================
637 BrowserMouseEvent::BrowserMouseEvent( BrowserDataWin *pWindow,
638 const MouseEvent& rEvt ):
639 MouseEvent(rEvt),
640 BrowseEvent( pWindow->CreateBrowseEvent( rEvt.GetPosPixel() ) )
644 //-------------------------------------------------------------------
646 BrowserMouseEvent::BrowserMouseEvent( Window *pWindow, const MouseEvent& rEvt,
647 long nAbsRow, sal_uInt16 nColumn, sal_uInt16 nColumnId,
648 const Rectangle& rRect ):
649 MouseEvent(rEvt),
650 BrowseEvent( pWindow, nAbsRow, nColumn, nColumnId, rRect )
654 //===================================================================
656 BrowserAcceptDropEvent::BrowserAcceptDropEvent( BrowserDataWin *pWindow, const AcceptDropEvent& rEvt )
657 :AcceptDropEvent(rEvt)
658 ,BrowseEvent( pWindow->CreateBrowseEvent( rEvt.maPosPixel ) )
662 //===================================================================
664 BrowserExecuteDropEvent::BrowserExecuteDropEvent( BrowserDataWin *pWindow, const ExecuteDropEvent& rEvt )
665 :ExecuteDropEvent(rEvt)
666 ,BrowseEvent( pWindow->CreateBrowseEvent( rEvt.maPosPixel ) )
670 //===================================================================
672 //-------------------------------------------------------------------
674 void BrowserDataWin::SetUpdateMode( sal_Bool bMode )
676 DBG_ASSERT( !bUpdateMode || aInvalidRegion.empty(), "invalid region not empty" );
677 if ( (bool) bMode == bUpdateMode )
678 return;
680 bUpdateMode = bMode;
681 if ( bMode )
682 DoOutstandingInvalidations();
685 //-------------------------------------------------------------------
686 void BrowserDataWin::DoOutstandingInvalidations()
688 for ( size_t i = 0, n = aInvalidRegion.size(); i < n; ++i ) {
689 Control::Invalidate( *aInvalidRegion[ i ] );
690 delete aInvalidRegion[ i ];
692 aInvalidRegion.clear();
695 //-------------------------------------------------------------------
697 void BrowserDataWin::Invalidate( sal_uInt16 nFlags )
699 if ( !GetUpdateMode() )
701 for ( size_t i = 0, n = aInvalidRegion.size(); i < n; ++i )
702 delete aInvalidRegion[ i ];
703 aInvalidRegion.clear();
704 aInvalidRegion.push_back( new Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) );
706 else
707 Window::Invalidate( nFlags );
710 //-------------------------------------------------------------------
712 void BrowserDataWin::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags )
714 if ( !GetUpdateMode() )
715 aInvalidRegion.push_back( new Rectangle( rRect ) );
716 else
717 Window::Invalidate( rRect, nFlags );
720 //===================================================================
722 void BrowserScrollBar::Tracking( const TrackingEvent& rTEvt )
724 sal_uLong nPos = GetThumbPos();
725 if ( nPos != _nLastPos )
727 String aTip( OUString::number(nPos) );
728 aTip += '/';
729 if ( _pDataWin->GetRealRowCount().Len() )
730 aTip += _pDataWin->GetRealRowCount();
731 else
732 aTip += OUString::number(GetRangeMax());
734 Rectangle aRect( GetPointerPosPixel(), Size( GetTextHeight(), GetTextWidth( aTip ) ) );
735 if ( _nTip )
736 Help::UpdateTip( _nTip, this, aRect, aTip );
737 else
738 _nTip = Help::ShowTip( this, aRect, aTip );
739 _nLastPos = nPos;
742 ScrollBar::Tracking( rTEvt );
745 //-------------------------------------------------------------------
747 void BrowserScrollBar::EndScroll()
749 if ( _nTip )
750 Help::HideTip( _nTip );
751 _nTip = 0;
752 ScrollBar::EndScroll();
756 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */