LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svtools/source/brwbox - datwin.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 123 379 32.5 %
Date: 2013-07-09 Functions: 18 43 41.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : 
      21             : #include "datwin.hxx"
      22             : 
      23             : #include <vcl/svapp.hxx>
      24             : 
      25             : #include <vcl/help.hxx>
      26             : #include <vcl/image.hxx>
      27             : 
      28             : #include <tools/debug.hxx>
      29             : 
      30             : //===================================================================
      31          50 : void ButtonFrame::Draw( OutputDevice& rDev )
      32             : {
      33          50 :     Color aOldFillColor = rDev.GetFillColor();
      34          50 :     Color aOldLineColor = rDev.GetLineColor();
      35             : 
      36          50 :     const StyleSettings &rSettings = rDev.GetSettings().GetStyleSettings();
      37          50 :     Color aColLight( rSettings.GetLightColor() );
      38          50 :     Color aColShadow( rSettings.GetShadowColor() );
      39          50 :     Color aColFace( rSettings.GetFaceColor() );
      40             : 
      41          50 :     rDev.SetLineColor( aColFace );
      42          50 :     rDev.SetFillColor( aColFace );
      43          50 :     rDev.DrawRect( aRect );
      44             : 
      45          50 :     if( rDev.GetOutDevType() == OUTDEV_WINDOW )
      46             :     {
      47          50 :         Window *pWin = (Window*) &rDev;
      48          50 :         if( bPressed )
      49           0 :             pWin->DrawSelectionBackground( aRect, 0, sal_True, sal_False, sal_False );
      50             :     }
      51             :     else
      52             :     {
      53           0 :         rDev.SetLineColor( bPressed ? aColShadow : aColLight );
      54           0 :         rDev.DrawLine( aRect.TopLeft(), Point( aRect.Right(), aRect.Top() ) );
      55           0 :         rDev.DrawLine( aRect.TopLeft(), Point( aRect.Left(), aRect.Bottom() - 1 ) );
      56           0 :         rDev.SetLineColor( bPressed ? aColLight : aColShadow );
      57           0 :         rDev.DrawLine( aRect.BottomRight(), Point( aRect.Right(), aRect.Top() ) );
      58           0 :         rDev.DrawLine( aRect.BottomRight(), Point( aRect.Left(), aRect.Bottom() ) );
      59             :     }
      60             : 
      61          50 :     if ( aText.Len() )
      62             :     {
      63           0 :         OUString aVal = rDev.GetEllipsisString(aText,aInnerRect.GetWidth() - 2*MIN_COLUMNWIDTH);
      64             : 
      65           0 :         Font aFont( rDev.GetFont() );
      66           0 :         sal_Bool bOldTransp = aFont.IsTransparent();
      67           0 :         if ( !bOldTransp )
      68             :         {
      69           0 :             aFont.SetTransparent( sal_True );
      70           0 :             rDev.SetFont( aFont );
      71             :         }
      72             : 
      73           0 :         Color aOldColor = rDev.GetTextColor();
      74           0 :         if (m_bDrawDisabled)
      75           0 :             rDev.SetTextColor(rSettings.GetDisableColor());
      76             : 
      77             :         rDev.DrawText( Point(
      78           0 :             ( aInnerRect.Left() + aInnerRect.Right() ) / 2 - ( rDev.GetTextWidth(aVal) / 2 ),
      79           0 :             aInnerRect.Top() ), aVal );
      80             : 
      81             :         // restore settings
      82           0 :         if ( !bOldTransp )
      83             :         {
      84           0 :             aFont.SetTransparent(sal_False);
      85           0 :             rDev.SetFont( aFont );
      86             :         }
      87           0 :         if (m_bDrawDisabled)
      88           0 :             rDev.SetTextColor(aOldColor);
      89             :     }
      90             : 
      91          50 :     if ( bCurs )
      92             :     {
      93           0 :         rDev.SetLineColor( Color( COL_BLACK ) );
      94           0 :         rDev.SetFillColor();
      95             :         rDev.DrawRect( Rectangle(
      96           0 :             Point( aRect.Left(), aRect.Top() ), Point( aRect.Right(), aRect.Bottom() ) ) );
      97             :     }
      98             : 
      99          50 :     rDev.SetLineColor( aOldLineColor );
     100          50 :     rDev.SetFillColor( aOldFillColor );
     101          50 : }
     102             : 
     103             : //-------------------------------------------------------------------
     104             : 
     105         106 : 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         106 :     _bFrozen( sal_False )
     112             : {
     113         106 :     double n = (double)_nWidth;
     114         106 :     n *= (double)rCurrentZoom.GetDenominator();
     115         106 :     n /= (double)rCurrentZoom.GetNumerator();
     116         106 :     _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
     117         106 : }
     118             : 
     119         212 : BrowserColumn::~BrowserColumn()
     120             : {
     121         212 : }
     122             : 
     123             : //-------------------------------------------------------------------
     124             : 
     125           0 : void BrowserColumn::SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom)
     126             : {
     127           0 :     _nWidth = nNewWidthPixel;
     128           0 :     double n = (double)_nWidth;
     129           0 :     n *= (double)rCurrentZoom.GetDenominator();
     130           0 :     n /= (double)rCurrentZoom.GetNumerator();
     131           0 :     _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
     132           0 : }
     133             : 
     134             : //-------------------------------------------------------------------
     135             : 
     136          64 : void BrowserColumn::Draw( BrowseBox& rBox, OutputDevice& rDev, const Point& rPos, sal_Bool bCurs  )
     137             : {
     138          64 :     if ( _nId == 0 )
     139             :     {
     140             :         // paint handle column
     141          16 :         ButtonFrame( rPos, Size( Width()-1, rBox.GetDataRowHeight()-1 ),
     142          24 :                      String(), sal_False, bCurs, false ).Draw( rDev );
     143           8 :         Color aOldLineColor = rDev.GetLineColor();
     144           8 :         rDev.SetLineColor( Color( COL_BLACK ) );
     145             :         rDev.DrawLine(
     146           8 :             Point( rPos.X(), rPos.Y()+rBox.GetDataRowHeight()-1 ),
     147          16 :             Point( rPos.X() + Width() - 1, rPos.Y()+rBox.GetDataRowHeight()-1 ) );
     148             :         rDev.DrawLine(
     149           8 :             Point( rPos.X() + Width() - 1, rPos.Y() ),
     150          16 :             Point( rPos.X() + Width() - 1, rPos.Y()+rBox.GetDataRowHeight()-1 ) );
     151           8 :         rDev.SetLineColor( aOldLineColor );
     152             : 
     153             :         rBox.DoPaintField( rDev,
     154             :             Rectangle(
     155          16 :                 Point( rPos.X() + 2, rPos.Y() + 2 ),
     156          16 :                 Size( Width()-1, rBox.GetDataRowHeight()-1 ) ),
     157           8 :             GetId(),
     158          48 :             BrowseBox::BrowserColumnAccess() );
     159             :     }
     160             :     else
     161             :     {
     162             :         // paint data column
     163          56 :         long nWidth = Width() == LONG_MAX ? rBox.GetDataWindow().GetSizePixel().Width() : Width();
     164             : 
     165             :         rBox.DoPaintField( rDev,
     166             :             Rectangle(
     167          56 :                 Point( rPos.X() + MIN_COLUMNWIDTH, rPos.Y() ),
     168          56 :                 Size( nWidth-2*MIN_COLUMNWIDTH, rBox.GetDataRowHeight()-1 ) ),
     169          56 :             GetId(),
     170         224 :             BrowseBox::BrowserColumnAccess() );
     171             :     }
     172          64 : }
     173             : 
     174             : //-------------------------------------------------------------------
     175             : 
     176           0 : void BrowserColumn::ZoomChanged(const Fraction& rNewZoom)
     177             : {
     178           0 :     double n = (double)_nOriginalWidth;
     179           0 :     n *= (double)rNewZoom.GetNumerator();
     180           0 :     n /= (double)rNewZoom.GetDenominator();
     181             : 
     182           0 :     _nWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
     183           0 : }
     184             : 
     185             : //-------------------------------------------------------------------
     186             : 
     187          21 : 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          21 :     ,m_nDragRowDividerOffset( 0 )
     211             : {
     212          21 :     aMouseTimer.SetTimeoutHdl( LINK( this, BrowserDataWin, RepeatedMouseMove ) );
     213          21 :     aMouseTimer.SetTimeout( 100 );
     214          21 : }
     215             : 
     216             : //-------------------------------------------------------------------
     217          63 : BrowserDataWin::~BrowserDataWin()
     218             : {
     219          21 :     if( pDtorNotify )
     220           0 :         *pDtorNotify = sal_True;
     221             : 
     222          21 :     for ( size_t i = 0, n = aInvalidRegion.size(); i < n; ++i )
     223           0 :         delete aInvalidRegion[ i ];
     224          21 :     aInvalidRegion.clear();
     225          42 : }
     226             : 
     227             : //-------------------------------------------------------------------
     228           1 : void BrowserDataWin::LeaveUpdateLock()
     229             : {
     230           1 :     if ( !--nUpdateLock )
     231             :     {
     232           1 :         DoOutstandingInvalidations();
     233           1 :         if (bUpdateOnUnlock )
     234             :         {
     235           0 :             Control::Update();
     236           0 :             bUpdateOnUnlock = sal_False;
     237             :         }
     238             :     }
     239           1 : }
     240             : 
     241             : //-------------------------------------------------------------------
     242         114 : void InitSettings_Impl( Window *pWin,
     243             :                      sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
     244             : {
     245             :     const StyleSettings& rStyleSettings =
     246         114 :             pWin->GetSettings().GetStyleSettings();
     247             : 
     248         114 :     if ( bFont )
     249             :     {
     250         114 :         Font aFont = rStyleSettings.GetFieldFont();
     251         114 :         if ( pWin->IsControlFont() )
     252          52 :             aFont.Merge( pWin->GetControlFont() );
     253         114 :         pWin->SetZoomedPointFont( aFont );
     254             :     }
     255             : 
     256         114 :     if ( bFont || bForeground )
     257             :     {
     258         114 :         Color aTextColor = rStyleSettings.GetWindowTextColor();
     259         114 :         if ( pWin->IsControlForeground() )
     260           0 :             aTextColor = pWin->GetControlForeground();
     261         114 :         pWin->SetTextColor( aTextColor );
     262             :     }
     263             : 
     264         114 :     if ( bBackground )
     265             :     {
     266         114 :         if( pWin->IsControlBackground() )
     267           0 :             pWin->SetBackground( pWin->GetControlBackground() );
     268             :         else
     269         114 :             pWin->SetBackground( rStyleSettings.GetWindowColor() );
     270             :     }
     271         114 : }
     272             : 
     273             : //-------------------------------------------------------------------
     274           0 : void BrowserDataWin::Update()
     275             : {
     276           0 :     if ( !nUpdateLock )
     277           0 :         Control::Update();
     278             :     else
     279           0 :         bUpdateOnUnlock = sal_True;
     280           0 : }
     281             : 
     282             : //-------------------------------------------------------------------
     283          36 : void BrowserDataWin::DataChanged( const DataChangedEvent& rDCEvt )
     284             : {
     285          72 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
     286          36 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     287             :     {
     288          36 :         if( !bOwnDataChangedHdl )
     289             :         {
     290          36 :             InitSettings_Impl( this, sal_True, sal_True, sal_True );
     291          36 :             Invalidate();
     292          36 :             InitSettings_Impl( GetParent(), sal_True, sal_True, sal_True );
     293          36 :             GetParent()->Invalidate();
     294          36 :             GetParent()->Resize();
     295             :         }
     296             :     }
     297             :     else
     298           0 :         Control::DataChanged( rDCEvt );
     299          36 : }
     300             : 
     301             : //-------------------------------------------------------------------
     302          87 : void BrowserDataWin::Paint( const Rectangle& rRect )
     303             : {
     304          87 :     if ( !nUpdateLock && GetUpdateMode() )
     305             :     {
     306          87 :         if ( bInPaint )
     307             :         {
     308          24 :             aInvalidRegion.push_back( new Rectangle( rRect ) );
     309         111 :             return;
     310             :         }
     311          63 :         bInPaint = sal_True;
     312          63 :         ( (BrowseBox*) GetParent() )->PaintData( *this, rRect );
     313          63 :         bInPaint = sal_False;
     314          63 :         DoOutstandingInvalidations();
     315             :     }
     316             :     else
     317           0 :         aInvalidRegion.push_back( new Rectangle( rRect ) );
     318             : }
     319             : 
     320             : //-------------------------------------------------------------------
     321             : 
     322           0 : BrowseEvent BrowserDataWin::CreateBrowseEvent( const Point& rPosPixel )
     323             : {
     324           0 :     BrowseBox *pBox = GetParent();
     325             : 
     326             :     // seek to row under mouse
     327           0 :     long nRelRow = rPosPixel.Y() < 0
     328             :             ? -1
     329           0 :             : rPosPixel.Y() / pBox->GetDataRowHeight();
     330           0 :     long nRow = nRelRow < 0 ? -1 : nRelRow + pBox->nTopRow;
     331             : 
     332             :     // find column under mouse
     333           0 :     long nMouseX = rPosPixel.X();
     334           0 :     long nColX = 0;
     335             :     size_t nCol;
     336           0 :     for ( nCol = 0;
     337           0 :           nCol < pBox->pCols->size() && nColX < GetSizePixel().Width();
     338             :           ++nCol )
     339           0 :         if ( (*pBox->pCols)[ nCol ]->IsFrozen() || nCol >= pBox->nFirstCol )
     340             :         {
     341           0 :             nColX += (*pBox->pCols)[ nCol ]->Width();
     342           0 :             if ( nMouseX < nColX )
     343           0 :                 break;
     344             :         }
     345           0 :     sal_uInt16 nColId = BROWSER_INVALIDID;
     346           0 :     if ( nCol < pBox->pCols->size() )
     347           0 :         nColId = (*pBox->pCols)[ nCol ]->GetId();
     348             : 
     349             :     // compute the field rectangle and field relative MouseEvent
     350           0 :     Rectangle aFieldRect;
     351           0 :     if ( nCol < pBox->pCols->size() )
     352             :     {
     353           0 :         nColX -= (*pBox->pCols)[ nCol ]->Width();
     354             :         aFieldRect = Rectangle(
     355           0 :             Point( nColX, nRelRow * pBox->GetDataRowHeight() ),
     356           0 :             Size( (*pBox->pCols)[ nCol ]->Width(),
     357           0 :                   pBox->GetDataRowHeight() ) );
     358             :     }
     359             : 
     360             :     // assemble and return the BrowseEvent
     361           0 :     return BrowseEvent( this, nRow, nCol, nColId, aFieldRect );
     362             : }
     363             : 
     364             : //-------------------------------------------------------------------
     365           0 : sal_Int8 BrowserDataWin::AcceptDrop( const AcceptDropEvent& _rEvt )
     366             : {
     367           0 :     bCallingDropCallback = sal_True;
     368           0 :     sal_Int8 nReturn = GetParent()->AcceptDrop( BrowserAcceptDropEvent( this, _rEvt ) );
     369           0 :     bCallingDropCallback = sal_False;
     370           0 :     return nReturn;
     371             : }
     372             : 
     373             : //-------------------------------------------------------------------
     374           0 : sal_Int8 BrowserDataWin::ExecuteDrop( const ExecuteDropEvent& _rEvt )
     375             : {
     376           0 :     bCallingDropCallback = sal_True;
     377           0 :     sal_Int8 nReturn = GetParent()->ExecuteDrop( BrowserExecuteDropEvent( this, _rEvt ) );
     378           0 :     bCallingDropCallback = sal_False;
     379           0 :     return nReturn;
     380             : }
     381             : 
     382             : //-------------------------------------------------------------------
     383           0 : void BrowserDataWin::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel )
     384             : {
     385           0 :     if ( !GetParent()->bRowDividerDrag )
     386             :     {
     387           0 :         Point aEventPos( _rPosPixel );
     388           0 :         aEventPos.Y() += GetParent()->GetTitleHeight();
     389           0 :         GetParent()->StartDrag( _nAction, aEventPos );
     390             :     }
     391           0 : }
     392             : 
     393             : //-------------------------------------------------------------------
     394           0 : void BrowserDataWin::Command( const CommandEvent& rEvt )
     395             : {
     396             :     // scroll mouse event?
     397           0 :     BrowseBox *pBox = GetParent();
     398           0 :     if ( ( (rEvt.GetCommand() == COMMAND_WHEEL) ||
     399           0 :            (rEvt.GetCommand() == COMMAND_STARTAUTOSCROLL) ||
     400           0 :            (rEvt.GetCommand() == COMMAND_AUTOSCROLL) ) &&
     401           0 :          ( HandleScrollCommand( rEvt, &pBox->aHScroll, pBox->pVScroll ) ) )
     402           0 :       return;
     403             : 
     404           0 :     Point aEventPos( rEvt.GetMousePosPixel() );
     405           0 :     long nRow = pBox->GetRowAtYPosPixel( aEventPos.Y(), sal_False);
     406           0 :     MouseEvent aMouseEvt( aEventPos, 1, MOUSE_SELECT, MOUSE_LEFT );
     407           0 :     if ( COMMAND_CONTEXTMENU == rEvt.GetCommand() && rEvt.IsMouseEvent() &&
     408           0 :          nRow < pBox->GetRowCount() && !pBox->IsRowSelected(nRow) )
     409             :     {
     410           0 :         sal_Bool bDeleted = sal_False;
     411           0 :         pDtorNotify = &bDeleted;
     412           0 :         bInCommand = sal_True;
     413           0 :         MouseButtonDown( aMouseEvt );
     414           0 :         if( bDeleted )
     415           0 :             return;
     416           0 :         MouseButtonUp( aMouseEvt );
     417           0 :         if( bDeleted )
     418           0 :             return;
     419           0 :         pDtorNotify = 0;
     420           0 :         bInCommand = sal_False;
     421             :     }
     422             : 
     423           0 :     aEventPos.Y() += GetParent()->GetTitleHeight();
     424           0 :     CommandEvent aEvt( aEventPos, rEvt.GetCommand(),
     425           0 :                         rEvt.IsMouseEvent(), rEvt.GetData() );
     426           0 :     bInCommand = sal_True;
     427           0 :     sal_Bool bDeleted = sal_False;
     428           0 :     pDtorNotify = &bDeleted;
     429           0 :     GetParent()->Command( aEvt );
     430           0 :     if( bDeleted )
     431           0 :         return;
     432           0 :     pDtorNotify = 0;
     433           0 :     bInCommand = sal_False;
     434             : 
     435           0 :     if ( COMMAND_STARTDRAG == rEvt.GetCommand() )
     436           0 :         MouseButtonUp( aMouseEvt );
     437             : 
     438           0 :     Control::Command( rEvt );
     439             : }
     440             : 
     441             : //-------------------------------------------------------------------
     442             : 
     443           0 : sal_Bool BrowserDataWin::ImplRowDividerHitTest( const BrowserMouseEvent& _rEvent )
     444             : {
     445           0 :     if ( ! (  GetParent()->IsInteractiveRowHeightEnabled()
     446           0 :            && ( _rEvent.GetRow() >= 0 )
     447           0 :            && ( _rEvent.GetRow() < GetParent()->GetRowCount() )
     448           0 :            && ( _rEvent.GetColumnId() == BrowseBox::HandleColumnId )
     449           0 :            )
     450             :        )
     451           0 :        return sal_False;
     452             : 
     453           0 :     long nDividerDistance = GetParent()->GetDataRowHeight() - ( _rEvent.GetPosPixel().Y() % GetParent()->GetDataRowHeight() );
     454           0 :     return ( nDividerDistance <= 4 );
     455             : }
     456             : 
     457             : //-------------------------------------------------------------------
     458             : 
     459           0 : void BrowserDataWin::MouseButtonDown( const MouseEvent& rEvt )
     460             : {
     461           0 :     aLastMousePos = OutputToScreenPixel( rEvt.GetPosPixel() );
     462             : 
     463           0 :     BrowserMouseEvent aBrowserEvent( this, rEvt );
     464           0 :     if ( ( aBrowserEvent.GetClicks() == 1 ) && ImplRowDividerHitTest( aBrowserEvent ) )
     465             :     {
     466           0 :         StartRowDividerDrag( aBrowserEvent.GetPosPixel() );
     467           0 :         return;
     468             :     }
     469             : 
     470           0 :     GetParent()->MouseButtonDown( BrowserMouseEvent( this, rEvt ) );
     471             : }
     472             : 
     473             : //-------------------------------------------------------------------
     474             : 
     475           0 : void BrowserDataWin::MouseMove( const MouseEvent& rEvt )
     476             : {
     477             :     // avoid pseudo MouseMoves
     478           0 :     Point aNewPos = OutputToScreenPixel( rEvt.GetPosPixel() );
     479           0 :     if ( ( aNewPos == aLastMousePos ) )
     480           0 :         return;
     481           0 :     aLastMousePos = aNewPos;
     482             : 
     483             :     // transform to a BrowseEvent
     484           0 :     BrowserMouseEvent aBrowserEvent( this, rEvt );
     485           0 :     GetParent()->MouseMove( aBrowserEvent );
     486             : 
     487             :     // pointer shape
     488           0 :     PointerStyle ePointerStyle = POINTER_ARROW;
     489           0 :     if ( ImplRowDividerHitTest( aBrowserEvent ) )
     490           0 :         ePointerStyle = POINTER_VSIZEBAR;
     491           0 :     SetPointer( Pointer( ePointerStyle ) );
     492             : 
     493             :     // dragging out of the visible area?
     494           0 :     if ( rEvt.IsLeft() &&
     495           0 :          ( rEvt.GetPosPixel().Y() > GetSizePixel().Height() ||
     496           0 :            rEvt.GetPosPixel().Y() < 0 ) )
     497             :     {
     498             :         // repeat the event
     499           0 :         aRepeatEvt = rEvt;
     500           0 :         aMouseTimer.Start();
     501             :     }
     502             :     else
     503             :         // killing old repeat-event
     504           0 :         if ( aMouseTimer.IsActive() )
     505           0 :             aMouseTimer.Stop();
     506             : }
     507             : 
     508             : //-------------------------------------------------------------------
     509             : 
     510           0 : IMPL_LINK_NOARG_INLINE_START(BrowserDataWin, RepeatedMouseMove)
     511             : {
     512           0 :     GetParent()->MouseMove( BrowserMouseEvent( this, aRepeatEvt ) );
     513           0 :     return 0;
     514             : }
     515           0 : IMPL_LINK_NOARG_INLINE_END(BrowserDataWin, RepeatedMouseMove)
     516             : 
     517             : //-------------------------------------------------------------------
     518             : 
     519           0 : void BrowserDataWin::MouseButtonUp( const MouseEvent& rEvt )
     520             : {
     521             :     // avoid pseudo MouseMoves
     522           0 :     Point aNewPos = OutputToScreenPixel( rEvt.GetPosPixel() );
     523           0 :     aLastMousePos = aNewPos;
     524             : 
     525             :     // simulate a move to the current position
     526           0 :     MouseMove( rEvt );
     527             : 
     528             :     // actual button up handling
     529           0 :     ReleaseMouse();
     530           0 :     if ( aMouseTimer.IsActive() )
     531           0 :         aMouseTimer.Stop();
     532           0 :     GetParent()->MouseButtonUp( BrowserMouseEvent( this, rEvt ) );
     533           0 : }
     534             : 
     535             : //-------------------------------------------------------------------
     536             : 
     537           0 : void BrowserDataWin::StartRowDividerDrag( const Point& _rStartPos )
     538             : {
     539           0 :     long nDataRowHeight = GetParent()->GetDataRowHeight();
     540             :     // the exact separation pos of the two rows
     541           0 :     long nDragRowDividerCurrentPos = _rStartPos.Y();
     542           0 :     if ( ( nDragRowDividerCurrentPos % nDataRowHeight ) > nDataRowHeight / 2 )
     543           0 :         nDragRowDividerCurrentPos += nDataRowHeight;
     544           0 :     nDragRowDividerCurrentPos /= nDataRowHeight;
     545           0 :     nDragRowDividerCurrentPos *= nDataRowHeight;
     546             : 
     547           0 :     m_nDragRowDividerOffset = nDragRowDividerCurrentPos - _rStartPos.Y();
     548             : 
     549           0 :     m_nDragRowDividerLimit = nDragRowDividerCurrentPos - nDataRowHeight;
     550             : 
     551           0 :     GetParent()->bRowDividerDrag = sal_True;
     552           0 :     GetParent()->ImplStartTracking();
     553             : 
     554           0 :     Rectangle aDragSplitRect( 0, m_nDragRowDividerLimit, GetOutputSizePixel().Width(), nDragRowDividerCurrentPos );
     555           0 :     ShowTracking( aDragSplitRect, SHOWTRACK_SMALL );
     556             : 
     557           0 :     StartTracking();
     558           0 : }
     559             : 
     560             : //-------------------------------------------------------------------
     561             : 
     562           0 : void BrowserDataWin::Tracking( const TrackingEvent& rTEvt )
     563             : {
     564           0 :     if ( !GetParent()->bRowDividerDrag )
     565           0 :         return;
     566             : 
     567           0 :     Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
     568             :     // stop resizing at our bottom line
     569           0 :     if ( aMousePos.Y() > GetOutputSizePixel().Height() )
     570           0 :         aMousePos.Y() = GetOutputSizePixel().Height();
     571             : 
     572           0 :     if ( rTEvt.IsTrackingEnded() )
     573             :     {
     574           0 :         HideTracking();
     575           0 :         GetParent()->bRowDividerDrag = sal_False;
     576           0 :         GetParent()->ImplEndTracking();
     577             : 
     578           0 :         if ( !rTEvt.IsTrackingCanceled() )
     579             :         {
     580           0 :             long nNewRowHeight = aMousePos.Y() + m_nDragRowDividerOffset - m_nDragRowDividerLimit;
     581             : 
     582             :             // care for minimum row height
     583           0 :             if ( nNewRowHeight < GetParent()->QueryMinimumRowHeight() )
     584           0 :                 nNewRowHeight = GetParent()->QueryMinimumRowHeight();
     585             : 
     586           0 :             GetParent()->SetDataRowHeight( nNewRowHeight );
     587           0 :             GetParent()->RowHeightChanged();
     588             :         }
     589             :     }
     590             :     else
     591             :     {
     592           0 :         GetParent()->ImplTracking();
     593             : 
     594           0 :         long nDragRowDividerCurrentPos = aMousePos.Y() + m_nDragRowDividerOffset;
     595             : 
     596             :         // care for minimum row height
     597           0 :         if ( nDragRowDividerCurrentPos < m_nDragRowDividerLimit + GetParent()->QueryMinimumRowHeight() )
     598           0 :             nDragRowDividerCurrentPos = m_nDragRowDividerLimit + GetParent()->QueryMinimumRowHeight();
     599             : 
     600           0 :         Rectangle aDragSplitRect( 0, m_nDragRowDividerLimit, GetOutputSizePixel().Width(), nDragRowDividerCurrentPos );
     601           0 :         ShowTracking( aDragSplitRect, SHOWTRACK_SMALL );
     602             :     }
     603             : }
     604             : 
     605             : //-------------------------------------------------------------------
     606             : 
     607           0 : void BrowserDataWin::KeyInput( const KeyEvent& rEvt )
     608             : {
     609             :     // pass to parent window
     610           0 :     if ( !GetParent()->ProcessKey( rEvt ) )
     611           0 :         Control::KeyInput( rEvt );
     612           0 : }
     613             : 
     614             : //-------------------------------------------------------------------
     615             : 
     616           0 : void BrowserDataWin::RequestHelp( const HelpEvent& rHEvt )
     617             : {
     618           0 :     pEventWin = this;
     619           0 :     GetParent()->RequestHelp( rHEvt );
     620           0 :     pEventWin = GetParent();
     621           0 : }
     622             : 
     623             : //===================================================================
     624             : 
     625           0 : 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           0 :     nColId(nColumnId)
     633             : {
     634           0 : }
     635             : 
     636             : //===================================================================
     637           0 : BrowserMouseEvent::BrowserMouseEvent( BrowserDataWin *pWindow,
     638             :                           const MouseEvent& rEvt ):
     639             :     MouseEvent(rEvt),
     640           0 :     BrowseEvent( pWindow->CreateBrowseEvent( rEvt.GetPosPixel() ) )
     641             : {
     642           0 : }
     643             : 
     644             : //-------------------------------------------------------------------
     645             : 
     646           0 : BrowserMouseEvent::BrowserMouseEvent( Window *pWindow, const MouseEvent& rEvt,
     647             :                           long nAbsRow, sal_uInt16 nColumn, sal_uInt16 nColumnId,
     648             :                           const Rectangle& rRect ):
     649             :     MouseEvent(rEvt),
     650           0 :     BrowseEvent( pWindow, nAbsRow, nColumn, nColumnId, rRect )
     651             : {
     652           0 : }
     653             : 
     654             : //===================================================================
     655             : 
     656           0 : BrowserAcceptDropEvent::BrowserAcceptDropEvent( BrowserDataWin *pWindow, const AcceptDropEvent& rEvt )
     657             :     :AcceptDropEvent(rEvt)
     658           0 :     ,BrowseEvent( pWindow->CreateBrowseEvent( rEvt.maPosPixel ) )
     659             : {
     660           0 : }
     661             : 
     662             : //===================================================================
     663             : 
     664           0 : BrowserExecuteDropEvent::BrowserExecuteDropEvent( BrowserDataWin *pWindow, const ExecuteDropEvent& rEvt )
     665             :     :ExecuteDropEvent(rEvt)
     666           0 :     ,BrowseEvent( pWindow->CreateBrowseEvent( rEvt.maPosPixel ) )
     667             : {
     668           0 : }
     669             : 
     670             : //===================================================================
     671             : 
     672             : //-------------------------------------------------------------------
     673             : 
     674          44 : void BrowserDataWin::SetUpdateMode( sal_Bool bMode )
     675             : {
     676             :     DBG_ASSERT( !bUpdateMode || aInvalidRegion.empty(), "invalid region not empty" );
     677          44 :     if ( (bool) bMode == bUpdateMode )
     678          44 :         return;
     679             : 
     680          44 :     bUpdateMode = bMode;
     681          44 :     if ( bMode )
     682          22 :         DoOutstandingInvalidations();
     683             : }
     684             : 
     685             : //-------------------------------------------------------------------
     686          86 : void BrowserDataWin::DoOutstandingInvalidations()
     687             : {
     688         132 :     for ( size_t i = 0, n = aInvalidRegion.size(); i < n; ++i ) {
     689          46 :         Control::Invalidate( *aInvalidRegion[ i ] );
     690          46 :         delete aInvalidRegion[ i ];
     691             :     }
     692          86 :     aInvalidRegion.clear();
     693          86 : }
     694             : 
     695             : //-------------------------------------------------------------------
     696             : 
     697         315 : void BrowserDataWin::Invalidate( sal_uInt16 nFlags )
     698             : {
     699         315 :     if ( !GetUpdateMode() )
     700             :     {
     701          25 :         for ( size_t i = 0, n = aInvalidRegion.size(); i < n; ++i )
     702           2 :             delete aInvalidRegion[ i ];
     703          23 :         aInvalidRegion.clear();
     704          23 :         aInvalidRegion.push_back( new Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) );
     705             :     }
     706             :     else
     707         292 :         Window::Invalidate( nFlags );
     708         315 : }
     709             : 
     710             : //-------------------------------------------------------------------
     711             : 
     712          40 : void BrowserDataWin::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags )
     713             : {
     714          40 :     if ( !GetUpdateMode() )
     715           1 :         aInvalidRegion.push_back( new Rectangle( rRect ) );
     716             :     else
     717          39 :         Window::Invalidate( rRect, nFlags );
     718          40 : }
     719             : 
     720             : //===================================================================
     721             : 
     722           0 : void BrowserScrollBar::Tracking( const TrackingEvent& rTEvt )
     723             : {
     724           0 :     sal_uLong nPos = GetThumbPos();
     725           0 :     if ( nPos != _nLastPos )
     726             :     {
     727           0 :         String aTip( OUString::number(nPos) );
     728           0 :         aTip += '/';
     729           0 :         if ( _pDataWin->GetRealRowCount().Len() )
     730           0 :             aTip += _pDataWin->GetRealRowCount();
     731             :         else
     732           0 :             aTip += OUString::number(GetRangeMax());
     733             : 
     734           0 :         Rectangle aRect( GetPointerPosPixel(), Size( GetTextHeight(), GetTextWidth( aTip ) ) );
     735           0 :         if ( _nTip )
     736           0 :             Help::UpdateTip( _nTip, this, aRect, aTip );
     737             :         else
     738           0 :             _nTip = Help::ShowTip( this, aRect, aTip );
     739           0 :         _nLastPos = nPos;
     740             :     }
     741             : 
     742           0 :     ScrollBar::Tracking( rTEvt );
     743           0 : }
     744             : 
     745             : //-------------------------------------------------------------------
     746             : 
     747           0 : void BrowserScrollBar::EndScroll()
     748             : {
     749           0 :     if ( _nTip )
     750           0 :         Help::HideTip( _nTip );
     751           0 :     _nTip = 0;
     752           0 :     ScrollBar::EndScroll();
     753         465 : }
     754             : 
     755             : 
     756             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10