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_SVDDRAG_HXX
21 #define INCLUDED_SVX_SVDDRAG_HXX
24 #include <tools/gen.hxx>
25 #include <tools/fract.hxx>
26 #include <svx/svxdllapi.h>
30 // Status information for specialized object dragging. In order for the model
31 // to stay status free, the status data is kept on the View
32 // and handed over to the object at the appropriate time as a parameter.
33 // This also includes the status of the operation and Interactive
34 // Object creation. In this case, pHdl is null.
40 struct SVX_DLLPUBLIC SdrDragStatUserData
44 class SVX_DLLPUBLIC SdrDragStat
{
46 SdrHdl
* pHdl
; // The Handle for the User
48 SdrPageView
* pPageView
;
49 std::vector
<Point
*> aPnts
; // All previous Points: [0]=Start, [Count()-2]=Prev
50 Point aRef1
; // Referencepoint: Resize fixed point, (axis of rotation,
51 Point aRef2
; // axis of reflection, ...)
52 Point aPos0
; // Position at the last Event
53 Point aRealNow
; // Current dragging position without Snap, Ortho and Limit
54 Rectangle aActionRect
;
56 bool bEndDragChangesAttributes
;
57 bool bEndDragChangesGeoAndAttributes
;
60 bool bShown
; // Xor visible?
61 sal_uInt16 nMinMov
; // So much has to be minimally moved first
62 bool bMinMoved
; // MinMove surpassed?
64 bool bHorFixed
; // Dragging only vertical
65 bool bVerFixed
; // Dragging only horizontal
66 bool bWantNoSnap
; // To decide if pObj-> MovCreate () should use NoSnapPos or not.
67 // Therefore, NoSnapPos is written into the buffer.
71 SdrDragMethod
* pDragMethod
;
74 void Clear(bool bLeaveOne
);
75 Point
& Pnt(sal_uIntPtr nNum
) { return *aPnts
[nNum
]; }
77 SdrDragStatUserData
* pUser
; // Userdata
79 SdrDragStat(): aPnts() { pUser
=NULL
; Reset(); }
80 ~SdrDragStat() { Clear(false); }
82 SdrView
* GetView() const { return pView
; }
83 void SetView(SdrView
* pV
) { pView
=pV
; }
84 SdrPageView
* GetPageView() const { return pPageView
; }
85 void SetPageView(SdrPageView
* pPV
) { pPageView
=pPV
; }
86 const Point
& GetPoint(sal_uIntPtr nNum
) const { return *aPnts
[nNum
]; }
87 sal_uIntPtr
GetPointAnz() const { return aPnts
.size(); }
88 const Point
& GetStart() const { return GetPoint(0); }
89 Point
& Start() { return Pnt(0); }
90 const Point
& GetPrev() const { return GetPoint(GetPointAnz()-(GetPointAnz()>=2 ? 2:1)); }
91 Point
& Prev() { return Pnt(GetPointAnz()-(GetPointAnz()>=2 ? 2:1)); }
92 const Point
& GetPos0() const { return aPos0
; }
93 Point
& Pos0() { return aPos0
; }
94 const Point
& GetNow() const { return GetPoint(GetPointAnz()-1); }
95 Point
& Now() { return Pnt(GetPointAnz()-1); }
96 const Point
& GetRealNow() const { return aRealNow
; }
97 Point
& RealNow() { return aRealNow
; }
98 const Point
& GetRef1() const { return aRef1
; }
99 Point
& Ref1() { return aRef1
; }
100 const Point
& GetRef2() const { return aRef2
; }
101 Point
& Ref2() { return aRef2
; }
102 const SdrHdl
* GetHdl() const { return pHdl
; }
103 void SetHdl(SdrHdl
* pH
) { pHdl
=pH
; }
104 SdrDragStatUserData
* GetUser() const { return pUser
; }
105 void SetUser(SdrDragStatUserData
* pU
) { pUser
=pU
; }
106 bool IsShown() const { return bShown
; }
107 void SetShown(bool bOn
) { bShown
=bOn
; }
109 bool IsMinMoved() const { return bMinMoved
; }
110 void SetMinMoved() { bMinMoved
=true; }
111 void ResetMinMoved() { bMinMoved
=false; }
112 void SetMinMove(sal_uInt16 nDist
) { nMinMov
=nDist
; if (nMinMov
<1) nMinMov
=1; }
113 sal_uInt16
GetMinMove() const { return nMinMov
; }
115 bool IsHorFixed() const { return bHorFixed
; }
116 void SetHorFixed(bool bOn
) { bHorFixed
=bOn
; }
117 bool IsVerFixed() const { return bVerFixed
; }
118 void SetVerFixed(bool bOn
) { bVerFixed
=bOn
; }
120 // Here, the object can say: "I do not want to snap to coordinates!"
121 // for example, the angle of the arc ...
122 bool IsNoSnap() const { return bWantNoSnap
; }
123 void SetNoSnap(bool bOn
= true) { bWantNoSnap
=bOn
; }
125 // And here the Obj say which Ortho (if there is one) can be usefully applied to him.
126 // Ortho4 means Ortho in four directions (for Rect and CIRT)
127 bool IsOrtho4Possible() const { return bOrtho4
; }
128 void SetOrtho4Possible(bool bOn
= true) { bOrtho4
=bOn
; }
129 // Ortho8 means Ortho in 8 directions (for lines)
130 bool IsOrtho8Possible() const { return bOrtho8
; }
131 void SetOrtho8Possible(bool bOn
= true) { bOrtho8
=bOn
; }
133 // Is set by an object that was dragged.
134 bool IsEndDragChangesAttributes() const { return bEndDragChangesAttributes
; }
135 void SetEndDragChangesAttributes(bool bOn
) { bEndDragChangesAttributes
=bOn
; }
136 bool IsEndDragChangesGeoAndAttributes() const { return bEndDragChangesGeoAndAttributes
; }
137 void SetEndDragChangesGeoAndAttributes(bool bOn
) { bEndDragChangesGeoAndAttributes
=bOn
; }
139 // Is set by the view and can be evaluated by Obj
140 bool IsMouseDown() const { return !bMouseIsUp
; }
141 void SetMouseDown(bool bDown
) { bMouseIsUp
=!bDown
; }
143 static Point
KorregPos(const Point
& rNow
, const Point
& rPrev
);
144 void Reset(const Point
& rPnt
);
145 void NextMove(const Point
& rPnt
);
146 void NextPoint(bool bSaveReal
=false);
148 bool CheckMinMoved(const Point
& rPnt
);
149 long GetDX() const { return GetNow().X()-GetPrev().X(); }
150 long GetDY() const { return GetNow().Y()-GetPrev().Y(); }
151 Fraction
GetXFact() const;
152 Fraction
GetYFact() const;
154 SdrDragMethod
* GetDragMethod() const { return pDragMethod
; }
155 void SetDragMethod(SdrDragMethod
* pMth
) { pDragMethod
=pMth
; }
157 const Rectangle
& GetActionRect() const { return aActionRect
; }
158 void SetActionRect(const Rectangle
& rR
) { aActionRect
=rR
; }
160 // Also considering 1stPointAsCenter
161 void TakeCreateRect(Rectangle
& rRect
) const;
164 #endif // INCLUDED_SVX_SVDDRAG_HXX
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */