Branch data 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 : :
29 : 0 : SwShadowCursor::~SwShadowCursor()
30 : : {
31 [ # # ]: 0 : if( USHRT_MAX != nOldMode )
32 : 0 : DrawCrsr( aOldPt, nOldHeight, nOldMode );
33 : 0 : }
34 : :
35 : 0 : void SwShadowCursor::SetPos( const Point& rPt, long nHeight, sal_uInt16 nMode )
36 : : {
37 [ # # ]: 0 : Point aPt( pWin->LogicToPixel( rPt ));
38 [ # # ]: 0 : nHeight = pWin->LogicToPixel( Size( 0, nHeight )).Height();
39 [ # # ][ # # ]: 0 : if( aOldPt != aPt || nOldHeight != nHeight || nOldMode != nMode )
[ # # ][ # # ]
40 : : {
41 [ # # ]: 0 : if( USHRT_MAX != nOldMode )
42 [ # # ]: 0 : DrawCrsr( aOldPt, nOldHeight, nOldMode );
43 : :
44 [ # # ]: 0 : DrawCrsr( aPt, nHeight, nMode );
45 : 0 : nOldMode = nMode;
46 : 0 : nOldHeight = nHeight;
47 : 0 : aOldPt = aPt;
48 : : }
49 : 0 : }
50 : :
51 : 0 : void SwShadowCursor::DrawTri( const Point& rPt, long nHeight, sal_Bool bLeft )
52 : : {
53 : 0 : long nLineDiff = ( nHeight / 2 );
54 : 0 : long nLineDiffHalf = nLineDiff / 2;
55 : :
56 : : // Punkt oben
57 : 0 : Point aPt1( (bLeft ? rPt.X() - 3 : rPt.X() + 3),
58 [ # # ]: 0 : rPt.Y() + nLineDiffHalf );
59 : : // Punkt unten
60 : 0 : Point aPt2( aPt1.X(), aPt1.Y() + nHeight - nLineDiff - 1 );
61 [ # # ]: 0 : long nDiff = bLeft ? -1 : 1;
62 [ # # ]: 0 : while( aPt1.Y() <= aPt2.Y() )
63 : : {
64 [ # # ]: 0 : pWin->DrawLine( aPt1, aPt2 );
65 : 0 : aPt1.Y()++, aPt2.Y()--;
66 : 0 : aPt2.X() = aPt1.X() += nDiff;
67 : : }
68 : 0 : }
69 : :
70 : 0 : void SwShadowCursor::DrawCrsr( const Point& rPt, long nHeight, sal_uInt16 nMode )
71 : : {
72 : 0 : nHeight = (((nHeight / 4)+1) * 4) + 1;
73 : :
74 : 0 : pWin->Push();
75 : :
76 [ # # ]: 0 : pWin->SetMapMode( MAP_PIXEL );
77 : 0 : pWin->SetRasterOp( ROP_XOR );
78 : :
79 [ # # ]: 0 : pWin->SetLineColor( Color( aCol.GetColor() ^ COL_WHITE ) );
80 : :
81 : : // 1. der Strich:
82 : 0 : pWin->DrawLine( Point( rPt.X(), rPt.Y() + 1),
83 [ # # ]: 0 : Point( rPt.X(), rPt.Y() - 2 + nHeight ));
84 : :
85 : : // 2. das Dreieck
86 [ # # ][ # # ]: 0 : if( text::HoriOrientation::LEFT == nMode || text::HoriOrientation::CENTER == nMode ) // Pfeil nach rechts
87 : 0 : DrawTri( rPt, nHeight, sal_False );
88 [ # # ][ # # ]: 0 : if( text::HoriOrientation::RIGHT == nMode || text::HoriOrientation::CENTER == nMode ) // Pfeil nach links
89 : 0 : DrawTri( rPt, nHeight, sal_True );
90 : :
91 : 0 : pWin->Pop();
92 : 0 : }
93 : :
94 : 0 : void SwShadowCursor::Paint()
95 : : {
96 [ # # ]: 0 : if( USHRT_MAX != nOldMode )
97 : 0 : DrawCrsr( aOldPt, nOldHeight, nOldMode );
98 : 0 : }
99 : :
100 : 0 : Rectangle SwShadowCursor::GetRect() const
101 : : {
102 : 0 : long nH = nOldHeight;
103 : 0 : Point aPt( aOldPt );
104 : :
105 : 0 : nH = (((nH / 4)+1) * 4) + 1;
106 : 0 : long nWidth = nH / 4 + 3 + 1;
107 : :
108 : 0 : Size aSz( nWidth, nH );
109 : :
110 [ # # ]: 0 : if( text::HoriOrientation::RIGHT == nOldMode )
111 : 0 : aPt.X() -= aSz.Width();
112 [ # # ]: 0 : else if( text::HoriOrientation::CENTER == nOldMode )
113 : : {
114 : 0 : aPt.X() -= aSz.Width();
115 : 0 : aSz.Width() *= 2;
116 : : }
117 : :
118 [ # # ][ # # ]: 0 : return pWin->PixelToLogic( Rectangle( aPt, aSz ) );
119 : : }
120 : :
121 : :
122 : :
123 : :
124 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|