1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <svx/svdhlpln.hxx>
23 #include <vcl/outdev.hxx>
24 #include <vcl/ptrstyle.hxx>
27 PointerStyle
SdrHelpLine::GetPointer() const
30 case SdrHelpLineKind::Vertical
: return PointerStyle::ESize
;
31 case SdrHelpLineKind::Horizontal
: return PointerStyle::SSize
;
32 default : return PointerStyle::Move
;
36 bool SdrHelpLine::IsHit(const Point
& rPnt
, sal_uInt16 nTolLog
, const OutputDevice
& rOut
) const
38 Size
a1Pix(rOut
.PixelToLogic(Size(1,1)));
39 bool bXHit
=rPnt
.X()>=m_aPos
.X()-nTolLog
&& rPnt
.X()<=m_aPos
.X()+nTolLog
+a1Pix
.Width();
40 bool bYHit
=rPnt
.Y()>=m_aPos
.Y()-nTolLog
&& rPnt
.Y()<=m_aPos
.Y()+nTolLog
+a1Pix
.Height();
42 case SdrHelpLineKind::Vertical
: return bXHit
;
43 case SdrHelpLineKind::Horizontal
: return bYHit
;
44 case SdrHelpLineKind::Point
: {
46 Size
aRad(rOut
.PixelToLogic(Size(SDRHELPLINE_POINT_PIXELSIZE
,SDRHELPLINE_POINT_PIXELSIZE
)));
47 return rPnt
.X()>=m_aPos
.X()-aRad
.Width() && rPnt
.X()<=m_aPos
.X()+aRad
.Width()+a1Pix
.Width() &&
48 rPnt
.Y()>=m_aPos
.Y()-aRad
.Height() && rPnt
.Y()<=m_aPos
.Y()+aRad
.Height()+a1Pix
.Height();
55 tools::Rectangle
SdrHelpLine::GetBoundRect(const OutputDevice
& rOut
) const
57 tools::Rectangle
aRet(m_aPos
,m_aPos
);
58 Point
aOfs(rOut
.GetMapMode().GetOrigin());
59 Size
aSiz(rOut
.GetOutputSize());
61 case SdrHelpLineKind::Vertical
: aRet
.SetTop(-aOfs
.Y() ); aRet
.SetBottom(-aOfs
.Y()+aSiz
.Height() ); break;
62 case SdrHelpLineKind::Horizontal
: aRet
.SetLeft(-aOfs
.X() ); aRet
.SetRight(-aOfs
.X()+aSiz
.Width() ); break;
63 case SdrHelpLineKind::Point
: {
64 Size
aRad(rOut
.PixelToLogic(Size(SDRHELPLINE_POINT_PIXELSIZE
,SDRHELPLINE_POINT_PIXELSIZE
)));
65 aRet
.AdjustLeft( -(aRad
.Width()) );
66 aRet
.AdjustRight(aRad
.Width() );
67 aRet
.AdjustTop( -(aRad
.Height()) );
68 aRet
.AdjustBottom(aRad
.Height() );
74 SdrHelpLineList
& SdrHelpLineList::operator=(const SdrHelpLineList
& rSrcList
)
77 sal_uInt16 nCount
=rSrcList
.GetCount();
78 for (sal_uInt16 i
=0; i
<nCount
; i
++) {
84 bool SdrHelpLineList::operator==(const SdrHelpLineList
& rSrcList
) const
87 sal_uInt16 nCount
=GetCount();
88 if (nCount
==rSrcList
.GetCount()) {
90 for (sal_uInt16 i
=0; i
<nCount
&& bEqual
; i
++) {
91 if (*m_aList
[i
]!=*rSrcList
.m_aList
[i
]) {
99 sal_uInt16
SdrHelpLineList::HitTest(const Point
& rPnt
, sal_uInt16 nTolLog
, const OutputDevice
& rOut
) const
101 sal_uInt16 nCount
=GetCount();
102 for (sal_uInt16 i
=nCount
; i
>0;) {
104 if (m_aList
[i
]->IsHit(rPnt
,nTolLog
,rOut
)) return i
;
106 return SDRHELPLINE_NOTFOUND
;
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */