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 .
20 #ifndef INCLUDED_SVX_SVDDRGV_HXX
21 #define INCLUDED_SVX_SVDDRGV_HXX
23 #include <svx/svxdllapi.h>
24 #include <svx/svdxcgv.hxx>
28 class SVX_DLLPUBLIC SdrDragView
: public SdrExchangeView
30 friend class SdrPageView
;
31 friend class SdrDragMethod
;
35 SdrDragMethod
* mpCurrentSdrDragMethod
;
36 SdrUndoGeoObj
* pInsPointUndo
;
38 OUString aInsPointUndoStr
;
39 SdrMarkList aFollowingEdges
; // If nodes are dragged, all edges should follow as Xor
42 sal_uIntPtr nDragXorPolyLimit
;
43 sal_uIntPtr nDragXorPointLimit
;
44 sal_uInt16 nDetailedEdgeDraggingLimit
;
46 bool bFramDrag
: 1; // currently frame dragging
47 bool bDragSpecial
: 1; // currently Special Obj-dragging
48 bool bMarkedHitMovesAlways
: 1; // Persistent
49 bool bDragLimit
: 1; // Limit on SnapRect instead of BoundRect
50 bool bDragHdl
: 1; // TRUE: RefPt is slid
51 bool bDragStripes
: 1; // Persistent
52 bool bMirrRefDragObj
: 1; // Persistent - During the drag, show the mirror axis of the mirrored objects as Xor
53 bool mbSolidDragging
: 1; // allow solid create/drag of objects
54 bool bMouseHideWhileDraggingPoints
: 1;
55 bool bResizeAtCenter
: 1;
56 bool bCrookAtCenter
: 1;
57 bool bDragWithCopy
: 1;
58 bool bInsGluePoint
: 1;
59 bool bInsObjPointMode
: 1;
60 bool bInsGluePointMode
: 1;
61 bool bNoDragXorPolys
: 1;
62 bool bAutoVertexCon
: 1; // automatic generation of connectors at the vertices
63 bool bAutoCornerCon
: 1; // automatic geneartion of connectors at the corners
64 bool bRubberEdgeDragging
: 1;
65 bool bDetailedEdgeDragging
: 1;
68 SVX_DLLPRIVATE
void ImpClearVars();
71 virtual void SetMarkHandles() SAL_OVERRIDE
;
74 bool ImpBegInsObjPoint(bool bIdxZwang
, sal_uInt32 nIdx
, const Point
& rPnt
, bool bNewObj
, OutputDevice
* pOut
);
77 // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
78 SdrDragView(SdrModel
* pModel1
, OutputDevice
* pOut
= 0L);
79 virtual ~SdrDragView();
82 virtual bool IsAction() const SAL_OVERRIDE
;
83 virtual void MovAction(const Point
& rPnt
) SAL_OVERRIDE
;
84 virtual void EndAction() SAL_OVERRIDE
;
85 virtual void BckAction() SAL_OVERRIDE
;
86 virtual void BrkAction() SAL_OVERRIDE
;
87 virtual void TakeActionRect(Rectangle
& rRect
) const SAL_OVERRIDE
;
89 // special implementation for Writer:
90 // TakeDragObjAnchorPos() returns the position at which an object
91 // approximately ends up during dragging when it is "released"
93 // As a general rule, this is the left upper corner of the expected
94 // new SnapRect. Exception: CaptionObj. There, it is the position
96 // In case of return value 'false', the position could not be
97 // determined (e.g. point shift, multiple selection, shift of the
99 bool TakeDragObjAnchorPos(Point
& rPos
, bool bTopRight
= false ) const;
101 // If pForcedMeth is passed, then pHdl, ... is not evaluated, but this Drag
102 // method is used. In this, the ownership of the instance passes
103 // to the View and is destroyed at the end of the dragging.
104 virtual bool BegDragObj(const Point
& rPnt
, OutputDevice
* pOut
=NULL
, SdrHdl
* pHdl
=NULL
, short nMinMov
=-3, SdrDragMethod
* pForcedMeth
=NULL
);
105 void MovDragObj(const Point
& rPnt
);
106 bool EndDragObj(bool bCopy
=false);
108 bool IsDragObj() const { return mpCurrentSdrDragMethod
&& !bInsPolyPoint
&& !bInsGluePoint
; }
109 SdrHdl
* GetDragHdl() const { return pDragHdl
; }
110 SdrDragMethod
* GetDragMethod() const { return mpCurrentSdrDragMethod
; }
111 bool IsDraggingPoints() const { return eDragHdl
==HDL_POLY
; }
112 bool IsDraggingGluePoints() const { return eDragHdl
==HDL_GLUE
; }
114 // If you want to define that already during BegDrag
116 // (Is reset to 'false' on each BegDrag, so set it after BegDrag.)
117 void SetDragWithCopy(bool bOn
) { bDragWithCopy
= bOn
; }
118 bool IsDragWithCopy() const { return bDragWithCopy
; }
120 void SetInsertGluePoint(bool bOn
) { bInsGluePoint
= bOn
; }
121 bool IsInsertGluePoint() const { return bInsGluePoint
; }
123 // Interactive insertion of a new point. nIdx=0 => in front of the first point
124 bool IsInsObjPointPossible() const;
125 bool BegInsObjPoint(const Point
& rPnt
, bool bNewObj
) { return ImpBegInsObjPoint(false, 0L, rPnt
, bNewObj
, 0L); }
126 void MovInsObjPoint(const Point
& rPnt
) { MovDragObj(rPnt
); }
127 bool EndInsObjPoint(SdrCreateCmd eCmd
);
128 void BrkInsObjPoint() { BrkDragObj(); }
129 bool IsInsObjPoint() const { return mpCurrentSdrDragMethod
&& bInsPolyPoint
; }
131 // For the app to manage the status. GetPreferredPointer() is
132 // possibly going to deliver a matching pointer for it.
133 void SetInsObjPointMode(bool bOn
) { bInsObjPointMode
= bOn
; }
134 bool IsInsObjPointMode() const { return bInsObjPointMode
; }
136 bool IsInsGluePointPossible() const;
137 bool BegInsGluePoint(const Point
& rPnt
);
138 void MovInsGluePoint(const Point
& rPnt
) { MovDragObj(rPnt
); }
139 bool EndInsGluePoint() { return EndDragObj(); }
140 void BrkInsGluePoint() { BrkDragObj(); }
141 bool IsInsGluePoint() const { return mpCurrentSdrDragMethod
&& bInsGluePoint
; }
143 // For the app to manage the status. GetPreferredPointer() is
144 // possibly going to deliver a matching pointer for it.
145 void SetInsGluePointMode(bool bOn
) { bInsGluePointMode
= bOn
; }
146 bool IsInsGluePointMode() const { return bInsGluePointMode
; }
148 // border lines over the whole win persistent during the
149 // whole dragging. Default=FALSE.
150 void SetDragStripes(bool bOn
);
151 bool IsDragStripes() const { return bDragStripes
; }
153 // hide handles during dragging
154 //HMHvoid SetDragHdlHide(bool bOn);
155 //HMHBOOL IsDragHdlHide() const { return bNoDragHdl; }
157 // Hide the mouse when dragging polygon points or glue points.
159 void SetMouseHideWhileDraggingPoints(bool bOn
) { bMouseHideWhileDraggingPoints
= bOn
; }
160 bool IsMouseHideWhileDraggingPoints() const { return bMouseHideWhileDraggingPoints
; }
162 // As a general rule, the contours of the selected objects
163 // are displayed as Xor-polygons. If this flag is set, only one
164 // Xor-Frame is drawn (e.g. in case of multiple selection).
165 // In case of object-specific dragging (polygon points, corner radius,...),
166 // this setting has no influence.
167 // Also changeable during the dragging.
169 void SetNoDragXorPolys(bool bOn
);
170 bool IsNoDragXorPolys() const { return bNoDragXorPolys
; }
172 // If the number of selected objects exceeds te value set here,
173 // NoDragPolys is (temporarily) activated implicitely.
174 // PolyPolygons etc. are regarded as multiple objects respectively.
176 void SetDragXorPolyLimit(sal_uIntPtr nObjAnz
) { nDragXorPolyLimit
=nObjAnz
; }
177 sal_uIntPtr
GetDragXorPolyLimit() const { return nDragXorPolyLimit
; }
179 // Like DragXorPolyLimit, but in respect to the total number of
180 // all polygons. Default=500.
181 // NoDragPolys is (temporarily) activated, if one of the limits
183 void SetDragXorPointLimit(sal_uIntPtr nPointCount
) { nDragXorPointLimit
=nPointCount
; }
184 sal_uIntPtr
GetDragXorPointLimit() const { return nDragXorPointLimit
; }
186 void SetSolidDragging(bool bOn
);
187 bool IsSolidDragging() const;
189 // Dragging/Creation of connectors:
190 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191 // Stick Connectors to vertices
193 void SetAutoVertexConnectors(bool bOn
) { bAutoVertexCon
= bOn
; }
194 bool IsAutoVertexConnectors() const { return bAutoVertexCon
; }
196 // Stick Connectors to Corners
198 void SetAutoCornerConnectors(bool bOn
) { bAutoCornerCon
= bOn
; }
199 bool IsAutoCornerConnectors() const { return bAutoCornerCon
; }
201 // Dragging of connected objects (Nodes):
202 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
203 // DetailedEdgeDraggingLimit: like RubberEdgeDraggingLimit,
204 // but this limit refers to the detailed depiction, i.e. not
205 // only rubber bands but total recalculations are visible while
206 // dragging. This detailed depiction is only possible in MoveDrag.
208 bool IsDetailedEdgeDragging() const { return bDetailedEdgeDragging
; }
210 sal_uInt16
GetDetailedEdgeDraggingLimit() const { return nDetailedEdgeDraggingLimit
; }
212 // EdgeDraggingLimit: If more than nEdgeObjCount edges are affected,
213 // they are not shown in the interactive dragging.
214 // This here talks about the "rubber bands", which take less computing time
215 // than the complete recalculations in the DetailedEdgeDragging.
216 // default value: 100
217 bool IsRubberEdgeDragging() const { return bRubberEdgeDragging
; }
219 // Connector handling is thus as follows (when using default settings):
220 // - If at most 10 Connectors are affected, they are recalculated
221 // on each MouseMove.
222 // - If 11 to 100 Connectors are affected, the connections
223 // are shown as straight lines while dragging.
224 // - In case of more than 100 affected Connectors, nothing that refers
225 // to the Connectors is drawn while dragging.
227 // If a special drag mode like Rotate, Mirror or Crook is enabled,
228 // then a Hit on the selected object triggers exactly this dragging.
229 // If MarkedHitMovesAlways is set to 'true', a Hit on the selected
230 // object always triggers a Move, independent of the DragMode that is
231 // set. This flag is persistent and should be configurable in the app
233 void SetMarkedHitMovesAlways(bool bOn
) { bMarkedHitMovesAlways
= bOn
; }
234 bool IsMarkedHitMovesAlways() const { return bMarkedHitMovesAlways
; }
236 // Show the mirror image of the selected objects as Xor while dragging
237 // the mirror axis? Persistent. Not yet implemented. Default: true
238 void SetMirrRefDragObj(bool bOn
) { bMirrRefDragObj
= bOn
; }
239 bool IsMirrRefDragObj() const { return bMirrRefDragObj
; }
241 bool IsOrthoDesired() const;
243 // center as reference on Resize
245 bool IsResizeAtCenter() const { return bResizeAtCenter
; }
246 void SetResizeAtCenter(bool bOn
) { bResizeAtCenter
= bOn
; }
250 bool IsCrookAtCenter() const { return bCrookAtCenter
; }
251 void SetCrookAtCenter(bool bOn
) { bCrookAtCenter
= bOn
; }
253 // Limitation of the working area. The limitation refers to the View,
254 // not to the single PageViews. This limitation is only evaluated by
255 // the View on interactions like Dragging and Create.
256 // In case of actions controlled by the app through algorithms or
257 // UI-controlled actions (SetGeoAttr, MoveMarkedObj, ...), the
258 // app must honor this limit itself.
259 // Furthermore, this limit is to be seen as a rough limit. In certain
260 // cases (e.g. while rotating), objects cannot be dragged exactly
261 // up to this limit, objects can overlap a bit because of rounding
263 // Default=EmptyRect=no limitation
264 // only partially implemented
265 void SetWorkArea(const Rectangle
& rRect
) { aMaxWorkArea
=rRect
; }
266 const Rectangle
& GetWorkArea() const { return aMaxWorkArea
; }
269 // The DragLimit refers to the Page of the object.
270 // (TODO or to the View?? - must be researched...)
271 // 'false' = no limit
272 // The return Rect must contain absolute coordinates. The maximum
273 // drag area is then selected by the View in a way that the object's
274 // SnapRect is moved or resized at most up to the corner of the
275 // LimitRect. For objects like Bezier curves, rotated rectangles,
276 // it must be taken into account that because of subsequent
277 // recalculation of the SnapRect (on Resize), rounding errors can
278 // occur, because of which the LimitRect might be exceeded by a
279 // very small extent....
280 // Implemented for Move and Resize
281 virtual bool TakeDragLimit(SdrDragMode eMode
, Rectangle
& rRect
) const;
284 #endif // INCLUDED_SVX_SVDDRGV_HXX
286 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */