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_SVDHDL_HXX
21 #define INCLUDED_SVX_SVDHDL_HXX
23 #include <tools/gen.hxx>
25 #include <vcl/pointr.hxx>
27 #include <svl/solar.hrc>
29 #include <svx/xpoly.hxx>
30 #include <svx/svdoedge.hxx>
31 #include <basegfx/matrix/b2dhommatrix.hxx>
32 #include <svx/sdgcpitm.hxx>
33 #include <svx/sdr/overlay/overlayobjectlist.hxx>
34 #include <svx/svxdllapi.h>
44 // Every object must be able to create its handles. They will be fetched on
45 // selection, registered at the View and made visible.
46 // Wird ein Handle von der Maus beruehrt (IsHit()), so wird von der View der
47 // entsprechende Mauszeiger vom Handle abgeholt und der App auf Anfrage zum
48 // reinschalten uebergeben.
49 // Handles wie z.B. der Rotationsmittelpunkt oder die Spiegelachse werden von
50 // der View generiert, wenn vom Controller der entsprechende Transformations-
51 // Modus selektiert wird.
52 // HDL_MOVE...HDL_LWRGT muessen im enum immer zusammen stehen bleiben!
56 HDL_MOVE
, // Handle zum Verschieben des Objekts
57 HDL_UPLFT
, // Oben links
59 HDL_UPRGT
, // Oben rechts
62 HDL_LWLFT
, // Unten links
64 HDL_LWRGT
, // Unten rechts
65 HDL_POLY
, // Punktselektion an Polygon oder Bezierkurve
66 HDL_BWGT
, // Gewicht an einer Bezierkurve
67 HDL_CIRC
, // Winkel an Kreissegmenten, Eckenradius am Rect
68 HDL_REF1
, // Referenzpunkt 1, z.B. Rotationsmitte
69 HDL_REF2
, // Referenzpunkt 2, z.B. Endpunkt der Spiegelachse
70 HDL_MIRX
, // Die Spiegelachse selbst
71 HDL_GLUE
, // GluePoint
72 HDL_GLUE_DESELECTED
, // GluePoint
73 HDL_ANCHOR
, // anchor symbol (SD, SW)
74 HDL_TRNS
, // interactive transparence
75 HDL_GRAD
, // interactive gradient
76 HDL_COLR
, // interactive color
78 HDL_ANCHOR_TR
, // #101688# Anchor handle with (0,0) at top right for SW
80 // for SJ and the CustomShapeHandles:
100 enum BitmapMarkerKind
121 // #98388# add AnchorPressed to be able to aninate anchor control, too.
124 // #101688# AnchorTR for SW
128 // for SJ and the CustomShapeHandles:
136 class SVX_DLLPUBLIC SdrHdl
138 friend class SdrMarkView
; // fuer den Zugriff auf nObjHdlNum
139 friend class SdrHdlList
;
141 static BitmapEx
ImpGetBitmapEx(BitmapMarkerKind eKindOfMarker
, sal_uInt16 nInd
);
144 SdrObject
* pObj
; // Gehoert das Handle zu einem Objekt?
145 SdrPageView
* pPV
; // Gehoert das Handle zu einem Objekt in einer bestimmten PageView?
146 SdrHdlList
* pHdlList
; // Zum Feststelen der Handlegroesse
149 sdr::overlay::OverlayObjectList maOverlayGroup
;
155 long nRotationAngle
; // Handles bzw. Mauszeiger drehen
156 sal_uInt32 nObjHdlNum
; // wird von der MarkView benoetigt
157 sal_uInt32 nPolyNum
; // Polygonpunktes
158 sal_uInt32 nPPntNum
; // Punktnummer des Polygons
159 sal_uInt32 nSourceHdlNum
; // ist noch vollstaendig zu implementieren
161 bool bSelect
: 1; // Ein selektierter Polygonpunkt?
162 bool b1PixMore
: 1; // True=Handle wird 1 Pixel groesser dargestellt
163 bool bPlusHdl
: 1; // u.a. fuer Hld-Paint Optimierung bei MarkPoint/UnmarkPoint, ...
165 bool mbMoveOutside
; // forces this handle to be moved outside of the selection rectangle
167 // create marker for this kind
168 virtual void CreateB2dIAObject();
170 // cleanup marker if one exists
171 void GetRidOfIAObject();
174 bool mbMouseOver
; // is true if the mouse is over this handle
177 sdr::overlay::OverlayObject
* CreateOverlayObject(
178 const basegfx::B2DPoint
& rPos
,
179 BitmapColorIndex eColIndex
, BitmapMarkerKind eKindOfMarker
,
180 OutputDevice
& rOutDev
, Point aMoveOutsideOffset
= Point());
181 static BitmapMarkerKind
GetNextBigger(BitmapMarkerKind eKnd
);
185 explicit SdrHdl(const Point
& rPnt
, SdrHdlKind eNewKind
=HDL_MOVE
);
188 const sdr::overlay::OverlayObjectList
& getOverlayObjectList() const { return maOverlayGroup
; }
190 void SetHdlList(SdrHdlList
* pList
);
191 SdrHdlKind
GetKind() const { return eKind
; }
194 const Point
& GetPos() const { return aPos
; }
195 void SetPos(const Point
& rPnt
);
197 SdrPageView
* GetPageView() const { return pPV
; }
198 void SetPageView(SdrPageView
* pNewPV
) { pPV
=pNewPV
; }
200 SdrObject
* GetObj() const { return pObj
; }
201 void SetObj(SdrObject
* pNewObj
);
203 bool IsSelected() const { return bSelect
; }
204 void SetSelected(bool bJa
=true);
206 void Set1PixMore(bool bJa
=true);
207 void SetRotationAngle(long n
);
209 bool IsCornerHdl() const { return eKind
==HDL_UPLFT
|| eKind
==HDL_UPRGT
|| eKind
==HDL_LWLFT
|| eKind
==HDL_LWRGT
; }
210 bool IsVertexHdl() const { return eKind
==HDL_UPPER
|| eKind
==HDL_LOWER
|| eKind
==HDL_LEFT
|| eKind
==HDL_RIGHT
; }
212 void SetObjHdlNum(sal_uInt32 nNum
) { nObjHdlNum
=nNum
; }
213 sal_uInt32
GetObjHdlNum() const { return nObjHdlNum
; }
215 void SetPolyNum(sal_uInt32 nNum
) { nPolyNum
=nNum
; }
216 sal_uInt32
GetPolyNum() const { return nPolyNum
; }
218 void SetPointNum(sal_uInt32 nNum
) { nPPntNum
=nNum
; }
219 sal_uInt32
GetPointNum() const { return nPPntNum
; }
221 void SetPlusHdl(bool bOn
) { bPlusHdl
=bOn
; }
222 bool IsPlusHdl() const { return bPlusHdl
; }
224 void SetSourceHdlNum(sal_uInt32 nNum
) { nSourceHdlNum
=nNum
; }
225 sal_uInt32
GetSourceHdlNum() const { return nSourceHdlNum
; }
227 virtual Pointer
GetPointer() const;
228 bool IsHdlHit(const Point
& rPnt
) const;
231 virtual bool IsFocusHdl() const;
233 void SetMoveOutside( bool bMoveOutside
);
235 /** is called when the mouse enters the area of this handle. If the handle changes his
236 visualisation during mouse over it must override this method and call Touch(). */
237 virtual void onMouseEnter(const MouseEvent
& rMEvt
);
239 /** is called when the mouse leaves the area of this handle. If the handle changes his
240 visualisation during mouse over it must override this method and call Touch(). */
241 virtual void onMouseLeave();
243 static BitmapEx
createGluePointBitmap() { return ImpGetBitmapEx(Glue_Deselected
, 0); }
248 #define SDR_HANDLE_COLOR_SIZE_NORMAL Size(13, 13)
249 #define SDR_HANDLE_COLOR_SIZE_SELECTED Size(17, 17)
251 class SVX_DLLPUBLIC SdrHdlColor
: public SdrHdl
254 // size of colr markers
260 // callback link when value changed
261 Link
<> aColorChangeHdl
;
263 // use luminance values only
264 bool bUseLuminance
: 1;
266 // create marker for this kind
267 SVX_DLLPRIVATE
virtual void CreateB2dIAObject() SAL_OVERRIDE
;
270 SVX_DLLPRIVATE Bitmap
CreateColorDropper(Color aCol
);
271 SVX_DLLPRIVATE Color
GetLuminance(const Color
& rCol
);
272 SVX_DLLPRIVATE
void CallColorChangeLink();
275 explicit SdrHdlColor(const Point
& rRef
, Color aCol
= Color(COL_BLACK
), const Size
& rSize
= Size(11, 11), bool bLum
= false);
276 virtual ~SdrHdlColor();
278 bool IsUseLuminance() const { return bUseLuminance
; }
280 Color
GetColor() const { return aMarkerColor
; }
281 void SetColor(Color aNew
, bool bCallLink
= false);
283 const Size
& GetSize() const { return aMarkerSize
; }
284 void SetSize(const Size
& rNew
);
286 void SetColorChangeHdl(const Link
<>& rLink
) { aColorChangeHdl
= rLink
; }
287 const Link
<>& GetColorChangeHdl() const { return aColorChangeHdl
; }
292 class SdrHdlGradient
: public SdrHdl
295 // pointer to used color handles
296 SdrHdlColor
* pColHdl1
;
297 SdrHdlColor
* pColHdl2
;
302 // is this a gradient or a transparence
305 // select which handle to move
306 bool bMoveSingleHandle
: 1;
307 bool bMoveFirstHandle
: 1;
309 // create marker for this kind
310 virtual void CreateB2dIAObject() SAL_OVERRIDE
;
313 SdrHdlGradient(const Point
& rRef1
, const Point
& rRef2
, bool bGrad
= true);
314 virtual ~SdrHdlGradient();
316 bool IsGradient() const { return bGradient
; }
318 // set the associated color handles
319 void SetColorHandles(SdrHdlColor
* pL1
, SdrHdlColor
* pL2
) { pColHdl1
= pL1
; pColHdl2
= pL2
; }
320 SdrHdlColor
* GetColorHdl1() const { return pColHdl1
; }
321 SdrHdlColor
* GetColorHdl2() const { return pColHdl2
; }
323 const Point
& Get2ndPos() const { return a2ndPos
; }
324 void Set2ndPos(const Point
& rPnt
);
326 // the link called by the color handles
327 DECL_LINK(ColorChangeHdl
, SdrHdl
*);
329 // transformation call, create gradient from this handle
330 void FromIAOToItem(SdrObject
* pObj
, bool bSetItemOnObject
, bool bUndo
);
332 // selection flags for interaction
333 bool IsMoveSingleHandle() const { return bMoveSingleHandle
; }
334 void SetMoveSingleHandle(bool bNew
) { bMoveSingleHandle
= bNew
; }
335 bool IsMoveFirstHandle() const { return bMoveFirstHandle
; }
336 void SetMoveFirstHandle(bool bNew
) { bMoveFirstHandle
= bNew
; }
342 class SdrHdlLine
: public SdrHdl
344 // create marker for this kind
345 virtual void CreateB2dIAObject() SAL_OVERRIDE
;
352 SdrHdlLine(SdrHdl
& rHdl1
, SdrHdl
& rHdl2
, SdrHdlKind eNewKind
=HDL_MIRX
) { eKind
=eNewKind
; pHdl1
=&rHdl1
; pHdl2
=&rHdl2
; }
353 virtual ~SdrHdlLine();
355 virtual Pointer
GetPointer() const SAL_OVERRIDE
;
358 // Ein SdrHdlBezWgt hat Kenntnis von seinem "BasisHandle". Seine Draw-Methode
359 // zeichnet zusaetzlich eine Linie von seiner Position zur Position dieses
361 class SdrHdlBezWgt
: public SdrHdl
363 // create marker for this kind
364 virtual void CreateB2dIAObject() SAL_OVERRIDE
;
370 // das ist kein Copy-Ctor!!!
371 SdrHdlBezWgt(const SdrHdl
* pRefHdl1
, SdrHdlKind eNewKind
=HDL_BWGT
) { eKind
=eNewKind
; pHdl1
=pRefHdl1
; }
372 virtual ~SdrHdlBezWgt();
377 class E3dVolumeMarker
: public SdrHdl
379 basegfx::B2DPolyPolygon aWireframePoly
;
381 // create marker for this kind
382 virtual void CreateB2dIAObject() SAL_OVERRIDE
;
385 explicit E3dVolumeMarker(const basegfx::B2DPolyPolygon
& rWireframePoly
);
390 class ImpEdgeHdl
: public SdrHdl
392 SdrEdgeLineCode eLineCode
;
394 // create marker for this kind
395 virtual void CreateB2dIAObject() SAL_OVERRIDE
;
398 ImpEdgeHdl(const Point
& rPnt
, SdrHdlKind eNewKind
): SdrHdl(rPnt
,eNewKind
),eLineCode(MIDDLELINE
) {}
399 virtual ~ImpEdgeHdl();
401 void SetLineCode(SdrEdgeLineCode eCode
);
402 SdrEdgeLineCode
GetLineCode() const { return eLineCode
; }
403 bool IsHorzDrag() const;
404 virtual Pointer
GetPointer() const SAL_OVERRIDE
;
409 class ImpMeasureHdl
: public SdrHdl
411 // create marker for this kind
412 virtual void CreateB2dIAObject() SAL_OVERRIDE
;
415 ImpMeasureHdl(const Point
& rPnt
, SdrHdlKind eNewKind
): SdrHdl(rPnt
,eNewKind
) {}
416 virtual ~ImpMeasureHdl();
418 virtual Pointer
GetPointer() const SAL_OVERRIDE
;
423 class ImpTextframeHdl
: public SdrHdl
425 const Rectangle maRect
;
427 // create marker for this kind
428 virtual void CreateB2dIAObject() SAL_OVERRIDE
;
431 explicit ImpTextframeHdl(const Rectangle
& rRect
);
438 class SVX_DLLPUBLIC SdrHdlList
443 std::deque
<SdrHdl
*> aList
;
446 bool bRotateShear
: 1;
447 bool bDistortShear
: 1;
448 bool bMoveOutside
: 1; // Handles nach aussen ruecken (fuer TextEdit)
451 SVX_DLLPRIVATE
SdrHdlList(const SdrHdlList
&): aList() {}
452 SVX_DLLPRIVATE
void operator=(const SdrHdlList
&) {}
453 SVX_DLLPRIVATE
bool operator==(const SdrHdlList
&) const { return false; }
454 SVX_DLLPRIVATE
bool operator!=(const SdrHdlList
&) const { return false; }
457 explicit SdrHdlList(SdrMarkView
* pV
);
462 void TravelFocusHdl(bool bForward
);
463 SdrHdl
* GetFocusHdl() const;
464 void SetFocusHdl(SdrHdl
* pNew
);
465 void ResetFocusHdl();
468 SdrMarkView
* GetView() const { return pView
;}
470 // Sortierung: 1.Level Erst Refpunkt-Handles, dann normale Handles, dann Glue, dann User, dann Plushandles
471 // 2.Level PageView (Pointer)
472 // 3.Level Position (x+y)
474 size_t GetHdlCount() const { return aList
.size(); }
475 SdrHdl
* GetHdl(size_t nNum
) const { return nNum
<aList
.size() ? aList
[nNum
] : NULL
; }
476 size_t GetHdlNum(const SdrHdl
* pHdl
) const;
477 void SetHdlSize(sal_uInt16 nSiz
);
478 sal_uInt16
GetHdlSize() const { return nHdlSize
; }
479 void SetMoveOutside(bool bOn
);
480 bool IsMoveOutside() const { return bMoveOutside
; }
481 void SetRotateShear(bool bOn
);
482 bool IsRotateShear() const { return bRotateShear
; }
483 void SetDistortShear(bool bOn
);
484 bool IsDistortShear() const { return bDistortShear
; }
486 // AddHdl uebernimmt das Handle in sein Eigentum. Es muss
487 // also auf dem Heap stehen, da Clear() ein delete macht.
488 void AddHdl(SdrHdl
* pHdl
, bool bAtBegin
=false);
489 SdrHdl
* RemoveHdl(size_t nNum
);
490 void RemoveAllByKind(SdrHdlKind eKind
);
492 // Zuletzt eingefuegte Handles werden am ehesten getroffen
493 // (wenn Handles uebereinander liegen).
494 SdrHdl
* IsHdlListHit(const Point
& rPnt
, bool bBack
=false, bool bNext
=false, SdrHdl
* pHdl0
=NULL
) const;
495 SdrHdl
* GetHdl(SdrHdlKind eKind1
) const;
500 class SVX_DLLPUBLIC SdrCropHdl
: public SdrHdl
503 // evtl. shear and rotation, equal to the object's one to allow adaption of
504 // the visualization handles
516 // create marker for this kind
517 virtual void CreateB2dIAObject() SAL_OVERRIDE
;
519 BitmapEx
GetBitmapForHandle( const BitmapEx
& rBitmap
, int nSize
);
521 static BitmapEx
GetHandlesBitmap();
526 class SVX_DLLPUBLIC SdrCropViewHdl
: public SdrHdl
529 basegfx::B2DHomMatrix maObjectTransform
;
538 const basegfx::B2DHomMatrix
& rObjectTransform
,
539 const Graphic
& rGraphic
,
546 // create marker for this kind
547 virtual void CreateB2dIAObject() SAL_OVERRIDE
;
552 #endif // INCLUDED_SVX_SVDHDL_HXX
554 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */