LibreOffice Module sw (master)  1
shdwcrsr.cxx
Go to the documentation of this file.
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 <shdwcrsr.hxx>
22 
23 using namespace ::com::sun::star;
24 
26 {
27  if( USHRT_MAX != nOldMode )
29 }
30 
31 void SwShadowCursor::SetPos( const Point& rPt, tools::Long nHeight, sal_uInt16 nMode )
32 {
33  Point aPt( pWin->LogicToPixel( rPt ));
34  nHeight = pWin->LogicToPixel( Size( 0, nHeight )).Height();
35  if( aOldPt != aPt || nOldHeight != nHeight || nOldMode != nMode )
36  {
37  if( USHRT_MAX != nOldMode )
39 
40  DrawCursor( aPt, nHeight, nMode );
41  nOldMode = nMode;
42  nOldHeight = nHeight;
43  aOldPt = aPt;
44  }
45 }
46 
47 void SwShadowCursor::DrawTri( const Point& rPt, tools::Long nHeight, bool bLeft )
48 {
49  tools::Long nLineDiff = nHeight / 2;
50  tools::Long nLineDiffHalf = nLineDiff / 2;
51 
52  // Dot above
53  Point aPt1( (bLeft ? rPt.X() - 3 : rPt.X() + 3),
54  rPt.Y() + nLineDiffHalf );
55  // Dot below
56  Point aPt2( aPt1.X(), aPt1.Y() + nHeight - nLineDiff - 1 );
57  tools::Long nDiff = bLeft ? -1 : 1;
58  while( aPt1.Y() <= aPt2.Y() )
59  {
60  pWin->DrawLine( aPt1, aPt2 );
61  aPt1.AdjustY( 1 );
62  aPt2.AdjustY( -1 );
63  aPt2.setX( aPt1.AdjustX(nDiff ) );
64  }
65 }
66 
67 void SwShadowCursor::DrawCursor( const Point& rPt, tools::Long nHeight, sal_uInt16 nMode )
68 {
69  nHeight = (((nHeight / 4)+1) * 4) + 1;
70 
71  pWin->Push();
72 
73  pWin->SetMapMode(MapMode(MapUnit::MapPixel));
74  pWin->SetRasterOp( RasterOp::Xor );
75 
76  pWin->SetLineColor( Color( ColorTransparency, sal_uInt32(aCol) ^ sal_uInt32(COL_WHITE) ) );
77 
78  // 1. The Line:
79  pWin->DrawLine( Point( rPt.X(), rPt.Y() + 1),
80  Point( rPt.X(), rPt.Y() - 2 + nHeight ));
81 
82  // 2. The Triangle
83  if( text::HoriOrientation::LEFT == nMode || text::HoriOrientation::CENTER == nMode ) // Arrow to the right
84  DrawTri( rPt, nHeight, false );
85  if( text::HoriOrientation::RIGHT == nMode || text::HoriOrientation::CENTER == nMode ) // Arrow to the left
86  DrawTri( rPt, nHeight, true );
87 
88  pWin->Pop();
89 }
90 
92 {
93  if( USHRT_MAX != nOldMode )
95 }
96 
98 {
100  Point aPt( aOldPt );
101 
102  nH = (((nH / 4)+1) * 4) + 1;
103  tools::Long nWidth = nH / 4 + 3 + 1;
104 
105  Size aSz( nWidth, nH );
106 
107  if( text::HoriOrientation::RIGHT == nOldMode )
108  aPt.AdjustX( -(aSz.Width()) );
109  else if( text::HoriOrientation::CENTER == nOldMode )
110  {
111  aPt.AdjustX( -(aSz.Width()) );
112  aSz.setWidth( aSz.Width() * 2 );
113  }
114 
115  return pWin->PixelToLogic( tools::Rectangle( aPt, aSz ) );
116 }
117 
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 nOldMode
Definition: shdwcrsr.hxx:34
void setWidth(tools::Long nWidth)
long Long
void DrawTri(const Point &rPt, tools::Long nHeight, bool bLeft)
Definition: shdwcrsr.cxx:47
VclPtr< vcl::Window > pWin
Definition: shdwcrsr.hxx:30
void DrawCursor(const Point &rPt, tools::Long nHeight, sal_uInt16 nMode)
Definition: shdwcrsr.cxx:67
void SetPos(const Point &rPt, tools::Long nHeight, sal_uInt16 nMode)
Definition: shdwcrsr.cxx:31
void SetMapMode()
constexpr tools::Long Width() const
tools::Rectangle GetRect() const
Definition: shdwcrsr.cxx:97
void Paint()
Definition: shdwcrsr.cxx:91
void DrawLine(const Point &rStartPt, const Point &rEndPt)
void SetLineColor()
ColorTransparency
Point PixelToLogic(const Point &rDevicePt) const
Point LogicToPixel(const Point &rLogicPt) const
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
void SetRasterOp(RasterOp eRasterOp)
void Push(PushFlags nFlags=PushFlags::ALL)
tools::Long nOldHeight
Definition: shdwcrsr.hxx:33