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