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, // Oben links 74 HDL_UPPER, // Oben 75 HDL_UPRGT, // Oben rechts 76 HDL_LEFT, // Links 77 HDL_RIGHT, // Rechts 78 HDL_LWLFT, // Unten links 79 HDL_LOWER, // Unten 80 HDL_LWRGT, // Unten rechts 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, // GluePoint 88 HDL_ANCHOR, // anchor symbol (SD, SW) 89 HDL_TRNS, // interactive transparence 90 HDL_GRAD, // interactive gradient 91 HDL_COLR, // interactive color 92 HDL_USER, 93 HDL_ANCHOR_TR, // #101688# Anchor handle with (0,0) at top right for SW 94 95 // for SJ and the CustomShapeHandles: 96 HDL_CUSTOMSHAPE1, 97 98 HDL_SMARTTAG 99 }; 100 101 //////////////////////////////////////////////////////////////////////////////////////////////////// 102 103 enum BitmapColorIndex 104 { 105 LightGreen, 106 Cyan, 107 LightCyan, 108 Red, 109 LightRed, 110 Yellow 111 }; 112 113 //////////////////////////////////////////////////////////////////////////////////////////////////// 114 115 enum BitmapMarkerKind 116 { 117 Rect_7x7, 118 Rect_9x9, 119 Rect_11x11, 120 Rect_13x13, 121 Circ_7x7, 122 Circ_9x9, 123 Circ_11x11, 124 Elli_7x9, 125 Elli_9x11, 126 Elli_9x7, 127 Elli_11x9, 128 RectPlus_7x7, 129 RectPlus_9x9, 130 RectPlus_11x11, 131 Crosshair, 132 Glue, 133 Anchor, 134 135 // #98388# add AnchorPressed to be able to aninate anchor control, too. 136 AnchorPressed, 137 138 // #101688# AnchorTR for SW 139 AnchorTR, 140 AnchorPressedTR, 141 142 // for SJ and the CustomShapeHandles: 143 Customshape_7x7, 144 Customshape_9x9, 145 Customshape_11x11 146 }; 147 148 //////////////////////////////////////////////////////////////////////////////////////////////////// 149 150 class SVX_DLLPUBLIC SdrHdl 151 { 152 friend class SdrMarkView; // fuer den Zugriff auf nObjHdlNum 153 friend class SdrHdlList; 154 155 // #101928# 156 BitmapEx ImpGetBitmapEx(BitmapMarkerKind eKindOfMarker, sal_uInt16 nInd, sal_Bool bFine, sal_Bool bIsHighContrast); 157 158 protected: 159 SdrObject* pObj; // Gehoert das Handle zu einem Objekt? 160 SdrPageView* pPV; // Gehoert das Handle zu einem Objekt in einer bestimmten PageView? 161 SdrHdlList* pHdlList; // Zum Feststelen der Handlegroesse 162 163 // OVERLAYMANAGER 164 ::sdr::overlay::OverlayObjectList maOverlayGroup; 165 166 Point aPos; 167 168 SdrHdlKind eKind; 169 170 long nDrehWink; // Handles bzw. Mauszeiger drehen 171 sal_uInt32 nObjHdlNum; // wird von der MarkView benoetigt 172 sal_uInt32 nPolyNum; // Polygonpunktes 173 sal_uInt32 nPPntNum; // Punktnummer des Polygons 174 sal_uInt32 nSourceHdlNum; // ist noch vollstaendig zu implementieren 175 176 unsigned bSelect : 1; // Ein selektierter Polygonpunkt? 177 unsigned b1PixMore : 1; // True=Handle wird 1 Pixel groesser dargestellt 178 unsigned bPlusHdl : 1; // u.a. fuer Hld-Paint Optimierung bei MarkPoint/UnmarkPoint, ... 179 180 bool mbMoveOutside; // forces this handle to be moved outside of the selection rectangle 181 182 // create marker for this kind 183 virtual void CreateB2dIAObject(); 184 185 // cleanup marker if one exists 186 void GetRidOfIAObject(); 187 188 private: 189 bool mbMouseOver; // is true if the mouse is over this handle 190 191 protected: 192 ::sdr::overlay::OverlayObject* CreateOverlayObject( 193 const basegfx::B2DPoint& rPos, 194 BitmapColorIndex eColIndex, BitmapMarkerKind eKindOfMarker, Point aMoveOutsideOffset = Point()); 195 BitmapMarkerKind GetNextBigger(BitmapMarkerKind eKnd) const; 196 197 public: 198 SdrHdl(); 199 SdrHdl(const Point& rPnt, SdrHdlKind eNewKind=HDL_MOVE); 200 virtual ~SdrHdl(); 201 getOverlayObjectList() const202 const ::sdr::overlay::OverlayObjectList& getOverlayObjectList() const { return maOverlayGroup; } 203 204 void SetHdlList(SdrHdlList* pList); GetKind() const205 SdrHdlKind GetKind() const { return eKind; } 206 void Touch(); 207 GetPos() const208 const Point& GetPos() const { return aPos; } 209 void SetPos(const Point& rPnt); 210 GetPageView() const211 SdrPageView* GetPageView() const { return pPV; } SetPageView(SdrPageView * pNewPV)212 void SetPageView(SdrPageView* pNewPV) { pPV=pNewPV; } 213 GetObj() const214 SdrObject* GetObj() const { return pObj; } 215 void SetObj(SdrObject* pNewObj); 216 IsSelected() const217 sal_Bool IsSelected() const { return bSelect; } 218 void SetSelected(sal_Bool bJa=sal_True); 219 220 void Set1PixMore(sal_Bool bJa=sal_True); 221 void SetDrehWink(long n); 222 IsCornerHdl() const223 sal_Bool IsCornerHdl() const { return eKind==HDL_UPLFT || eKind==HDL_UPRGT || eKind==HDL_LWLFT || eKind==HDL_LWRGT; } IsVertexHdl() const224 sal_Bool IsVertexHdl() const { return eKind==HDL_UPPER || eKind==HDL_LOWER || eKind==HDL_LEFT || eKind==HDL_RIGHT; } 225 SetObjHdlNum(sal_uInt32 nNum)226 void SetObjHdlNum(sal_uInt32 nNum) { nObjHdlNum=nNum; } GetObjHdlNum() const227 sal_uInt32 GetObjHdlNum() const { return nObjHdlNum; } 228 SetPolyNum(sal_uInt32 nNum)229 void SetPolyNum(sal_uInt32 nNum) { nPolyNum=nNum; } GetPolyNum() const230 sal_uInt32 GetPolyNum() const { return nPolyNum; } 231 SetPointNum(sal_uInt32 nNum)232 void SetPointNum(sal_uInt32 nNum) { nPPntNum=nNum; } GetPointNum() const233 sal_uInt32 GetPointNum() const { return nPPntNum; } 234 SetPlusHdl(sal_Bool bOn)235 void SetPlusHdl(sal_Bool bOn) { bPlusHdl=bOn; } IsPlusHdl() const236 sal_Bool IsPlusHdl() const { return bPlusHdl; } 237 SetSourceHdlNum(sal_uInt32 nNum)238 void SetSourceHdlNum(sal_uInt32 nNum) { nSourceHdlNum=nNum; } GetSourceHdlNum() const239 sal_uInt32 GetSourceHdlNum() const { return nSourceHdlNum; } 240 241 virtual Pointer GetPointer() const; 242 bool IsHdlHit(const Point& rPnt) const; 243 244 // #97016# II 245 virtual sal_Bool IsFocusHdl() const; 246 247 void SetMoveOutside( bool bMoveOutside ); 248 249 /** is called when the mouse enters the area of this handle. If the handle changes his 250 visualisation during mouse over it must override this method and call Touch(). */ 251 virtual void onMouseEnter(const MouseEvent& rMEvt); 252 253 /** is called when the mouse leaves the area of this handle. If the handle changes his 254 visualisation during mouse over it must override this method and call Touch(). */ 255 virtual void onMouseLeave(); 256 257 bool isMouseOver() const; 258 }; 259 260 //////////////////////////////////////////////////////////////////////////////////////////////////// 261 262 #define SDR_HANDLE_COLOR_SIZE_NORMAL Size(13, 13) 263 #define SDR_HANDLE_COLOR_SIZE_SELECTED Size(17, 17) 264 265 class SVX_DLLPUBLIC SdrHdlColor : public SdrHdl 266 { 267 private: 268 // size of colr markers 269 Size aMarkerSize; 270 271 // color 272 Color aMarkerColor; 273 274 // callback link when value changed 275 Link aColorChangeHdl; 276 277 // use luminance values only 278 unsigned bUseLuminance : 1; 279 280 // create marker for this kind 281 SVX_DLLPRIVATE virtual void CreateB2dIAObject(); 282 283 // help functions 284 SVX_DLLPRIVATE Bitmap CreateColorDropper(Color aCol); 285 SVX_DLLPRIVATE Color GetLuminance(const Color& rCol); 286 SVX_DLLPRIVATE void CallColorChangeLink(); 287 288 public: 289 SdrHdlColor(const Point& rRef, Color aCol = Color(COL_BLACK), const Size& rSize = Size(11, 11), sal_Bool bLum = sal_False); 290 virtual ~SdrHdlColor(); 291 IsUseLuminance() const292 sal_Bool IsUseLuminance() const { return bUseLuminance; } 293 GetColor() const294 Color GetColor() const { return aMarkerColor; } 295 void SetColor(Color aNew, sal_Bool bCallLink = sal_False); 296 GetSize() const297 const Size& GetSize() const { return aMarkerSize; } 298 void SetSize(const Size& rNew); 299 SetColorChangeHdl(const Link & rLink)300 void SetColorChangeHdl(const Link& rLink) { aColorChangeHdl = rLink; } GetColorChangeHdl() const301 const Link& GetColorChangeHdl() const { return aColorChangeHdl; } 302 }; 303 304 //////////////////////////////////////////////////////////////////////////////////////////////////// 305 306 class SdrHdlGradient : public SdrHdl 307 { 308 private: 309 // pointer to used color handles 310 SdrHdlColor* pColHdl1; 311 SdrHdlColor* pColHdl2; 312 313 // 2nd position 314 Point a2ndPos; 315 316 // is this a gradient or a transparence 317 unsigned bGradient : 1; 318 319 // select which handle to move 320 unsigned bMoveSingleHandle : 1; 321 unsigned bMoveFirstHandle : 1; 322 323 // create marker for this kind 324 virtual void CreateB2dIAObject(); 325 326 public: 327 SdrHdlGradient(const Point& rRef1, const Point& rRef2, sal_Bool bGrad = sal_True); 328 virtual ~SdrHdlGradient(); 329 IsGradient() const330 sal_Bool IsGradient() const { return bGradient; } 331 332 // set the associated color handles SetColorHandles(SdrHdlColor * pL1,SdrHdlColor * pL2)333 void SetColorHandles(SdrHdlColor* pL1, SdrHdlColor* pL2) { pColHdl1 = pL1; pColHdl2 = pL2; } GetColorHdl1() const334 SdrHdlColor* GetColorHdl1() const { return pColHdl1; } GetColorHdl2() const335 SdrHdlColor* GetColorHdl2() const { return pColHdl2; } 336 Get2ndPos() const337 const Point& Get2ndPos() const { return a2ndPos; } 338 void Set2ndPos(const Point& rPnt); 339 340 // the link called by the color handles 341 DECL_LINK(ColorChangeHdl, SdrHdl*); 342 343 // transformation call, create gradient from this handle 344 void FromIAOToItem(SdrObject* pObj, sal_Bool bSetItemOnObject, sal_Bool bUndo); 345 346 // selection flags for interaction IsMoveSingleHandle() const347 sal_Bool IsMoveSingleHandle() const { return bMoveSingleHandle; } SetMoveSingleHandle(sal_Bool bNew)348 void SetMoveSingleHandle(sal_Bool bNew) { bMoveSingleHandle = bNew; } IsMoveFirstHandle() const349 sal_Bool IsMoveFirstHandle() const { return bMoveFirstHandle; } SetMoveFirstHandle(sal_Bool bNew)350 void SetMoveFirstHandle(sal_Bool bNew) { bMoveFirstHandle = bNew; } 351 }; 352 353 //////////////////////////////////////////////////////////////////////////////////////////////////// 354 355 // Spiegelachse 356 class SdrHdlLine: public SdrHdl 357 { 358 // create marker for this kind 359 virtual void CreateB2dIAObject(); 360 361 protected: 362 SdrHdl* pHdl1; 363 SdrHdl* pHdl2; 364 365 public: SdrHdlLine(SdrHdl & rHdl1,SdrHdl & rHdl2,SdrHdlKind eNewKind=HDL_MIRX)366 SdrHdlLine(SdrHdl& rHdl1, SdrHdl& rHdl2, SdrHdlKind eNewKind=HDL_MIRX) { eKind=eNewKind; pHdl1=&rHdl1; pHdl2=&rHdl2; } 367 virtual ~SdrHdlLine(); 368 369 virtual Pointer GetPointer() const; 370 }; 371 372 // Ein SdrHdlBezWgt hat Kenntnis von seinem "BasisHandle". Seine Draw-Methode 373 // zeichnet zusaetzlich eine Linie von seiner Position zur Position dieses 374 // BasisHandles. 375 class SdrHdlBezWgt: public SdrHdl 376 { 377 // create marker for this kind 378 virtual void CreateB2dIAObject(); 379 380 protected: 381 const SdrHdl* pHdl1; 382 383 public: 384 // das ist kein Copy-Ctor!!! SdrHdlBezWgt(const SdrHdl * pRefHdl1,SdrHdlKind eNewKind=HDL_BWGT)385 SdrHdlBezWgt(const SdrHdl* pRefHdl1, SdrHdlKind eNewKind=HDL_BWGT) { eKind=eNewKind; pHdl1=pRefHdl1; } 386 virtual ~SdrHdlBezWgt(); 387 }; 388 389 //////////////////////////////////////////////////////////////////////////////////////////////////// 390 391 class E3dVolumeMarker : public SdrHdl 392 { 393 basegfx::B2DPolyPolygon aWireframePoly; 394 395 // create marker for this kind 396 virtual void CreateB2dIAObject(); 397 398 public: 399 E3dVolumeMarker(const basegfx::B2DPolyPolygon& rWireframePoly); 400 }; 401 402 //////////////////////////////////////////////////////////////////////////////////////////////////// 403 404 class ImpEdgeHdl: public SdrHdl 405 { 406 SdrEdgeLineCode eLineCode; 407 408 // create marker for this kind 409 virtual void CreateB2dIAObject(); 410 411 public: ImpEdgeHdl(const Point & rPnt,SdrHdlKind eNewKind)412 ImpEdgeHdl(const Point& rPnt, SdrHdlKind eNewKind): SdrHdl(rPnt,eNewKind),eLineCode(MIDDLELINE) {} 413 virtual ~ImpEdgeHdl(); 414 415 void SetLineCode(SdrEdgeLineCode eCode); GetLineCode() const416 SdrEdgeLineCode GetLineCode() const { return eLineCode; } 417 sal_Bool IsHorzDrag() const; 418 virtual Pointer GetPointer() const; 419 }; 420 421 //////////////////////////////////////////////////////////////////////////////////////////////////// 422 423 class ImpMeasureHdl: public SdrHdl 424 { 425 // create marker for this kind 426 virtual void CreateB2dIAObject(); 427 428 public: ImpMeasureHdl(const Point & rPnt,SdrHdlKind eNewKind)429 ImpMeasureHdl(const Point& rPnt, SdrHdlKind eNewKind): SdrHdl(rPnt,eNewKind) {} 430 virtual ~ImpMeasureHdl(); 431 432 virtual Pointer GetPointer() const; 433 }; 434 435 //////////////////////////////////////////////////////////////////////////////////////////////////// 436 437 class ImpTextframeHdl: public SdrHdl 438 { 439 const Rectangle maRect; 440 441 // create marker for this kind 442 virtual void CreateB2dIAObject(); 443 444 public: 445 explicit ImpTextframeHdl(const Rectangle& rRect); 446 }; 447 448 //////////////////////////////////////////////////////////////////////////////////////////////////// 449 //////////////////////////////////////////////////////////////////////////////////////////////////// 450 //////////////////////////////////////////////////////////////////////////////////////////////////// 451 452 // #97016# II 453 class ImplHdlListData; 454 455 class SVX_DLLPUBLIC SdrHdlList 456 { 457 protected: 458 sal_uIntPtr mnFocusIndex; 459 SdrMarkView* pView; 460 Container aList; 461 sal_uInt16 nHdlSize; 462 463 unsigned bRotateShear : 1; 464 unsigned bDistortShear : 1; 465 unsigned bMoveOutside : 1; // Handles nach aussen ruecken (fuer TextEdit) 466 unsigned bFineHandles : 1; 467 468 private: SdrHdlList(const SdrHdlList &)469 SVX_DLLPRIVATE SdrHdlList(const SdrHdlList&): aList(1024,64,64) {} operator =(const SdrHdlList &)470 SVX_DLLPRIVATE void operator=(const SdrHdlList&) {} operator ==(const SdrHdlList &) const471 SVX_DLLPRIVATE sal_Bool operator==(const SdrHdlList&) const { return sal_False; } operator !=(const SdrHdlList &) const472 SVX_DLLPRIVATE sal_Bool operator!=(const SdrHdlList&) const { return sal_False; } 473 474 public: 475 SdrHdlList(SdrMarkView* pV); 476 ~SdrHdlList(); 477 void Clear(); 478 479 // #97016# II 480 void TravelFocusHdl(sal_Bool bForward); 481 SdrHdl* GetFocusHdl() const; 482 void SetFocusHdl(SdrHdl* pNew); 483 void ResetFocusHdl(); 484 485 // Access to View 486 SdrMarkView* GetView() const; 487 488 // Sortierung: 1.Level Erst Refpunkt-Handles, dann normale Handles, dann Glue, dann User, dann Plushandles 489 // 2.Level PageView (Pointer) 490 // 3.Level Position (x+y) 491 void Sort(); GetHdlCount() const492 sal_uIntPtr GetHdlCount() const { return aList.Count(); } GetHdl(sal_uIntPtr nNum) const493 SdrHdl* GetHdl(sal_uIntPtr nNum) const { return (SdrHdl*)(aList.GetObject(nNum)); } 494 sal_uIntPtr GetHdlNum(const SdrHdl* pHdl) const; 495 void SetHdlSize(sal_uInt16 nSiz); GetHdlSize() const496 sal_uInt16 GetHdlSize() const { return nHdlSize; } 497 void SetMoveOutside(sal_Bool bOn); IsMoveOutside() const498 sal_Bool IsMoveOutside() const { return bMoveOutside; } 499 void SetRotateShear(sal_Bool bOn); IsRotateShear() const500 sal_Bool IsRotateShear() const { return bRotateShear; } 501 void SetDistortShear(sal_Bool bOn); IsDistortShear() const502 sal_Bool IsDistortShear() const { return bDistortShear; } 503 void SetFineHdl(sal_Bool bOn); IsFineHdl() const504 sal_Bool IsFineHdl() const { return bFineHandles; } 505 506 // AddHdl uebernimmt das Handle in sein Eigentum. Es muss 507 // also auf dem Heap stehen, da Clear() ein delete macht. 508 void AddHdl(SdrHdl* pHdl, sal_Bool bAtBegin=sal_False); 509 SdrHdl* RemoveHdl(sal_uIntPtr nNum); 510 511 // Zuletzt eingefuegte Handles werden am ehesten getroffen 512 // (wenn Handles uebereinander liegen). 513 SdrHdl* IsHdlListHit(const Point& rPnt, sal_Bool bBack=sal_False, sal_Bool bNext=sal_False, SdrHdl* pHdl0=NULL) const; 514 SdrHdl* GetHdl(SdrHdlKind eKind1) const; 515 }; 516 517 //////////////////////////////////////////////////////////////////////////////////////////////////// 518 519 class SVX_DLLPUBLIC SdrCropHdl : public SdrHdl 520 { 521 private: 522 // evtl. shear and rotation, equal to the object's one to allow adaption of 523 // the visualization handles 524 double mfShearX; 525 double mfRotation; 526 527 public: 528 SdrCropHdl( 529 const Point& rPnt, 530 SdrHdlKind eNewKind, 531 double fShearX, 532 double fRotation); 533 534 protected: 535 // create marker for this kind 536 virtual void CreateB2dIAObject(); 537 538 BitmapEx GetBitmapForHandle( const BitmapEx& rBitmap, int nSize ); 539 540 static BitmapEx GetHandlesBitmap( bool bIsFineHdl, bool bIsHighContrast ); 541 }; 542 543 //////////////////////////////////////////////////////////////////////////////////////////////////// 544 545 class SVX_DLLPUBLIC SdrCropViewHdl : public SdrHdl 546 { 547 private: 548 basegfx::B2DHomMatrix maObjectTransform; 549 Graphic maGraphic; 550 double mfCropLeft; 551 double mfCropTop; 552 double mfCropRight; 553 double mfCropBottom; 554 555 public: 556 SdrCropViewHdl( 557 const basegfx::B2DHomMatrix& rObjectTransform, 558 const Graphic& rGraphic, 559 double fCropLeft, 560 double fCropTop, 561 double fCropRight, 562 double fCropBottom); 563 564 protected: 565 // create marker for this kind 566 virtual void CreateB2dIAObject(); 567 }; 568 569 //////////////////////////////////////////////////////////////////////////////////////////////////// 570 571 #endif //_SVDHDL_HXX 572 573 //////////////////////////////////////////////////////////////////////////////////////////////////// 574 // eof 575