Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _SVDDRAG_HXX
21 : #define _SVDDRAG_HXX
22 :
23 :
24 : #include <tools/gen.hxx>
25 : #include <tools/fract.hxx>
26 : #include "svx/svxdllapi.h"
27 :
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.
33 : class SdrHdl;
34 : class SdrView;
35 : class SdrPageView;
36 : class SdrDragMethod;
37 :
38 : struct SVX_DLLPUBLIC SdrDragStatUserData
39 : {
40 : };
41 :
42 : class SVX_DLLPUBLIC SdrDragStat {
43 : protected:
44 : SdrHdl* pHdl; // Der Handle an dem der User zottelt
45 : SdrView* pView;
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;
55 :
56 : // Reserve fuer kompatible Erweiterungen, die sonst inkompatibel wuerden.
57 : Point aReservePoint1;
58 : Point aReservePoint2;
59 : Point aReservePoint3;
60 : Point aReservePoint4;
61 : Rectangle aReserveRect1;
62 : Rectangle aReserveRect2;
63 : bool bEndDragChangesAttributes;
64 : bool bEndDragChangesGeoAndAttributes;
65 : bool bMouseIsUp;
66 : bool aReserveBool3;
67 : bool aReserveBool4;
68 : long aReserveLong1;
69 : long aReserveLong2;
70 : long aReserveLong3;
71 : long aReserveLong4;
72 : void* aReservePtr1;
73 : void* aReservePtr2;
74 : void* aReservePtr3;
75 : void* aReservePtr4;
76 :
77 : bool bShown; // Xor visible?
78 : sal_uInt16 nMinMov; // So much has to be minimally moved first
79 : bool bMinMoved; // MinMove surpassed?
80 :
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.
85 : bool bOrtho4;
86 : bool bOrtho8;
87 :
88 : SdrDragMethod* pDragMethod;
89 :
90 : protected:
91 : void Clear(bool bLeaveOne);
92 : Point& Pnt(sal_uIntPtr nNum) { return *aPnts[nNum]; }
93 : //public:
94 : SdrDragStatUserData* pUser; // Userdata
95 : public:
96 : SdrDragStat(): aPnts() { pUser=NULL; Reset(); }
97 : ~SdrDragStat() { Clear(sal_False); }
98 : void Reset();
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 0 : const Point& GetPoint(sal_uIntPtr nNum) const { return *aPnts[nNum]; }
104 0 : sal_uIntPtr GetPointAnz() const { return aPnts.size(); }
105 0 : const Point& GetStart() const { return GetPoint(0); }
106 : Point& Start() { return Pnt(0); }
107 0 : 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 0 : 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 0 : const Point& GetRef1() const { return aRef1; }
116 0 : Point& Ref1() { return aRef1; }
117 : const Point& GetRef2() const { return aRef2; }
118 : Point& Ref2() { return aRef2; }
119 0 : 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 0 : bool IsShown() const { return bShown; }
124 0 : void SetShown(bool bOn) { bShown=bOn; }
125 :
126 : bool IsMinMoved() const { return bMinMoved; }
127 0 : 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; }
131 :
132 0 : bool IsHorFixed() const { return bHorFixed; }
133 : void SetHorFixed(bool bOn) { bHorFixed=bOn; }
134 0 : bool IsVerFixed() const { return bVerFixed; }
135 : void SetVerFixed(bool bOn) { bVerFixed=bOn; }
136 :
137 : // Here, the object can say: "I do not want to snap to coordinates!"
138 : // for example, the angle of the arc ...
139 0 : bool IsNoSnap() const { return bWantNoSnap; }
140 0 : void SetNoSnap(bool bOn = true) { bWantNoSnap=bOn; }
141 :
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; }
150 :
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; }
156 :
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; }
160 :
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);
165 : void PrevPoint();
166 : bool CheckMinMoved(const Point& rPnt);
167 0 : long GetDX() const { return GetNow().X()-GetPrev().X(); }
168 0 : long GetDY() const { return GetNow().Y()-GetPrev().Y(); }
169 : Fraction GetXFact() const;
170 : Fraction GetYFact() const;
171 :
172 0 : SdrDragMethod* GetDragMethod() const { return pDragMethod; }
173 : void SetDragMethod(SdrDragMethod* pMth) { pDragMethod=pMth; }
174 :
175 0 : const Rectangle& GetActionRect() const { return aActionRect; }
176 0 : void SetActionRect(const Rectangle& rR) { aActionRect=rR; }
177 :
178 : // also considering 1stPointAsCenter
179 : void TakeCreateRect(Rectangle& rRect) const;
180 : };
181 :
182 : #endif //_SVDDRAG_HXX
183 :
184 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|