update dev300-m58
[ooovba.git] / svtools / source / brwbox / datwin.cxx
blobe4909c8c3266d1a42d8ec68b5fbba9d7edd913b2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: datwin.cxx,v $
10 * $Revision: 1.23 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #include "datwin.hxx"
36 #ifndef GCC
37 #endif
39 #ifndef _APP_HXX //autogen
40 #include <vcl/svapp.hxx>
41 #endif
43 #ifndef _HELP_HXX
44 #include <vcl/help.hxx>
45 #endif
46 #ifndef _IMAGE_HXX
47 #include <vcl/image.hxx>
48 #endif
50 #include <tools/debug.hxx>
52 DECLARE_LIST( BrowserColumns, BrowserColumn* )
54 //===================================================================
55 void ButtonFrame::Draw( OutputDevice& rDev )
57 Color aOldFillColor = rDev.GetFillColor();
58 Color aOldLineColor = rDev.GetLineColor();
60 const StyleSettings &rSettings = rDev.GetSettings().GetStyleSettings();
61 Color aColLight( rSettings.GetLightColor() );
62 Color aColShadow( rSettings.GetShadowColor() );
63 Color aColFace( rSettings.GetFaceColor() );
65 rDev.SetLineColor( aColFace );
66 rDev.SetFillColor( aColFace );
67 rDev.DrawRect( aRect );
69 if( rDev.GetOutDevType() == OUTDEV_WINDOW )
71 Window *pWin = (Window*) &rDev;
72 if( bPressed )
73 pWin->DrawSelectionBackground( aRect, 0, TRUE, FALSE, FALSE );
75 else
77 rDev.SetLineColor( bPressed ? aColShadow : aColLight );
78 rDev.DrawLine( aRect.TopLeft(), Point( aRect.Right(), aRect.Top() ) );
79 rDev.DrawLine( aRect.TopLeft(), Point( aRect.Left(), aRect.Bottom() - 1 ) );
80 rDev.SetLineColor( bPressed ? aColLight : aColShadow );
81 rDev.DrawLine( aRect.BottomRight(), Point( aRect.Right(), aRect.Top() ) );
82 rDev.DrawLine( aRect.BottomRight(), Point( aRect.Left(), aRect.Bottom() ) );
85 if ( aText.Len() )
87 String aVal = rDev.GetEllipsisString(aText,aInnerRect.GetWidth() - 2*MIN_COLUMNWIDTH);
89 Font aFont( rDev.GetFont() );
90 BOOL bOldTransp = aFont.IsTransparent();
91 if ( !bOldTransp )
93 aFont.SetTransparent( TRUE );
94 rDev.SetFont( aFont );
97 Color aOldColor = rDev.GetTextColor();
98 if (m_bDrawDisabled)
99 rDev.SetTextColor(rSettings.GetDisableColor());
101 rDev.DrawText( Point(
102 ( aInnerRect.Left() + aInnerRect.Right() ) / 2 - ( rDev.GetTextWidth(aVal) / 2 ),
103 aInnerRect.Top() ), aVal );
105 // restore settings
106 if ( !bOldTransp )
108 aFont.SetTransparent(FALSE);
109 rDev.SetFont( aFont );
111 if (m_bDrawDisabled)
112 rDev.SetTextColor(aOldColor);
115 if ( bCurs )
117 rDev.SetLineColor( Color( COL_BLACK ) );
118 rDev.SetFillColor();
119 rDev.DrawRect( Rectangle(
120 Point( aRect.Left(), aRect.Top() ), Point( aRect.Right(), aRect.Bottom() ) ) );
123 rDev.SetLineColor( aOldLineColor );
124 rDev.SetFillColor( aOldFillColor );
127 //-------------------------------------------------------------------
129 BrowserColumn::BrowserColumn( USHORT nItemId, const class Image &rImage,
130 const String& rTitle, ULONG nWidthPixel, const Fraction& rCurrentZoom,
131 HeaderBarItemBits nFlags )
132 : _nId( nItemId ),
133 _nWidth( nWidthPixel ),
134 _aImage( rImage ),
135 _aTitle( rTitle ),
136 _bFrozen( FALSE ),
137 _nFlags( nFlags )
139 double n = (double)_nWidth;
140 n *= (double)rCurrentZoom.GetDenominator();
141 n /= (double)rCurrentZoom.GetNumerator();
142 _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
145 BrowserColumn::~BrowserColumn()
149 //-------------------------------------------------------------------
151 void BrowserColumn::SetWidth(ULONG nNewWidthPixel, const Fraction& rCurrentZoom)
153 _nWidth = nNewWidthPixel;
154 double n = (double)_nWidth;
155 n *= (double)rCurrentZoom.GetDenominator();
156 n /= (double)rCurrentZoom.GetNumerator();
157 _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
160 //-------------------------------------------------------------------
162 void BrowserColumn::Draw( BrowseBox& rBox, OutputDevice& rDev, const Point& rPos, BOOL bCurs )
164 if ( _nId == 0 )
166 // paint handle column
167 ButtonFrame( rPos, Size( Width()-1, rBox.GetDataRowHeight()-1 ),
168 String(), FALSE, bCurs,
169 0 != (BROWSER_COLUMN_TITLEABBREVATION&_nFlags) ).Draw( rDev );
170 Color aOldLineColor = rDev.GetLineColor();
171 rDev.SetLineColor( Color( COL_BLACK ) );
172 rDev.DrawLine(
173 Point( rPos.X(), rPos.Y()+rBox.GetDataRowHeight()-1 ),
174 Point( rPos.X() + Width() - 1, rPos.Y()+rBox.GetDataRowHeight()-1 ) );
175 rDev.DrawLine(
176 Point( rPos.X() + Width() - 1, rPos.Y() ),
177 Point( rPos.X() + Width() - 1, rPos.Y()+rBox.GetDataRowHeight()-1 ) );
178 rDev.SetLineColor( aOldLineColor );
180 rBox.DoPaintField( rDev,
181 Rectangle(
182 Point( rPos.X() + 2, rPos.Y() + 2 ),
183 Size( Width()-1, rBox.GetDataRowHeight()-1 ) ),
184 GetId(),
185 BrowseBox::BrowserColumnAccess() );
187 else
189 // paint data column
190 long nWidth = Width() == LONG_MAX ? rBox.GetDataWindow().GetSizePixel().Width() : Width();
192 rBox.DoPaintField( rDev,
193 Rectangle(
194 Point( rPos.X() + MIN_COLUMNWIDTH, rPos.Y() ),
195 Size( nWidth-2*MIN_COLUMNWIDTH, rBox.GetDataRowHeight()-1 ) ),
196 GetId(),
197 BrowseBox::BrowserColumnAccess() );
201 //-------------------------------------------------------------------
203 void BrowserColumn::ZoomChanged(const Fraction& rNewZoom)
205 double n = (double)_nOriginalWidth;
206 n *= (double)rNewZoom.GetNumerator();
207 n /= (double)rNewZoom.GetDenominator();
209 _nWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
212 //-------------------------------------------------------------------
214 BrowserDataWin::BrowserDataWin( BrowseBox* pParent )
215 :Control( pParent, WinBits(WB_CLIPCHILDREN) )
216 ,DragSourceHelper( this )
217 ,DropTargetHelper( this )
218 ,pHeaderBar( 0 )
219 ,pEventWin( pParent )
220 ,pCornerWin( 0 )
221 ,pDtorNotify( 0 )
222 ,bInPaint( FALSE )
223 ,bInCommand( FALSE )
224 ,bNoScrollBack( FALSE )
225 ,bNoHScroll( FALSE )
226 ,bNoVScroll( FALSE )
227 ,bUpdateMode( TRUE )
228 ,bResizeOnPaint( FALSE )
229 ,bUpdateOnUnlock( FALSE )
230 ,bInUpdateScrollbars( FALSE )
231 ,bHadRecursion( FALSE )
232 ,bOwnDataChangedHdl( FALSE )
233 ,bCallingDropCallback( FALSE )
234 ,nUpdateLock( 0 )
235 ,nCursorHidden( 0 )
236 ,m_nDragRowDividerLimit( 0 )
237 ,m_nDragRowDividerOffset( 0 )
239 aMouseTimer.SetTimeoutHdl( LINK( this, BrowserDataWin, RepeatedMouseMove ) );
240 aMouseTimer.SetTimeout( 100 );
243 //-------------------------------------------------------------------
244 BrowserDataWin::~BrowserDataWin()
246 if( pDtorNotify )
247 *pDtorNotify = TRUE;
250 //-------------------------------------------------------------------
251 void BrowserDataWin::LeaveUpdateLock()
253 if ( !--nUpdateLock )
255 DoOutstandingInvalidations();
256 if (bUpdateOnUnlock )
258 Control::Update();
259 bUpdateOnUnlock = FALSE;
264 //-------------------------------------------------------------------
265 void InitSettings_Impl( Window *pWin,
266 BOOL bFont, BOOL bForeground, BOOL bBackground )
268 const StyleSettings& rStyleSettings =
269 pWin->GetSettings().GetStyleSettings();
271 if ( bFont )
273 Font aFont = rStyleSettings.GetFieldFont();
274 if ( pWin->IsControlFont() )
275 aFont.Merge( pWin->GetControlFont() );
276 pWin->SetZoomedPointFont( aFont );
279 if ( bFont || bForeground )
281 Color aTextColor = rStyleSettings.GetWindowTextColor();
282 if ( pWin->IsControlForeground() )
283 aTextColor = pWin->GetControlForeground();
284 pWin->SetTextColor( aTextColor );
287 if ( bBackground )
289 if( pWin->IsControlBackground() )
290 pWin->SetBackground( pWin->GetControlBackground() );
291 else
292 pWin->SetBackground( rStyleSettings.GetWindowColor() );
296 //-------------------------------------------------------------------
297 void BrowserDataWin::Update()
299 if ( !nUpdateLock )
300 Control::Update();
301 else
302 bUpdateOnUnlock = TRUE;
305 //-------------------------------------------------------------------
306 void BrowserDataWin::DataChanged( const DataChangedEvent& rDCEvt )
308 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
309 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
311 if( !bOwnDataChangedHdl )
313 InitSettings_Impl( this, TRUE, TRUE, TRUE );
314 Invalidate();
315 InitSettings_Impl( GetParent(), TRUE, TRUE, TRUE );
316 GetParent()->Invalidate();
317 GetParent()->Resize();
320 else
321 Control::DataChanged( rDCEvt );
324 //-------------------------------------------------------------------
325 void BrowserDataWin::Paint( const Rectangle& rRect )
327 if ( !nUpdateLock && GetUpdateMode() )
329 if ( bInPaint )
331 aInvalidRegion.Insert( new Rectangle( rRect ) );
332 return;
334 bInPaint = TRUE;
335 ( (BrowseBox*) GetParent() )->PaintData( *this, rRect );
336 bInPaint = FALSE;
337 DoOutstandingInvalidations();
339 else
340 aInvalidRegion.Insert( new Rectangle( rRect ) );
343 //-------------------------------------------------------------------
345 BrowseEvent BrowserDataWin::CreateBrowseEvent( const Point& rPosPixel )
347 BrowseBox *pBox = GetParent();
349 // seek to row under mouse
350 long nRelRow = rPosPixel.Y() < 0
351 ? -1
352 : rPosPixel.Y() / pBox->GetDataRowHeight();
353 long nRow = nRelRow < 0 ? -1 : nRelRow + pBox->nTopRow;
355 // find column under mouse
356 long nMouseX = rPosPixel.X();
357 long nColX = 0;
358 USHORT nCol;
359 for ( nCol = 0;
360 nCol < pBox->pCols->Count() && nColX < GetSizePixel().Width();
361 ++nCol )
362 if ( pBox->pCols->GetObject(nCol)->IsFrozen() || nCol >= pBox->nFirstCol )
364 nColX += pBox->pCols->GetObject(nCol)->Width();
365 if ( nMouseX < nColX )
366 break;
368 USHORT nColId = BROWSER_INVALIDID;
369 if ( nCol < pBox->pCols->Count() )
370 nColId = pBox->pCols->GetObject(nCol)->GetId();
372 // compute the field rectangle and field relative MouseEvent
373 Rectangle aFieldRect;
374 if ( nCol < pBox->pCols->Count() )
376 nColX -= pBox->pCols->GetObject(nCol)->Width();
377 aFieldRect = Rectangle(
378 Point( nColX, nRelRow * pBox->GetDataRowHeight() ),
379 Size( pBox->pCols->GetObject(nCol)->Width(),
380 pBox->GetDataRowHeight() ) );
383 // assemble and return the BrowseEvent
384 return BrowseEvent( this, nRow, nCol, nColId, aFieldRect );
387 //-------------------------------------------------------------------
388 sal_Int8 BrowserDataWin::AcceptDrop( const AcceptDropEvent& _rEvt )
390 bCallingDropCallback = sal_True;
391 sal_Int8 nReturn = DND_ACTION_NONE;
392 nReturn = GetParent()->AcceptDrop( BrowserAcceptDropEvent( this, _rEvt ) );
393 bCallingDropCallback = sal_False;
394 return nReturn;
397 //-------------------------------------------------------------------
398 sal_Int8 BrowserDataWin::ExecuteDrop( const ExecuteDropEvent& _rEvt )
400 bCallingDropCallback = sal_True;
401 sal_Int8 nReturn = DND_ACTION_NONE;
402 nReturn = GetParent()->ExecuteDrop( BrowserExecuteDropEvent( this, _rEvt ) );
403 bCallingDropCallback = sal_False;
404 return nReturn;
407 //-------------------------------------------------------------------
408 void BrowserDataWin::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel )
410 if ( !GetParent()->bRowDividerDrag )
412 Point aEventPos( _rPosPixel );
413 aEventPos.Y() += GetParent()->GetTitleHeight();
414 GetParent()->StartDrag( _nAction, aEventPos );
418 //-------------------------------------------------------------------
419 void BrowserDataWin::Command( const CommandEvent& rEvt )
421 // Scrollmaus-Event?
422 BrowseBox *pBox = GetParent();
423 if ( ( (rEvt.GetCommand() == COMMAND_WHEEL) ||
424 (rEvt.GetCommand() == COMMAND_STARTAUTOSCROLL) ||
425 (rEvt.GetCommand() == COMMAND_AUTOSCROLL) ) &&
426 ( HandleScrollCommand( rEvt, &pBox->aHScroll, pBox->pVScroll ) ) )
427 return;
429 Point aEventPos( rEvt.GetMousePosPixel() );
430 long nRow = pBox->GetRowAtYPosPixel( aEventPos.Y(), FALSE);
431 MouseEvent aMouseEvt( aEventPos, 1, MOUSE_SELECT, MOUSE_LEFT );
432 if ( COMMAND_CONTEXTMENU == rEvt.GetCommand() && rEvt.IsMouseEvent() &&
433 nRow < pBox->GetRowCount() && !pBox->IsRowSelected(nRow) )
435 BOOL bDeleted = FALSE;
436 pDtorNotify = &bDeleted;
437 bInCommand = TRUE;
438 MouseButtonDown( aMouseEvt );
439 if( bDeleted )
440 return;
441 MouseButtonUp( aMouseEvt );
442 if( bDeleted )
443 return;
444 pDtorNotify = 0;
445 bInCommand = FALSE;
448 aEventPos.Y() += GetParent()->GetTitleHeight();
449 CommandEvent aEvt( aEventPos, rEvt.GetCommand(),
450 rEvt.IsMouseEvent(), rEvt.GetData() );
451 bInCommand = TRUE;
452 BOOL bDeleted = FALSE;
453 pDtorNotify = &bDeleted;
454 GetParent()->Command( aEvt );
455 if( bDeleted )
456 return;
457 pDtorNotify = 0;
458 bInCommand = FALSE;
460 if ( COMMAND_STARTDRAG == rEvt.GetCommand() )
461 MouseButtonUp( aMouseEvt );
463 Control::Command( rEvt );
466 //-------------------------------------------------------------------
468 BOOL BrowserDataWin::ImplRowDividerHitTest( const BrowserMouseEvent& _rEvent )
470 if ( ! ( GetParent()->IsInteractiveRowHeightEnabled()
471 && ( _rEvent.GetRow() >= 0 )
472 && ( _rEvent.GetRow() < GetParent()->GetRowCount() )
473 && ( _rEvent.GetColumnId() == 0 )
476 return FALSE;
478 long nDividerDistance = GetParent()->GetDataRowHeight() - ( _rEvent.GetPosPixel().Y() % GetParent()->GetDataRowHeight() );
479 return ( nDividerDistance <= 4 );
482 //-------------------------------------------------------------------
484 void BrowserDataWin::MouseButtonDown( const MouseEvent& rEvt )
486 aLastMousePos = OutputToScreenPixel( rEvt.GetPosPixel() );
488 BrowserMouseEvent aBrowserEvent( this, rEvt );
489 if ( ( aBrowserEvent.GetClicks() == 1 ) && ImplRowDividerHitTest( aBrowserEvent ) )
491 StartRowDividerDrag( aBrowserEvent.GetPosPixel() );
492 return;
495 GetParent()->MouseButtonDown( BrowserMouseEvent( this, rEvt ) );
498 //-------------------------------------------------------------------
500 void BrowserDataWin::MouseMove( const MouseEvent& rEvt )
502 // Pseudo MouseMoves verhindern
503 Point aNewPos = OutputToScreenPixel( rEvt.GetPosPixel() );
504 if ( ( aNewPos == aLastMousePos ) )
505 return;
506 aLastMousePos = aNewPos;
508 // transform to a BrowseEvent
509 BrowserMouseEvent aBrowserEvent( this, rEvt );
510 GetParent()->MouseMove( aBrowserEvent );
512 // pointer shape
513 PointerStyle ePointerStyle = POINTER_ARROW;
514 if ( ImplRowDividerHitTest( aBrowserEvent ) )
515 ePointerStyle = POINTER_VSIZEBAR;
516 SetPointer( Pointer( ePointerStyle ) );
518 // dragging out of the visible area?
519 if ( rEvt.IsLeft() &&
520 ( rEvt.GetPosPixel().Y() > GetSizePixel().Height() ||
521 rEvt.GetPosPixel().Y() < 0 ) )
523 // repeat the event
524 aRepeatEvt = rEvt;
525 aMouseTimer.Start();
527 else
528 // killing old repeat-event
529 if ( aMouseTimer.IsActive() )
530 aMouseTimer.Stop();
533 //-------------------------------------------------------------------
535 IMPL_LINK_INLINE_START( BrowserDataWin, RepeatedMouseMove, void *, EMPTYARG )
537 GetParent()->MouseMove( BrowserMouseEvent( this, aRepeatEvt ) );
538 return 0;
540 IMPL_LINK_INLINE_END( BrowserDataWin, RepeatedMouseMove, void *, EMPTYARG )
542 //-------------------------------------------------------------------
544 void BrowserDataWin::MouseButtonUp( const MouseEvent& rEvt )
546 // Pseudo MouseMoves verhindern
547 Point aNewPos = OutputToScreenPixel( rEvt.GetPosPixel() );
548 aLastMousePos = aNewPos;
550 // Move an die aktuelle Position simulieren
551 MouseMove( rEvt );
553 // eigentliches Up-Handling
554 ReleaseMouse();
555 if ( aMouseTimer.IsActive() )
556 aMouseTimer.Stop();
557 GetParent()->MouseButtonUp( BrowserMouseEvent( this, rEvt ) );
560 //-------------------------------------------------------------------
562 void BrowserDataWin::StartRowDividerDrag( const Point& _rStartPos )
564 long nDataRowHeight = GetParent()->GetDataRowHeight();
565 // the exact separation pos of the two rows
566 long nDragRowDividerCurrentPos = _rStartPos.Y();
567 if ( ( nDragRowDividerCurrentPos % nDataRowHeight ) > nDataRowHeight / 2 )
568 nDragRowDividerCurrentPos += nDataRowHeight;
569 nDragRowDividerCurrentPos /= nDataRowHeight;
570 nDragRowDividerCurrentPos *= nDataRowHeight;
572 m_nDragRowDividerOffset = nDragRowDividerCurrentPos - _rStartPos.Y();
574 m_nDragRowDividerLimit = nDragRowDividerCurrentPos - nDataRowHeight;
576 GetParent()->bRowDividerDrag = TRUE;
577 GetParent()->ImplStartTracking();
579 Rectangle aDragSplitRect( 0, m_nDragRowDividerLimit, GetOutputSizePixel().Width(), nDragRowDividerCurrentPos );
580 ShowTracking( aDragSplitRect, SHOWTRACK_SMALL );
582 StartTracking();
585 //-------------------------------------------------------------------
587 void BrowserDataWin::Tracking( const TrackingEvent& rTEvt )
589 if ( !GetParent()->bRowDividerDrag )
590 return;
592 Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
593 // stop resizing at our bottom line
594 if ( aMousePos.Y() > GetOutputSizePixel().Height() )
595 aMousePos.Y() = GetOutputSizePixel().Height();
597 if ( rTEvt.IsTrackingEnded() )
599 HideTracking();
600 GetParent()->bRowDividerDrag = FALSE;
601 GetParent()->ImplEndTracking();
603 if ( !rTEvt.IsTrackingCanceled() )
605 long nNewRowHeight = aMousePos.Y() + m_nDragRowDividerOffset - m_nDragRowDividerLimit;
607 // care for minimum row height
608 if ( nNewRowHeight < GetParent()->QueryMinimumRowHeight() )
609 nNewRowHeight = GetParent()->QueryMinimumRowHeight();
611 GetParent()->SetDataRowHeight( nNewRowHeight );
612 GetParent()->RowHeightChanged();
615 else
617 GetParent()->ImplTracking();
619 long nDragRowDividerCurrentPos = aMousePos.Y() + m_nDragRowDividerOffset;
621 // care for minimum row height
622 if ( nDragRowDividerCurrentPos < m_nDragRowDividerLimit + GetParent()->QueryMinimumRowHeight() )
623 nDragRowDividerCurrentPos = m_nDragRowDividerLimit + GetParent()->QueryMinimumRowHeight();
625 Rectangle aDragSplitRect( 0, m_nDragRowDividerLimit, GetOutputSizePixel().Width(), nDragRowDividerCurrentPos );
626 ShowTracking( aDragSplitRect, SHOWTRACK_SMALL );
630 //-------------------------------------------------------------------
632 void BrowserDataWin::KeyInput( const KeyEvent& rEvt )
634 // pass to parent window
635 if ( !GetParent()->ProcessKey( rEvt ) )
636 Control::KeyInput( rEvt );
639 //-------------------------------------------------------------------
641 void BrowserDataWin::RequestHelp( const HelpEvent& rHEvt )
643 pEventWin = this;
644 GetParent()->RequestHelp( rHEvt );
645 pEventWin = GetParent();
648 //===================================================================
650 BrowseEvent::BrowseEvent( Window* pWindow,
651 long nAbsRow, USHORT nColumn, USHORT nColumnId,
652 const Rectangle& rRect ):
653 pWin(pWindow),
654 nRow(nAbsRow),
655 aRect(rRect),
656 nCol(nColumn),
657 nColId(nColumnId)
661 //===================================================================
662 BrowserMouseEvent::BrowserMouseEvent( BrowserDataWin *pWindow,
663 const MouseEvent& rEvt ):
664 MouseEvent(rEvt),
665 BrowseEvent( pWindow->CreateBrowseEvent( rEvt.GetPosPixel() ) )
669 //-------------------------------------------------------------------
671 BrowserMouseEvent::BrowserMouseEvent( Window *pWindow, const MouseEvent& rEvt,
672 long nAbsRow, USHORT nColumn, USHORT nColumnId,
673 const Rectangle& rRect ):
674 MouseEvent(rEvt),
675 BrowseEvent( pWindow, nAbsRow, nColumn, nColumnId, rRect )
679 //===================================================================
681 BrowserAcceptDropEvent::BrowserAcceptDropEvent( BrowserDataWin *pWindow, const AcceptDropEvent& rEvt )
682 :AcceptDropEvent(rEvt)
683 ,BrowseEvent( pWindow->CreateBrowseEvent( rEvt.maPosPixel ) )
687 //===================================================================
689 BrowserExecuteDropEvent::BrowserExecuteDropEvent( BrowserDataWin *pWindow, const ExecuteDropEvent& rEvt )
690 :ExecuteDropEvent(rEvt)
691 ,BrowseEvent( pWindow->CreateBrowseEvent( rEvt.maPosPixel ) )
695 //===================================================================
697 //-------------------------------------------------------------------
699 void BrowserDataWin::SetUpdateMode( BOOL bMode )
701 DBG_ASSERT( !bUpdateMode || aInvalidRegion.Count() == 0,
702 "invalid region not empty" );
703 if ( bMode == bUpdateMode )
704 return;
706 bUpdateMode = bMode;
707 if ( bMode )
708 DoOutstandingInvalidations();
711 //-------------------------------------------------------------------
712 void BrowserDataWin::DoOutstandingInvalidations()
714 for ( Rectangle* pRect = aInvalidRegion.First();
715 pRect;
716 pRect = aInvalidRegion.Next() )
718 Control::Invalidate( *pRect );
719 delete pRect;
721 aInvalidRegion.Clear();
724 //-------------------------------------------------------------------
726 void BrowserDataWin::Invalidate( USHORT nFlags )
728 if ( !GetUpdateMode() )
730 for ( Rectangle* pRect = aInvalidRegion.First();
731 pRect;
732 pRect = aInvalidRegion.Next() )
733 delete pRect;
734 aInvalidRegion.Clear();
735 aInvalidRegion.Insert( new Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) );
737 else
738 Window::Invalidate( nFlags );
741 //-------------------------------------------------------------------
743 void BrowserDataWin::Invalidate( const Rectangle& rRect, USHORT nFlags )
745 if ( !GetUpdateMode() )
746 aInvalidRegion.Insert( new Rectangle( rRect ) );
747 else
748 Window::Invalidate( rRect, nFlags );
751 //===================================================================
753 void BrowserScrollBar::Tracking( const TrackingEvent& rTEvt )
755 ULONG nPos = GetThumbPos();
756 if ( nPos != _nLastPos )
758 if ( _nTip )
759 Help::HideTip( _nTip );
761 String aTip( String::CreateFromInt32(nPos) );
762 aTip += '/';
763 if ( _pDataWin->GetRealRowCount().Len() )
764 aTip += _pDataWin->GetRealRowCount();
765 else
766 aTip += String::CreateFromInt32(GetRangeMax());
767 Rectangle aRect( GetPointerPosPixel(), Size( GetTextHeight(), GetTextWidth( aTip ) ) );
768 _nTip = Help::ShowTip( this, aRect, aTip );
769 _nLastPos = nPos;
772 ScrollBar::Tracking( rTEvt );
775 //-------------------------------------------------------------------
777 void BrowserScrollBar::EndScroll()
779 if ( _nTip )
780 Help::HideTip( _nTip );
781 _nTip = 0;
782 ScrollBar::EndScroll();