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 INCLUDED_SVX_SVDDRAG_HXX
21 : #define INCLUDED_SVX_SVDDRAG_HXX
22 :
23 :
24 : #include <tools/gen.hxx>
25 : #include <tools/fract.hxx>
26 : #include <svx/svxdllapi.h>
27 :
28 : #include <vector>
29 :
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.
35 : class SdrHdl;
36 : class SdrView;
37 : class SdrPageView;
38 : class SdrDragMethod;
39 :
40 15 : struct SVX_DLLPUBLIC SdrDragStatUserData
41 : {
42 : };
43 :
44 : class SVX_DLLPUBLIC SdrDragStat {
45 : protected:
46 : SdrHdl* pHdl; // The Handle for the User
47 : SdrView* pView;
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;
55 :
56 : bool bEndDragChangesAttributes;
57 : bool bEndDragChangesGeoAndAttributes;
58 : bool bMouseIsUp;
59 :
60 : bool bShown; // Xor visible?
61 : sal_uInt16 nMinMov; // So much has to be minimally moved first
62 : bool bMinMoved; // MinMove surpassed?
63 :
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.
68 : bool bOrtho4;
69 : bool bOrtho8;
70 :
71 : SdrDragMethod* pDragMethod;
72 :
73 : protected:
74 : void Clear(bool bLeaveOne);
75 6 : Point& Pnt(sal_uIntPtr nNum) { return *aPnts[nNum]; }
76 : //public:
77 : SdrDragStatUserData* pUser; // Userdata
78 : public:
79 9504 : SdrDragStat(): aPnts() { pUser=NULL; Reset(); }
80 9438 : ~SdrDragStat() { Clear(false); }
81 : void Reset();
82 12 : SdrView* GetView() const { return pView; }
83 2 : void SetView(SdrView* pV) { pView=pV; }
84 0 : SdrPageView* GetPageView() const { return pPageView; }
85 2 : void SetPageView(SdrPageView* pPV) { pPageView=pPV; }
86 30 : const Point& GetPoint(sal_uIntPtr nNum) const { return *aPnts[nNum]; }
87 46 : sal_uIntPtr GetPointAnz() const { return aPnts.size(); }
88 0 : const Point& GetStart() const { return GetPoint(0); }
89 2 : Point& Start() { return Pnt(0); }
90 10 : const Point& GetPrev() const { return GetPoint(GetPointAnz()-(GetPointAnz()>=2 ? 2:1)); }
91 2 : Point& Prev() { return Pnt(GetPointAnz()-(GetPointAnz()>=2 ? 2:1)); }
92 0 : const Point& GetPos0() const { return aPos0; }
93 : Point& Pos0() { return aPos0; }
94 20 : const Point& GetNow() const { return GetPoint(GetPointAnz()-1); }
95 2 : Point& Now() { return Pnt(GetPointAnz()-1); }
96 4 : const Point& GetRealNow() const { return aRealNow; }
97 4 : Point& RealNow() { return aRealNow; }
98 0 : const Point& GetRef1() const { return aRef1; }
99 0 : Point& Ref1() { return aRef1; }
100 0 : const Point& GetRef2() const { return aRef2; }
101 0 : Point& Ref2() { return aRef2; }
102 18 : const SdrHdl* GetHdl() const { return pHdl; }
103 2 : void SetHdl(SdrHdl* pH) { pHdl=pH; }
104 0 : SdrDragStatUserData* GetUser() const { return pUser; }
105 0 : void SetUser(SdrDragStatUserData* pU) { pUser=pU; }
106 6 : bool IsShown() const { return bShown; }
107 4 : void SetShown(bool bOn) { bShown=bOn; }
108 :
109 4 : bool IsMinMoved() const { return bMinMoved; }
110 0 : void SetMinMoved() { bMinMoved=true; }
111 0 : void ResetMinMoved() { bMinMoved=false; }
112 2 : void SetMinMove(sal_uInt16 nDist) { nMinMov=nDist; if (nMinMov<1) nMinMov=1; }
113 : sal_uInt16 GetMinMove() const { return nMinMov; }
114 :
115 0 : bool IsHorFixed() const { return bHorFixed; }
116 0 : void SetHorFixed(bool bOn) { bHorFixed=bOn; }
117 0 : bool IsVerFixed() const { return bVerFixed; }
118 0 : void SetVerFixed(bool bOn) { bVerFixed=bOn; }
119 :
120 : // Here, the object can say: "I do not want to snap to coordinates!"
121 : // for example, the angle of the arc ...
122 3 : bool IsNoSnap() const { return bWantNoSnap; }
123 0 : void SetNoSnap(bool bOn = true) { bWantNoSnap=bOn; }
124 :
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 0 : bool IsOrtho4Possible() const { return bOrtho4; }
128 0 : void SetOrtho4Possible(bool bOn = true) { bOrtho4=bOn; }
129 : // Ortho8 means Ortho in 8 directions (for lines)
130 0 : bool IsOrtho8Possible() const { return bOrtho8; }
131 0 : void SetOrtho8Possible(bool bOn = true) { bOrtho8=bOn; }
132 :
133 : // Is set by an object that was dragged.
134 2 : bool IsEndDragChangesAttributes() const { return bEndDragChangesAttributes; }
135 0 : void SetEndDragChangesAttributes(bool bOn) { bEndDragChangesAttributes=bOn; }
136 0 : bool IsEndDragChangesGeoAndAttributes() const { return bEndDragChangesGeoAndAttributes; }
137 0 : void SetEndDragChangesGeoAndAttributes(bool bOn) { bEndDragChangesGeoAndAttributes=bOn; }
138 :
139 : // Is set by the view and can be evaluated by Obj
140 0 : bool IsMouseDown() const { return !bMouseIsUp; }
141 10 : void SetMouseDown(bool bDown) { bMouseIsUp=!bDown; }
142 :
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);
147 : void PrevPoint();
148 : bool CheckMinMoved(const Point& rPnt);
149 0 : long GetDX() const { return GetNow().X()-GetPrev().X(); }
150 0 : long GetDY() const { return GetNow().Y()-GetPrev().Y(); }
151 : Fraction GetXFact() const;
152 : Fraction GetYFact() const;
153 :
154 0 : SdrDragMethod* GetDragMethod() const { return pDragMethod; }
155 2 : void SetDragMethod(SdrDragMethod* pMth) { pDragMethod=pMth; }
156 :
157 9 : const Rectangle& GetActionRect() const { return aActionRect; }
158 0 : void SetActionRect(const Rectangle& rR) { aActionRect=rR; }
159 :
160 : // Also considering 1stPointAsCenter
161 : void TakeCreateRect(Rectangle& rRect) const;
162 : };
163 :
164 : #endif // INCLUDED_SVX_SVDDRAG_HXX
165 :
166 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|