Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / svdhdl.hxx
blobce74428e219b1a2663d293035eeb76a4b6cc86a1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
35 #include <deque>
37 class OutputDevice;
38 class SdrHdlList;
39 class SdrMarkView;
40 class SdrObject;
41 class SdrPageView;
42 class MouseEvent;
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!
54 enum SdrHdlKind
56 HDL_MOVE, // Handle zum Verschieben des Objekts
57 HDL_UPLFT, // Oben links
58 HDL_UPPER, // Oben
59 HDL_UPRGT, // Oben rechts
60 HDL_LEFT, // Links
61 HDL_RIGHT, // Rechts
62 HDL_LWLFT, // Unten links
63 HDL_LOWER, // Unten
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
77 HDL_USER,
78 HDL_ANCHOR_TR, // #101688# Anchor handle with (0,0) at top right for SW
80 // for SJ and the CustomShapeHandles:
81 HDL_CUSTOMSHAPE1,
83 HDL_SMARTTAG
88 enum BitmapColorIndex
90 LightGreen,
91 Cyan,
92 LightCyan,
93 Red,
94 LightRed,
95 Yellow
100 enum BitmapMarkerKind
102 Rect_7x7,
103 Rect_9x9,
104 Rect_11x11,
105 Rect_13x13,
106 Circ_7x7,
107 Circ_9x9,
108 Circ_11x11,
109 Elli_7x9,
110 Elli_9x11,
111 Elli_9x7,
112 Elli_11x9,
113 RectPlus_7x7,
114 RectPlus_9x9,
115 RectPlus_11x11,
116 Crosshair,
117 Glue,
118 Glue_Deselected,
119 Anchor,
121 // #98388# add AnchorPressed to be able to aninate anchor control, too.
122 AnchorPressed,
124 // #101688# AnchorTR for SW
125 AnchorTR,
126 AnchorPressedTR,
128 // for SJ and the CustomShapeHandles:
129 Customshape_7x7,
130 Customshape_9x9,
131 Customshape_11x11
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);
143 protected:
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
148 // OVERLAYMANAGER
149 sdr::overlay::OverlayObjectList maOverlayGroup;
151 Point aPos;
153 SdrHdlKind eKind;
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();
173 private:
174 bool mbMouseOver; // is true if the mouse is over this handle
176 protected:
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);
183 public:
184 SdrHdl();
185 explicit SdrHdl(const Point& rPnt, SdrHdlKind eNewKind=HDL_MOVE);
186 virtual ~SdrHdl();
188 const sdr::overlay::OverlayObjectList& getOverlayObjectList() const { return maOverlayGroup; }
190 void SetHdlList(SdrHdlList* pList);
191 SdrHdlKind GetKind() const { return eKind; }
192 void Touch();
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;
230 // #97016# II
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
253 private:
254 // size of colr markers
255 Size aMarkerSize;
257 // color
258 Color aMarkerColor;
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;
269 // help functions
270 SVX_DLLPRIVATE Bitmap CreateColorDropper(Color aCol);
271 SVX_DLLPRIVATE Color GetLuminance(const Color& rCol);
272 SVX_DLLPRIVATE void CallColorChangeLink();
274 public:
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
294 private:
295 // pointer to used color handles
296 SdrHdlColor* pColHdl1;
297 SdrHdlColor* pColHdl2;
299 // 2nd position
300 Point a2ndPos;
302 // is this a gradient or a transparence
303 bool bGradient : 1;
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;
312 public:
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; }
341 // Spiegelachse
342 class SdrHdlLine: public SdrHdl
344 // create marker for this kind
345 virtual void CreateB2dIAObject() SAL_OVERRIDE;
347 protected:
348 SdrHdl* pHdl1;
349 SdrHdl* pHdl2;
351 public:
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
360 // BasisHandles.
361 class SdrHdlBezWgt: public SdrHdl
363 // create marker for this kind
364 virtual void CreateB2dIAObject() SAL_OVERRIDE;
366 protected:
367 const SdrHdl* pHdl1;
369 public:
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;
384 public:
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;
397 public:
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;
414 public:
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;
430 public:
431 explicit ImpTextframeHdl(const Rectangle& rRect);
438 class SVX_DLLPUBLIC SdrHdlList
440 protected:
441 size_t mnFocusIndex;
442 SdrMarkView* pView;
443 std::deque<SdrHdl*> aList;
444 sal_uInt16 nHdlSize;
446 bool bRotateShear : 1;
447 bool bDistortShear : 1;
448 bool bMoveOutside : 1; // Handles nach aussen ruecken (fuer TextEdit)
450 private:
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; }
456 public:
457 explicit SdrHdlList(SdrMarkView* pV);
458 ~SdrHdlList();
459 void Clear();
461 // #97016# II
462 void TravelFocusHdl(bool bForward);
463 SdrHdl* GetFocusHdl() const;
464 void SetFocusHdl(SdrHdl* pNew);
465 void ResetFocusHdl();
467 // Access to View
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)
473 void Sort();
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
502 private:
503 // evtl. shear and rotation, equal to the object's one to allow adaption of
504 // the visualization handles
505 double mfShearX;
506 double mfRotation;
508 public:
509 SdrCropHdl(
510 const Point& rPnt,
511 SdrHdlKind eNewKind,
512 double fShearX,
513 double fRotation);
515 protected:
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
528 private:
529 basegfx::B2DHomMatrix maObjectTransform;
530 Graphic maGraphic;
531 double mfCropLeft;
532 double mfCropTop;
533 double mfCropRight;
534 double mfCropBottom;
536 public:
537 SdrCropViewHdl(
538 const basegfx::B2DHomMatrix& rObjectTransform,
539 const Graphic& rGraphic,
540 double fCropLeft,
541 double fCropTop,
542 double fCropRight,
543 double fCropBottom);
545 protected:
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: */