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/window.hxx>
25 #include <tools/poly.hxx>
26 #include <vcl/lineinfo.hxx>
30 Pointer
SdrHelpLine::GetPointer() const
33 case SDRHELPLINE_VERTICAL
: return Pointer(POINTER_ESIZE
);
34 case SDRHELPLINE_HORIZONTAL
: return Pointer(POINTER_SSIZE
);
35 default : return Pointer(POINTER_MOVE
);
39 bool SdrHelpLine::IsHit(const Point
& rPnt
, sal_uInt16 nTolLog
, const OutputDevice
& rOut
) const
41 Size
a1Pix(rOut
.PixelToLogic(Size(1,1)));
42 bool bXHit
=rPnt
.X()>=aPos
.X()-nTolLog
&& rPnt
.X()<=aPos
.X()+nTolLog
+a1Pix
.Width();
43 bool bYHit
=rPnt
.Y()>=aPos
.Y()-nTolLog
&& rPnt
.Y()<=aPos
.Y()+nTolLog
+a1Pix
.Height();
45 case SDRHELPLINE_VERTICAL
: return bXHit
;
46 case SDRHELPLINE_HORIZONTAL
: return bYHit
;
47 case SDRHELPLINE_POINT
: {
49 Size
aRad(rOut
.PixelToLogic(Size(SDRHELPLINE_POINT_PIXELSIZE
,SDRHELPLINE_POINT_PIXELSIZE
)));
50 return rPnt
.X()>=aPos
.X()-aRad
.Width() && rPnt
.X()<=aPos
.X()+aRad
.Width()+a1Pix
.Width() &&
51 rPnt
.Y()>=aPos
.Y()-aRad
.Height() && rPnt
.Y()<=aPos
.Y()+aRad
.Height()+a1Pix
.Height();
58 Rectangle
SdrHelpLine::GetBoundRect(const OutputDevice
& rOut
) const
60 Rectangle
aRet(aPos
,aPos
);
61 Point
aOfs(rOut
.GetMapMode().GetOrigin());
62 Size
aSiz(rOut
.GetOutputSize());
64 case SDRHELPLINE_VERTICAL
: aRet
.Top()=-aOfs
.Y(); aRet
.Bottom()=-aOfs
.Y()+aSiz
.Height(); break;
65 case SDRHELPLINE_HORIZONTAL
: aRet
.Left()=-aOfs
.X(); aRet
.Right()=-aOfs
.X()+aSiz
.Width(); break;
66 case SDRHELPLINE_POINT
: {
67 Size
aRad(rOut
.PixelToLogic(Size(SDRHELPLINE_POINT_PIXELSIZE
,SDRHELPLINE_POINT_PIXELSIZE
)));
68 aRet
.Left() -=aRad
.Width();
69 aRet
.Right() +=aRad
.Width();
70 aRet
.Top() -=aRad
.Height();
71 aRet
.Bottom()+=aRad
.Height();
77 void SdrHelpLineList::Clear()
79 sal_uInt16 nAnz
=GetCount();
80 for (sal_uInt16 i
=0; i
<nAnz
; i
++) {
86 void SdrHelpLineList::operator=(const SdrHelpLineList
& rSrcList
)
89 sal_uInt16 nAnz
=rSrcList
.GetCount();
90 for (sal_uInt16 i
=0; i
<nAnz
; i
++) {
95 bool SdrHelpLineList::operator==(const SdrHelpLineList
& rSrcList
) const
98 sal_uInt16 nAnz
=GetCount();
99 if (nAnz
==rSrcList
.GetCount()) {
101 for (sal_uInt16 i
=0; i
<nAnz
&& bEqual
; i
++) {
102 if (*GetObject(i
)!=*rSrcList
.GetObject(i
)) {
110 sal_uInt16
SdrHelpLineList::HitTest(const Point
& rPnt
, sal_uInt16 nTolLog
, const OutputDevice
& rOut
) const
112 sal_uInt16 nAnz
=GetCount();
113 for (sal_uInt16 i
=nAnz
; i
>0;) {
115 if (GetObject(i
)->IsHit(rPnt
,nTolLog
,rOut
)) return i
;
117 return SDRHELPLINE_NOTFOUND
;
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */