xref: /trunk/main/svx/inc/svx/svdhlpln.hxx (revision 3334a7e6)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVDHLPLN_HXX
25 #define _SVDHLPLN_HXX
26 
27 #include <sal/types.h>
28 #include <tools/color.hxx>
29 #include <tools/gen.hxx>
30 
31 #ifndef _POINTR_HXX //autogen
32 #include <vcl/pointr.hxx>
33 #endif
34 #include <tools/contnr.hxx>
35 #include "svx/svxdllapi.h"
36 
37 class OutputDevice;
38 ////////////////////////////////////////////////////////////////////////////////////////////////////
39 
40 enum SdrHelpLineKind {SDRHELPLINE_POINT,SDRHELPLINE_VERTICAL,SDRHELPLINE_HORIZONTAL};
41 #define SDRHELPLINE_MIN SDRHELPLINE_POINT
42 #define SDRHELPLINE_MAX SDRHELPLINE_HORIZONTAL
43 
44 #define SDRHELPLINE_POINT_PIXELSIZE 15 /* Tatsaechliche Groesse= PIXELSIZE*2+1 */
45 
46 class SdrHelpLine {
47 	Point            aPos; // je nach Wert von eKind ist X oder Y evtl. belanglos
48 	SdrHelpLineKind  eKind;
49 
50 	// #i27493#
51 	// Helper method to draw a hor or ver two-colored dashed line
52 	void ImpDrawDashedTwoColorLine(OutputDevice& rOut, sal_Int32 nStart, sal_Int32 nEnd, sal_Int32 nFixPos,
53 		sal_Int32 nStepWidth, Color aColA, Color aColB, sal_Bool bHorizontal) const;
54 
55 public:
SdrHelpLine(SdrHelpLineKind eNewKind=SDRHELPLINE_POINT)56 	SdrHelpLine(SdrHelpLineKind eNewKind=SDRHELPLINE_POINT): eKind(eNewKind) {}
SdrHelpLine(SdrHelpLineKind eNewKind,const Point & rNewPos)57 	SdrHelpLine(SdrHelpLineKind eNewKind, const Point& rNewPos): aPos(rNewPos), eKind(eNewKind) {}
operator ==(const SdrHelpLine & rCmp) const58 	bool operator==(const SdrHelpLine& rCmp) const { return aPos==rCmp.aPos && eKind==rCmp.eKind; }
operator !=(const SdrHelpLine & rCmp) const59 	bool operator!=(const SdrHelpLine& rCmp) const { return !operator==(rCmp); }
60 
SetKind(SdrHelpLineKind eNewKind)61 	void            SetKind(SdrHelpLineKind eNewKind) { eKind=eNewKind; }
GetKind() const62 	SdrHelpLineKind GetKind() const                   { return eKind; }
SetPos(const Point & rPnt)63 	void            SetPos(const Point& rPnt)         { aPos=rPnt; }
GetPos() const64 	const Point&    GetPos() const                    { return aPos; }
65 
66 	Pointer         GetPointer() const;
67 	FASTBOOL        IsHit(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const;
68 	// OutputDevice wird benoetigt, da Fangpunkte eine feste Pixelgroesse haben
69 	Rectangle       GetBoundRect(const OutputDevice& rOut) const;
70 
71 	/* returns true if this and the given help line would be rendered at the same pixel position
72 		of the given OutputDevice. This can be used to avoid drawing multiple help lines with xor
73 		on same position which could render them invisible */
74 	bool			IsVisibleEqual( const SdrHelpLine& rHelpLine, const OutputDevice& rOut ) const;
75 };
76 
77 #define SDRHELPLINE_NOTFOUND 0xFFFF
78 
79 class SVX_DLLPUBLIC SdrHelpLineList {
80 	Container aList;
81 protected:
GetObject(sal_uInt16 i) const82 	SdrHelpLine* GetObject(sal_uInt16 i) const { return (SdrHelpLine*)(aList.GetObject(i)); }
83 public:
SdrHelpLineList()84 	SdrHelpLineList(): aList(1024,4,4) {}
SdrHelpLineList(const SdrHelpLineList & rSrcList)85 	SdrHelpLineList(const SdrHelpLineList& rSrcList): aList(1024,4,4)      { *this=rSrcList; }
~SdrHelpLineList()86 	~SdrHelpLineList()                                                     { Clear(); }
87 	void               Clear();
88 	void               operator=(const SdrHelpLineList& rSrcList);
89 	bool operator==(const SdrHelpLineList& rCmp) const;
operator !=(const SdrHelpLineList & rCmp) const90 	bool operator!=(const SdrHelpLineList& rCmp) const                 { return !operator==(rCmp); }
GetCount() const91 	sal_uInt16             GetCount() const                                    { return sal_uInt16(aList.Count()); }
Insert(const SdrHelpLine & rHL,sal_uInt16 nPos=0xFFFF)92 	void               Insert(const SdrHelpLine& rHL, sal_uInt16 nPos=0xFFFF)  { aList.Insert(new SdrHelpLine(rHL),nPos); }
Delete(sal_uInt16 nPos)93 	void               Delete(sal_uInt16 nPos)                                 { delete (SdrHelpLine*)aList.Remove(nPos); } // #i24900#
Move(sal_uInt16 nPos,sal_uInt16 nNewPos)94 	void               Move(sal_uInt16 nPos, sal_uInt16 nNewPos)                   { aList.Insert(aList.Remove(nPos),nNewPos); }
operator [](sal_uInt16 nPos)95 	SdrHelpLine&       operator[](sal_uInt16 nPos)                             { return *GetObject(nPos); }
operator [](sal_uInt16 nPos) const96 	const SdrHelpLine& operator[](sal_uInt16 nPos) const                       { return *GetObject(nPos); }
97 	sal_uInt16             HitTest(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const;
98 };
99 
100 ////////////////////////////////////////////////////////////////////////////////////////////////////
101 
102 #endif //_SVDHLPLN_HXX
103 
104