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 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_svx.hxx" 26 27 // include --------------------------------------------------------------- 28 #include <tools/shl.hxx> 29 #include <vcl/svapp.hxx> 30 #include <svx/xtable.hxx> 31 #include <svx/xpool.hxx> 32 #include <svx/dialogs.hrc> 33 #include <accessibility.hrc> 34 #include <svx/dlgctrl.hxx> 35 #include <svx/dialmgr.hxx> 36 #include <tools/poly.hxx> 37 #include <vcl/region.hxx> 38 #include <vcl/gradient.hxx> 39 #include <vcl/hatch.hxx> 40 // IAccessibility2 implementation 2009. ------ 41 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTOBJECT_HPP_ 42 #include <com/sun/star/accessibility/AccessibleEventObject.hpp> 43 #endif 44 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_ 45 #include <com/sun/star/accessibility/AccessibleEventId.hpp> 46 #endif 47 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_ 48 #include <com/sun/star/accessibility/AccessibleStateType.hpp> 49 #endif 50 #include "svxpixelctlaccessiblecontext.hxx" 51 // ------ IAccessibility2 implementation 2009. 52 #include <svtools/colorcfg.hxx> 53 #include <svxrectctaccessiblecontext.hxx> 54 #include <com/sun/star/lang/XUnoTunnel.hpp> 55 #include <basegfx/point/b2dpoint.hxx> 56 #include <basegfx/polygon/b2dpolygon.hxx> 57 #include <svx/svdorect.hxx> 58 #include <svx/svdmodel.hxx> 59 #include <svx/svdopath.hxx> 60 #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx> 61 #include <svx/sdr/contact/displayinfo.hxx> 62 #include <vcl/bmpacc.hxx> 63 #include <svx/xbtmpit.hxx> 64 65 #define OUTPUT_DRAWMODE_COLOR (DRAWMODE_DEFAULT) 66 #define OUTPUT_DRAWMODE_CONTRAST (DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT) 67 68 using namespace ::com::sun::star::uno; 69 using namespace ::com::sun::star::lang; 70 using namespace ::com::sun::star::accessibility; 71 72 73 /************************************************************************* 74 |* 75 |* Control zur Darstellung und Auswahl der Eckpunkte (und Mittelpunkt) 76 |* eines Objekts 77 |* 78 \************************************************************************/ 79 80 Bitmap& SvxRectCtl::GetRectBitmap( void ) 81 { 82 if( !pBitmap ) 83 InitRectBitmap(); 84 85 return *pBitmap; 86 } 87 88 SvxRectCtl::SvxRectCtl( Window* pParent, const ResId& rResId, RECT_POINT eRpt, 89 sal_uInt16 nBorder, sal_uInt16 nCircle, CTL_STYLE eStyle ) : 90 91 Control( pParent, rResId ), 92 93 pAccContext ( NULL ), 94 nBorderWidth( nBorder ), 95 nRadius ( nCircle), 96 eDefRP ( eRpt ), 97 eCS ( eStyle ), 98 pBitmap ( NULL ), 99 m_nState ( 0 ), 100 mbCompleteDisable(sal_False) 101 { 102 SetMapMode( MAP_100TH_MM ); 103 Resize_Impl(); 104 } 105 106 // ----------------------------------------------------------------------- 107 108 SvxRectCtl::~SvxRectCtl() 109 { 110 delete pBitmap; 111 112 if( pAccContext ) 113 pAccContext->release(); 114 } 115 116 // ----------------------------------------------------------------------- 117 void SvxRectCtl::Resize() 118 { 119 Resize_Impl(); 120 Control::Resize(); 121 } 122 123 // ----------------------------------------------------------------------- 124 125 void SvxRectCtl::Resize_Impl() 126 { 127 aSize = GetOutputSize(); 128 129 switch( eCS ) 130 { 131 case CS_RECT: 132 case CS_ANGLE: 133 case CS_SHADOW: 134 aPtLT = Point( 0 + nBorderWidth, 0 + nBorderWidth ); 135 aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth ); 136 aPtRT = Point( aSize.Width() - nBorderWidth, 0 + nBorderWidth ); 137 138 aPtLM = Point( 0 + nBorderWidth, aSize.Height() / 2 ); 139 aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 ); 140 aPtRM = Point( aSize.Width() - nBorderWidth, aSize.Height() / 2 ); 141 142 aPtLB = Point( 0 + nBorderWidth, aSize.Height() - nBorderWidth ); 143 aPtMB = Point( aSize.Width() / 2, aSize.Height() - nBorderWidth ); 144 aPtRB = Point( aSize.Width() - nBorderWidth, aSize.Height() - nBorderWidth ); 145 break; 146 147 case CS_LINE: 148 aPtLT = Point( 0 + 3 * nBorderWidth, 0 + nBorderWidth ); 149 aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth ); 150 aPtRT = Point( aSize.Width() - 3 * nBorderWidth, 0 + nBorderWidth ); 151 152 aPtLM = Point( 0 + 3 * nBorderWidth, aSize.Height() / 2 ); 153 aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 ); 154 aPtRM = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() / 2 ); 155 156 aPtLB = Point( 0 + 3 * nBorderWidth, aSize.Height() - nBorderWidth ); 157 aPtMB = Point( aSize.Width() / 2, aSize.Height() - nBorderWidth ); 158 aPtRB = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() - nBorderWidth ); 159 break; 160 } 161 Reset(); 162 InitSettings( sal_True, sal_True ); 163 } 164 // ----------------------------------------------------------------------- 165 166 void SvxRectCtl::InitRectBitmap( void ) 167 { 168 if( pBitmap ) 169 delete pBitmap; 170 171 const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); 172 svtools::ColorConfig aColorConfig; 173 174 pBitmap = new Bitmap( SVX_RES( RID_SVXCTRL_RECTBTNS ) ); 175 176 // set bitmap-colors 177 Color aColorAry1[7]; 178 Color aColorAry2[7]; 179 aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 ); // light-gray 180 aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 ); // yellow 181 aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF ); // white 182 aColorAry1[3] = Color( 0x80, 0x80, 0x80 ); // dark-gray 183 aColorAry1[4] = Color( 0x00, 0x00, 0x00 ); // black 184 aColorAry1[5] = Color( 0x00, 0xFF, 0x00 ); // green 185 aColorAry1[6] = Color( 0x00, 0x00, 0xFF ); // blue 186 aColorAry2[0] = rStyles.GetDialogColor(); // background 187 aColorAry2[1] = rStyles.GetWindowColor(); 188 aColorAry2[2] = rStyles.GetLightColor(); 189 aColorAry2[3] = rStyles.GetShadowColor(); 190 aColorAry2[4] = rStyles.GetDarkShadowColor(); 191 aColorAry2[5] = Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ); 192 aColorAry2[6] = rStyles.GetDialogColor(); 193 194 #ifdef DBG_UTIL 195 static sal_Bool bModify = sal_False; 196 sal_Bool& rModify = bModify; 197 if( rModify ) 198 { 199 static int n = 0; 200 static sal_uInt8 r = 0xFF; 201 static sal_uInt8 g = 0x00; 202 static sal_uInt8 b = 0xFF; 203 int& rn = n; 204 sal_uInt8& rr = r; 205 sal_uInt8& rg = g; 206 sal_uInt8& rb = b; 207 aColorAry2[ rn ] = Color( rr, rg, rb ); 208 } 209 #endif 210 211 pBitmap->Replace( aColorAry1, aColorAry2, 7, NULL ); 212 } 213 214 // ----------------------------------------------------------------------- 215 216 void SvxRectCtl::InitSettings( sal_Bool bForeground, sal_Bool bBackground ) 217 { 218 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 219 220 if( bForeground ) 221 { 222 svtools::ColorConfig aColorConfig; 223 Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ); 224 225 if ( IsControlForeground() ) 226 aTextColor = GetControlForeground(); 227 SetTextColor( aTextColor ); 228 } 229 230 if( bBackground ) 231 { 232 if ( IsControlBackground() ) 233 SetBackground( GetControlBackground() ); 234 else 235 SetBackground( rStyleSettings.GetWindowColor() ); 236 } 237 238 delete pBitmap; 239 pBitmap = NULL; // forces new creating of bitmap 240 241 Invalidate(); 242 } 243 244 /************************************************************************* 245 |* 246 |* Das angeklickte Rechteck (3 x 3) wird ermittelt und der Parent (Dialog) 247 |* wird benachrichtigt, dass der Punkt geaendert wurde 248 |* 249 \************************************************************************/ 250 251 void SvxRectCtl::MouseButtonDown( const MouseEvent& rMEvt ) 252 { 253 // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl 254 if(!IsCompletelyDisabled()) 255 { 256 Point aPtLast = aPtNew; 257 258 aPtNew = GetApproxLogPtFromPixPt( rMEvt.GetPosPixel() ); 259 260 if( aPtNew == aPtMM && ( eCS == CS_SHADOW || eCS == CS_ANGLE ) ) 261 { 262 aPtNew = aPtLast; 263 } 264 else 265 { 266 Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ), 267 aPtLast + Point( nRadius, nRadius ) ) ); 268 Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ), 269 aPtNew + Point( nRadius, nRadius ) ) ); 270 eRP = GetRPFromPoint( aPtNew ); 271 272 SetActualRP( eRP ); 273 274 if( WINDOW_TABPAGE == GetParent()->GetType() ) 275 ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP ); 276 } 277 } 278 } 279 280 // ----------------------------------------------------------------------- 281 282 void SvxRectCtl::KeyInput( const KeyEvent& rKeyEvt ) 283 { 284 // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl 285 if(!IsCompletelyDisabled()) 286 { 287 RECT_POINT eNewRP = eRP; 288 sal_Bool bUseMM = (eCS != CS_SHADOW) && (eCS != CS_ANGLE); 289 290 switch( rKeyEvt.GetKeyCode().GetCode() ) 291 { 292 case KEY_DOWN: 293 { 294 if( !(m_nState & CS_NOVERT) ) 295 switch( eNewRP ) 296 { 297 case RP_LT: eNewRP = RP_LM; break; 298 case RP_MT: eNewRP = bUseMM ? RP_MM : RP_MB; break; 299 case RP_RT: eNewRP = RP_RM; break; 300 case RP_LM: eNewRP = RP_LB; break; 301 case RP_MM: eNewRP = RP_MB; break; 302 case RP_RM: eNewRP = RP_RB; break; 303 default: ; //prevent warning 304 } 305 } 306 break; 307 case KEY_UP: 308 { 309 if( !(m_nState & CS_NOVERT) ) 310 switch( eNewRP ) 311 { 312 case RP_LM: eNewRP = RP_LT; break; 313 case RP_MM: eNewRP = RP_MT; break; 314 case RP_RM: eNewRP = RP_RT; break; 315 case RP_LB: eNewRP = RP_LM; break; 316 case RP_MB: eNewRP = bUseMM ? RP_MM : RP_MT; break; 317 case RP_RB: eNewRP = RP_RM; break; 318 default: ; //prevent warning 319 } 320 } 321 break; 322 case KEY_LEFT: 323 { 324 if( !(m_nState & CS_NOHORZ) ) 325 switch( eNewRP ) 326 { 327 case RP_MT: eNewRP = RP_LT; break; 328 case RP_RT: eNewRP = RP_MT; break; 329 case RP_MM: eNewRP = RP_LM; break; 330 case RP_RM: eNewRP = bUseMM ? RP_MM : RP_LM; break; 331 case RP_MB: eNewRP = RP_LB; break; 332 case RP_RB: eNewRP = RP_MB; break; 333 default: ; //prevent warning 334 } 335 } 336 break; 337 case KEY_RIGHT: 338 { 339 if( !(m_nState & CS_NOHORZ) ) 340 switch( eNewRP ) 341 { 342 case RP_LT: eNewRP = RP_MT; break; 343 case RP_MT: eNewRP = RP_RT; break; 344 case RP_LM: eNewRP = bUseMM ? RP_MM : RP_RM; break; 345 case RP_MM: eNewRP = RP_RM; break; 346 case RP_LB: eNewRP = RP_MB; break; 347 case RP_MB: eNewRP = RP_RB; break; 348 default: ; //prevent warning 349 } 350 } 351 break; 352 default: 353 Control::KeyInput( rKeyEvt ); 354 return; 355 } 356 if( eNewRP != eRP ) 357 { 358 SetActualRP( eNewRP ); 359 360 if( WINDOW_TABPAGE == GetParent()->GetType() ) 361 ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP ); 362 363 SetFocusRect(); 364 } 365 } 366 } 367 368 // ----------------------------------------------------------------------- 369 370 void SvxRectCtl::StateChanged( StateChangedType nType ) 371 { 372 if ( nType == STATE_CHANGE_CONTROLFOREGROUND ) 373 InitSettings( sal_True, sal_False ); 374 else if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) 375 InitSettings( sal_False, sal_True ); 376 377 Window::StateChanged( nType ); 378 } 379 380 // ----------------------------------------------------------------------- 381 382 void SvxRectCtl::DataChanged( const DataChangedEvent& rDCEvt ) 383 { 384 if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) 385 InitSettings( sal_True, sal_True ); 386 else 387 Window::DataChanged( rDCEvt ); 388 } 389 390 /************************************************************************* 391 |* 392 |* Zeichnet das Control (Rechteck mit 9 Kreisen) 393 |* 394 \************************************************************************/ 395 396 void SvxRectCtl::Paint( const Rectangle& ) 397 { 398 Point aPtDiff( PixelToLogic( Point( 1, 1 ) ) ); 399 400 const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings(); 401 402 SetLineColor( rStyles.GetDialogColor() ); 403 SetFillColor( rStyles.GetDialogColor() ); 404 DrawRect( Rectangle( Point(0,0), GetOutputSize() ) ); 405 406 if( IsEnabled() ) 407 SetLineColor( rStyles.GetLabelTextColor() ); 408 else 409 SetLineColor( rStyles.GetShadowColor() ); 410 411 SetFillColor(); 412 413 switch( eCS ) 414 { 415 416 case CS_RECT: 417 case CS_SHADOW: 418 if( !IsEnabled() ) 419 { 420 Color aOldCol = GetLineColor(); 421 SetLineColor( rStyles.GetLightColor() ); 422 DrawRect( Rectangle( aPtLT + aPtDiff, aPtRB + aPtDiff ) ); 423 SetLineColor( aOldCol ); 424 } 425 DrawRect( Rectangle( aPtLT, aPtRB ) ); 426 break; 427 428 case CS_LINE: 429 if( !IsEnabled() ) 430 { 431 Color aOldCol = GetLineColor(); 432 SetLineColor( rStyles.GetLightColor() ); 433 DrawLine( aPtLM - Point( 2 * nBorderWidth, 0) + aPtDiff, 434 aPtRM + Point( 2 * nBorderWidth, 0 ) + aPtDiff ); 435 SetLineColor( aOldCol ); 436 } 437 DrawLine( aPtLM - Point( 2 * nBorderWidth, 0), 438 aPtRM + Point( 2 * nBorderWidth, 0 ) ); 439 break; 440 441 case CS_ANGLE: 442 if( !IsEnabled() ) 443 { 444 Color aOldCol = GetLineColor(); 445 SetLineColor( rStyles.GetLightColor() ); 446 DrawLine( aPtLT + aPtDiff, aPtRB + aPtDiff ); 447 DrawLine( aPtLB + aPtDiff, aPtRT + aPtDiff ); 448 DrawLine( aPtLM + aPtDiff, aPtRM + aPtDiff ); 449 DrawLine( aPtMT + aPtDiff, aPtMB + aPtDiff ); 450 SetLineColor( aOldCol ); 451 } 452 DrawLine( aPtLT, aPtRB ); 453 DrawLine( aPtLB, aPtRT ); 454 DrawLine( aPtLM, aPtRM ); 455 DrawLine( aPtMT, aPtMB ); 456 break; 457 458 default: 459 break; 460 } 461 SetFillColor( GetBackground().GetColor() ); 462 463 Size aBtnSize( 11, 11 ); 464 Size aDstBtnSize( PixelToLogic( aBtnSize ) ); 465 Point aToCenter( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1); 466 Point aBtnPnt1( IsEnabled()?0:22,0 ); 467 Point aBtnPnt2( 11,0 ); 468 Point aBtnPnt3( 22,0 ); 469 470 sal_Bool bNoHorz = (m_nState & CS_NOHORZ) != 0; 471 sal_Bool bNoVert = (m_nState & CS_NOVERT) != 0; 472 473 Bitmap& rBitmap = GetRectBitmap(); 474 475 // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl 476 if(IsCompletelyDisabled()) 477 { 478 DrawBitmap( aPtLT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 479 DrawBitmap( aPtMT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 480 DrawBitmap( aPtRT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 481 DrawBitmap( aPtLM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 482 if( eCS == CS_RECT || eCS == CS_LINE ) 483 DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 484 DrawBitmap( aPtRM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 485 DrawBitmap( aPtLB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 486 DrawBitmap( aPtMB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 487 DrawBitmap( aPtRB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap ); 488 } 489 else 490 { 491 DrawBitmap( aPtLT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap ); 492 DrawBitmap( aPtMT - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap ); 493 DrawBitmap( aPtRT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap ); 494 495 DrawBitmap( aPtLM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap ); 496 497 // Mittelpunkt bei Rechteck und Linie 498 if( eCS == CS_RECT || eCS == CS_LINE ) 499 DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt1, aBtnSize, rBitmap ); 500 501 DrawBitmap( aPtRM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap ); 502 503 DrawBitmap( aPtLB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap ); 504 DrawBitmap( aPtMB - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap ); 505 DrawBitmap( aPtRB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap ); 506 } 507 508 // draw active button, avoid center pos for angle 509 // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl 510 if(!IsCompletelyDisabled()) 511 { 512 if( IsEnabled() && (eCS != CS_ANGLE || aPtNew != aPtMM) ) 513 { 514 Point aCenterPt( aPtNew ); 515 aCenterPt -= aToCenter; 516 517 DrawBitmap( aCenterPt, aDstBtnSize, aBtnPnt2, aBtnSize, rBitmap ); 518 } 519 } 520 } 521 522 /************************************************************************* 523 |* 524 |* Konvertiert RECT_POINT in Point 525 |* 526 \************************************************************************/ 527 528 Point SvxRectCtl::GetPointFromRP( RECT_POINT _eRP) const 529 { 530 switch( _eRP ) 531 { 532 case RP_LT: return aPtLT; 533 case RP_MT: return aPtMT; 534 case RP_RT: return aPtRT; 535 case RP_LM: return aPtLM; 536 case RP_MM: return aPtMM; 537 case RP_RM: return aPtRM; 538 case RP_LB: return aPtLB; 539 case RP_MB: return aPtMB; 540 case RP_RB: return aPtRB; 541 } 542 return( aPtMM ); // default 543 } 544 545 546 void SvxRectCtl::SetFocusRect( const Rectangle* pRect ) 547 { 548 HideFocus(); 549 550 if( pRect ) 551 ShowFocus( *pRect ); 552 else 553 ShowFocus( CalculateFocusRectangle() ); 554 } 555 556 Point SvxRectCtl::SetActualRPWithoutInvalidate( RECT_POINT eNewRP ) 557 { 558 Point aPtLast = aPtNew; 559 aPtNew = GetPointFromRP( eNewRP ); 560 561 if( (m_nState & CS_NOHORZ) != 0 ) 562 aPtNew.X() = aPtMM.X(); 563 564 if( (m_nState & CS_NOVERT) != 0 ) 565 aPtNew.Y() = aPtMM.Y(); 566 567 eNewRP = GetRPFromPoint( aPtNew ); 568 569 eDefRP = eNewRP; 570 eRP = eNewRP; 571 572 return aPtLast; 573 } 574 575 void SvxRectCtl::GetFocus() 576 { 577 SetFocusRect(); 578 // IAccessibility2 implementation 2009. ------ 579 //Solution: Send the accessible focused event 580 Control::GetFocus(); 581 // Send accessibility event. 582 if(pAccContext) 583 { 584 pAccContext->FireChildFocus(GetActualRP()); 585 } 586 // ------ IAccessibility2 implementation 2009. 587 } 588 589 590 void SvxRectCtl::LoseFocus() 591 { 592 HideFocus(); 593 } 594 595 596 Point SvxRectCtl::GetApproxLogPtFromPixPt( const Point& rPt ) const 597 { 598 Point aPt = PixelToLogic( rPt ); 599 long x; 600 long y; 601 602 if( ( m_nState & CS_NOHORZ ) == 0 ) 603 { 604 if( aPt.X() < aSize.Width() / 3 ) 605 x = aPtLT.X(); 606 else if( aPt.X() < aSize.Width() * 2 / 3 ) 607 x = aPtMM.X(); 608 else 609 x = aPtRB.X(); 610 } 611 else 612 x = aPtMM.X(); 613 614 if( ( m_nState & CS_NOVERT ) == 0 ) 615 { 616 if( aPt.Y() < aSize.Height() / 3 ) 617 y = aPtLT.Y(); 618 else if( aPt.Y() < aSize.Height() * 2 / 3 ) 619 y = aPtMM.Y(); 620 else 621 y = aPtRB.Y(); 622 } 623 else 624 y = aPtMM.Y(); 625 626 return Point( x, y ); 627 } 628 629 630 /************************************************************************* 631 |* 632 |* Konvertiert Point in RECT_POINT 633 |* 634 \************************************************************************/ 635 636 RECT_POINT SvxRectCtl::GetRPFromPoint( Point aPt ) const 637 { 638 if ( aPt == aPtLT) return RP_LT; 639 else if( aPt == aPtMT) return RP_MT; 640 else if( aPt == aPtRT) return RP_RT; 641 else if( aPt == aPtLM) return RP_LM; 642 else if( aPt == aPtRM) return RP_RM; 643 else if( aPt == aPtLB) return RP_LB; 644 else if( aPt == aPtMB) return RP_MB; 645 else if( aPt == aPtRB) return RP_RB; 646 647 else 648 return RP_MM; // default 649 } 650 651 /************************************************************************* 652 |* 653 |* Bewirkt den Ursprungszustand des Controls 654 |* 655 \************************************************************************/ 656 657 void SvxRectCtl::Reset() 658 { 659 aPtNew = GetPointFromRP( eDefRP ); 660 eRP = eDefRP; 661 Invalidate(); 662 } 663 664 /************************************************************************* 665 |* 666 |* Gibt den aktuell ausgewaehlten RECT_POINT zur�ck 667 |* 668 \************************************************************************/ 669 670 RECT_POINT SvxRectCtl::GetActualRP() const 671 { 672 return( eRP ); 673 } 674 675 /************************************************************************* 676 |* 677 |* Gibt den aktuell ausgewaehlten RECT_POINT zur�ck 678 |* 679 \************************************************************************/ 680 // IAccessibility2 implementation 2009. ------ 681 void SvxRectCtl::SetActualRP( RECT_POINT eNewRP /* MT: , sal_Bool bFireFocus */ ) 682 { 683 // MT: bFireFox as API parameter is ugly... 684 Point aPtLast( SetActualRPWithoutInvalidate( eNewRP ) ); 685 686 Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ), aPtLast + Point( nRadius, nRadius ) ) ); 687 Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ), aPtNew + Point( nRadius, nRadius ) ) ); 688 689 // notify accessibility object about change 690 if( pAccContext ) 691 pAccContext->selectChild( eNewRP /* MT, bFireFocus */ ); 692 } 693 // ------ IAccessibility2 implementation 2009. 694 void SvxRectCtl::SetState( CTL_STATE nState ) 695 { 696 m_nState = nState; 697 698 Point aPtLast( GetPointFromRP( eRP ) ); 699 Point _aPtNew( aPtLast ); 700 701 if( (m_nState & CS_NOHORZ) != 0 ) 702 _aPtNew.X() = aPtMM.X(); 703 704 if( (m_nState & CS_NOVERT) != 0 ) 705 _aPtNew.Y() = aPtMM.Y(); 706 707 eRP = GetRPFromPoint( _aPtNew ); 708 Invalidate(); 709 710 if( WINDOW_TABPAGE == GetParent()->GetType() ) 711 ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP ); 712 } 713 714 sal_uInt8 SvxRectCtl::GetNumOfChilds( void ) const 715 { 716 return ( eCS == CS_ANGLE )? 8 : 9; 717 } 718 719 Rectangle SvxRectCtl::CalculateFocusRectangle( void ) const 720 { 721 Size aDstBtnSize( PixelToLogic( Size( 15, 15 ) ) ); 722 return Rectangle( aPtNew - Point( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1 ), aDstBtnSize ); 723 } 724 725 Rectangle SvxRectCtl::CalculateFocusRectangle( RECT_POINT eRectPoint ) const 726 { 727 Rectangle aRet; 728 RECT_POINT eOldRectPoint = GetActualRP(); 729 730 if( eOldRectPoint == eRectPoint ) 731 aRet = CalculateFocusRectangle(); 732 else 733 { 734 SvxRectCtl* pThis = const_cast< SvxRectCtl* >( this ); 735 736 pThis->SetActualRPWithoutInvalidate( eRectPoint ); // no invalidation because it's only temporary! 737 aRet = CalculateFocusRectangle(); 738 739 pThis->SetActualRPWithoutInvalidate( eOldRectPoint ); // no invalidation because nothing has changed! 740 } 741 742 return aRet; 743 } 744 745 Reference< XAccessible > SvxRectCtl::CreateAccessible() 746 { 747 Window* pParent = GetAccessibleParentWindow(); 748 749 DBG_ASSERT( pParent, "-SvxRectCtl::CreateAccessible(): No Parent!" ); 750 751 Reference< XAccessible > xAccParent = pParent->GetAccessible(); 752 if( xAccParent.is() ) 753 { 754 pAccContext = new SvxRectCtlAccessibleContext( xAccParent, *this ); 755 pAccContext->acquire(); 756 757 SetActualRP( GetActualRP() ); 758 759 return pAccContext; 760 } 761 else 762 return Reference< XAccessible >(); 763 } 764 765 RECT_POINT SvxRectCtl::GetApproxRPFromPixPt( const ::com::sun::star::awt::Point& r ) const 766 { 767 return GetRPFromPoint( GetApproxLogPtFromPixPt( Point( r.X, r.Y ) ) ); 768 } 769 770 // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl 771 void SvxRectCtl::DoCompletelyDisable(sal_Bool bNew) 772 { 773 mbCompleteDisable = bNew; 774 Invalidate(); 775 } 776 777 /************************************************************************* 778 |* 779 |* Konstruktor ohne Size-Parameter 780 |* 781 \************************************************************************/ 782 783 SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId ) : 784 785 SvxRectCtl( pParent, rResId ), 786 787 aFont( Application::GetSettings().GetStyleSettings().GetAppFont() ) 788 { 789 aFontSize = Size( 250, 400 ); 790 Initialize(); 791 } 792 793 /************************************************************************* 794 |* 795 |* Konstruktor mit Size-Parameter 796 |* 797 \************************************************************************/ 798 799 SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId, Size _aSize ) : 800 801 SvxRectCtl( pParent, rResId ), 802 803 aFont( Application::GetSettings().GetStyleSettings().GetAppFont() ) 804 { 805 aFontSize = _aSize; 806 Initialize(); 807 } 808 809 /************************************************************************* 810 |* 811 |* Initialisierung 812 |* 813 \************************************************************************/ 814 815 void SvxAngleCtl::Initialize() 816 { 817 bPositive = sal_True; 818 819 // aFont.SetName( "Helvetica" ); 820 aFont.SetSize( aFontSize ); 821 aFont.SetWeight( WEIGHT_NORMAL ); 822 aFont.SetTransparent( sal_False ); 823 824 SetFont( aFont ); 825 } 826 827 /************************************************************************* 828 |* 829 |* Zeichnet das (Mini-)Koordinatensystem 830 |* 831 \************************************************************************/ 832 833 void SvxAngleCtl::Paint( const Rectangle& ) 834 { 835 SetLineColor( Color( COL_BLACK ) ); // PEN_DOT ??? 836 DrawLine( aPtLT - Point( 0, 0), aPtRB + Point( 0, 0 ) ); 837 DrawLine( aPtLB - Point( 0, 0), aPtRT + Point( 0, 0 ) ); 838 839 SetLineColor( Color( COL_BLACK ) ); 840 DrawLine( aPtLM - Point( 0, 0), aPtRM + Point( 0, 0 ) ); 841 DrawLine( aPtMT - Point( 0, 0), aPtMB + Point( 0, 0 ) ); 842 843 Point aDiff(aFontSize.Width() / 2, aFontSize.Height() / 2); 844 845 DrawText( aPtLT - aDiff, UniString::CreateFromAscii( 846 RTL_CONSTASCII_STRINGPARAM( "135" ) ) ); 847 DrawText( aPtLM - aDiff, UniString::CreateFromAscii( 848 RTL_CONSTASCII_STRINGPARAM( "180" ) ) ); 849 850 if ( bPositive ) 851 DrawText( aPtLB - aDiff, UniString::CreateFromAscii( 852 RTL_CONSTASCII_STRINGPARAM( "225" ) ) ); 853 else 854 DrawText( aPtLB - aDiff, UniString::CreateFromAscii( 855 RTL_CONSTASCII_STRINGPARAM( "-135" ) ) ); 856 857 aDiff.X() = aFontSize.Width(); 858 DrawText( aPtMT - aDiff, UniString::CreateFromAscii( 859 RTL_CONSTASCII_STRINGPARAM( "90" ) ) ); 860 DrawText( aPtRT - aDiff, UniString::CreateFromAscii( 861 RTL_CONSTASCII_STRINGPARAM( "45" ) ) ); 862 aDiff.X() = aDiff .X() * 3 / 2; 863 864 if ( bPositive ) 865 DrawText( aPtMB - aDiff, UniString::CreateFromAscii( 866 RTL_CONSTASCII_STRINGPARAM( "270" ) ) ); 867 else 868 DrawText( aPtMB - aDiff, UniString::CreateFromAscii( 869 RTL_CONSTASCII_STRINGPARAM( "-90" ) ) ); 870 871 DrawText( aPtRM - Point( 0, aDiff.Y() ), UniString::CreateFromAscii( 872 RTL_CONSTASCII_STRINGPARAM( "0" ) ) ); 873 aDiff.X() = aFontSize.Width() * 2; 874 875 if ( bPositive ) 876 DrawText( aPtRB - aDiff, UniString::CreateFromAscii( 877 RTL_CONSTASCII_STRINGPARAM( "315" ) ) ); 878 else 879 DrawText( aPtRB - aDiff, UniString::CreateFromAscii( 880 RTL_CONSTASCII_STRINGPARAM( "-45" ) ) ); 881 } 882 883 /************************************************************************* 884 |* 885 |* Control zum Editieren von Bitmaps 886 |* 887 \************************************************************************/ 888 // IAccessibility2 implementation 2009. ------ 889 890 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SvxPixelCtl::CreateAccessible() 891 { 892 if(!m_xAccess.is()) 893 { 894 m_xAccess = m_pAccess = new SvxPixelCtlAccessible(*this); 895 } 896 return m_xAccess; 897 } 898 899 //Logic Pixel 900 long SvxPixelCtl::PointToIndex(const Point &aPt) const 901 { 902 sal_uInt16 nX, nY; 903 904 nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() ); 905 nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() ); 906 907 return nX + nY * nLines ; 908 } 909 Point SvxPixelCtl::IndexToPoint(long nIndex) const 910 { 911 DBG_ASSERT(nIndex >= 0 && nIndex < nSquares ," Check Index"); 912 913 sal_uInt16 nXIndex = nIndex % nLines ; 914 sal_uInt16 nYIndex = sal_uInt16(nIndex / nLines) ; 915 916 Point aPtTl; 917 aPtTl.Y() = aRectSize.Height() * nYIndex / nLines + 1; 918 aPtTl.X() = aRectSize.Width() * nXIndex / nLines + 1; 919 920 return aPtTl; 921 } 922 long SvxPixelCtl::GetFoucsPosIndex() const 923 { 924 return aFocusPosition.getX() + aFocusPosition.getY() * nLines ; 925 } 926 long SvxPixelCtl::ShowPosition( const Point &pt) 927 { 928 Point aPt = PixelToLogic( pt ); 929 930 sal_uInt16 nX, nY; 931 nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() ); 932 nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() ); 933 934 ChangePixel( nX + nY * nLines ); 935 936 //Solution:Set new focus position and repaint 937 //Invalidate( Rectangle( aPtTl, aPtBr ) ); 938 aFocusPosition.setX(nX); 939 aFocusPosition.setY(nY); 940 Invalidate(Rectangle(Point(0,0),aRectSize)); 941 942 if( WINDOW_TABPAGE == GetParent()->GetType() ) 943 ( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint ist dummy 944 945 return GetFoucsPosIndex(); 946 947 } 948 // ------ IAccessibility2 implementation 2009. 949 SvxPixelCtl::SvxPixelCtl( Window* pParent, const ResId& rResId, sal_uInt16 nNumber ) : 950 Control ( pParent, rResId ), 951 nLines ( nNumber ), 952 bPaintable ( sal_True ) 953 // IAccessibility2 implementation 2009. ------ 954 //Solution:Initialize it's value to Point(0,0) 955 ,aFocusPosition(0,0) 956 { 957 // SetMapMode( MAP_100TH_MM ); 958 aRectSize = GetOutputSize(); 959 960 SetPixelColor( Color( COL_BLACK ) ); 961 SetBackgroundColor( Color( COL_WHITE ) ); 962 SetLineColor( Application::GetSettings().GetStyleSettings().GetShadowColor() ); 963 964 nSquares = nLines * nLines; 965 pPixel = new sal_uInt16[ nSquares ]; 966 rtl_zeroMemory(pPixel, nSquares * sizeof(sal_uInt16)); 967 // IAccessibility2 implementation 2009. ------ 968 m_pAccess=NULL; 969 } 970 971 /************************************************************************* 972 |* 973 |* Destruktor dealociert dyn. Array 974 |* 975 \************************************************************************/ 976 977 SvxPixelCtl::~SvxPixelCtl( ) 978 { 979 delete []pPixel; 980 } 981 982 /************************************************************************* 983 |* 984 |* Wechselt die Vordergrund- ,bzw. Hintergrundfarbe 985 |* 986 \************************************************************************/ 987 988 void SvxPixelCtl::ChangePixel( sal_uInt16 nPixel ) 989 { 990 if( *( pPixel + nPixel) == 0 ) 991 *( pPixel + nPixel) = 1; // koennte erweitert werden auf mehrere Farben 992 else 993 *( pPixel + nPixel) = 0; 994 } 995 996 /************************************************************************* 997 |* 998 |* Das angeklickte Rechteck wird ermittelt um die Farbe zu wechseln 999 |* 1000 \************************************************************************/ 1001 1002 void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt ) 1003 { 1004 // IAccessibility2 implementation 2009. ------ 1005 //Point aPt = PixelToLogic( rMEvt.GetPosPixel() ); 1006 //Point aPtTl, aPtBr; 1007 //sal_uInt16 nX, nY; 1008 1009 //nX = (sal_uInt16) ( aPt.X() * nLines / aRectSize.Width() ); 1010 //nY = (sal_uInt16) ( aPt.Y() * nLines / aRectSize.Height() ); 1011 1012 //ChangePixel( nX + nY * nLines ); 1013 1014 //aPtTl.X() = aRectSize.Width() * nX / nLines + 1; 1015 //aPtBr.X() = aRectSize.Width() * (nX + 1) / nLines - 1; 1016 //aPtTl.Y() = aRectSize.Height() * nY / nLines + 1; 1017 //aPtBr.Y() = aRectSize.Height() * (nY + 1) / nLines - 1; 1018 1019 //Invalidate( Rectangle( aPtTl, aPtBr ) ); 1020 1021 //if( WINDOW_TABPAGE == GetParent()->GetType() ) 1022 // ( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint ist dummy 1023 //Solution:Grab focus when click in window 1024 if( !HasFocus() ) 1025 { 1026 GrabFocus(); 1027 } 1028 long nIndex = ShowPosition(rMEvt.GetPosPixel()); 1029 1030 if(m_pAccess) 1031 { 1032 m_pAccess->NotifyChild(nIndex,sal_True,sal_True); 1033 } 1034 // ------ IAccessibility2 implementation 2009. 1035 } 1036 1037 /************************************************************************* 1038 |* 1039 |* Zeichnet das Control (Rechteck mit 9 Kreisen) 1040 |* 1041 \************************************************************************/ 1042 1043 void SvxPixelCtl::Paint( const Rectangle& ) 1044 { 1045 sal_uInt16 i, j, nTmp; 1046 Point aPtTl, aPtBr; 1047 1048 if( bPaintable ) 1049 { 1050 // Linien Zeichnen 1051 Control::SetLineColor( aLineColor ); 1052 for( i = 1; i < nLines; i++) 1053 { 1054 // horizontal 1055 nTmp = (sal_uInt16) ( aRectSize.Height() * i / nLines ); 1056 DrawLine( Point( 0, nTmp ), Point( aRectSize.Width(), nTmp ) ); 1057 // vertikal 1058 nTmp = (sal_uInt16) ( aRectSize.Width() * i / nLines ); 1059 DrawLine( Point( nTmp, 0 ), Point( nTmp, aRectSize.Height() ) ); 1060 } 1061 1062 // Rechtecke (Quadrate) zeichnen 1063 Control::SetLineColor(); 1064 sal_uInt16 nLastPixel = *pPixel ? 0 : 1; 1065 1066 for( i = 0; i < nLines; i++) 1067 { 1068 aPtTl.Y() = aRectSize.Height() * i / nLines + 1; 1069 aPtBr.Y() = aRectSize.Height() * (i + 1) / nLines - 1; 1070 1071 for( j = 0; j < nLines; j++) 1072 { 1073 aPtTl.X() = aRectSize.Width() * j / nLines + 1; 1074 aPtBr.X() = aRectSize.Width() * (j + 1) / nLines - 1; 1075 1076 if ( *( pPixel + i * nLines + j ) != nLastPixel ) 1077 { 1078 nLastPixel = *( pPixel + i * nLines + j ); 1079 // Farbe wechseln: 0 -> Hintergrundfarbe 1080 SetFillColor( nLastPixel ? aPixelColor : aBackgroundColor ); 1081 } 1082 DrawRect( Rectangle( aPtTl, aPtBr ) ); 1083 } 1084 } 1085 // IAccessibility2 implementation 2009. ------ 1086 //Solution:Draw visual focus when has focus 1087 if( HasFocus() ) 1088 { 1089 ShowFocus(implCalFocusRect(aFocusPosition)); 1090 } 1091 // ------ IAccessibility2 implementation 2009. 1092 } // bPaintable 1093 else 1094 { 1095 SetBackground( Wallpaper( Color( COL_LIGHTGRAY ) ) ); 1096 Control::SetLineColor( Color( COL_LIGHTRED ) ); 1097 DrawLine( Point( 0, 0 ), Point( aRectSize.Width(), aRectSize.Height() ) ); 1098 DrawLine( Point( 0, aRectSize.Height() ), Point( aRectSize.Width(), 0 ) ); 1099 } 1100 } 1101 // IAccessibility2 implementation 2009. ------ 1102 //Solution:Caculate visual focus rectangle via focus position 1103 Rectangle SvxPixelCtl::implCalFocusRect( const Point& aPosition ) 1104 { 1105 long nLeft,nTop,nRight,nBottom; 1106 long i,j; 1107 i = aPosition.Y(); 1108 j = aPosition.X(); 1109 nLeft = aRectSize.Width() * j / nLines + 1; 1110 nRight = aRectSize.Width() * (j + 1) / nLines - 1; 1111 nTop = aRectSize.Height() * i / nLines + 1; 1112 nBottom = aRectSize.Height() * (i + 1) / nLines - 1; 1113 return Rectangle(nLeft,nTop,nRight,nBottom); 1114 } 1115 1116 //Solution:Keyboard fucntion 1117 void SvxPixelCtl::KeyInput( const KeyEvent& rKEvt ) 1118 { 1119 KeyCode aKeyCode = rKEvt.GetKeyCode(); 1120 sal_uInt16 nCode = aKeyCode.GetCode(); 1121 sal_Bool bIsMod = aKeyCode.IsShift() || aKeyCode.IsMod1() || aKeyCode.IsMod2(); 1122 1123 if( !bIsMod ) 1124 { 1125 Point pRepaintPoint( aRectSize.Width() *( aFocusPosition.getX() - 1)/ nLines - 1, 1126 aRectSize.Height() *( aFocusPosition.getY() - 1)/ nLines -1 1127 ); 1128 Size mRepaintSize( aRectSize.Width() *3/ nLines + 2,aRectSize.Height() *3/ nLines + 2); 1129 Rectangle mRepaintRect( pRepaintPoint, mRepaintSize ); 1130 sal_Bool bFocusPosChanged=sal_False; 1131 switch(nCode) 1132 { 1133 case KEY_LEFT: 1134 if((aFocusPosition.getX() >= 1)) 1135 { 1136 aFocusPosition.setX( aFocusPosition.getX() - 1 ); 1137 Invalidate(mRepaintRect); 1138 bFocusPosChanged=sal_True; 1139 } 1140 break; 1141 case KEY_RIGHT: 1142 if( aFocusPosition.getX() < (nLines - 1) ) 1143 { 1144 aFocusPosition.setX( aFocusPosition.getX() + 1 ); 1145 Invalidate(mRepaintRect); 1146 bFocusPosChanged=sal_True; 1147 } 1148 break; 1149 case KEY_UP: 1150 if((aFocusPosition.getY() >= 1)) 1151 { 1152 aFocusPosition.setY( aFocusPosition.getY() - 1 ); 1153 Invalidate(mRepaintRect); 1154 bFocusPosChanged=sal_True; 1155 } 1156 break; 1157 case KEY_DOWN: 1158 if( aFocusPosition.getY() < ( nLines - 1 ) ) 1159 { 1160 aFocusPosition.setY( aFocusPosition.getY() + 1 ); 1161 Invalidate(mRepaintRect); 1162 bFocusPosChanged=sal_True; 1163 } 1164 break; 1165 case KEY_SPACE: 1166 ChangePixel( sal_uInt16(aFocusPosition.getX() + aFocusPosition.getY() * nLines) ); 1167 Invalidate( implCalFocusRect(aFocusPosition) ); 1168 break; 1169 default: 1170 Control::KeyInput( rKEvt ); 1171 return; 1172 } 1173 if(m_xAccess.is()) 1174 { 1175 long nIndex = GetFoucsPosIndex(); 1176 switch(nCode) 1177 { 1178 case KEY_LEFT: 1179 case KEY_RIGHT: 1180 case KEY_UP: 1181 case KEY_DOWN: 1182 if (bFocusPosChanged) 1183 { 1184 m_pAccess->NotifyChild(nIndex,sal_False,sal_False); 1185 } 1186 break; 1187 case KEY_SPACE: 1188 m_pAccess->NotifyChild(nIndex,sal_False,sal_True); 1189 break; 1190 default: 1191 break; 1192 } 1193 } 1194 } 1195 else 1196 { 1197 Control::KeyInput( rKEvt ); 1198 } 1199 } 1200 1201 //Draw focus when get focus 1202 void SvxPixelCtl::GetFocus() 1203 { 1204 Invalidate(implCalFocusRect(aFocusPosition)); 1205 1206 if(m_pAccess) 1207 { 1208 m_pAccess->NotifyChild(GetFoucsPosIndex(),sal_True,sal_False); 1209 } 1210 1211 Control::GetFocus(); 1212 } 1213 1214 //Hide focus when lose focus 1215 void SvxPixelCtl::LoseFocus() 1216 { 1217 HideFocus(); 1218 if (m_pAccess) 1219 { 1220 m_pAccess->LoseFocus(); 1221 } 1222 Control::LoseFocus(); 1223 } 1224 // ------ IAccessibility2 implementation 2009. 1225 1226 /************************************************************************* 1227 |* 1228 |* 1229 |* 1230 \************************************************************************/ 1231 1232 void SvxPixelCtl::SetXBitmap( const BitmapEx& rBitmapEx ) 1233 { 1234 BitmapColor aBack; 1235 BitmapColor aFront; 1236 1237 if(isHistorical8x8(rBitmapEx, aBack, aFront)) 1238 { 1239 Bitmap aBitmap(rBitmapEx.GetBitmap()); 1240 BitmapReadAccess* pRead = aBitmap.AcquireReadAccess(); 1241 1242 aBackgroundColor = aBack; 1243 aPixelColor = aFront; 1244 1245 for(sal_uInt16 i(0); i < nSquares; i++) 1246 { 1247 const BitmapColor aColor(pRead->GetColor(i/8, i%8)); 1248 1249 if(aColor == aBack) 1250 { 1251 *( pPixel + i ) = 0; 1252 } 1253 else 1254 { 1255 *( pPixel + i ) = 1; 1256 } 1257 } 1258 1259 aBitmap.ReleaseAccess(pRead); 1260 } 1261 } 1262 1263 /************************************************************************* 1264 |* 1265 |* Gibt ein bestimmtes Pixel zurueck 1266 |* 1267 \************************************************************************/ 1268 1269 sal_uInt16 SvxPixelCtl::GetBitmapPixel( const sal_uInt16 nPixel ) 1270 { 1271 return( *( pPixel + nPixel ) ); 1272 } 1273 1274 /************************************************************************* 1275 |* 1276 |* Bewirkt den Ursprungszustand des Controls 1277 |* 1278 \************************************************************************/ 1279 1280 void SvxPixelCtl::Reset() 1281 { 1282 // clear pixel area 1283 rtl_zeroMemory(pPixel, nSquares * sizeof(sal_uInt16)); 1284 Invalidate(); 1285 } 1286 1287 /************************************************************************* 1288 |* 1289 |* Ctor: BitmapCtl fuer SvxPixelCtl 1290 |* 1291 \************************************************************************/ 1292 1293 SvxBitmapCtl::SvxBitmapCtl( Window* /*pParent*/, const Size& rSize ) 1294 { 1295 aSize = rSize; 1296 // aVD.SetOutputSizePixel( aSize ); 1297 } 1298 1299 /************************************************************************* 1300 |* 1301 |* Dtor 1302 |* 1303 \************************************************************************/ 1304 1305 SvxBitmapCtl::~SvxBitmapCtl() 1306 { 1307 } 1308 1309 /************************************************************************* 1310 |* 1311 |* BitmapCtl: Gibt die Bitmap zurueck 1312 |* 1313 \************************************************************************/ 1314 1315 BitmapEx SvxBitmapCtl::GetBitmapEx() 1316 { 1317 const Bitmap aRetval(createHistorical8x8FromArray(pBmpArray, aPixelColor, aBackgroundColor)); 1318 1319 return BitmapEx(aRetval); 1320 } 1321 1322 /************************************************************************* 1323 |* 1324 |* Fuellt die Listbox mit Farben und Strings 1325 |* 1326 \************************************************************************/ 1327 1328 void ColorLB::Fill( const XColorList* pColorTab ) 1329 { 1330 long nCount = pColorTab->Count(); 1331 XColorEntry* pEntry; 1332 SetUpdateMode( sal_False ); 1333 1334 for( long i = 0; i < nCount; i++ ) 1335 { 1336 pEntry = pColorTab->GetColor( i ); 1337 InsertEntry( pEntry->GetColor(), pEntry->GetName() ); 1338 } 1339 SetUpdateMode( sal_True ); 1340 } 1341 1342 /************************************************************************/ 1343 1344 void ColorLB::Append( XColorEntry* pEntry, Bitmap* ) 1345 { 1346 InsertEntry( pEntry->GetColor(), pEntry->GetName() ); 1347 } 1348 1349 /************************************************************************/ 1350 1351 void ColorLB::Modify( XColorEntry* pEntry, sal_uInt16 nPos, Bitmap* ) 1352 { 1353 RemoveEntry( nPos ); 1354 InsertEntry( pEntry->GetColor(), pEntry->GetName(), nPos ); 1355 } 1356 1357 /************************************************************************* 1358 |* 1359 |* Fuellt die Listbox mit Farben und Strings 1360 |* 1361 \************************************************************************/ 1362 1363 void FillAttrLB::Fill( const XColorList* pColorTab ) 1364 { 1365 long nCount = pColorTab->Count(); 1366 XColorEntry* pEntry; 1367 SetUpdateMode( sal_False ); 1368 1369 for( long i = 0; i < nCount; i++ ) 1370 { 1371 pEntry = pColorTab->GetColor( i ); 1372 InsertEntry( pEntry->GetColor(), pEntry->GetName() ); 1373 } 1374 SetUpdateMode( sal_True ); 1375 } 1376 1377 /************************************************************************* 1378 |* 1379 |* Fuellt die Listbox (vorlaeufig) mit Strings 1380 |* 1381 \************************************************************************/ 1382 1383 HatchingLB::HatchingLB( Window* pParent, ResId Id, sal_Bool bUserDraw /*= sal_True*/ ) 1384 : ListBox( pParent, Id ), 1385 mpList ( NULL ), 1386 mbUserDraw( bUserDraw ) 1387 { 1388 EnableUserDraw( mbUserDraw ); 1389 } 1390 1391 HatchingLB::HatchingLB( Window* pParent, WinBits aWB, sal_Bool bUserDraw /*= sal_True*/ ) 1392 : ListBox( pParent, aWB ), 1393 mpList ( NULL ), 1394 mbUserDraw( bUserDraw ) 1395 { 1396 EnableUserDraw( mbUserDraw ); 1397 } 1398 1399 void HatchingLB::Fill( const XHatchList* pList ) 1400 { 1401 mpList = (XHatchList*)pList; 1402 XHatchEntry* pEntry; 1403 long nCount = pList->Count(); 1404 1405 SetUpdateMode( sal_False ); 1406 1407 if( mbUserDraw ) 1408 { 1409 for( long i = 0; i < nCount; i++ ) 1410 InsertEntry( pList->GetHatch( i )->GetName() ); 1411 } 1412 else 1413 { 1414 for( long i = 0; i < nCount; i++ ) 1415 { 1416 pEntry = pList->GetHatch( i ); 1417 const Bitmap aBitmap = pList->GetUiBitmap( i ); 1418 if( !aBitmap.IsEmpty() ) 1419 InsertEntry( pEntry->GetName(), aBitmap ); 1420 else 1421 InsertEntry( pEntry->GetName() ); 1422 } 1423 } 1424 1425 SetUpdateMode( sal_True ); 1426 } 1427 1428 void HatchingLB::UserDraw( const UserDrawEvent& rUDEvt ) 1429 { 1430 if( mpList != NULL ) 1431 { 1432 // Draw gradient with borderrectangle 1433 const Rectangle& rDrawRect = rUDEvt.GetRect(); 1434 Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 ); 1435 1436 sal_Int32 nId = rUDEvt.GetItemId(); 1437 if( nId >= 0 && nId <= mpList->Count() ) 1438 { 1439 OutputDevice* pDevice = rUDEvt.GetDevice(); 1440 1441 sal_uIntPtr nOldDrawMode = pDevice->GetDrawMode(); 1442 pDevice->SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR ); 1443 1444 const XHatch& rXHatch = mpList->GetHatch( rUDEvt.GetItemId() )->GetHatch(); 1445 MapMode aMode( MAP_100TH_MM ); 1446 Hatch aHatch( (HatchStyle) rXHatch.GetHatchStyle(), 1447 rXHatch.GetColor(), 1448 rUDEvt.GetDevice()->LogicToPixel( Point( rXHatch.GetDistance(), 0 ), aMode ).X(), 1449 (sal_uInt16)rXHatch.GetAngle() ); 1450 const Polygon aPolygon( aRect ); 1451 const PolyPolygon aPolypoly( aPolygon ); 1452 pDevice->DrawHatch( aPolypoly, aHatch ); 1453 1454 pDevice->SetLineColor( COL_BLACK ); 1455 pDevice->SetFillColor(); 1456 pDevice->DrawRect( aRect ); 1457 1458 pDevice->SetDrawMode( nOldDrawMode ); 1459 1460 // Draw name 1461 pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->GetHatch( rUDEvt.GetItemId() )->GetName() ); 1462 } 1463 } 1464 } 1465 1466 /************************************************************************/ 1467 1468 void HatchingLB::Append( XHatchEntry* pEntry, Bitmap* pBmp ) 1469 { 1470 if( pBmp ) 1471 InsertEntry( pEntry->GetName(), *pBmp ); 1472 else 1473 InsertEntry( pEntry->GetName() ); 1474 } 1475 1476 /************************************************************************/ 1477 1478 void HatchingLB::Modify( XHatchEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp ) 1479 { 1480 RemoveEntry( nPos ); 1481 1482 if( pBmp ) 1483 InsertEntry( pEntry->GetName(), *pBmp, nPos ); 1484 else 1485 InsertEntry( pEntry->GetName(), nPos ); 1486 } 1487 1488 /************************************************************************/ 1489 1490 void HatchingLB::SelectEntryByList( const XHatchList* pList, const String& rStr, 1491 const XHatch& rHatch, sal_uInt16 nDist ) 1492 { 1493 long nCount = pList->Count(); 1494 XHatchEntry* pEntry; 1495 sal_Bool bFound = sal_False; 1496 String aStr; 1497 1498 long i; 1499 for( i = 0; i < nCount && !bFound; i++ ) 1500 { 1501 pEntry = pList->GetHatch( i ); 1502 1503 aStr = pEntry->GetName(); 1504 1505 if( rStr == aStr && rHatch == pEntry->GetHatch() ) 1506 bFound = sal_True; 1507 } 1508 if( bFound ) 1509 SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) ); 1510 } 1511 1512 /************************************************************************* 1513 |* 1514 |* Fuellt die Listbox (vorlaeufig) mit Strings 1515 |* 1516 \************************************************************************/ 1517 1518 void FillAttrLB::Fill( const XHatchList* pList ) 1519 { 1520 long nCount = pList->Count(); 1521 XHatchEntry* pEntry; 1522 ListBox::SetUpdateMode( sal_False ); 1523 1524 for( long i = 0; i < nCount; i++ ) 1525 { 1526 pEntry = pList->GetHatch( i ); 1527 const Bitmap aBitmap = pList->GetUiBitmap( i ); 1528 if( !aBitmap.IsEmpty() ) 1529 ListBox::InsertEntry( pEntry->GetName(), aBitmap ); 1530 else 1531 InsertEntry( pEntry->GetName() ); 1532 } 1533 ListBox::SetUpdateMode( sal_True ); 1534 } 1535 1536 /************************************************************************* 1537 |* 1538 |* Fuellt die Listbox (vorlaeufig) mit Strings 1539 |* 1540 \************************************************************************/ 1541 1542 GradientLB::GradientLB( Window* pParent, ResId Id, sal_Bool bUserDraw /*= sal_True*/ ) 1543 : ListBox( pParent, Id ), 1544 mpList(NULL), 1545 mbUserDraw( bUserDraw ) 1546 { 1547 EnableUserDraw( mbUserDraw); 1548 } 1549 1550 GradientLB::GradientLB( Window* pParent, WinBits aWB, sal_Bool bUserDraw /*= sal_True*/ ) 1551 : ListBox( pParent, aWB ), 1552 mpList(NULL), 1553 mbUserDraw( bUserDraw ) 1554 { 1555 EnableUserDraw( mbUserDraw ); 1556 } 1557 1558 void GradientLB::Fill( const XGradientList* pList ) 1559 { 1560 mpList = (XGradientList*)pList; 1561 XGradientEntry* pEntry; 1562 long nCount = pList->Count(); 1563 1564 SetUpdateMode( sal_False ); 1565 1566 if( mbUserDraw ) 1567 { 1568 for( long i = 0; i < nCount; i++ ) 1569 InsertEntry( pList->GetGradient( i )->GetName() ); 1570 } 1571 else 1572 { 1573 for( long i = 0; i < nCount; i++ ) 1574 { 1575 pEntry = pList->GetGradient( i ); 1576 const Bitmap aBitmap = pList->GetUiBitmap( i ); 1577 if( !aBitmap.IsEmpty() ) 1578 InsertEntry( pEntry->GetName(), aBitmap ); 1579 else 1580 InsertEntry( pEntry->GetName() ); 1581 } 1582 } 1583 1584 SetUpdateMode( sal_True ); 1585 } 1586 1587 void GradientLB::UserDraw( const UserDrawEvent& rUDEvt ) 1588 { 1589 if( mpList != NULL ) 1590 { 1591 // Draw gradient with borderrectangle 1592 const Rectangle& rDrawRect = rUDEvt.GetRect(); 1593 Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 ); 1594 1595 sal_Int32 nId = rUDEvt.GetItemId(); 1596 if( nId >= 0 && nId <= mpList->Count() ) 1597 { 1598 OutputDevice* pDevice = rUDEvt.GetDevice(); 1599 1600 const XGradient& rXGrad = mpList->GetGradient( rUDEvt.GetItemId() )->GetGradient(); 1601 Gradient aGradient( (GradientStyle) rXGrad.GetGradientStyle(), rXGrad.GetStartColor(), rXGrad.GetEndColor() ); 1602 aGradient.SetAngle( (sal_uInt16)rXGrad.GetAngle() ); 1603 aGradient.SetBorder( rXGrad.GetBorder() ); 1604 aGradient.SetOfsX( rXGrad.GetXOffset() ); 1605 aGradient.SetOfsY( rXGrad.GetYOffset() ); 1606 aGradient.SetStartIntensity( rXGrad.GetStartIntens() ); 1607 aGradient.SetEndIntensity( rXGrad.GetEndIntens() ); 1608 aGradient.SetSteps( 255 ); 1609 1610 // #i76307# always paint the preview in LTR, because this is what the document does 1611 Window* pWin = dynamic_cast<Window*>(pDevice); 1612 if( pWin && pWin->IsRTLEnabled() && Application::GetSettings().GetLayoutRTL()) 1613 { 1614 long nWidth = pDevice->GetOutputSize().Width(); 1615 1616 pWin->EnableRTL( sal_False ); 1617 1618 Rectangle aMirrorRect( Point( nWidth - aRect.Left() - aRect.GetWidth(), aRect.Top() ), 1619 aRect.GetSize() ); 1620 1621 pDevice->DrawGradient( aMirrorRect, aGradient ); 1622 1623 pWin->EnableRTL( sal_True ); 1624 } 1625 else 1626 pDevice->DrawGradient( aRect, aGradient ); 1627 1628 pDevice->SetLineColor( COL_BLACK ); 1629 pDevice->SetFillColor(); 1630 pDevice->DrawRect( aRect ); 1631 1632 // Draw name 1633 pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->GetGradient( rUDEvt.GetItemId() )->GetName() ); 1634 } 1635 } 1636 } 1637 1638 /************************************************************************/ 1639 1640 void GradientLB::Append( XGradientEntry* pEntry, Bitmap* pBmp ) 1641 { 1642 if( pBmp ) 1643 InsertEntry( pEntry->GetName(), *pBmp ); 1644 else 1645 InsertEntry( pEntry->GetName() ); 1646 } 1647 1648 /************************************************************************/ 1649 1650 void GradientLB::Modify( XGradientEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp ) 1651 { 1652 RemoveEntry( nPos ); 1653 1654 if( pBmp ) 1655 InsertEntry( pEntry->GetName(), *pBmp, nPos ); 1656 else 1657 InsertEntry( pEntry->GetName(), nPos ); 1658 } 1659 1660 /************************************************************************/ 1661 1662 void GradientLB::SelectEntryByList( const XGradientList* pList, const String& rStr, 1663 const XGradient& rGradient, sal_uInt16 nDist ) 1664 { 1665 long nCount = pList->Count(); 1666 XGradientEntry* pEntry; 1667 sal_Bool bFound = sal_False; 1668 String aStr; 1669 1670 long i; 1671 for( i = 0; i < nCount && !bFound; i++ ) 1672 { 1673 pEntry = pList->GetGradient( i ); 1674 1675 aStr = pEntry->GetName(); 1676 1677 if( rStr == aStr && rGradient == pEntry->GetGradient() ) 1678 bFound = sal_True; 1679 } 1680 if( bFound ) 1681 SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) ); 1682 } 1683 1684 /************************************************************************* 1685 |* 1686 |* Fuellt die Listbox (vorlaeufig) mit Strings 1687 |* 1688 \************************************************************************/ 1689 1690 void FillAttrLB::Fill( const XGradientList* pList ) 1691 { 1692 long nCount = pList->Count(); 1693 XGradientEntry* pEntry; 1694 ListBox::SetUpdateMode( sal_False ); 1695 1696 for( long i = 0; i < nCount; i++ ) 1697 { 1698 pEntry = pList->GetGradient( i ); 1699 const Bitmap aBitmap = pList->GetUiBitmap( i ); 1700 if( !aBitmap.IsEmpty() ) 1701 ListBox::InsertEntry( pEntry->GetName(), aBitmap ); 1702 else 1703 InsertEntry( pEntry->GetName() ); 1704 } 1705 ListBox::SetUpdateMode( sal_True ); 1706 } 1707 1708 /************************************************************************* 1709 |* 1710 |* Konstruktor von BitmapLB 1711 |* 1712 \************************************************************************/ 1713 1714 BitmapLB::BitmapLB(Window* pParent, ResId Id, bool bUserDraw /*= false*/ ) 1715 : ListBox(pParent, Id), 1716 maVD(), 1717 maBitmapEx(), 1718 mpList(NULL), 1719 mbUserDraw(bUserDraw) 1720 { 1721 EnableUserDraw(mbUserDraw); 1722 } 1723 1724 /************************************************************************/ 1725 1726 void BitmapLB::SetVirtualDevice(const Size& rSize) 1727 { 1728 maVD.SetOutputSizePixel(rSize); 1729 1730 if(maBitmapEx.GetSizePixel().Width() > 8 || maBitmapEx.GetSizePixel().Height() > 8) 1731 { 1732 maVD.DrawBitmapEx(Point(0, 0), rSize, maBitmapEx); 1733 } 1734 else 1735 { 1736 const Size aBitmapSize(maBitmapEx.GetSizePixel()); 1737 1738 for(sal_Int32 y(0); y < rSize.Height(); y += aBitmapSize.Height()) 1739 { 1740 for(sal_Int32 x(0); x < rSize.Width(); x += aBitmapSize.Width()) 1741 { 1742 maVD.DrawBitmapEx( 1743 Point(x, y), 1744 maBitmapEx); 1745 } 1746 } 1747 } 1748 } 1749 1750 /************************************************************************/ 1751 1752 void BitmapLB::Fill(const XBitmapList* pList) 1753 { 1754 mpList = (XBitmapList*)pList; 1755 XBitmapEntry* pEntry; 1756 const long nCount(pList->Count()); 1757 1758 SetUpdateMode(false); 1759 1760 if(mbUserDraw) 1761 { 1762 for(long i(0); i < nCount; i++) 1763 { 1764 InsertEntry(pList->GetBitmap(i)->GetName()); 1765 } 1766 } 1767 else 1768 { 1769 for(long i(0); i < nCount; i++) 1770 { 1771 pEntry = pList->GetBitmap(i); 1772 maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx(); 1773 const Size aSize(pList->getUiBitmapWidth(), pList->getUiBitmapHeight()); 1774 SetVirtualDevice(aSize); 1775 InsertEntry( 1776 pEntry->GetName(), 1777 maVD.GetBitmap(Point(0, 0), 1778 aSize)); 1779 } 1780 } 1781 1782 SetUpdateMode(true); 1783 } 1784 1785 void BitmapLB::UserDraw(const UserDrawEvent& rUDEvt) 1786 { 1787 if(mpList) 1788 { 1789 // Draw bitmap 1790 const Rectangle& rDrawRect = rUDEvt.GetRect(); 1791 const Rectangle aRect(rDrawRect.nLeft + 1, rDrawRect.nTop + 1, rDrawRect.nLeft + 33, rDrawRect.nBottom - 1); 1792 const sal_Int32 nId(rUDEvt.GetItemId()); 1793 1794 if(nId >= 0 && nId <= mpList->Count()) 1795 { 1796 const Rectangle aClipRect(rDrawRect.nLeft + 1, rDrawRect.nTop + 1, rDrawRect.nRight - 1, rDrawRect.nBottom - 1); 1797 OutputDevice* pDevice = rUDEvt.GetDevice(); 1798 pDevice->SetClipRegion(Region(aClipRect)); 1799 maBitmapEx = mpList->GetBitmap(nId)->GetGraphicObject().GetGraphic().GetBitmapEx(); 1800 long nPosBaseX = aRect.nLeft; 1801 long nPosBaseY = aRect.nTop; 1802 1803 if(maBitmapEx.GetSizePixel().Width() > 8 || maBitmapEx.GetSizePixel().Height() > 8) 1804 { 1805 pDevice->DrawBitmapEx(Point(nPosBaseX, nPosBaseY), Size(32, 16), maBitmapEx); 1806 } 1807 else 1808 { 1809 pDevice->DrawBitmapEx(Point(nPosBaseX+ 0, nPosBaseY+0 ), maBitmapEx); 1810 pDevice->DrawBitmapEx(Point(nPosBaseX+ 8, nPosBaseY+0 ), maBitmapEx); 1811 pDevice->DrawBitmapEx(Point(nPosBaseX+16, nPosBaseY+0 ), maBitmapEx); 1812 pDevice->DrawBitmapEx(Point(nPosBaseX+24, nPosBaseY+0 ), maBitmapEx); 1813 pDevice->DrawBitmapEx(Point(nPosBaseX+ 0, nPosBaseY+8 ), maBitmapEx); 1814 pDevice->DrawBitmapEx(Point(nPosBaseX+ 8, nPosBaseY+8 ), maBitmapEx); 1815 pDevice->DrawBitmapEx(Point(nPosBaseX+16, nPosBaseY+8 ), maBitmapEx); 1816 pDevice->DrawBitmapEx(Point(nPosBaseX+24, nPosBaseY+8 ), maBitmapEx); 1817 } 1818 1819 pDevice->SetClipRegion(); 1820 1821 // Draw name 1822 pDevice->DrawText(Point(aRect.nRight + 7, aRect.nTop - 1), mpList->GetBitmap(nId)->GetName()); 1823 } 1824 } 1825 } 1826 1827 /************************************************************************/ 1828 1829 void BitmapLB::Append(const Size& rSize, const XBitmapEntry& rEntry, BitmapEx* pBmpEx) 1830 { 1831 if(pBmpEx) 1832 { 1833 maBitmapEx = rEntry.GetGraphicObject().GetGraphic().GetBitmapEx(); 1834 SetVirtualDevice(rSize); 1835 InsertEntry( 1836 rEntry.GetName(), 1837 maVD.GetBitmap(Point(0, 0), 1838 rSize)); 1839 } 1840 else 1841 { 1842 InsertEntry(rEntry.GetName()); 1843 } 1844 } 1845 1846 /************************************************************************/ 1847 1848 void BitmapLB::Modify(const Size& rSize, const XBitmapEntry& rEntry, sal_uInt16 nPos, BitmapEx* pBmpEx) 1849 { 1850 RemoveEntry(nPos); 1851 1852 if(pBmpEx) 1853 { 1854 maBitmapEx = rEntry.GetGraphicObject().GetGraphic().GetBitmapEx(); 1855 SetVirtualDevice(rSize); 1856 InsertEntry( 1857 rEntry.GetName(), 1858 maVD.GetBitmap(Point(0, 0), rSize), 1859 nPos); 1860 } 1861 else 1862 { 1863 InsertEntry(rEntry.GetName()); 1864 } 1865 } 1866 1867 /************************************************************************/ 1868 1869 void BitmapLB::SelectEntryByList(const XBitmapList* pList, const String& rStr) 1870 { 1871 const long nCount(pList->Count()); 1872 XBitmapEntry* pEntry; 1873 bool bFound(false); 1874 long i(0); 1875 1876 for(i = 0; i < nCount && !bFound; i++) 1877 { 1878 pEntry = pList->GetBitmap(i); 1879 const String aStr(pEntry->GetName()); 1880 1881 if(rStr == aStr) 1882 { 1883 bFound = true; 1884 } 1885 } 1886 1887 if(bFound) 1888 { 1889 SelectEntryPos((sal_uInt16)(i - 1)); 1890 } 1891 } 1892 1893 /************************************************************************* 1894 |* 1895 |* Konstruktor von FillAttrLB 1896 |* 1897 \************************************************************************/ 1898 1899 FillAttrLB::FillAttrLB( Window* pParent, ResId Id ) 1900 : ColorListBox(pParent, Id), 1901 maVD(), 1902 maBitmapEx() 1903 { 1904 } 1905 1906 /************************************************************************/ 1907 1908 FillAttrLB::FillAttrLB(Window* pParent, WinBits aWB) 1909 : ColorListBox(pParent, aWB) 1910 { 1911 } 1912 1913 /************************************************************************/ 1914 1915 void FillAttrLB::SetVirtualDevice(const Size& rSize) 1916 { 1917 maVD.SetOutputSizePixel(rSize); 1918 maVD.Erase(); 1919 1920 if(maBitmapEx.GetSizePixel().Width() > 8 || maBitmapEx.GetSizePixel().Height() > 8) 1921 { 1922 maVD.DrawBitmapEx(Point(0, 0), rSize, maBitmapEx); 1923 } 1924 else 1925 { 1926 const Size aBitmapSize(maBitmapEx.GetSizePixel()); 1927 1928 for(sal_Int32 y(0); y < rSize.Height(); y += aBitmapSize.Height()) 1929 { 1930 for(sal_Int32 x(0); x < rSize.Width(); x += aBitmapSize.Width()) 1931 { 1932 maVD.DrawBitmapEx( 1933 Point(x, y), 1934 maBitmapEx); 1935 } 1936 } 1937 } 1938 } 1939 1940 /************************************************************************/ 1941 1942 void FillAttrLB::Fill(const XBitmapList* pList) 1943 { 1944 const long nCount(pList->Count()); 1945 XBitmapEntry* pEntry; 1946 1947 ListBox::SetUpdateMode(false); 1948 1949 for(long i(0); i < nCount; i++) 1950 { 1951 pEntry = pList->GetBitmap( i ); 1952 maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx(); 1953 const Size aSize(pList->getUiBitmapWidth(), pList->getUiBitmapHeight()); 1954 SetVirtualDevice(aSize); 1955 ListBox::InsertEntry( 1956 pEntry->GetName(), 1957 maVD.GetBitmap(Point(0, 0), 1958 aSize)); 1959 } 1960 1961 ListBox::SetUpdateMode(true); 1962 } 1963 1964 /************************************************************************/ 1965 1966 void FillAttrLB::SelectEntryByList( const XBitmapList* pList, const String& rStr) 1967 { 1968 const long nCount(pList->Count()); 1969 XBitmapEntry* pEntry; 1970 bool bFound(false); 1971 long i(0); 1972 1973 for(i = 0; i < nCount && !bFound; i++) 1974 { 1975 pEntry = pList->GetBitmap(i); 1976 const String aStr(pEntry->GetName()); 1977 1978 if(rStr == aStr) 1979 { 1980 bFound = true; 1981 } 1982 } 1983 1984 if(bFound) 1985 { 1986 SelectEntryPos((sal_uInt16)(i - 1)); 1987 } 1988 } 1989 1990 /************************************************************************* 1991 |* 1992 |* Fuellt die Listbox (vorlaeufig) mit Strings 1993 |* 1994 \************************************************************************/ 1995 1996 void FillTypeLB::Fill() 1997 { 1998 SetUpdateMode( sal_False ); 1999 InsertEntry( String( SVX_RES( RID_SVXSTR_INVISIBLE ) ) ); 2000 InsertEntry( String( SVX_RES( RID_SVXSTR_COLOR ) ) ); 2001 InsertEntry( String( SVX_RES( RID_SVXSTR_GRADIENT ) ) ); 2002 InsertEntry( String( SVX_RES( RID_SVXSTR_HATCH ) ) ); 2003 InsertEntry( String( SVX_RES( RID_SVXSTR_BITMAP ) ) ); 2004 SetUpdateMode( sal_True ); 2005 } 2006 2007 /************************************************************************* 2008 |* 2009 |* Fuellt die Listbox (vorlaeufig) mit Strings 2010 |* 2011 \************************************************************************/ 2012 LineLB::LineLB(Window* pParent, ResId Id) 2013 : ListBox(pParent, Id), 2014 mbAddStandardFields(true) 2015 { 2016 } 2017 2018 LineLB::LineLB(Window* pParent, WinBits aWB) 2019 : ListBox(pParent, aWB), 2020 mbAddStandardFields(true) 2021 { 2022 } 2023 2024 LineLB::~LineLB() 2025 { 2026 } 2027 2028 void LineLB::setAddStandardFields(bool bNew) 2029 { 2030 if(getAddStandardFields() != bNew) 2031 { 2032 mbAddStandardFields = bNew; 2033 } 2034 } 2035 2036 void LineLB::Fill( const XDashList* pList ) 2037 { 2038 Clear(); 2039 2040 if(getAddStandardFields()) 2041 { 2042 // entry for 'none' 2043 InsertEntry(pList->GetStringForUiNoLine()); 2044 2045 // entry for solid line 2046 InsertEntry(pList->GetStringForUiSolidLine(), pList->GetBitmapForUISolidLine()); 2047 } 2048 2049 // entries for dashed lines 2050 long nCount = pList->Count(); 2051 XDashEntry* pEntry; 2052 SetUpdateMode( sal_False ); 2053 2054 for( long i = 0; i < nCount; i++ ) 2055 { 2056 pEntry = pList->GetDash( i ); 2057 const Bitmap aBitmap = const_cast< XDashList* >(pList)->GetUiBitmap( i ); 2058 if( !aBitmap.IsEmpty() ) 2059 { 2060 InsertEntry( pEntry->GetName(), aBitmap ); 2061 //delete pBitmap; 2062 } 2063 else 2064 InsertEntry( pEntry->GetName() ); 2065 } 2066 SetUpdateMode( sal_True ); 2067 } 2068 2069 /************************************************************************/ 2070 2071 void LineLB::Append( XDashEntry* pEntry, const Bitmap* pBmp ) 2072 { 2073 if( pBmp ) 2074 InsertEntry( pEntry->GetName(), *pBmp ); 2075 else 2076 InsertEntry( pEntry->GetName() ); 2077 } 2078 2079 /************************************************************************/ 2080 2081 void LineLB::Modify( XDashEntry* pEntry, sal_uInt16 nPos, const Bitmap* pBmp ) 2082 { 2083 RemoveEntry( nPos ); 2084 2085 if( pBmp ) 2086 InsertEntry( pEntry->GetName(), *pBmp, nPos ); 2087 else 2088 InsertEntry( pEntry->GetName(), nPos ); 2089 } 2090 2091 /************************************************************************/ 2092 2093 void LineLB::SelectEntryByList( const XDashList* pList, const String& rStr, 2094 const XDash& rDash, sal_uInt16 nDist ) 2095 { 2096 long nCount = pList->Count(); 2097 XDashEntry* pEntry; 2098 sal_Bool bFound = sal_False; 2099 String aStr; 2100 XDash aDash; 2101 2102 long i; 2103 for( i = 0; i < nCount && !bFound; i++ ) 2104 { 2105 pEntry = pList->GetDash( i ); 2106 2107 aStr = pEntry->GetName(); 2108 aDash = pEntry->GetDash(); 2109 2110 if( rStr == aStr && rDash == aDash ) 2111 bFound = sal_True; 2112 } 2113 if( bFound ) 2114 SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) ); 2115 } 2116 2117 /************************************************************************* 2118 |* 2119 |* Fuellt die Listbox (vorlaeufig) mit Strings 2120 |* 2121 \************************************************************************/ 2122 LineEndLB::LineEndLB( Window* pParent, ResId Id ) 2123 : ListBox( pParent, Id ) 2124 { 2125 } 2126 2127 LineEndLB::LineEndLB( Window* pParent, WinBits aWB ) 2128 : ListBox( pParent, aWB ) 2129 { 2130 } 2131 2132 LineEndLB::~LineEndLB(void) 2133 { 2134 } 2135 2136 2137 void LineEndLB::Fill( const XLineEndList* pList, sal_Bool bStart ) 2138 { 2139 long nCount = pList->Count(); 2140 XLineEndEntry* pEntry; 2141 VirtualDevice aVD; 2142 SetUpdateMode( sal_False ); 2143 2144 for( long i = 0; i < nCount; i++ ) 2145 { 2146 pEntry = pList->GetLineEnd( i ); 2147 const Bitmap aBitmap = const_cast< XLineEndList* >(pList)->GetUiBitmap( i ); 2148 if( !aBitmap.IsEmpty() ) 2149 { 2150 Size aBmpSize( aBitmap.GetSizePixel() ); 2151 aVD.SetOutputSizePixel( aBmpSize, sal_False ); 2152 aVD.DrawBitmap( Point(), aBitmap ); 2153 InsertEntry( pEntry->GetName(), 2154 aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ), 2155 Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) ); 2156 //delete pBitmap; 2157 } 2158 else 2159 InsertEntry( pEntry->GetName() ); 2160 } 2161 SetUpdateMode( sal_True ); 2162 } 2163 2164 /************************************************************************/ 2165 2166 void LineEndLB::Append( XLineEndEntry* pEntry, const Bitmap* pBmp, sal_Bool bStart ) 2167 { 2168 if( pBmp ) 2169 { 2170 VirtualDevice aVD; 2171 Size aBmpSize( pBmp->GetSizePixel() ); 2172 2173 aVD.SetOutputSizePixel( aBmpSize, sal_False ); 2174 aVD.DrawBitmap( Point(), *pBmp ); 2175 InsertEntry( pEntry->GetName(), 2176 aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ), 2177 Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) ); 2178 } 2179 else 2180 InsertEntry( pEntry->GetName() ); 2181 } 2182 2183 /************************************************************************/ 2184 2185 void LineEndLB::Modify( XLineEndEntry* pEntry, sal_uInt16 nPos, const Bitmap* pBmp, sal_Bool bStart ) 2186 { 2187 RemoveEntry( nPos ); 2188 2189 if( pBmp ) 2190 { 2191 VirtualDevice aVD; 2192 Size aBmpSize( pBmp->GetSizePixel() ); 2193 2194 aVD.SetOutputSizePixel( aBmpSize, sal_False ); 2195 aVD.DrawBitmap( Point(), *pBmp ); 2196 InsertEntry( pEntry->GetName(), 2197 aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ), 2198 Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ), nPos ); 2199 } 2200 else 2201 InsertEntry( pEntry->GetName(), nPos ); 2202 } 2203 2204 ////////////////////////////////////////////////////////////////////////////// 2205 2206 void SvxPreviewBase::InitSettings(bool bForeground, bool bBackground) 2207 { 2208 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 2209 2210 if(bForeground) 2211 { 2212 svtools::ColorConfig aColorConfig; 2213 Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor); 2214 2215 if(IsControlForeground()) 2216 { 2217 aTextColor = GetControlForeground(); 2218 } 2219 2220 getBufferDevice().SetTextColor(aTextColor); 2221 } 2222 2223 if(bBackground) 2224 { 2225 if(IsControlBackground()) 2226 { 2227 getBufferDevice().SetBackground(GetControlBackground()); 2228 } 2229 else 2230 { 2231 getBufferDevice().SetBackground(rStyleSettings.GetWindowColor()); 2232 } 2233 } 2234 2235 // do not paint background self, it gets painted buffered 2236 SetControlBackground(); 2237 SetBackground(); 2238 2239 Invalidate(); 2240 } 2241 2242 SvxPreviewBase::SvxPreviewBase( Window* pParent, const ResId& rResId ) 2243 : Control( pParent, rResId ), 2244 mpModel( new SdrModel() ), 2245 mpBufferDevice( new VirtualDevice(*this) ) 2246 { 2247 // Draw the control's border as a flat thin black line. 2248 SetBorderStyle(WINDOW_BORDER_MONO); 2249 SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR ); 2250 SetMapMode(MAP_100TH_MM); 2251 2252 // init model 2253 mpModel->GetItemPool().FreezeIdRanges(); 2254 } 2255 2256 SvxPreviewBase::~SvxPreviewBase() 2257 { 2258 delete mpModel; 2259 delete mpBufferDevice; 2260 } 2261 2262 void SvxPreviewBase::LocalPrePaint() 2263 { 2264 // init BufferDevice 2265 if(mpBufferDevice->GetOutputSizePixel() != GetOutputSizePixel()) 2266 { 2267 mpBufferDevice->SetDrawMode(GetDrawMode()); 2268 mpBufferDevice->SetSettings(GetSettings()); 2269 mpBufferDevice->SetAntialiasing(GetAntialiasing()); 2270 mpBufferDevice->SetOutputSizePixel(GetOutputSizePixel()); 2271 mpBufferDevice->SetMapMode(GetMapMode()); 2272 } 2273 2274 mpBufferDevice->Erase(); 2275 } 2276 2277 void SvxPreviewBase::LocalPostPaint() 2278 { 2279 // copy to front (in pixel mode) 2280 const bool bWasEnabledSrc(mpBufferDevice->IsMapModeEnabled()); 2281 const bool bWasEnabledDst(IsMapModeEnabled()); 2282 const Point aEmptyPoint; 2283 2284 mpBufferDevice->EnableMapMode(false); 2285 EnableMapMode(false); 2286 2287 DrawOutDev( 2288 aEmptyPoint, GetOutputSizePixel(), 2289 aEmptyPoint, GetOutputSizePixel(), 2290 *mpBufferDevice); 2291 2292 mpBufferDevice->EnableMapMode(bWasEnabledSrc); 2293 EnableMapMode(bWasEnabledDst); 2294 } 2295 2296 void SvxPreviewBase::StateChanged(StateChangedType nType) 2297 { 2298 Control::StateChanged(nType); 2299 2300 if(STATE_CHANGE_CONTROLFOREGROUND == nType) 2301 { 2302 InitSettings(true, false); 2303 } 2304 else if(STATE_CHANGE_CONTROLBACKGROUND == nType) 2305 { 2306 InitSettings(false, true); 2307 } 2308 } 2309 2310 void SvxPreviewBase::DataChanged(const DataChangedEvent& rDCEvt) 2311 { 2312 SetDrawMode(GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR); 2313 2314 if((DATACHANGED_SETTINGS == rDCEvt.GetType()) && (rDCEvt.GetFlags() & SETTINGS_STYLE)) 2315 { 2316 InitSettings(true, true); 2317 } 2318 else 2319 { 2320 Control::DataChanged(rDCEvt); 2321 } 2322 } 2323 2324 /************************************************************************* 2325 |* 2326 |* SvxXLinePreview::SvxXLinePreview() 2327 |* 2328 *************************************************************************/ 2329 2330 SvxXLinePreview::SvxXLinePreview( Window* pParent, const ResId& rResId ) 2331 : SvxPreviewBase( pParent, rResId ), 2332 mpLineObjA( 0L ), 2333 mpLineObjB( 0L ), 2334 mpLineObjC( 0L ), 2335 mpGraphic( 0L ), 2336 mbWithSymbol( sal_False ) 2337 { 2338 const Size aOutputSize(GetOutputSize()); 2339 InitSettings( sal_True, sal_True ); 2340 2341 const sal_Int32 nDistance(500L); 2342 const sal_Int32 nAvailableLength(aOutputSize.Width() - (4 * nDistance)); 2343 2344 // create DrawObectA 2345 const sal_Int32 aYPosA(aOutputSize.Height() / 2); 2346 const basegfx::B2DPoint aPointA1( nDistance, aYPosA); 2347 const basegfx::B2DPoint aPointA2( aPointA1.getX() + ((nAvailableLength * 14) / 20), aYPosA ); 2348 basegfx::B2DPolygon aPolygonA; 2349 aPolygonA.append(aPointA1); 2350 aPolygonA.append(aPointA2); 2351 mpLineObjA = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygonA)); 2352 mpLineObjA->SetModel(&getModel()); 2353 2354 // create DrawObectB 2355 const sal_Int32 aYPosB1((aOutputSize.Height() * 3) / 4); 2356 const sal_Int32 aYPosB2((aOutputSize.Height() * 1) / 4); 2357 const basegfx::B2DPoint aPointB1( aPointA2.getX() + nDistance, aYPosB1); 2358 const basegfx::B2DPoint aPointB2( aPointB1.getX() + ((nAvailableLength * 2) / 20), aYPosB2 ); 2359 const basegfx::B2DPoint aPointB3( aPointB2.getX() + ((nAvailableLength * 2) / 20), aYPosB1 ); 2360 basegfx::B2DPolygon aPolygonB; 2361 aPolygonB.append(aPointB1); 2362 aPolygonB.append(aPointB2); 2363 aPolygonB.append(aPointB3); 2364 mpLineObjB = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonB)); 2365 mpLineObjB->SetModel(&getModel()); 2366 2367 // create DrawObectC 2368 const basegfx::B2DPoint aPointC1( aPointB3.getX() + nDistance, aYPosB1); 2369 const basegfx::B2DPoint aPointC2( aPointC1.getX() + ((nAvailableLength * 1) / 20), aYPosB2 ); 2370 const basegfx::B2DPoint aPointC3( aPointC2.getX() + ((nAvailableLength * 1) / 20), aYPosB1 ); 2371 basegfx::B2DPolygon aPolygonC; 2372 aPolygonC.append(aPointC1); 2373 aPolygonC.append(aPointC2); 2374 aPolygonC.append(aPointC3); 2375 mpLineObjC = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonC)); 2376 mpLineObjC->SetModel(&getModel()); 2377 } 2378 2379 SvxXLinePreview::~SvxXLinePreview() 2380 { 2381 SdrObject::Free( mpLineObjA ); 2382 SdrObject::Free( mpLineObjB ); 2383 SdrObject::Free( mpLineObjC ); 2384 } 2385 2386 // ----------------------------------------------------------------------- 2387 2388 void SvxXLinePreview::SetSymbol(Graphic* p,const Size& s) 2389 { 2390 mpGraphic = p; 2391 maSymbolSize = s; 2392 } 2393 2394 // ----------------------------------------------------------------------- 2395 2396 void SvxXLinePreview::ResizeSymbol(const Size& s) 2397 { 2398 if ( s != maSymbolSize ) 2399 { 2400 maSymbolSize = s; 2401 Invalidate(); 2402 } 2403 } 2404 2405 // ----------------------------------------------------------------------- 2406 2407 void SvxXLinePreview::SetLineAttributes(const SfxItemSet& rItemSet) 2408 { 2409 // Set ItemSet at objects 2410 mpLineObjA->SetMergedItemSet(rItemSet); 2411 2412 // At line joints, do not use arrows 2413 SfxItemSet aTempSet(rItemSet); 2414 aTempSet.ClearItem(XATTR_LINESTART); 2415 aTempSet.ClearItem(XATTR_LINEEND); 2416 2417 mpLineObjB->SetMergedItemSet(aTempSet); 2418 mpLineObjC->SetMergedItemSet(aTempSet); 2419 } 2420 2421 // ----------------------------------------------------------------------- 2422 2423 void SvxXLinePreview::Paint( const Rectangle& ) 2424 { 2425 LocalPrePaint(); 2426 2427 // paint objects to buffer device 2428 sdr::contact::SdrObjectVector aObjectVector; 2429 aObjectVector.push_back(mpLineObjA); 2430 aObjectVector.push_back(mpLineObjB); 2431 aObjectVector.push_back(mpLineObjC); 2432 2433 sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0); 2434 sdr::contact::DisplayInfo aDisplayInfo; 2435 2436 // do processing 2437 aPainter.ProcessDisplay(aDisplayInfo); 2438 2439 if ( mbWithSymbol && mpGraphic ) 2440 { 2441 const Size aOutputSize(GetOutputSize()); 2442 Point aPos = Point( aOutputSize.Width() / 3, aOutputSize.Height() / 2 ); 2443 aPos.X() -= maSymbolSize.Width() / 2; 2444 aPos.Y() -= maSymbolSize.Height() / 2; 2445 mpGraphic->Draw( &getBufferDevice(), aPos, maSymbolSize ); 2446 } 2447 2448 LocalPostPaint(); 2449 } 2450 2451 /************************************************************************* 2452 |* 2453 |* SvxXRectPreview::SvxXRectPreview() 2454 |* 2455 *************************************************************************/ 2456 2457 SvxXRectPreview::SvxXRectPreview( Window* pParent, const ResId& rResId ) 2458 : SvxPreviewBase( pParent, rResId ), 2459 mpRectangleObject(0) 2460 { 2461 InitSettings(true, true); 2462 2463 // create RectangleObject 2464 const Rectangle aObjectSize(Point(), GetOutputSize()); 2465 mpRectangleObject = new SdrRectObj(aObjectSize); 2466 mpRectangleObject->SetModel(&getModel()); 2467 } 2468 2469 SvxXRectPreview::~SvxXRectPreview() 2470 { 2471 SdrObject::Free(mpRectangleObject); 2472 } 2473 2474 void SvxXRectPreview::SetAttributes(const SfxItemSet& rItemSet) 2475 { 2476 mpRectangleObject->SetMergedItemSet(rItemSet, true); 2477 mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE)); 2478 } 2479 2480 void SvxXRectPreview::Paint( const Rectangle& ) 2481 { 2482 LocalPrePaint(); 2483 2484 sdr::contact::SdrObjectVector aObjectVector; 2485 2486 aObjectVector.push_back(mpRectangleObject); 2487 2488 sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0); 2489 sdr::contact::DisplayInfo aDisplayInfo; 2490 2491 aPainter.ProcessDisplay(aDisplayInfo); 2492 2493 LocalPostPaint(); 2494 } 2495 2496 /************************************************************************* 2497 |* 2498 |* SvxXShadowPreview::SvxXShadowPreview() 2499 |* 2500 *************************************************************************/ 2501 2502 SvxXShadowPreview::SvxXShadowPreview( Window* pParent, const ResId& rResId ) 2503 : SvxPreviewBase( pParent, rResId ), 2504 mpRectangleObject(0), 2505 mpRectangleShadow(0) 2506 { 2507 InitSettings(true, true); 2508 2509 // prepare size 2510 Size aSize = GetOutputSize(); 2511 aSize.Width() = aSize.Width() / 3; 2512 aSize.Height() = aSize.Height() / 3; 2513 2514 // create RectangleObject 2515 const Rectangle aObjectSize( Point( aSize.Width(), aSize.Height() ), aSize ); 2516 mpRectangleObject = new SdrRectObj(aObjectSize); 2517 mpRectangleObject->SetModel(&getModel()); 2518 2519 // create ShadowObject 2520 const Rectangle aShadowSize( Point( aSize.Width(), aSize.Height() ), aSize ); 2521 mpRectangleShadow = new SdrRectObj(aShadowSize); 2522 mpRectangleShadow->SetModel(&getModel()); 2523 } 2524 2525 SvxXShadowPreview::~SvxXShadowPreview() 2526 { 2527 SdrObject::Free(mpRectangleObject); 2528 SdrObject::Free(mpRectangleShadow); 2529 } 2530 2531 void SvxXShadowPreview::SetRectangleAttributes(const SfxItemSet& rItemSet) 2532 { 2533 mpRectangleObject->SetMergedItemSet(rItemSet, true); 2534 mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE)); 2535 } 2536 2537 void SvxXShadowPreview::SetShadowAttributes(const SfxItemSet& rItemSet) 2538 { 2539 mpRectangleShadow->SetMergedItemSet(rItemSet, true); 2540 mpRectangleShadow->SetMergedItem(XLineStyleItem(XLINE_NONE)); 2541 } 2542 2543 void SvxXShadowPreview::SetShadowPosition(const Point& rPos) 2544 { 2545 Rectangle aObjectPosition(mpRectangleObject->GetSnapRect()); 2546 aObjectPosition.Move(rPos.X(), rPos.Y()); 2547 mpRectangleShadow->SetSnapRect(aObjectPosition); 2548 } 2549 2550 void SvxXShadowPreview::Paint( const Rectangle& ) 2551 { 2552 LocalPrePaint(); 2553 2554 sdr::contact::SdrObjectVector aObjectVector; 2555 2556 aObjectVector.push_back(mpRectangleShadow); 2557 aObjectVector.push_back(mpRectangleObject); 2558 2559 sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0); 2560 sdr::contact::DisplayInfo aDisplayInfo; 2561 2562 aPainter.ProcessDisplay(aDisplayInfo); 2563 2564 LocalPostPaint(); 2565 } 2566 2567 // ----------------------------------------------------------------------- 2568 // eof 2569