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 .
20 #ifndef INCLUDED_SVX_SVDHLPLN_HXX
21 #define INCLUDED_SVX_SVDHLPLN_HXX
23 #include <sal/types.h>
24 #include <tools/color.hxx>
25 #include <tools/gen.hxx>
27 #include <vcl/pointr.hxx>
28 #include <svx/svxdllapi.h>
31 ////////////////////////////////////////////////////////////////////////////////////////////////////
33 enum SdrHelpLineKind
{SDRHELPLINE_POINT
,SDRHELPLINE_VERTICAL
,SDRHELPLINE_HORIZONTAL
};
35 #define SDRHELPLINE_POINT_PIXELSIZE 15 /* Tatsaechliche Groesse= PIXELSIZE*2+1 */
38 Point aPos
; // je nach Wert von eKind ist X oder Y evtl. belanglos
39 SdrHelpLineKind eKind
;
42 // Helper method to draw a hor or ver two-colored dashed line
43 void ImpDrawDashedTwoColorLine(OutputDevice
& rOut
, sal_Int32 nStart
, sal_Int32 nEnd
, sal_Int32 nFixPos
,
44 sal_Int32 nStepWidth
, Color aColA
, Color aColB
, sal_Bool bHorizontal
) const;
47 explicit SdrHelpLine(SdrHelpLineKind eNewKind
=SDRHELPLINE_POINT
): eKind(eNewKind
) {}
48 SdrHelpLine(SdrHelpLineKind eNewKind
, const Point
& rNewPos
): aPos(rNewPos
), eKind(eNewKind
) {}
49 bool operator==(const SdrHelpLine
& rCmp
) const { return aPos
==rCmp
.aPos
&& eKind
==rCmp
.eKind
; }
50 bool operator!=(const SdrHelpLine
& rCmp
) const { return !operator==(rCmp
); }
52 void SetKind(SdrHelpLineKind eNewKind
) { eKind
=eNewKind
; }
53 SdrHelpLineKind
GetKind() const { return eKind
; }
54 void SetPos(const Point
& rPnt
) { aPos
=rPnt
; }
55 const Point
& GetPos() const { return aPos
; }
57 Pointer
GetPointer() const;
58 bool IsHit(const Point
& rPnt
, sal_uInt16 nTolLog
, const OutputDevice
& rOut
) const;
59 // OutputDevice wird benoetigt, da Fangpunkte eine feste Pixelgroesse haben
60 Rectangle
GetBoundRect(const OutputDevice
& rOut
) const;
63 #define SDRHELPLINE_NOTFOUND 0xFFFF
65 class SVX_DLLPUBLIC SdrHelpLineList
{
66 std::vector
<SdrHelpLine
*> aList
;
68 SdrHelpLine
* GetObject(sal_uInt16 i
) const { return aList
[i
]; }
70 SdrHelpLineList(): aList() {}
71 SdrHelpLineList(const SdrHelpLineList
& rSrcList
): aList() { *this=rSrcList
; }
72 ~SdrHelpLineList() { Clear(); }
74 void operator=(const SdrHelpLineList
& rSrcList
);
75 bool operator==(const SdrHelpLineList
& rCmp
) const;
76 bool operator!=(const SdrHelpLineList
& rCmp
) const { return !operator==(rCmp
); }
77 sal_uInt16
GetCount() const { return sal_uInt16(aList
.size()); }
78 void Insert(const SdrHelpLine
& rHL
) { aList
.push_back(new SdrHelpLine(rHL
)); }
79 void Insert(const SdrHelpLine
& rHL
, sal_uInt16 nPos
)
82 aList
.push_back(new SdrHelpLine(rHL
));
84 aList
.insert(aList
.begin() + nPos
, new SdrHelpLine(rHL
));
86 void Delete(sal_uInt16 nPos
)
88 SdrHelpLine
* p
= aList
[nPos
];
90 aList
.erase(aList
.begin() + nPos
);
92 void Move(sal_uInt16 nPos
, sal_uInt16 nNewPos
)
94 SdrHelpLine
* p
= aList
[nPos
];
95 aList
.erase(aList
.begin() + nPos
);
96 aList
.insert(aList
.begin() + nNewPos
, p
);
98 SdrHelpLine
& operator[](sal_uInt16 nPos
) { return *GetObject(nPos
); }
99 const SdrHelpLine
& operator[](sal_uInt16 nPos
) const { return *GetObject(nPos
); }
100 sal_uInt16
HitTest(const Point
& rPnt
, sal_uInt16 nTolLog
, const OutputDevice
& rOut
) const;
103 ////////////////////////////////////////////////////////////////////////////////////////////////////
105 #endif // INCLUDED_SVX_SVDHLPLN_HXX
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */