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