LCOV - code coverage report
Current view: top level - sw/source/core/uibase/utlui - shdwcrsr.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 57 0.0 %
Date: 2014-04-14 Functions: 0 6 0.0 %
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             : #include <com/sun/star/text/HoriOrientation.hpp>
      21             : #include <vcl/window.hxx>
      22             : 
      23             : #include "swtypes.hxx"
      24             : #include "shdwcrsr.hxx"
      25             : 
      26             : using namespace ::com::sun::star;
      27             : 
      28           0 : SwShadowCursor::~SwShadowCursor()
      29             : {
      30           0 :     if( USHRT_MAX != nOldMode )
      31           0 :         DrawCrsr( aOldPt, nOldHeight, nOldMode );
      32           0 : }
      33             : 
      34           0 : void SwShadowCursor::SetPos( const Point& rPt, long nHeight, sal_uInt16 nMode )
      35             : {
      36           0 :     Point aPt( pWin->LogicToPixel( rPt ));
      37           0 :     nHeight = pWin->LogicToPixel( Size( 0, nHeight )).Height();
      38           0 :     if( aOldPt != aPt || nOldHeight != nHeight || nOldMode != nMode )
      39             :     {
      40           0 :         if( USHRT_MAX != nOldMode )
      41           0 :             DrawCrsr( aOldPt, nOldHeight, nOldMode );
      42             : 
      43           0 :         DrawCrsr( aPt, nHeight, nMode );
      44           0 :         nOldMode = nMode;
      45           0 :         nOldHeight = nHeight;
      46           0 :         aOldPt = aPt;
      47             :     }
      48           0 : }
      49             : 
      50           0 : void SwShadowCursor::DrawTri( const Point& rPt, long nHeight, bool bLeft )
      51             : {
      52           0 :     long nLineDiff = ( nHeight / 2 );
      53           0 :     long nLineDiffHalf = nLineDiff / 2;
      54             : 
      55             :     // Dot above
      56           0 :     Point aPt1( (bLeft ? rPt.X() - 3 : rPt.X() + 3),
      57           0 :                 rPt.Y() + nLineDiffHalf );
      58             :     // Dot below
      59           0 :     Point aPt2( aPt1.X(), aPt1.Y() + nHeight - nLineDiff - 1 );
      60           0 :     long nDiff = bLeft ? -1 : 1;
      61           0 :     while( aPt1.Y() <= aPt2.Y() )
      62             :     {
      63           0 :         pWin->DrawLine( aPt1, aPt2 );
      64           0 :         aPt1.Y()++, aPt2.Y()--;
      65           0 :         aPt2.X() = aPt1.X() += nDiff;
      66             :     }
      67           0 : }
      68             : 
      69           0 : void SwShadowCursor::DrawCrsr( const Point& rPt, long nHeight, sal_uInt16 nMode )
      70             : {
      71           0 :     nHeight = (((nHeight / 4)+1) * 4) + 1;
      72             : 
      73           0 :     pWin->Push();
      74             : 
      75           0 :     pWin->SetMapMode( MAP_PIXEL );
      76           0 :     pWin->SetRasterOp( ROP_XOR );
      77             : 
      78           0 :     pWin->SetLineColor( Color( aCol.GetColor() ^ COL_WHITE ) );
      79             : 
      80             :     // 1. The Line:
      81           0 :     pWin->DrawLine( Point( rPt.X(), rPt.Y() + 1),
      82           0 :               Point( rPt.X(), rPt.Y() - 2 + nHeight ));
      83             : 
      84             :     // 2. The Triangle
      85           0 :     if( text::HoriOrientation::LEFT == nMode || text::HoriOrientation::CENTER == nMode )    // Arrow to the right
      86           0 :         DrawTri( rPt, nHeight, false );
      87           0 :     if( text::HoriOrientation::RIGHT == nMode || text::HoriOrientation::CENTER == nMode )   // Arrow to the left
      88           0 :         DrawTri( rPt, nHeight, true );
      89             : 
      90           0 :     pWin->Pop();
      91           0 : }
      92             : 
      93           0 : void SwShadowCursor::Paint()
      94             : {
      95           0 :     if( USHRT_MAX != nOldMode )
      96           0 :         DrawCrsr( aOldPt, nOldHeight, nOldMode );
      97           0 : }
      98             : 
      99           0 : Rectangle SwShadowCursor::GetRect() const
     100             : {
     101           0 :     long nH = nOldHeight;
     102           0 :     Point aPt( aOldPt );
     103             : 
     104           0 :     nH = (((nH / 4)+1) * 4) + 1;
     105           0 :     long nWidth = nH / 4 + 3 + 1;
     106             : 
     107           0 :     Size aSz( nWidth, nH );
     108             : 
     109           0 :     if( text::HoriOrientation::RIGHT == nOldMode )
     110           0 :         aPt.X() -= aSz.Width();
     111           0 :     else if( text::HoriOrientation::CENTER == nOldMode )
     112             :     {
     113           0 :         aPt.X() -= aSz.Width();
     114           0 :         aSz.Width() *= 2;
     115             :     }
     116             : 
     117           0 :     return pWin->PixelToLogic( Rectangle( aPt, aSz ) );
     118             : }
     119             : 
     120             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10