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
23using namespace ::com::sun::star;
24
26{
27 if( USHRT_MAX != m_nOldMode )
29}
30
31void SwShadowCursor::SetPos( const Point& rPt, tools::Long nHeight, sal_uInt16 nMode )
32{
33 Point aPt( m_pWin->LogicToPixel( rPt ));
34 nHeight = m_pWin->LogicToPixel( Size( 0, nHeight )).Height();
35 if( m_aOldPt != aPt || m_nOldHeight != nHeight || m_nOldMode != nMode )
36 {
37 if( USHRT_MAX != m_nOldMode )
39
40 DrawCursor( aPt, nHeight, nMode );
41 m_nOldMode = nMode;
42 m_nOldHeight = nHeight;
43 m_aOldPt = aPt;
44 }
45}
46
47void 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 m_pWin->GetOutDev()->DrawLine( aPt1, aPt2 );
61 aPt1.AdjustY( 1 );
62 aPt2.AdjustY( -1 );
63 aPt2.setX( aPt1.AdjustX(nDiff ) );
64 }
65}
66
67void SwShadowCursor::DrawCursor( const Point& rPt, tools::Long nHeight, sal_uInt16 nMode )
68{
69 nHeight = (((nHeight / 4)+1) * 4) + 1;
70
71 m_pWin->GetOutDev()->Push();
72
73 m_pWin->SetMapMode(MapMode(MapUnit::MapPixel));
74 m_pWin->GetOutDev()->SetRasterOp( RasterOp::Xor );
75
76 m_pWin->GetOutDev()->SetLineColor( Color( ColorTransparency, sal_uInt32(m_aCol) ^ sal_uInt32(COL_WHITE) ) );
77
78 // 1. The Line:
79 m_pWin->GetOutDev()->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 m_pWin->GetOutDev()->Pop();
89}
90
92{
93 if( USHRT_MAX != m_nOldMode )
95}
96
98{
100 Point aPt( m_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 == m_nOldMode )
108 aPt.AdjustX( -(aSz.Width()) );
109 else if( text::HoriOrientation::CENTER == m_nOldMode )
110 {
111 aPt.AdjustX( -(aSz.Width()) );
112 aSz.setWidth( aSz.Width() * 2 );
113 }
114
115 return m_pWin->PixelToLogic( tools::Rectangle( aPt, aSz ) );
116}
117
118/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void setWidth(tools::Long nWidth)
constexpr tools::Long Width() const
void Paint()
Definition: shdwcrsr.cxx:91
VclPtr< vcl::Window > m_pWin
Definition: shdwcrsr.hxx:30
sal_uInt16 m_nOldMode
Definition: shdwcrsr.hxx:34
tools::Rectangle GetRect() const
Definition: shdwcrsr.cxx:97
void SetPos(const Point &rPt, tools::Long nHeight, sal_uInt16 nMode)
Definition: shdwcrsr.cxx:31
Point m_aOldPt
Definition: shdwcrsr.hxx:32
void DrawTri(const Point &rPt, tools::Long nHeight, bool bLeft)
Definition: shdwcrsr.cxx:47
tools::Long m_nOldHeight
Definition: shdwcrsr.hxx:33
void DrawCursor(const Point &rPt, tools::Long nHeight, sal_uInt16 nMode)
Definition: shdwcrsr.cxx:67
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
ColorTransparency
long Long