1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SVDHDL_HXX 25 #define _SVDHDL_HXX 26 27 #include <tools/gen.hxx> 28 29 #ifndef _POINTR_HXX //autogen 30 #include <vcl/pointr.hxx> 31 #endif 32 #include <tools/contnr.hxx> 33 34 #ifndef _SOLAR_HRC 35 #include <svl/solar.hrc> 36 #endif 37 38 #include <svx/xpoly.hxx> 39 #include <svx/svdoedge.hxx> 40 #include <svx/sdr/overlay/overlayobjectlist.hxx> 41 #include "svx/svxdllapi.h" 42 43 #include <svx/xpoly.hxx> 44 #include <svx/svdoedge.hxx> 45 #include <basegfx/matrix/b2dhommatrix.hxx> 46 #include <svx/sdgcpitm.hxx> 47 48 class VirtualDevice; 49 class OutputDevice; 50 class Region; 51 class Window; 52 class SdrHdlList; 53 class SdrMarkView; 54 class SdrObject; 55 class SdrPageView; 56 class MouseEvent; 57 58 //////////////////////////////////////////////////////////////////////////////////////////////////// 59 60 // Jedes Objekt muss in der Lage seine Handles zu erzeugen. Diese werden dann 61 // bei einer Selektion abgeholt, bei der View angemeldet und sichtbar gemacht. 62 // Wird ein Handle von der Maus beruehrt (IsHit()), so wird von der View der 63 // entsprechende Mauszeiger vom Handle abgeholt und der App auf Anfrage zum 64 // reinschalten uebergeben. 65 // Handles wie z.B. der Rotationsmittelpunkt oder die Spiegelachse werden von 66 // der View generiert, wenn vom Controller der entsprechende Transformations- 67 // Modus selektiert wird. 68 // HDL_MOVE...HDL_LWRGT muessen im enum immer zusammen stehen bleiben! 69 70 enum SdrHdlKind 71 { 72 HDL_MOVE, // Handle zum Verschieben des Objekts 73 HDL_UPLFT, // top left 74 HDL_UPPER, // top 75 HDL_UPRGT, // top right 76 HDL_LEFT, // left 77 HDL_RIGHT, // right 78 HDL_LWLFT, // bottom left 79 HDL_LOWER, // bottom 80 HDL_LWRGT, // bottom right 81 HDL_POLY, // Punktselektion an Polygon oder Bezierkurve 82 HDL_BWGT, // Gewicht an einer Bezierkurve 83 HDL_CIRC, // Winkel an Kreissegmenten, Eckenradius am Rect 84 HDL_REF1, // Referenzpunkt 1, z.B. Rotationsmitte 85 HDL_REF2, // Referenzpunkt 2, z.B. Endpunkt der Spiegelachse 86 HDL_MIRX, // Die Spiegelachse selbst 87 HDL_GLUE, // glue point 88 HDL_GLUE_UNSEL, // glue point unselected 89 HDL_ANCHOR, // anchor symbol (SD, SW) 90 HDL_TRNS, // interactive transparency 91 HDL_GRAD, // interactive gradient 92 HDL_COLR, // interactive color 93 HDL_USER, 94 HDL_ANCHOR_TR, // #101688# Anchor handle with (0,0) at top right for SW 95 96 // for SJ and the CustomShapeHandles: 97 HDL_CUSTOMSHAPE1, 98 99 HDL_SMARTTAG 100 }; 101 102 //////////////////////////////////////////////////////////////////////////////////////////////////// 103 104 enum BitmapColorIndex 105 { 106 LightGreen, 107 Cyan, 108 LightCyan, 109 Red, 110 LightRed, 111 Yellow 112 }; 113 114 //////////////////////////////////////////////////////////////////////////////////////////////////// 115 116 enum BitmapMarkerKind 117 { 118 Rect_7x7, 119 Rect_9x9, 120 Rect_11x11, 121 Rect_13x13, 122 Circ_7x7, 123 Circ_9x9, 124 Circ_11x11, 125 Elli_7x9, 126 Elli_9x11, 127 Elli_9x7, 128 Elli_11x9, 129 RectPlus_7x7, 130 RectPlus_9x9, 131 RectPlus_11x11, 132 Crosshair, 133 Crosshair_Unselected, 134 Glue, 135 Glue_Unselected, 136 Anchor, 137 138 // #98388# add AnchorPressed to be able to animate anchor control, too. 139 AnchorPressed, 140 141 // #101688# AnchorTR for SW 142 AnchorTR, 143 AnchorPressedTR, 144 145 // for SJ and the CustomShapeHandles: 146 Customshape_7x7, 147 Customshape_9x9, 148 Customshape_11x11 149 }; 150 151 //////////////////////////////////////////////////////////////////////////////////////////////////// 152 153 class SVX_DLLPUBLIC SdrHdl 154 { 155 friend class SdrMarkView; // fuer den Zugriff auf nObjHdlNum 156 friend class SdrHdlList; 157 158 // #101928# 159 BitmapEx ImpGetBitmapEx(BitmapMarkerKind eKindOfMarker, sal_uInt16 nInd, sal_Bool bFine, sal_Bool bIsHighContrast); 160 161 protected: 162 SdrObject* pObj; // Gehoert das Handle zu einem Objekt? 163 SdrPageView* pPV; // Gehoert das Handle zu einem Objekt in einer bestimmten PageView? 164 SdrHdlList* pHdlList; // Zum Feststellen der Handlegroesse 165 166 // OVERLAYMANAGER 167 ::sdr::overlay::OverlayObjectList maOverlayGroup; 168 169 Point aPos; 170 171 SdrHdlKind eKind; 172 173 long nDrehWink; // Handles bzw. Mauszeiger drehen 174 sal_uInt32 nObjHdlNum; // wird von der MarkView benoetigt 175 sal_uInt32 nPolyNum; // Polygonpunktes 176 sal_uInt32 nPPntNum; // Punktnummer des Polygons 177 sal_uInt32 nSourceHdlNum; // ist noch vollstaendig zu implementieren 178 179 unsigned bSelect : 1; // Ein selektierter Polygonpunkt? 180 unsigned b1PixMore : 1; // True=Handle wird 1 Pixel groesser dargestellt 181 unsigned bPlusHdl : 1; // u.a. fuer Hld-Paint Optimierung bei MarkPoint/UnmarkPoint, ... 182 183 bool mbMoveOutside; // forces this handle to be moved outside of the selection rectangle 184 185 // create marker for this kind 186 virtual void CreateB2dIAObject(); 187 188 // cleanup marker if one exists 189 void GetRidOfIAObject(); 190 191 private: 192 bool mbMouseOver; // is true if the mouse is over this handle 193 194 protected: 195 ::sdr::overlay::OverlayObject* CreateOverlayObject( 196 const basegfx::B2DPoint& rPos, 197 BitmapColorIndex eColIndex, BitmapMarkerKind eKindOfMarker, Point aMoveOutsideOffset = Point()); 198 BitmapMarkerKind GetNextBigger(BitmapMarkerKind eKnd) const; 199 200 public: 201 SdrHdl(); 202 SdrHdl(const Point& rPnt, SdrHdlKind eNewKind=HDL_MOVE); 203 virtual ~SdrHdl(); 204 getOverlayObjectList() const205 const ::sdr::overlay::OverlayObjectList& getOverlayObjectList() const { return maOverlayGroup; } 206 207 void SetHdlList(SdrHdlList* pList); GetKind() const208 SdrHdlKind GetKind() const { return eKind; } 209 void Touch(); 210 GetPos() const211 const Point& GetPos() const { return aPos; } 212 void SetPos(const Point& rPnt); 213 GetPageView() const214 SdrPageView* GetPageView() const { return pPV; } SetPageView(SdrPageView * pNewPV)215 void SetPageView(SdrPageView* pNewPV) { pPV=pNewPV; } 216 GetObj() const217 SdrObject* GetObj() const { return pObj; } 218 void SetObj(SdrObject* pNewObj); 219 IsSelected() const220 sal_Bool IsSelected() const { return bSelect; } 221 void SetSelected(sal_Bool bJa=sal_True); 222 223 void Set1PixMore(sal_Bool bJa=sal_True); 224 void SetDrehWink(long n); 225 IsCornerHdl() const226 sal_Bool IsCornerHdl() const { return eKind==HDL_UPLFT || eKind==HDL_UPRGT || eKind==HDL_LWLFT || eKind==HDL_LWRGT; } IsVertexHdl() const227 sal_Bool IsVertexHdl() const { return eKind==HDL_UPPER || eKind==HDL_LOWER || eKind==HDL_LEFT || eKind==HDL_RIGHT; } 228 SetObjHdlNum(sal_uInt32 nNum)229 void SetObjHdlNum(sal_uInt32 nNum) { nObjHdlNum=nNum; } GetObjHdlNum() const230 sal_uInt32 GetObjHdlNum() const { return nObjHdlNum; } 231 SetPolyNum(sal_uInt32 nNum)232 void SetPolyNum(sal_uInt32 nNum) { nPolyNum=nNum; } GetPolyNum() const233 sal_uInt32 GetPolyNum() const { return nPolyNum; } 234 SetPointNum(sal_uInt32 nNum)235 void SetPointNum(sal_uInt32 nNum) { nPPntNum=nNum; } GetPointNum() const236 sal_uInt32 GetPointNum() const { return nPPntNum; } 237 SetPlusHdl(sal_Bool bOn)238 void SetPlusHdl(sal_Bool bOn) { bPlusHdl=bOn; } IsPlusHdl() const239 sal_Bool IsPlusHdl() const { return bPlusHdl; } 240 SetSourceHdlNum(sal_uInt32 nNum)241 void SetSourceHdlNum(sal_uInt32 nNum) { nSourceHdlNum=nNum; } GetSourceHdlNum() const242 sal_uInt32 GetSourceHdlNum() const { return nSourceHdlNum; } 243 244 virtual Pointer GetPointer() const; 245 bool IsHdlHit(const Point& rPnt) const; 246 247 // #97016# II 248 virtual sal_Bool IsFocusHdl() const; 249 250 void SetMoveOutside( bool bMoveOutside ); 251 252 /** is called when the mouse enters the area of this handle. If the handle changes his 253 visualization during mouse over it must override this method and call Touch(). */ 254 virtual void onMouseEnter(const MouseEvent& rMEvt); 255 256 /** is called when the mouse leaves the area of this handle. If the handle changes his 257 visualization during mouse over it must override this method and call Touch(). */ 258 virtual void onMouseLeave(); 259 260 bool isMouseOver() const; 261 }; 262 263 //////////////////////////////////////////////////////////////////////////////////////////////////// 264 265 #define SDR_HANDLE_COLOR_SIZE_NORMAL Size(13, 13) 266 #define SDR_HANDLE_COLOR_SIZE_SELECTED Size(17, 17) 267 268 class SVX_DLLPUBLIC SdrHdlColor : public SdrHdl 269 { 270 private: 271 // size of color markers 272 Size aMarkerSize; 273 274 // color 275 Color aMarkerColor; 276 277 // callback link when value changed 278 Link aColorChangeHdl; 279 280 // use luminance values only 281 unsigned bUseLuminance : 1; 282 283 // create marker for this kind 284 SVX_DLLPRIVATE virtual void CreateB2dIAObject(); 285 286 // help functions 287 SVX_DLLPRIVATE Bitmap CreateColorDropper(Color aCol); 288 SVX_DLLPRIVATE Color GetLuminance(const Color& rCol); 289 SVX_DLLPRIVATE void CallColorChangeLink(); 290 291 public: 292 SdrHdlColor(const Point& rRef, Color aCol = Color(COL_BLACK), const Size& rSize = Size(11, 11), sal_Bool bLum = sal_False); 293 virtual ~SdrHdlColor(); 294 IsUseLuminance() const295 sal_Bool IsUseLuminance() const { return bUseLuminance; } 296 GetColor() const297 Color GetColor() const { return aMarkerColor; } 298 void SetColor(Color aNew, sal_Bool bCallLink = sal_False); 299 GetSize() const300 const Size& GetSize() const { return aMarkerSize; } 301 void SetSize(const Size& rNew); 302 SetColorChangeHdl(const Link & rLink)303 void SetColorChangeHdl(const Link& rLink) { aColorChangeHdl = rLink; } GetColorChangeHdl() const304 const Link& GetColorChangeHdl() const { return aColorChangeHdl; } 305 }; 306 307 //////////////////////////////////////////////////////////////////////////////////////////////////// 308 309 class SdrHdlGradient : public SdrHdl 310 { 311 private: 312 // pointer to used color handles 313 SdrHdlColor* pColHdl1; 314 SdrHdlColor* pColHdl2; 315 316 // 2nd position 317 Point a2ndPos; 318 319 // is this a gradient or a transparency 320 unsigned bGradient : 1; 321 322 // select which handle to move 323 unsigned bMoveSingleHandle : 1; 324 unsigned bMoveFirstHandle : 1; 325 326 // create marker for this kind 327 virtual void CreateB2dIAObject(); 328 329 public: 330 SdrHdlGradient(const Point& rRef1, const Point& rRef2, sal_Bool bGrad = sal_True); 331 virtual ~SdrHdlGradient(); 332 IsGradient() const333 sal_Bool IsGradient() const { return bGradient; } 334 335 // set the associated color handles SetColorHandles(SdrHdlColor * pL1,SdrHdlColor * pL2)336 void SetColorHandles(SdrHdlColor* pL1, SdrHdlColor* pL2) { pColHdl1 = pL1; pColHdl2 = pL2; } GetColorHdl1() const337 SdrHdlColor* GetColorHdl1() const { return pColHdl1; } GetColorHdl2() const338 SdrHdlColor* GetColorHdl2() const { return pColHdl2; } 339 Get2ndPos() const340 const Point& Get2ndPos() const { return a2ndPos; } 341 void Set2ndPos(const Point& rPnt); 342 343 // the link called by the color handles 344 DECL_LINK(ColorChangeHdl, SdrHdl*); 345 346 // transformation call, create gradient from this handle 347 void FromIAOToItem(SdrObject* pObj, sal_Bool bSetItemOnObject, sal_Bool bUndo); 348 349 // selection flags for interaction IsMoveSingleHandle() const350 sal_Bool IsMoveSingleHandle() const { return bMoveSingleHandle; } SetMoveSingleHandle(sal_Bool bNew)351 void SetMoveSingleHandle(sal_Bool bNew) { bMoveSingleHandle = bNew; } IsMoveFirstHandle() const352 sal_Bool IsMoveFirstHandle() const { return bMoveFirstHandle; } SetMoveFirstHandle(sal_Bool bNew)353 void SetMoveFirstHandle(sal_Bool bNew) { bMoveFirstHandle = bNew; } 354 }; 355 356 //////////////////////////////////////////////////////////////////////////////////////////////////// 357 358 // Spiegelachse 359 class SdrHdlLine: public SdrHdl 360 { 361 // create marker for this kind 362 virtual void CreateB2dIAObject(); 363 364 protected: 365 SdrHdl* pHdl1; 366 SdrHdl* pHdl2; 367 368 public: SdrHdlLine(SdrHdl & rHdl1,SdrHdl & rHdl2,SdrHdlKind eNewKind=HDL_MIRX)369 SdrHdlLine(SdrHdl& rHdl1, SdrHdl& rHdl2, SdrHdlKind eNewKind=HDL_MIRX) { eKind=eNewKind; pHdl1=&rHdl1; pHdl2=&rHdl2; } 370 virtual ~SdrHdlLine(); 371 372 virtual Pointer GetPointer() const; 373 }; 374 375 // Ein SdrHdlBezWgt hat Kenntnis von seinem "BasisHandle". Seine Draw-Methode 376 // zeichnet zusaetzlich eine Linie von seiner Position zur Position dieses 377 // BasisHandles. 378 class SdrHdlBezWgt: public SdrHdl 379 { 380 // create marker for this kind 381 virtual void CreateB2dIAObject(); 382 383 protected: 384 const SdrHdl* pHdl1; 385 386 public: 387 // das ist kein Copy-Ctor!!! SdrHdlBezWgt(const SdrHdl * pRefHdl1,SdrHdlKind eNewKind=HDL_BWGT)388 SdrHdlBezWgt(const SdrHdl* pRefHdl1, SdrHdlKind eNewKind=HDL_BWGT) { eKind=eNewKind; pHdl1=pRefHdl1; } 389 virtual ~SdrHdlBezWgt(); 390 }; 391 392 //////////////////////////////////////////////////////////////////////////////////////////////////// 393 394 class E3dVolumeMarker : public SdrHdl 395 { 396 basegfx::B2DPolyPolygon aWireframePoly; 397 398 // create marker for this kind 399 virtual void CreateB2dIAObject(); 400 401 public: 402 E3dVolumeMarker(const basegfx::B2DPolyPolygon& rWireframePoly); 403 }; 404 405 //////////////////////////////////////////////////////////////////////////////////////////////////// 406 407 class ImpEdgeHdl: public SdrHdl 408 { 409 SdrEdgeLineCode eLineCode; 410 411 // create marker for this kind 412 virtual void CreateB2dIAObject(); 413 414 public: ImpEdgeHdl(const Point & rPnt,SdrHdlKind eNewKind)415 ImpEdgeHdl(const Point& rPnt, SdrHdlKind eNewKind): SdrHdl(rPnt,eNewKind),eLineCode(MIDDLELINE) {} 416 virtual ~ImpEdgeHdl(); 417 418 void SetLineCode(SdrEdgeLineCode eCode); GetLineCode() const419 SdrEdgeLineCode GetLineCode() const { return eLineCode; } 420 sal_Bool IsHorzDrag() const; 421 virtual Pointer GetPointer() const; 422 }; 423 424 //////////////////////////////////////////////////////////////////////////////////////////////////// 425 426 class ImpMeasureHdl: public SdrHdl 427 { 428 // create marker for this kind 429 virtual void CreateB2dIAObject(); 430 431 public: ImpMeasureHdl(const Point & rPnt,SdrHdlKind eNewKind)432 ImpMeasureHdl(const Point& rPnt, SdrHdlKind eNewKind): SdrHdl(rPnt,eNewKind) {} 433 virtual ~ImpMeasureHdl(); 434 435 virtual Pointer GetPointer() const; 436 }; 437 438 //////////////////////////////////////////////////////////////////////////////////////////////////// 439 440 class ImpTextframeHdl: public SdrHdl 441 { 442 const Rectangle maRect; 443 444 // create marker for this kind 445 virtual void CreateB2dIAObject(); 446 447 public: 448 explicit ImpTextframeHdl(const Rectangle& rRect); 449 }; 450 451 //////////////////////////////////////////////////////////////////////////////////////////////////// 452 453 // #97016# II 454 class ImplHdlListData; 455 456 class SVX_DLLPUBLIC SdrHdlList 457 { 458 protected: 459 sal_uIntPtr mnFocusIndex; 460 SdrMarkView* pView; 461 Container aList; 462 sal_uInt16 nHdlSize; 463 464 unsigned bRotateShear : 1; 465 unsigned bDistortShear : 1; 466 unsigned bMoveOutside : 1; // Handles nach aussen ruecken (fuer TextEdit) 467 unsigned bFineHandles : 1; 468 469 private: SdrHdlList(const SdrHdlList &)470 SVX_DLLPRIVATE SdrHdlList(const SdrHdlList&): aList(1024,64,64) {} operator =(const SdrHdlList &)471 SVX_DLLPRIVATE void operator=(const SdrHdlList&) {} operator ==(const SdrHdlList &) const472 SVX_DLLPRIVATE sal_Bool operator==(const SdrHdlList&) const { return sal_False; } operator !=(const SdrHdlList &) const473 SVX_DLLPRIVATE sal_Bool operator!=(const SdrHdlList&) const { return sal_False; } 474 475 public: 476 SdrHdlList(SdrMarkView* pV); 477 ~SdrHdlList(); 478 void Clear(); 479 480 // #97016# II 481 void TravelFocusHdl(sal_Bool bForward); 482 SdrHdl* GetFocusHdl() const; 483 void SetFocusHdl(SdrHdl* pNew); 484 void ResetFocusHdl(); 485 486 // Access to View 487 SdrMarkView* GetView() const; 488 489 // Sortierung: 1.Level Erst Refpunkt-Handles, dann normale Handles, dann Glue, dann User, dann Plushandles 490 // 2.Level PageView (Pointer) 491 // 3.Level Position (x+y) 492 void Sort(); GetHdlCount() const493 sal_uIntPtr GetHdlCount() const { return aList.Count(); } GetHdl(sal_uIntPtr nNum) const494 SdrHdl* GetHdl(sal_uIntPtr nNum) const { return (SdrHdl*)(aList.GetObject(nNum)); } 495 sal_uIntPtr GetHdlNum(const SdrHdl* pHdl) const; 496 void SetHdlSize(sal_uInt16 nSiz); GetHdlSize() const497 sal_uInt16 GetHdlSize() const { return nHdlSize; } 498 void SetMoveOutside(sal_Bool bOn); IsMoveOutside() const499 sal_Bool IsMoveOutside() const { return bMoveOutside; } 500 void SetRotateShear(sal_Bool bOn); IsRotateShear() const501 sal_Bool IsRotateShear() const { return bRotateShear; } 502 void SetDistortShear(sal_Bool bOn); IsDistortShear() const503 sal_Bool IsDistortShear() const { return bDistortShear; } 504 void SetFineHdl(sal_Bool bOn); IsFineHdl() const505 sal_Bool IsFineHdl() const { return bFineHandles; } 506 507 // AddHdl uebernimmt das Handle in sein Eigentum. Es muss 508 // also auf dem Heap stehen, da Clear() ein delete macht. 509 void AddHdl(SdrHdl* pHdl, sal_Bool bAtBegin=sal_False); 510 SdrHdl* RemoveHdl(sal_uIntPtr nNum); 511 512 // Zuletzt eingefuegte Handles werden am ehesten getroffen 513 // (wenn Handles uebereinander liegen). 514 SdrHdl* IsHdlListHit(const Point& rPnt, sal_Bool bBack=sal_False, sal_Bool bNext=sal_False, SdrHdl* pHdl0=NULL) const; 515 SdrHdl* GetHdl(SdrHdlKind eKind1) const; 516 }; 517 518 //////////////////////////////////////////////////////////////////////////////////////////////////// 519 520 class SVX_DLLPUBLIC SdrCropHdl : public SdrHdl 521 { 522 private: 523 // evtl. shear and rotation, equal to the object's one to allow adaption of 524 // the visualization handles 525 double mfShearX; 526 double mfRotation; 527 528 public: 529 SdrCropHdl( 530 const Point& rPnt, 531 SdrHdlKind eNewKind, 532 double fShearX, 533 double fRotation); 534 535 protected: 536 // create marker for this kind 537 virtual void CreateB2dIAObject(); 538 539 BitmapEx GetBitmapForHandle( const BitmapEx& rBitmap, int nSize ); 540 541 static BitmapEx GetHandlesBitmap( bool bIsFineHdl, bool bIsHighContrast ); 542 }; 543 544 //////////////////////////////////////////////////////////////////////////////////////////////////// 545 546 class SVX_DLLPUBLIC SdrCropViewHdl : public SdrHdl 547 { 548 private: 549 basegfx::B2DHomMatrix maObjectTransform; 550 Graphic maGraphic; 551 double mfCropLeft; 552 double mfCropTop; 553 double mfCropRight; 554 double mfCropBottom; 555 556 public: 557 SdrCropViewHdl( 558 const basegfx::B2DHomMatrix& rObjectTransform, 559 const Graphic& rGraphic, 560 double fCropLeft, 561 double fCropTop, 562 double fCropRight, 563 double fCropBottom); 564 565 protected: 566 // create marker for this kind 567 virtual void CreateB2dIAObject(); 568 }; 569 570 //////////////////////////////////////////////////////////////////////////////////////////////////// 571 572 #endif //_SVDHDL_HXX 573 574 //////////////////////////////////////////////////////////////////////////////////////////////////// 575 // eof 576