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 .
24 #include <tools/gen.hxx>
25 #include <tools/fract.hxx>
26 #include "svx/svxdllapi.h"
28 // Status information for specialized object dragging. In order for the model
29 // to stay status free, the status data is kept on the View
30 // and handed over to the object at the appropriate time as a parameter.
31 // This also includes the status of the operation and Interactive
32 // Object creation. In this case, pHdl is null.
38 struct SVX_DLLPUBLIC SdrDragStatUserData
42 class SVX_DLLPUBLIC SdrDragStat
{
44 SdrHdl
* pHdl
; // Der Handle an dem der User zottelt
46 SdrPageView
* pPageView
;
47 std::vector
<Point
*> aPnts
; // Alle bisherigen Punkte: [0]=Start, [Count()-2]=Prev
48 Point aRef1
; // Referenzpunkt: Resize-Fixpunkt, (Drehachse,
49 Point aRef2
; // Spiegelachse, ...)
50 Point aPos0
; // Position beim letzten Event
51 Point aRealPos0
; // Position beim letzten Event
52 Point aRealNow
; // Aktuelle Dragposition ohne Snap, Ortho und Limit
53 Point aRealLast
; // RealPos des letzten Punkts (fuer MinMoved)
54 Rectangle aActionRect
;
56 // Reserve fuer kompatible Erweiterungen, die sonst inkompatibel wuerden.
61 Rectangle aReserveRect1
;
62 Rectangle aReserveRect2
;
63 bool bEndDragChangesAttributes
;
64 bool bEndDragChangesGeoAndAttributes
;
77 bool bShown
; // Xor visible?
78 sal_uInt16 nMinMov
; // So much has to be minimally moved first
79 bool bMinMoved
; // MinMove surpassed?
81 bool bHorFixed
; // Dragging only vertical
82 bool bVerFixed
; // Dragging only horizontal
83 bool bWantNoSnap
; // To decide if pObj-> MovCreate () should use NoSnapPos or not.
84 // Therefore, NoSnapPos is written into the buffer.
88 SdrDragMethod
* pDragMethod
;
91 void Clear(bool bLeaveOne
);
92 Point
& Pnt(sal_uIntPtr nNum
) { return *aPnts
[nNum
]; }
94 SdrDragStatUserData
* pUser
; // Userdata
96 SdrDragStat(): aPnts() { pUser
=NULL
; Reset(); }
97 ~SdrDragStat() { Clear(sal_False
); }
99 SdrView
* GetView() const { return pView
; }
100 void SetView(SdrView
* pV
) { pView
=pV
; }
101 SdrPageView
* GetPageView() const { return pPageView
; }
102 void SetPageView(SdrPageView
* pPV
) { pPageView
=pPV
; }
103 const Point
& GetPoint(sal_uIntPtr nNum
) const { return *aPnts
[nNum
]; }
104 sal_uIntPtr
GetPointAnz() const { return aPnts
.size(); }
105 const Point
& GetStart() const { return GetPoint(0); }
106 Point
& Start() { return Pnt(0); }
107 const Point
& GetPrev() const { return GetPoint(GetPointAnz()-(GetPointAnz()>=2 ? 2:1)); }
108 Point
& Prev() { return Pnt(GetPointAnz()-(GetPointAnz()>=2 ? 2:1)); }
109 const Point
& GetPos0() const { return aPos0
; }
110 Point
& Pos0() { return aPos0
; }
111 const Point
& GetNow() const { return GetPoint(GetPointAnz()-1); }
112 Point
& Now() { return Pnt(GetPointAnz()-1); }
113 const Point
& GetRealNow() const { return aRealNow
; }
114 Point
& RealNow() { return aRealNow
; }
115 const Point
& GetRef1() const { return aRef1
; }
116 Point
& Ref1() { return aRef1
; }
117 const Point
& GetRef2() const { return aRef2
; }
118 Point
& Ref2() { return aRef2
; }
119 const SdrHdl
* GetHdl() const { return pHdl
; }
120 void SetHdl(SdrHdl
* pH
) { pHdl
=pH
; }
121 SdrDragStatUserData
* GetUser() const { return pUser
; }
122 void SetUser(SdrDragStatUserData
* pU
) { pUser
=pU
; }
123 bool IsShown() const { return bShown
; }
124 void SetShown(bool bOn
) { bShown
=bOn
; }
126 bool IsMinMoved() const { return bMinMoved
; }
127 void SetMinMoved() { bMinMoved
=sal_True
; }
128 void ResetMinMoved() { bMinMoved
=sal_False
; }
129 void SetMinMove(sal_uInt16 nDist
) { nMinMov
=nDist
; if (nMinMov
<1) nMinMov
=1; }
130 sal_uInt16
GetMinMove() const { return nMinMov
; }
132 bool IsHorFixed() const { return bHorFixed
; }
133 void SetHorFixed(bool bOn
) { bHorFixed
=bOn
; }
134 bool IsVerFixed() const { return bVerFixed
; }
135 void SetVerFixed(bool bOn
) { bVerFixed
=bOn
; }
137 // Here, the object can say: "I do not want to snap to coordinates!"
138 // for example, the angle of the arc ...
139 bool IsNoSnap() const { return bWantNoSnap
; }
140 void SetNoSnap(bool bOn
= true) { bWantNoSnap
=bOn
; }
142 // And here the Obj say which Ortho (if there is one)
143 // can be usefully applied to him.
144 // Ortho4 means Ortho in four directions (for Rect and CIRT)
145 bool IsOrtho4Possible() const { return bOrtho4
; }
146 void SetOrtho4Possible(bool bOn
= true) { bOrtho4
=bOn
; }
147 // Ortho8 means Ortho in 8 directions (for lines)
148 bool IsOrtho8Possible() const { return bOrtho8
; }
149 void SetOrtho8Possible(bool bOn
= true) { bOrtho8
=bOn
; }
151 // Is set by an object that was dragged.
152 bool IsEndDragChangesAttributes() const { return bEndDragChangesAttributes
; }
153 void SetEndDragChangesAttributes(bool bOn
) { bEndDragChangesAttributes
=bOn
; }
154 bool IsEndDragChangesGeoAndAttributes() const { return bEndDragChangesGeoAndAttributes
; }
155 void SetEndDragChangesGeoAndAttributes(bool bOn
) { bEndDragChangesGeoAndAttributes
=bOn
; }
157 // Is set by the view and can be evaluated by Obj
158 bool IsMouseDown() const { return !bMouseIsUp
; }
159 void SetMouseDown(bool bDown
) { bMouseIsUp
=!bDown
; }
161 Point
KorregPos(const Point
& rNow
, const Point
& rPrev
) const;
162 void Reset(const Point
& rPnt
);
163 void NextMove(const Point
& rPnt
);
164 void NextPoint(bool bSaveReal
=sal_False
);
166 bool CheckMinMoved(const Point
& rPnt
);
167 long GetDX() const { return GetNow().X()-GetPrev().X(); }
168 long GetDY() const { return GetNow().Y()-GetPrev().Y(); }
169 Fraction
GetXFact() const;
170 Fraction
GetYFact() const;
172 SdrDragMethod
* GetDragMethod() const { return pDragMethod
; }
173 void SetDragMethod(SdrDragMethod
* pMth
) { pDragMethod
=pMth
; }
175 const Rectangle
& GetActionRect() const { return aActionRect
; }
176 void SetActionRect(const Rectangle
& rR
) { aActionRect
=rR
; }
178 // also considering 1stPointAsCenter
179 void TakeCreateRect(Rectangle
& rRect
) const;
182 #endif //_SVDDRAG_HXX
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */