Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SVDDRAG_HXX
30 : : #define _SVDDRAG_HXX
31 : :
32 : :
33 : : #include <tools/gen.hxx>
34 : : #include <tools/fract.hxx>
35 : : #include "svx/svxdllapi.h"
36 : :
37 : : // Status information for specialized object dragging. In order for the model
38 : : // to stay status free, the status data is kept on the View
39 : : // and handed over to the object at the appropriate time as a parameter.
40 : : // This also includes the status of the operation and Interactive
41 : : // Object creation. In this case, pHdl is null.
42 : : class SdrHdl;
43 : : class SdrView;
44 : : class SdrPageView;
45 : : class SdrDragMethod;
46 : :
47 : : struct SVX_DLLPUBLIC SdrDragStatUserData
48 : : {
49 : : };
50 : :
51 : : class SVX_DLLPUBLIC SdrDragStat {
52 : : protected:
53 : : SdrHdl* pHdl; // Der Handle an dem der User zottelt
54 : : SdrView* pView;
55 : : SdrPageView* pPageView;
56 : : std::vector<Point*> aPnts; // Alle bisherigen Punkte: [0]=Start, [Count()-2]=Prev
57 : : Point aRef1; // Referenzpunkt: Resize-Fixpunkt, (Drehachse,
58 : : Point aRef2; // Spiegelachse, ...)
59 : : Point aPos0; // Position beim letzten Event
60 : : Point aRealPos0; // Position beim letzten Event
61 : : Point aRealNow; // Aktuelle Dragposition ohne Snap, Ortho und Limit
62 : : Point aRealLast; // RealPos des letzten Punkts (fuer MinMoved)
63 : : Rectangle aActionRect;
64 : :
65 : : // Reserve fuer kompatible Erweiterungen, die sonst inkompatibel wuerden.
66 : : Point aReservePoint1;
67 : : Point aReservePoint2;
68 : : Point aReservePoint3;
69 : : Point aReservePoint4;
70 : : Rectangle aReserveRect1;
71 : : Rectangle aReserveRect2;
72 : : bool bEndDragChangesAttributes;
73 : : bool bEndDragChangesGeoAndAttributes;
74 : : bool bMouseIsUp;
75 : : bool aReserveBool3;
76 : : bool aReserveBool4;
77 : : long aReserveLong1;
78 : : long aReserveLong2;
79 : : long aReserveLong3;
80 : : long aReserveLong4;
81 : : void* aReservePtr1;
82 : : void* aReservePtr2;
83 : : void* aReservePtr3;
84 : : void* aReservePtr4;
85 : :
86 : : bool bShown; // Xor visible?
87 : : sal_uInt16 nMinMov; // So much has to be minimally moved first
88 : : bool bMinMoved; // MinMove surpassed?
89 : :
90 : : bool bHorFixed; // Dragging only vertical
91 : : bool bVerFixed; // Dragging only horizontal
92 : : bool bWantNoSnap; // To decide if pObj-> MovCreate () should use NoSnapPos or not.
93 : : // Therefore, NoSnapPos is written into the buffer.
94 : : bool bOrtho4;
95 : : bool bOrtho8;
96 : :
97 : : SdrDragMethod* pDragMethod;
98 : :
99 : : protected:
100 : : void Clear(bool bLeaveOne);
101 : : Point& Pnt(sal_uIntPtr nNum) { return *aPnts[nNum]; }
102 : : //public:
103 : : SdrDragStatUserData* pUser; // Userdata
104 : : public:
105 : : SdrDragStat(): aPnts() { pUser=NULL; Reset(); }
106 : : ~SdrDragStat() { Clear(sal_False); }
107 : : void Reset();
108 : : SdrView* GetView() const { return pView; }
109 : : void SetView(SdrView* pV) { pView=pV; }
110 : : SdrPageView* GetPageView() const { return pPageView; }
111 : : void SetPageView(SdrPageView* pPV) { pPageView=pPV; }
112 : 0 : const Point& GetPoint(sal_uIntPtr nNum) const { return *aPnts[nNum]; }
113 : 0 : sal_uIntPtr GetPointAnz() const { return aPnts.size(); }
114 : 0 : const Point& GetStart() const { return GetPoint(0); }
115 : : Point& Start() { return Pnt(0); }
116 [ # # ]: 0 : const Point& GetPrev() const { return GetPoint(GetPointAnz()-(GetPointAnz()>=2 ? 2:1)); }
117 : : Point& Prev() { return Pnt(GetPointAnz()-(GetPointAnz()>=2 ? 2:1)); }
118 : : const Point& GetPos0() const { return aPos0; }
119 : : Point& Pos0() { return aPos0; }
120 : 0 : const Point& GetNow() const { return GetPoint(GetPointAnz()-1); }
121 : : Point& Now() { return Pnt(GetPointAnz()-1); }
122 : : const Point& GetRealNow() const { return aRealNow; }
123 : : Point& RealNow() { return aRealNow; }
124 : 0 : const Point& GetRef1() const { return aRef1; }
125 : 0 : Point& Ref1() { return aRef1; }
126 : : const Point& GetRef2() const { return aRef2; }
127 : : Point& Ref2() { return aRef2; }
128 : 0 : const SdrHdl* GetHdl() const { return pHdl; }
129 : : void SetHdl(SdrHdl* pH) { pHdl=pH; }
130 : : SdrDragStatUserData* GetUser() const { return pUser; }
131 : : void SetUser(SdrDragStatUserData* pU) { pUser=pU; }
132 : 0 : bool IsShown() const { return bShown; }
133 : 0 : void SetShown(bool bOn) { bShown=bOn; }
134 : :
135 : : bool IsMinMoved() const { return bMinMoved; }
136 : 0 : void SetMinMoved() { bMinMoved=sal_True; }
137 : : void ResetMinMoved() { bMinMoved=sal_False; }
138 : : void SetMinMove(sal_uInt16 nDist) { nMinMov=nDist; if (nMinMov<1) nMinMov=1; }
139 : : sal_uInt16 GetMinMove() const { return nMinMov; }
140 : :
141 : 0 : bool IsHorFixed() const { return bHorFixed; }
142 : : void SetHorFixed(bool bOn) { bHorFixed=bOn; }
143 : 0 : bool IsVerFixed() const { return bVerFixed; }
144 : : void SetVerFixed(bool bOn) { bVerFixed=bOn; }
145 : :
146 : : // Here, the object can say: "I do not want to snap to coordinates!"
147 : : // for example, the angle of the arc ...
148 : 0 : bool IsNoSnap() const { return bWantNoSnap; }
149 : 0 : void SetNoSnap(bool bOn = true) { bWantNoSnap=bOn; }
150 : :
151 : : // And here the Obj say which Ortho (if there is one)
152 : : // can be usefully applied to him.
153 : : // Ortho4 means Ortho in four directions (for Rect and CIRT)
154 : : bool IsOrtho4Possible() const { return bOrtho4; }
155 : : void SetOrtho4Possible(bool bOn = true) { bOrtho4=bOn; }
156 : : // Ortho8 means Ortho in 8 directions (for lines)
157 : : bool IsOrtho8Possible() const { return bOrtho8; }
158 : : void SetOrtho8Possible(bool bOn = true) { bOrtho8=bOn; }
159 : :
160 : : // Is set by an object that was dragged.
161 : : bool IsEndDragChangesAttributes() const { return bEndDragChangesAttributes; }
162 : : void SetEndDragChangesAttributes(bool bOn) { bEndDragChangesAttributes=bOn; }
163 : : bool IsEndDragChangesGeoAndAttributes() const { return bEndDragChangesGeoAndAttributes; }
164 : : void SetEndDragChangesGeoAndAttributes(bool bOn) { bEndDragChangesGeoAndAttributes=bOn; }
165 : :
166 : : // Is set by the view and can be evaluated by Obj
167 : : bool IsMouseDown() const { return !bMouseIsUp; }
168 : : void SetMouseDown(bool bDown) { bMouseIsUp=!bDown; }
169 : :
170 : : Point KorregPos(const Point& rNow, const Point& rPrev) const;
171 : : void Reset(const Point& rPnt);
172 : : void NextMove(const Point& rPnt);
173 : : void NextPoint(bool bSaveReal=sal_False);
174 : : void PrevPoint();
175 : : bool CheckMinMoved(const Point& rPnt);
176 : 0 : long GetDX() const { return GetNow().X()-GetPrev().X(); }
177 : 0 : long GetDY() const { return GetNow().Y()-GetPrev().Y(); }
178 : : Fraction GetXFact() const;
179 : : Fraction GetYFact() const;
180 : :
181 : 0 : SdrDragMethod* GetDragMethod() const { return pDragMethod; }
182 : : void SetDragMethod(SdrDragMethod* pMth) { pDragMethod=pMth; }
183 : :
184 : 0 : const Rectangle& GetActionRect() const { return aActionRect; }
185 : 0 : void SetActionRect(const Rectangle& rR) { aActionRect=rR; }
186 : :
187 : : // also considering 1stPointAsCenter
188 : : void TakeCreateRect(Rectangle& rRect) const;
189 : : };
190 : :
191 : : #endif //_SVDDRAG_HXX
192 : :
193 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|