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