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 #ifndef _SVX_DLG_CTRL_HXX 24 #define _SVX_DLG_CTRL_HXX 25 26 // include --------------------------------------------------------------- 27 28 #include <svtools/ctrlbox.hxx> 29 #include <sfx2/tabdlg.hxx> 30 #include "svx/svxdllapi.h" 31 #include <svx/rectenum.hxx> 32 #include <vcl/graph.hxx> 33 34 #ifndef _XTABLE_HXX 35 class XBitmapEntry; 36 class XColorEntry; 37 class XDash; 38 class XDashEntry; 39 class XGradient; 40 class XGradientEntry; 41 class XHatch; 42 class XHatchEntry; 43 class XLineEndEntry; 44 class XFillAttrSetItem; 45 #endif 46 47 class XOBitmap; 48 class XOutdevItemPool; 49 50 namespace com { namespace sun { namespace star { namespace awt { 51 struct Point; 52 } } } } 53 54 /************************************************************************* 55 |* 56 |* Von SfxTabPage abgeleitet, um vom Control ueber virtuelle Methode 57 |* benachrichtigt werden zu koennen. 58 |* 59 \************************************************************************/ 60 class SvxTabPage : public SfxTabPage 61 { 62 63 public: SvxTabPage(Window * pParent,ResId Id,const SfxItemSet & rInAttrs)64 SvxTabPage( Window* pParent, ResId Id, const SfxItemSet& rInAttrs ) : 65 SfxTabPage( pParent, Id, rInAttrs ) {} 66 67 virtual void PointChanged( Window* pWindow, RECT_POINT eRP ) = 0; 68 }; 69 70 /************************************************************************* 71 |* 72 |* Control zur Darstellung und Auswahl der Eckpunkte (und Mittelpunkt) 73 |* eines Objekts 74 |* 75 \************************************************************************/ 76 typedef sal_uInt16 CTL_STATE; 77 #define CS_NOHORZ 1 // no horizontal input information is used 78 #define CS_NOVERT 2 // no vertikal input information is used 79 80 class SvxRectCtlAccessibleContext; 81 class SvxPixelCtlAccessible; 82 class SVX_DLLPUBLIC SvxRectCtl : public Control 83 { 84 private: 85 SVX_DLLPRIVATE void InitSettings( sal_Bool bForeground, sal_Bool bBackground ); 86 SVX_DLLPRIVATE void InitRectBitmap( void ); 87 SVX_DLLPRIVATE Bitmap& GetRectBitmap( void ); 88 SVX_DLLPRIVATE void Resize_Impl(); 89 90 protected: 91 SvxRectCtlAccessibleContext* pAccContext; 92 sal_uInt16 nBorderWidth; 93 sal_uInt16 nRadius; 94 Size aSize; 95 Point aPtLT, aPtMT, aPtRT; 96 Point aPtLM, aPtMM, aPtRM; 97 Point aPtLB, aPtMB, aPtRB; 98 Point aPtNew; 99 RECT_POINT eRP, eDefRP; 100 CTL_STYLE eCS; 101 Bitmap* pBitmap; 102 CTL_STATE m_nState; 103 104 // #103516# Added a possibility to completely disable this control 105 sal_Bool mbCompleteDisable; 106 107 RECT_POINT GetRPFromPoint( Point ) const; 108 Point GetPointFromRP( RECT_POINT ) const; 109 void SetFocusRect( const Rectangle* pRect = NULL ); // pRect == NULL -> calculate rectangle in method 110 Point SetActualRPWithoutInvalidate( RECT_POINT eNewRP ); // returns the last point 111 112 virtual void GetFocus(); 113 virtual void LoseFocus(); 114 115 Point GetApproxLogPtFromPixPt( const Point& rRoughPixelPoint ) const; 116 public: 117 SvxRectCtl( Window* pParent, const ResId& rResId, RECT_POINT eRpt = RP_MM, 118 sal_uInt16 nBorder = 200, sal_uInt16 nCircle = 80, CTL_STYLE eStyle = CS_RECT ); 119 virtual ~SvxRectCtl(); 120 121 virtual void Paint( const Rectangle& rRect ); 122 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 123 virtual void KeyInput( const KeyEvent& rKeyEvt ); 124 virtual void StateChanged( StateChangedType nStateChange ); 125 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 126 virtual void Resize(); 127 128 void Reset(); 129 RECT_POINT GetActualRP() const; 130 void SetActualRP( RECT_POINT eNewRP ); 131 132 void SetState( CTL_STATE nState ); 133 134 sal_uInt8 GetNumOfChilds( void ) const; // returns number of usable radio buttons 135 136 Rectangle CalculateFocusRectangle( void ) const; 137 Rectangle CalculateFocusRectangle( RECT_POINT eRectPoint ) const; 138 139 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); 140 141 RECT_POINT GetApproxRPFromPixPt( const ::com::sun::star::awt::Point& rPixelPoint ) const; 142 143 // #103516# Added a possibility to completely disable this control IsCompletelyDisabled() const144 sal_Bool IsCompletelyDisabled() const { return mbCompleteDisable; } 145 void DoCompletelyDisable(sal_Bool bNew); 146 }; 147 148 /************************************************************************* 149 |* 150 |* Control zur Darstellung und Auswahl des Winkels der Eckpunkte 151 |* eines Objekts 152 |* 153 \************************************************************************/ 154 class SvxAngleCtl : public SvxRectCtl 155 { 156 private: 157 void Initialize(); 158 159 protected: 160 Font aFont; 161 Size aFontSize; 162 sal_Bool bPositive; 163 164 public: 165 SvxAngleCtl( Window* pParent, const ResId& rResId ); 166 SvxAngleCtl( Window* pParent, const ResId& rResId, Size aSize ); 167 ChangeMetric()168 void ChangeMetric() 169 { bPositive = !bPositive; } 170 virtual void Paint( const Rectangle& rRect ); 171 }; 172 173 /************************************************************************* 174 |* 175 |* Preview-Control zur Darstellung von Bitmaps 176 |* 177 \************************************************************************/ 178 179 class SVX_DLLPUBLIC SvxBitmapCtl 180 { 181 protected: 182 Size aSize; 183 sal_uInt16 nLines; 184 Color aPixelColor, aBackgroundColor; 185 const sal_uInt16* pBmpArray; 186 187 public: 188 SvxBitmapCtl( Window* pParent, const Size& rSize ); 189 ~SvxBitmapCtl(); 190 191 BitmapEx GetBitmapEx(); 192 SetBmpArray(const sal_uInt16 * pPixel)193 void SetBmpArray( const sal_uInt16* pPixel ) { pBmpArray = pPixel; } SetLines(sal_uInt16 nLns)194 void SetLines( sal_uInt16 nLns ) { nLines = nLns; } SetPixelColor(Color aColor)195 void SetPixelColor( Color aColor ) { aPixelColor = aColor; } SetBackgroundColor(Color aColor)196 void SetBackgroundColor( Color aColor ) { aBackgroundColor = aColor; } 197 }; 198 199 /************************************************************************* 200 |* 201 |* Control zum Editieren von Bitmaps 202 |* 203 \************************************************************************/ 204 class SVX_DLLPUBLIC SvxPixelCtl : public Control 205 { 206 private: 207 using OutputDevice::SetLineColor; 208 209 protected: 210 sal_uInt16 nLines, nSquares; 211 Color aPixelColor; 212 Color aBackgroundColor; 213 Color aLineColor; 214 Size aRectSize; 215 sal_uInt16* pPixel; 216 sal_Bool bPaintable; 217 //Solution:Add member identifying position 218 Point aFocusPosition; 219 Rectangle implCalFocusRect( const Point& aPosition ); 220 void ChangePixel( sal_uInt16 nPixel ); 221 222 public: 223 SvxPixelCtl( Window* pParent, const ResId& rResId, 224 sal_uInt16 nNumber = 8 ); 225 ~SvxPixelCtl(); 226 227 virtual void Paint( const Rectangle& rRect ); 228 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 229 230 void SetXBitmap( const BitmapEx& rBitmapEx ); 231 SetPixelColor(const Color & rCol)232 void SetPixelColor( const Color& rCol ) { aPixelColor = rCol; } SetBackgroundColor(const Color & rCol)233 void SetBackgroundColor( const Color& rCol ) { aBackgroundColor = rCol; } SetLineColor(const Color & rCol)234 void SetLineColor( const Color& rCol ) { aLineColor = rCol; } 235 GetLineCount() const236 sal_uInt16 GetLineCount() const { return nLines; } GetPixelColor() const237 Color GetPixelColor() const { return aPixelColor; } GetBackgroundColor() const238 Color GetBackgroundColor() const { return aBackgroundColor; } 239 240 sal_uInt16 GetBitmapPixel( const sal_uInt16 nPixelNumber ); GetBitmapPixelPtr()241 sal_uInt16* GetBitmapPixelPtr() { return pPixel; } 242 SetPaintable(sal_Bool bTmp)243 void SetPaintable( sal_Bool bTmp ) { bPaintable = bTmp; } 244 void Reset(); 245 SvxPixelCtlAccessible* m_pAccess; 246 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xAccess; 247 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); GetSquares() const248 long GetSquares() const { return nSquares ; } GetWidth() const249 long GetWidth() const { return aRectSize.getWidth() ; } GetHeight() const250 long GetHeight() const { return aRectSize.getHeight() ; } 251 252 //Device Pixel . 253 long ShowPosition( const Point &pt); 254 255 long PointToIndex(const Point &pt) const; 256 Point IndexToPoint(long nIndex) const ; 257 long GetFoucsPosIndex() const ; 258 //Solution:Keyboard fucntion for key input and focus handling function 259 virtual void KeyInput( const KeyEvent& rKEvt ); 260 virtual void GetFocus(); 261 virtual void LoseFocus(); 262 }; 263 264 /************************************************************************* 265 |* 266 |* ColorLB kann mit Farben und Namen gefuellt werden 267 |* 268 \************************************************************************/ 269 270 class XColorList; 271 typedef ::boost::shared_ptr< XColorList > XColorListSharedPtr; 272 273 class SVX_DLLPUBLIC ColorLB : public ColorListBox 274 { 275 276 public: ColorLB(Window * pParent,ResId Id)277 ColorLB( Window* pParent, ResId Id ) : ColorListBox( pParent, Id ) {} ColorLB(Window * pParent,WinBits aWB)278 ColorLB( Window* pParent, WinBits aWB ) : ColorListBox( pParent, aWB ) {} 279 280 virtual void Fill( const XColorListSharedPtr aTab ); 281 282 void Append( const XColorEntry& rEntry ); 283 void Modify( const XColorEntry& rEntry, sal_uInt16 nPos ); 284 }; 285 286 /************************************************************************* 287 |* 288 |* HatchingLB 289 |* 290 \************************************************************************/ 291 292 class XHatchList; 293 typedef ::boost::shared_ptr< XHatchList > XHatchListSharedPtr; 294 295 class SVX_DLLPUBLIC HatchingLB : public ListBox 296 { 297 public: 298 explicit HatchingLB( Window* pParent, ResId Id); 299 explicit HatchingLB( Window* pParent, WinBits aWB); 300 301 virtual void Fill( const XHatchListSharedPtr aList ); 302 303 void Append( const XHatchEntry& rEntry, const Bitmap& rBitmap ); 304 void Modify( const XHatchEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap ); 305 void SelectEntryByList( const XHatchListSharedPtr aList, const String& rStr, const XHatch& rXHatch, sal_uInt16 nDist = 0 ); 306 }; 307 308 /************************************************************************* 309 |* 310 |* GradientLB 311 |* 312 \************************************************************************/ 313 314 class XGradientList; 315 typedef ::boost::shared_ptr< XGradientList > XGradientListSharedPtr; 316 317 class SVX_DLLPUBLIC GradientLB : public ListBox 318 { 319 public: 320 explicit GradientLB( Window* pParent, ResId Id); 321 explicit GradientLB( Window* pParent, WinBits aWB); 322 323 virtual void Fill( const XGradientListSharedPtr aList ); 324 325 void Append( const XGradientEntry& rEntry, const Bitmap& rBitmap ); 326 void Modify( const XGradientEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap ); 327 void SelectEntryByList( const XGradientListSharedPtr aList, const String& rStr, const XGradient& rXGradient, sal_uInt16 nDist = 0 ); 328 329 private: 330 XGradientListSharedPtr maList; 331 }; 332 333 /************************************************************************* 334 |* 335 |* BitmapLB 336 |* 337 \************************************************************************/ 338 339 class XBitmapList; 340 typedef ::boost::shared_ptr< XBitmapList > XBitmapListSharedPtr; 341 342 class SVX_DLLPUBLIC BitmapLB : public ListBox 343 { 344 public: 345 explicit BitmapLB(Window* pParent, ResId Id); 346 347 virtual void Fill(const XBitmapListSharedPtr aList); 348 349 void Append(const Size& rSize, const XBitmapEntry& rEntry); 350 void Modify(const Size& rSize, const XBitmapEntry& rEntry, sal_uInt16 nPos); 351 void SelectEntryByList(const XBitmapListSharedPtr aList, const String& rStr); 352 353 private: 354 BitmapEx maBitmapEx; 355 }; 356 357 /************************************************************************* 358 |* 359 |* FillAttrLB vereint alle Fuellattribute in einer ListBox 360 |* 361 \************************************************************************/ 362 class FillAttrLB : public ColorListBox 363 { 364 private: 365 BitmapEx maBitmapEx; 366 367 public: 368 FillAttrLB( Window* pParent, ResId Id ); 369 FillAttrLB( Window* pParent, WinBits aWB ); 370 371 virtual void Fill( const XColorListSharedPtr aTab ); 372 virtual void Fill( const XHatchListSharedPtr aList ); 373 virtual void Fill( const XGradientListSharedPtr aList ); 374 virtual void Fill( const XBitmapListSharedPtr aList ); 375 376 void SelectEntryByList(const XBitmapListSharedPtr aList, const String& rStr); 377 }; 378 379 /************************************************************************* 380 |* 381 |* FillTypeLB 382 |* 383 \************************************************************************/ 384 class FillTypeLB : public ListBox 385 { 386 387 public: FillTypeLB(Window * pParent,ResId Id)388 FillTypeLB( Window* pParent, ResId Id ) : ListBox( pParent, Id ) {} FillTypeLB(Window * pParent,WinBits aWB)389 FillTypeLB( Window* pParent, WinBits aWB ) : ListBox( pParent, aWB ) {} 390 391 virtual void Fill(); 392 }; 393 394 /************************************************************************* 395 |* 396 |* LineLB 397 |* 398 \************************************************************************/ 399 400 class XDashList; 401 typedef ::boost::shared_ptr< XDashList > XDashListSharedPtr; 402 403 class SVX_DLLPUBLIC LineLB : public ListBox 404 { 405 private: 406 /// bitfield 407 /// defines if standard fields (none, solid) are added, default is true 408 bool mbAddStandardFields : 1; 409 410 public: 411 LineLB(Window* pParent, ResId Id); 412 LineLB(Window* pParent, WinBits aWB); 413 virtual ~LineLB(); 414 415 virtual void Fill(const XDashListSharedPtr aList); 416 getAddStandardFields() const417 bool getAddStandardFields() const { return mbAddStandardFields; } 418 void setAddStandardFields(bool bNew); 419 420 void Append(const XDashEntry& rEntry, const Bitmap& rBitmap ); 421 void Modify(const XDashEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap ); 422 void SelectEntryByList(const XDashListSharedPtr aList, const String& rStr, const XDash& rDash, sal_uInt16 nDist = 0); 423 }; 424 425 /************************************************************************* 426 |* 427 |* LineEndsLB 428 |* 429 \************************************************************************/ 430 431 class XLineEndList; 432 typedef ::boost::shared_ptr< XLineEndList > XLineEndListSharedPtr; 433 434 class SVX_DLLPUBLIC LineEndLB : public ListBox 435 { 436 437 public: 438 LineEndLB( Window* pParent, ResId Id ); 439 LineEndLB( Window* pParent, WinBits aWB ); 440 virtual ~LineEndLB (void); 441 442 virtual void Fill( const XLineEndListSharedPtr aList, bool bStart = true ); 443 444 void Append( const XLineEndEntry& rEntry, const Bitmap& rBitmap, bool bStart = true ); 445 void Modify( const XLineEndEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap, bool bStart = true ); 446 }; 447 448 ////////////////////////////////////////////////////////////////////////////// 449 450 class SdrObject; 451 class SdrModel; 452 453 class SvxPreviewBase : public Control 454 { 455 private: 456 SdrModel* mpModel; 457 VirtualDevice* mpBufferDevice; 458 459 protected: 460 void InitSettings(bool bForeground, bool bBackground); 461 462 // prepare buffered paint 463 void LocalPrePaint(); 464 465 // end and output buffered paint 466 void LocalPostPaint(); 467 468 public: 469 SvxPreviewBase( Window* pParent, const ResId& rResId ); 470 virtual ~SvxPreviewBase(); 471 472 // change support 473 virtual void StateChanged(StateChangedType nStateChange); 474 virtual void DataChanged(const DataChangedEvent& rDCEvt); 475 476 // dada read access getModel() const477 SdrModel& getModel() const { return *mpModel; } getBufferDevice() const478 OutputDevice& getBufferDevice() const { return *mpBufferDevice; } 479 }; 480 481 /************************************************************************* 482 |* 483 |* SvxLinePreview 484 |* 485 \************************************************************************/ 486 487 class SVX_DLLPUBLIC SvxXLinePreview : public SvxPreviewBase 488 { 489 private: 490 SdrObject* mpLineObjA; 491 SdrObject* mpLineObjB; 492 SdrObject* mpLineObjC; 493 494 //#58425# Symbole auf einer Linie (z.B. StarChart) 495 Graphic* mpGraphic; 496 sal_Bool mbWithSymbol; 497 Size maSymbolSize; 498 499 public: 500 SvxXLinePreview( Window* pParent, const ResId& rResId ); 501 virtual ~SvxXLinePreview(); 502 503 void SetLineAttributes(const SfxItemSet& rItemSet); 504 ShowSymbol(sal_Bool b)505 void ShowSymbol( sal_Bool b ) { mbWithSymbol = b; }; 506 void SetSymbol( Graphic* p, const Size& s ); 507 void ResizeSymbol( const Size& s ); 508 509 virtual void Paint( const Rectangle& rRect ); 510 }; 511 512 /************************************************************************* 513 |* 514 |* SvxXRectPreview 515 |* 516 \************************************************************************/ 517 518 class SVX_DLLPUBLIC SvxXRectPreview : public SvxPreviewBase 519 { 520 private: 521 SdrObject* mpRectangleObject; 522 523 public: 524 SvxXRectPreview( Window* pParent, const ResId& rResId ); 525 virtual ~SvxXRectPreview(); 526 527 void SetAttributes(const SfxItemSet& rItemSet); 528 529 virtual void Paint( const Rectangle& rRect ); 530 }; 531 532 /************************************************************************* 533 |* 534 |* SvxXShadowPreview 535 |* 536 \************************************************************************/ 537 538 class SVX_DLLPUBLIC SvxXShadowPreview : public SvxPreviewBase 539 { 540 private: 541 SdrObject* mpRectangleObject; 542 SdrObject* mpRectangleShadow; 543 544 public: 545 SvxXShadowPreview( Window* pParent, const ResId& rResId ); 546 virtual ~SvxXShadowPreview(); 547 548 void SetRectangleAttributes(const SfxItemSet& rItemSet); 549 void SetShadowAttributes(const SfxItemSet& rItemSet); 550 void SetShadowPosition(const Point& rPos); 551 552 virtual void Paint( const Rectangle& rRect ); 553 }; 554 555 #endif // _SVX_DLG_CTRL_HXX 556 557