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 XColorListSharedPtr aColorTab ) 1329 { 1330 long nCount = aColorTab->Count(); 1331 XColorEntry* pEntry; 1332 SetUpdateMode( sal_False ); 1333 1334 for( long i = 0; i < nCount; i++ ) 1335 { 1336 pEntry = aColorTab->GetColor( i ); 1337 InsertEntry( pEntry->GetColor(), pEntry->GetName() ); 1338 } 1339 1340 AdaptDropDownLineCountToMaximum(); 1341 SetUpdateMode( sal_True ); 1342 } 1343 1344 /************************************************************************/ 1345 1346 void ColorLB::Append( const XColorEntry& rEntry ) 1347 { 1348 InsertEntry( rEntry.GetColor(), rEntry.GetName() ); 1349 AdaptDropDownLineCountToMaximum(); 1350 } 1351 1352 /************************************************************************/ 1353 1354 void ColorLB::Modify( const XColorEntry& rEntry, sal_uInt16 nPos ) 1355 { 1356 RemoveEntry( nPos ); 1357 InsertEntry( rEntry.GetColor(), rEntry.GetName(), nPos ); 1358 } 1359 1360 /************************************************************************* 1361 |* 1362 |* Fuellt die Listbox mit Farben und Strings 1363 |* 1364 \************************************************************************/ 1365 1366 void FillAttrLB::Fill( const XColorListSharedPtr aColorTab ) 1367 { 1368 long nCount = aColorTab->Count(); 1369 XColorEntry* pEntry; 1370 SetUpdateMode( sal_False ); 1371 1372 for( long i = 0; i < nCount; i++ ) 1373 { 1374 pEntry = aColorTab->GetColor( i ); 1375 InsertEntry( pEntry->GetColor(), pEntry->GetName() ); 1376 } 1377 1378 AdaptDropDownLineCountToMaximum(); 1379 SetUpdateMode( sal_True ); 1380 } 1381 1382 /************************************************************************* 1383 |* 1384 |* Fuellt die Listbox (vorlaeufig) mit Strings 1385 |* 1386 \************************************************************************/ 1387 1388 HatchingLB::HatchingLB( Window* pParent, ResId Id) 1389 : ListBox( pParent, Id ) 1390 { 1391 SetEdgeBlending(true); 1392 } 1393 1394 HatchingLB::HatchingLB( Window* pParent, WinBits aWB) 1395 : ListBox( pParent, aWB ) 1396 { 1397 SetEdgeBlending(true); 1398 } 1399 1400 void HatchingLB::Fill( const XHatchListSharedPtr aList ) 1401 { 1402 XHatchEntry* pEntry; 1403 long nCount = aList.get() ? aList->Count() : 0; 1404 1405 SetUpdateMode( sal_False ); 1406 1407 for( long i = 0; i < nCount; i++ ) 1408 { 1409 pEntry = aList->GetHatch( i ); 1410 const Bitmap aBitmap = aList->GetUiBitmap( i ); 1411 if( !aBitmap.IsEmpty() ) 1412 InsertEntry( pEntry->GetName(), aBitmap ); 1413 else 1414 InsertEntry( pEntry->GetName() ); 1415 } 1416 1417 AdaptDropDownLineCountToMaximum(); 1418 SetUpdateMode( sal_True ); 1419 } 1420 1421 /************************************************************************/ 1422 1423 void HatchingLB::Append( const XHatchEntry& rEntry, const Bitmap& rBitmap ) 1424 { 1425 if(!rBitmap.IsEmpty()) 1426 { 1427 InsertEntry( rEntry.GetName(), rBitmap ); 1428 } 1429 else 1430 { 1431 InsertEntry( rEntry.GetName() ); 1432 } 1433 1434 AdaptDropDownLineCountToMaximum(); 1435 } 1436 1437 /************************************************************************/ 1438 1439 void HatchingLB::Modify( const XHatchEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap ) 1440 { 1441 RemoveEntry( nPos ); 1442 1443 if( !rBitmap.IsEmpty() ) 1444 { 1445 InsertEntry( rEntry.GetName(), rBitmap, nPos ); 1446 } 1447 else 1448 { 1449 InsertEntry( rEntry.GetName(), nPos ); 1450 } 1451 } 1452 1453 /************************************************************************/ 1454 1455 void HatchingLB::SelectEntryByList( const XHatchListSharedPtr aList, const String& rStr, const XHatch& rHatch, sal_uInt16 nDist ) 1456 { 1457 long nCount = aList.get() ? aList->Count() : 0; 1458 XHatchEntry* pEntry; 1459 sal_Bool bFound = sal_False; 1460 String aStr; 1461 1462 long i; 1463 for( i = 0; i < nCount && !bFound; i++ ) 1464 { 1465 pEntry = aList->GetHatch( i ); 1466 1467 aStr = pEntry->GetName(); 1468 1469 if( rStr == aStr && rHatch == pEntry->GetHatch() ) 1470 bFound = sal_True; 1471 } 1472 if( bFound ) 1473 SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) ); 1474 } 1475 1476 /************************************************************************* 1477 |* 1478 |* Fuellt die Listbox (vorlaeufig) mit Strings 1479 |* 1480 \************************************************************************/ 1481 1482 void FillAttrLB::Fill( const XHatchListSharedPtr aList ) 1483 { 1484 long nCount = aList.get() ? aList->Count() : 0; 1485 XHatchEntry* pEntry; 1486 ListBox::SetUpdateMode( sal_False ); 1487 1488 for( long i = 0; i < nCount; i++ ) 1489 { 1490 pEntry = aList->GetHatch( i ); 1491 const Bitmap aBitmap = aList->GetUiBitmap( i ); 1492 if( !aBitmap.IsEmpty() ) 1493 ListBox::InsertEntry( pEntry->GetName(), aBitmap ); 1494 else 1495 InsertEntry( pEntry->GetName() ); 1496 } 1497 1498 AdaptDropDownLineCountToMaximum(); 1499 ListBox::SetUpdateMode( sal_True ); 1500 } 1501 1502 /************************************************************************* 1503 |* 1504 |* Fuellt die Listbox (vorlaeufig) mit Strings 1505 |* 1506 \************************************************************************/ 1507 1508 GradientLB::GradientLB( Window* pParent, ResId Id) 1509 : ListBox( pParent, Id ) 1510 { 1511 SetEdgeBlending(true); 1512 } 1513 1514 GradientLB::GradientLB( Window* pParent, WinBits aWB) 1515 : ListBox( pParent, aWB ) 1516 { 1517 SetEdgeBlending(true); 1518 } 1519 1520 void GradientLB::Fill( const XGradientListSharedPtr aList ) 1521 { 1522 XGradientEntry* pEntry; 1523 long nCount = aList.get() ? aList->Count() : 0; 1524 1525 SetUpdateMode( sal_False ); 1526 1527 for( long i = 0; i < nCount; i++ ) 1528 { 1529 pEntry = aList->GetGradient( i ); 1530 const Bitmap aBitmap = aList->GetUiBitmap( i ); 1531 if( !aBitmap.IsEmpty() ) 1532 InsertEntry( pEntry->GetName(), aBitmap ); 1533 else 1534 InsertEntry( pEntry->GetName() ); 1535 } 1536 1537 AdaptDropDownLineCountToMaximum(); 1538 SetUpdateMode( sal_True ); 1539 } 1540 1541 /************************************************************************/ 1542 1543 void GradientLB::Append( const XGradientEntry& rEntry, const Bitmap& rBitmap ) 1544 { 1545 if(!rBitmap.IsEmpty()) 1546 { 1547 InsertEntry( rEntry.GetName(), rBitmap ); 1548 } 1549 else 1550 { 1551 InsertEntry( rEntry.GetName() ); 1552 } 1553 1554 AdaptDropDownLineCountToMaximum(); 1555 } 1556 1557 /************************************************************************/ 1558 1559 void GradientLB::Modify( const XGradientEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap ) 1560 { 1561 RemoveEntry( nPos ); 1562 1563 if(!rBitmap.IsEmpty()) 1564 { 1565 InsertEntry( rEntry.GetName(), rBitmap, nPos ); 1566 } 1567 else 1568 { 1569 InsertEntry( rEntry.GetName(), nPos ); 1570 } 1571 } 1572 1573 /************************************************************************/ 1574 1575 void GradientLB::SelectEntryByList( const XGradientListSharedPtr aList, const String& rStr, const XGradient& rGradient, sal_uInt16 nDist ) 1576 { 1577 long nCount = aList.get() ? aList->Count() : 0; 1578 XGradientEntry* pEntry; 1579 sal_Bool bFound = sal_False; 1580 String aStr; 1581 1582 long i; 1583 for( i = 0; i < nCount && !bFound; i++ ) 1584 { 1585 pEntry = aList->GetGradient( i ); 1586 1587 aStr = pEntry->GetName(); 1588 1589 if( rStr == aStr && rGradient == pEntry->GetGradient() ) 1590 bFound = sal_True; 1591 } 1592 if( bFound ) 1593 SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) ); 1594 } 1595 1596 /************************************************************************* 1597 |* 1598 |* Fuellt die Listbox (vorlaeufig) mit Strings 1599 |* 1600 \************************************************************************/ 1601 1602 void FillAttrLB::Fill( const XGradientListSharedPtr aList ) 1603 { 1604 long nCount = aList.get() ? aList->Count() : 0; 1605 XGradientEntry* pEntry; 1606 ListBox::SetUpdateMode( sal_False ); 1607 1608 for( long i = 0; i < nCount; i++ ) 1609 { 1610 pEntry = aList->GetGradient( i ); 1611 const Bitmap aBitmap = aList->GetUiBitmap( i ); 1612 if( !aBitmap.IsEmpty() ) 1613 ListBox::InsertEntry( pEntry->GetName(), aBitmap ); 1614 else 1615 InsertEntry( pEntry->GetName() ); 1616 } 1617 1618 AdaptDropDownLineCountToMaximum(); 1619 ListBox::SetUpdateMode( sal_True ); 1620 } 1621 1622 /************************************************************************* 1623 |* 1624 |* Konstruktor von BitmapLB 1625 |* 1626 \************************************************************************/ 1627 1628 BitmapLB::BitmapLB(Window* pParent, ResId Id) 1629 : ListBox(pParent, Id), 1630 maBitmapEx() 1631 { 1632 SetEdgeBlending(true); 1633 } 1634 1635 /************************************************************************/ 1636 1637 namespace 1638 { 1639 void formatBitmapExToSize(BitmapEx& rBitmapEx, const Size& rSize) 1640 { 1641 if(!rBitmapEx.IsEmpty() && rSize.Width() > 0 && rSize.Height() > 0) 1642 { 1643 VirtualDevice aVirtualDevice; 1644 aVirtualDevice.SetOutputSizePixel(rSize); 1645 1646 if(rBitmapEx.IsTransparent()) 1647 { 1648 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 1649 1650 if(rStyleSettings.GetPreviewUsesCheckeredBackground()) 1651 { 1652 const Point aNull(0, 0); 1653 static const sal_uInt32 nLen(8); 1654 static const Color aW(COL_WHITE); 1655 static const Color aG(0xef, 0xef, 0xef); 1656 1657 aVirtualDevice.DrawCheckered(aNull, rSize, nLen, aW, aG); 1658 } 1659 else 1660 { 1661 aVirtualDevice.SetBackground(rStyleSettings.GetFieldColor()); 1662 aVirtualDevice.Erase(); 1663 } 1664 } 1665 1666 if(rBitmapEx.GetSizePixel().Width() >= rSize.Width() && rBitmapEx.GetSizePixel().Height() >= rSize.Height()) 1667 { 1668 static sal_uInt32 nScaleFlag(BMP_SCALE_FASTESTINTERPOLATE); 1669 1670 rBitmapEx.Scale(rSize, nScaleFlag); 1671 aVirtualDevice.DrawBitmapEx(Point(0, 0), rBitmapEx); 1672 } 1673 else 1674 { 1675 const Size aBitmapSize(rBitmapEx.GetSizePixel()); 1676 1677 for(sal_Int32 y(0); y < rSize.Height(); y += aBitmapSize.Height()) 1678 { 1679 for(sal_Int32 x(0); x < rSize.Width(); x += aBitmapSize.Width()) 1680 { 1681 aVirtualDevice.DrawBitmapEx( 1682 Point(x, y), 1683 rBitmapEx); 1684 } 1685 } 1686 } 1687 1688 rBitmapEx = aVirtualDevice.GetBitmap(Point(0, 0), rSize); 1689 } 1690 } 1691 } // end of anonymous namespace 1692 1693 /************************************************************************/ 1694 1695 void BitmapLB::Fill(const XBitmapListSharedPtr aList) 1696 { 1697 XBitmapEntry* pEntry; 1698 const long nCount(aList.get() ? aList->Count() : 0); 1699 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 1700 const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize()); 1701 1702 SetUpdateMode(false); 1703 1704 for(long i(0); i < nCount; i++) 1705 { 1706 pEntry = aList->GetBitmap(i); 1707 maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx(); 1708 formatBitmapExToSize(maBitmapEx, aSize); 1709 InsertEntry(pEntry->GetName(), maBitmapEx); 1710 } 1711 1712 AdaptDropDownLineCountToMaximum(); 1713 SetUpdateMode(true); 1714 } 1715 1716 /************************************************************************/ 1717 1718 void BitmapLB::Append(const Size& rSize, const XBitmapEntry& rEntry) 1719 { 1720 maBitmapEx = rEntry.GetGraphicObject().GetGraphic().GetBitmapEx(); 1721 1722 if(!maBitmapEx.IsEmpty()) 1723 { 1724 formatBitmapExToSize(maBitmapEx, rSize); 1725 InsertEntry(rEntry.GetName(), maBitmapEx); 1726 } 1727 else 1728 { 1729 InsertEntry(rEntry.GetName()); 1730 } 1731 1732 AdaptDropDownLineCountToMaximum(); 1733 } 1734 1735 /************************************************************************/ 1736 1737 void BitmapLB::Modify(const Size& rSize, const XBitmapEntry& rEntry, sal_uInt16 nPos) 1738 { 1739 RemoveEntry(nPos); 1740 maBitmapEx = rEntry.GetGraphicObject().GetGraphic().GetBitmapEx(); 1741 1742 if(!maBitmapEx.IsEmpty()) 1743 { 1744 formatBitmapExToSize(maBitmapEx, rSize); 1745 InsertEntry(rEntry.GetName(), maBitmapEx, nPos); 1746 } 1747 else 1748 { 1749 InsertEntry(rEntry.GetName()); 1750 } 1751 } 1752 1753 /************************************************************************/ 1754 1755 void BitmapLB::SelectEntryByList(const XBitmapListSharedPtr aList, const String& rStr) 1756 { 1757 const long nCount(aList.get() ? aList->Count() : 0); 1758 XBitmapEntry* pEntry; 1759 bool bFound(false); 1760 long i(0); 1761 1762 for(i = 0; i < nCount && !bFound; i++) 1763 { 1764 pEntry = aList->GetBitmap(i); 1765 const String aStr(pEntry->GetName()); 1766 1767 if(rStr == aStr) 1768 { 1769 bFound = true; 1770 } 1771 } 1772 1773 if(bFound) 1774 { 1775 SelectEntryPos((sal_uInt16)(i - 1)); 1776 } 1777 } 1778 1779 /************************************************************************* 1780 |* 1781 |* Konstruktor von FillAttrLB 1782 |* 1783 \************************************************************************/ 1784 1785 FillAttrLB::FillAttrLB( Window* pParent, ResId Id ) 1786 : ColorListBox(pParent, Id), 1787 maBitmapEx() 1788 { 1789 } 1790 1791 /************************************************************************/ 1792 1793 FillAttrLB::FillAttrLB(Window* pParent, WinBits aWB) 1794 : ColorListBox(pParent, aWB) 1795 { 1796 } 1797 1798 /************************************************************************/ 1799 1800 void FillAttrLB::Fill(const XBitmapListSharedPtr aList) 1801 { 1802 const long nCount(aList.get() ? aList->Count() : 0); 1803 XBitmapEntry* pEntry; 1804 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 1805 const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize()); 1806 1807 ListBox::SetUpdateMode(false); 1808 1809 for(long i(0); i < nCount; i++) 1810 { 1811 pEntry = aList->GetBitmap( i ); 1812 maBitmapEx = pEntry->GetGraphicObject().GetGraphic().GetBitmapEx(); 1813 formatBitmapExToSize(maBitmapEx, aSize); 1814 ListBox::InsertEntry(pEntry->GetName(), maBitmapEx); 1815 } 1816 1817 AdaptDropDownLineCountToMaximum(); 1818 ListBox::SetUpdateMode(true); 1819 } 1820 1821 /************************************************************************/ 1822 1823 void FillAttrLB::SelectEntryByList( const XBitmapListSharedPtr aList, const String& rStr) 1824 { 1825 const long nCount(aList.get() ? aList->Count() : 0); 1826 XBitmapEntry* pEntry; 1827 bool bFound(false); 1828 long i(0); 1829 1830 for(i = 0; i < nCount && !bFound; i++) 1831 { 1832 pEntry = aList->GetBitmap(i); 1833 const String aStr(pEntry->GetName()); 1834 1835 if(rStr == aStr) 1836 { 1837 bFound = true; 1838 } 1839 } 1840 1841 if(bFound) 1842 { 1843 SelectEntryPos((sal_uInt16)(i - 1)); 1844 } 1845 } 1846 1847 /************************************************************************* 1848 |* 1849 |* Fuellt die Listbox (vorlaeufig) mit Strings 1850 |* 1851 \************************************************************************/ 1852 1853 void FillTypeLB::Fill() 1854 { 1855 SetUpdateMode( sal_False ); 1856 1857 InsertEntry( String( SVX_RES( RID_SVXSTR_INVISIBLE ) ) ); 1858 InsertEntry( String( SVX_RES( RID_SVXSTR_COLOR ) ) ); 1859 InsertEntry( String( SVX_RES( RID_SVXSTR_GRADIENT ) ) ); 1860 InsertEntry( String( SVX_RES( RID_SVXSTR_HATCH ) ) ); 1861 InsertEntry( String( SVX_RES( RID_SVXSTR_BITMAP ) ) ); 1862 1863 AdaptDropDownLineCountToMaximum(); 1864 SetUpdateMode( sal_True ); 1865 } 1866 1867 /************************************************************************* 1868 |* 1869 |* Fuellt die Listbox (vorlaeufig) mit Strings 1870 |* 1871 \************************************************************************/ 1872 LineLB::LineLB(Window* pParent, ResId Id) 1873 : ListBox(pParent, Id), 1874 mbAddStandardFields(true) 1875 { 1876 // No EdgeBlending for LineStyle/Dash SetEdgeBlending(true); 1877 } 1878 1879 LineLB::LineLB(Window* pParent, WinBits aWB) 1880 : ListBox(pParent, aWB), 1881 mbAddStandardFields(true) 1882 { 1883 // No EdgeBlending for LineStyle/Dash SetEdgeBlending(true); 1884 } 1885 1886 LineLB::~LineLB() 1887 { 1888 } 1889 1890 void LineLB::setAddStandardFields(bool bNew) 1891 { 1892 if(getAddStandardFields() != bNew) 1893 { 1894 mbAddStandardFields = bNew; 1895 } 1896 } 1897 1898 void LineLB::Fill( const XDashListSharedPtr aList ) 1899 { 1900 Clear(); 1901 1902 if(getAddStandardFields() && aList.get()) 1903 { 1904 // entry for 'none' 1905 InsertEntry(aList->GetStringForUiNoLine()); 1906 1907 // entry for solid line 1908 InsertEntry(aList->GetStringForUiSolidLine(), aList->GetBitmapForUISolidLine()); 1909 } 1910 1911 // entries for dashed lines 1912 long nCount = aList.get() ? aList->Count() : 0; 1913 XDashEntry* pEntry; 1914 SetUpdateMode( sal_False ); 1915 1916 for( long i = 0; i < nCount; i++ ) 1917 { 1918 pEntry = aList->GetDash( i ); 1919 const Bitmap aBitmap = aList->GetUiBitmap( i ); 1920 if( !aBitmap.IsEmpty() ) 1921 { 1922 InsertEntry( pEntry->GetName(), aBitmap ); 1923 //delete pBitmap; 1924 } 1925 else 1926 InsertEntry( pEntry->GetName() ); 1927 } 1928 1929 AdaptDropDownLineCountToMaximum(); 1930 SetUpdateMode( sal_True ); 1931 } 1932 1933 /************************************************************************/ 1934 1935 void LineLB::Append( const XDashEntry& rEntry, const Bitmap& rBitmap ) 1936 { 1937 if(!rBitmap.IsEmpty()) 1938 { 1939 InsertEntry( rEntry.GetName(), rBitmap ); 1940 } 1941 else 1942 { 1943 InsertEntry( rEntry.GetName() ); 1944 } 1945 1946 AdaptDropDownLineCountToMaximum(); 1947 } 1948 1949 /************************************************************************/ 1950 1951 void LineLB::Modify( const XDashEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap ) 1952 { 1953 RemoveEntry( nPos ); 1954 1955 if(!rBitmap.IsEmpty()) 1956 { 1957 InsertEntry( rEntry.GetName(), rBitmap, nPos ); 1958 } 1959 else 1960 { 1961 InsertEntry( rEntry.GetName(), nPos ); 1962 } 1963 } 1964 1965 /************************************************************************/ 1966 1967 void LineLB::SelectEntryByList( const XDashListSharedPtr aList, const String& rStr, const XDash& rDash, sal_uInt16 nDist ) 1968 { 1969 long nCount = aList.get() ? aList->Count() : 0; 1970 XDashEntry* pEntry; 1971 sal_Bool bFound = sal_False; 1972 String aStr; 1973 XDash aDash; 1974 1975 long i; 1976 for( i = 0; i < nCount && !bFound; i++ ) 1977 { 1978 pEntry = aList->GetDash( i ); 1979 1980 aStr = pEntry->GetName(); 1981 aDash = pEntry->GetDash(); 1982 1983 if( rStr == aStr && rDash == aDash ) 1984 bFound = sal_True; 1985 } 1986 if( bFound ) 1987 SelectEntryPos( (sal_uInt16) ( i - 1 + nDist ) ); 1988 } 1989 1990 /************************************************************************* 1991 |* 1992 |* Fuellt die Listbox (vorlaeufig) mit Strings 1993 |* 1994 \************************************************************************/ 1995 LineEndLB::LineEndLB( Window* pParent, ResId Id ) 1996 : ListBox( pParent, Id ) 1997 { 1998 // No EdgeBlending for LineEnds SetEdgeBlending(true); 1999 } 2000 2001 LineEndLB::LineEndLB( Window* pParent, WinBits aWB ) 2002 : ListBox( pParent, aWB ) 2003 { 2004 // No EdgeBlending for LineEnds SetEdgeBlending(true); 2005 } 2006 2007 LineEndLB::~LineEndLB(void) 2008 { 2009 } 2010 2011 2012 void LineEndLB::Fill( const XLineEndListSharedPtr aList, bool bStart ) 2013 { 2014 long nCount = aList.get() ? aList->Count() : 0; 2015 XLineEndEntry* pEntry; 2016 VirtualDevice aVD; 2017 SetUpdateMode( sal_False ); 2018 2019 for( long i = 0; i < nCount; i++ ) 2020 { 2021 pEntry = aList->GetLineEnd( i ); 2022 const Bitmap aBitmap = aList->GetUiBitmap( i ); 2023 if( !aBitmap.IsEmpty() ) 2024 { 2025 Size aBmpSize( aBitmap.GetSizePixel() ); 2026 aVD.SetOutputSizePixel( aBmpSize, sal_False ); 2027 aVD.DrawBitmap( Point(), aBitmap ); 2028 InsertEntry( pEntry->GetName(), 2029 aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ), 2030 Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) ); 2031 //delete pBitmap; 2032 } 2033 else 2034 InsertEntry( pEntry->GetName() ); 2035 } 2036 2037 AdaptDropDownLineCountToMaximum(); 2038 SetUpdateMode( sal_True ); 2039 } 2040 2041 /************************************************************************/ 2042 2043 void LineEndLB::Append( const XLineEndEntry& rEntry, const Bitmap& rBitmap, bool bStart ) 2044 { 2045 if(!rBitmap.IsEmpty()) 2046 { 2047 VirtualDevice aVD; 2048 const Size aBmpSize(rBitmap.GetSizePixel()); 2049 2050 aVD.SetOutputSizePixel(aBmpSize, false); 2051 aVD.DrawBitmap(Point(), rBitmap); 2052 InsertEntry( 2053 rEntry.GetName(), 2054 aVD.GetBitmap(bStart ? Point() : Point(aBmpSize.Width() / 2, 0 ), Size(aBmpSize.Width() / 2, aBmpSize.Height()))); 2055 } 2056 else 2057 { 2058 InsertEntry(rEntry.GetName()); 2059 } 2060 2061 AdaptDropDownLineCountToMaximum(); 2062 } 2063 2064 /************************************************************************/ 2065 2066 void LineEndLB::Modify( const XLineEndEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap, bool bStart ) 2067 { 2068 RemoveEntry( nPos ); 2069 2070 if(!rBitmap.IsEmpty()) 2071 { 2072 VirtualDevice aVD; 2073 const Size aBmpSize(rBitmap.GetSizePixel()); 2074 2075 aVD.SetOutputSizePixel(aBmpSize, false); 2076 aVD.DrawBitmap(Point(), rBitmap); 2077 InsertEntry( 2078 rEntry.GetName(), 2079 aVD.GetBitmap(bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ), Size( aBmpSize.Width() / 2, aBmpSize.Height())), 2080 nPos); 2081 } 2082 else 2083 { 2084 InsertEntry(rEntry.GetName(), nPos); 2085 } 2086 } 2087 2088 ////////////////////////////////////////////////////////////////////////////// 2089 2090 void SvxPreviewBase::InitSettings(bool bForeground, bool bBackground) 2091 { 2092 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 2093 2094 if(bForeground) 2095 { 2096 svtools::ColorConfig aColorConfig; 2097 Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor); 2098 2099 if(IsControlForeground()) 2100 { 2101 aTextColor = GetControlForeground(); 2102 } 2103 2104 getBufferDevice().SetTextColor(aTextColor); 2105 } 2106 2107 if(bBackground) 2108 { 2109 if(IsControlBackground()) 2110 { 2111 getBufferDevice().SetBackground(GetControlBackground()); 2112 } 2113 else 2114 { 2115 getBufferDevice().SetBackground(rStyleSettings.GetWindowColor()); 2116 } 2117 } 2118 2119 // do not paint background self, it gets painted buffered 2120 SetControlBackground(); 2121 SetBackground(); 2122 2123 Invalidate(); 2124 } 2125 2126 SvxPreviewBase::SvxPreviewBase( Window* pParent, const ResId& rResId ) 2127 : Control( pParent, rResId ), 2128 mpModel( new SdrModel() ), 2129 mpBufferDevice( new VirtualDevice(*this) ) 2130 { 2131 // Draw the control's border as a flat thin black line. 2132 SetBorderStyle(WINDOW_BORDER_MONO); 2133 SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR ); 2134 SetMapMode(MAP_100TH_MM); 2135 2136 // init model 2137 mpModel->GetItemPool().FreezeIdRanges(); 2138 } 2139 2140 SvxPreviewBase::~SvxPreviewBase() 2141 { 2142 delete mpModel; 2143 delete mpBufferDevice; 2144 } 2145 2146 void SvxPreviewBase::LocalPrePaint() 2147 { 2148 // init BufferDevice 2149 if(mpBufferDevice->GetOutputSizePixel() != GetOutputSizePixel()) 2150 { 2151 mpBufferDevice->SetDrawMode(GetDrawMode()); 2152 mpBufferDevice->SetSettings(GetSettings()); 2153 mpBufferDevice->SetAntialiasing(GetAntialiasing()); 2154 mpBufferDevice->SetOutputSizePixel(GetOutputSizePixel()); 2155 mpBufferDevice->SetMapMode(GetMapMode()); 2156 } 2157 2158 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 2159 2160 if(rStyleSettings.GetPreviewUsesCheckeredBackground()) 2161 { 2162 const Point aNull(0, 0); 2163 static const sal_uInt32 nLen(8); 2164 static const Color aW(COL_WHITE); 2165 static const Color aG(0xef, 0xef, 0xef); 2166 const bool bWasEnabled(mpBufferDevice->IsMapModeEnabled()); 2167 2168 mpBufferDevice->EnableMapMode(false); 2169 mpBufferDevice->DrawCheckered(aNull, mpBufferDevice->GetOutputSizePixel(), nLen, aW, aG); 2170 mpBufferDevice->EnableMapMode(bWasEnabled); 2171 } 2172 else 2173 { 2174 mpBufferDevice->Erase(); 2175 } 2176 } 2177 2178 void SvxPreviewBase::LocalPostPaint() 2179 { 2180 // copy to front (in pixel mode) 2181 const bool bWasEnabledSrc(mpBufferDevice->IsMapModeEnabled()); 2182 const bool bWasEnabledDst(IsMapModeEnabled()); 2183 const Point aEmptyPoint; 2184 2185 mpBufferDevice->EnableMapMode(false); 2186 EnableMapMode(false); 2187 2188 DrawOutDev( 2189 aEmptyPoint, GetOutputSizePixel(), 2190 aEmptyPoint, GetOutputSizePixel(), 2191 *mpBufferDevice); 2192 2193 mpBufferDevice->EnableMapMode(bWasEnabledSrc); 2194 EnableMapMode(bWasEnabledDst); 2195 } 2196 2197 void SvxPreviewBase::StateChanged(StateChangedType nType) 2198 { 2199 Control::StateChanged(nType); 2200 2201 if(STATE_CHANGE_CONTROLFOREGROUND == nType) 2202 { 2203 InitSettings(true, false); 2204 } 2205 else if(STATE_CHANGE_CONTROLBACKGROUND == nType) 2206 { 2207 InitSettings(false, true); 2208 } 2209 } 2210 2211 void SvxPreviewBase::DataChanged(const DataChangedEvent& rDCEvt) 2212 { 2213 SetDrawMode(GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR); 2214 2215 if((DATACHANGED_SETTINGS == rDCEvt.GetType()) && (rDCEvt.GetFlags() & SETTINGS_STYLE)) 2216 { 2217 InitSettings(true, true); 2218 } 2219 else 2220 { 2221 Control::DataChanged(rDCEvt); 2222 } 2223 } 2224 2225 /************************************************************************* 2226 |* 2227 |* SvxXLinePreview::SvxXLinePreview() 2228 |* 2229 *************************************************************************/ 2230 2231 SvxXLinePreview::SvxXLinePreview( Window* pParent, const ResId& rResId ) 2232 : SvxPreviewBase( pParent, rResId ), 2233 mpLineObjA( 0L ), 2234 mpLineObjB( 0L ), 2235 mpLineObjC( 0L ), 2236 mpGraphic( 0L ), 2237 mbWithSymbol( sal_False ) 2238 { 2239 const Size aOutputSize(GetOutputSize()); 2240 InitSettings( sal_True, sal_True ); 2241 2242 const sal_Int32 nDistance(500L); 2243 const sal_Int32 nAvailableLength(aOutputSize.Width() - (4 * nDistance)); 2244 2245 // create DrawObectA 2246 const sal_Int32 aYPosA(aOutputSize.Height() / 2); 2247 const basegfx::B2DPoint aPointA1( nDistance, aYPosA); 2248 const basegfx::B2DPoint aPointA2( aPointA1.getX() + ((nAvailableLength * 14) / 20), aYPosA ); 2249 basegfx::B2DPolygon aPolygonA; 2250 aPolygonA.append(aPointA1); 2251 aPolygonA.append(aPointA2); 2252 mpLineObjA = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygonA)); 2253 mpLineObjA->SetModel(&getModel()); 2254 2255 // create DrawObectB 2256 const sal_Int32 aYPosB1((aOutputSize.Height() * 3) / 4); 2257 const sal_Int32 aYPosB2((aOutputSize.Height() * 1) / 4); 2258 const basegfx::B2DPoint aPointB1( aPointA2.getX() + nDistance, aYPosB1); 2259 const basegfx::B2DPoint aPointB2( aPointB1.getX() + ((nAvailableLength * 2) / 20), aYPosB2 ); 2260 const basegfx::B2DPoint aPointB3( aPointB2.getX() + ((nAvailableLength * 2) / 20), aYPosB1 ); 2261 basegfx::B2DPolygon aPolygonB; 2262 aPolygonB.append(aPointB1); 2263 aPolygonB.append(aPointB2); 2264 aPolygonB.append(aPointB3); 2265 mpLineObjB = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonB)); 2266 mpLineObjB->SetModel(&getModel()); 2267 2268 // create DrawObectC 2269 const basegfx::B2DPoint aPointC1( aPointB3.getX() + nDistance, aYPosB1); 2270 const basegfx::B2DPoint aPointC2( aPointC1.getX() + ((nAvailableLength * 1) / 20), aYPosB2 ); 2271 const basegfx::B2DPoint aPointC3( aPointC2.getX() + ((nAvailableLength * 1) / 20), aYPosB1 ); 2272 basegfx::B2DPolygon aPolygonC; 2273 aPolygonC.append(aPointC1); 2274 aPolygonC.append(aPointC2); 2275 aPolygonC.append(aPointC3); 2276 mpLineObjC = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonC)); 2277 mpLineObjC->SetModel(&getModel()); 2278 } 2279 2280 SvxXLinePreview::~SvxXLinePreview() 2281 { 2282 SdrObject::Free( mpLineObjA ); 2283 SdrObject::Free( mpLineObjB ); 2284 SdrObject::Free( mpLineObjC ); 2285 } 2286 2287 // ----------------------------------------------------------------------- 2288 2289 void SvxXLinePreview::SetSymbol(Graphic* p,const Size& s) 2290 { 2291 mpGraphic = p; 2292 maSymbolSize = s; 2293 } 2294 2295 // ----------------------------------------------------------------------- 2296 2297 void SvxXLinePreview::ResizeSymbol(const Size& s) 2298 { 2299 if ( s != maSymbolSize ) 2300 { 2301 maSymbolSize = s; 2302 Invalidate(); 2303 } 2304 } 2305 2306 // ----------------------------------------------------------------------- 2307 2308 void SvxXLinePreview::SetLineAttributes(const SfxItemSet& rItemSet) 2309 { 2310 // Set ItemSet at objects 2311 mpLineObjA->SetMergedItemSet(rItemSet); 2312 2313 // At line joints, do not use arrows 2314 SfxItemSet aTempSet(rItemSet); 2315 aTempSet.ClearItem(XATTR_LINESTART); 2316 aTempSet.ClearItem(XATTR_LINEEND); 2317 2318 mpLineObjB->SetMergedItemSet(aTempSet); 2319 mpLineObjC->SetMergedItemSet(aTempSet); 2320 } 2321 2322 // ----------------------------------------------------------------------- 2323 2324 void SvxXLinePreview::Paint( const Rectangle& ) 2325 { 2326 LocalPrePaint(); 2327 2328 // paint objects to buffer device 2329 sdr::contact::SdrObjectVector aObjectVector; 2330 aObjectVector.push_back(mpLineObjA); 2331 aObjectVector.push_back(mpLineObjB); 2332 aObjectVector.push_back(mpLineObjC); 2333 2334 sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0); 2335 sdr::contact::DisplayInfo aDisplayInfo; 2336 2337 // do processing 2338 aPainter.ProcessDisplay(aDisplayInfo); 2339 2340 if ( mbWithSymbol && mpGraphic ) 2341 { 2342 const Size aOutputSize(GetOutputSize()); 2343 Point aPos = Point( aOutputSize.Width() / 3, aOutputSize.Height() / 2 ); 2344 aPos.X() -= maSymbolSize.Width() / 2; 2345 aPos.Y() -= maSymbolSize.Height() / 2; 2346 mpGraphic->Draw( &getBufferDevice(), aPos, maSymbolSize ); 2347 } 2348 2349 LocalPostPaint(); 2350 } 2351 2352 /************************************************************************* 2353 |* 2354 |* SvxXRectPreview::SvxXRectPreview() 2355 |* 2356 *************************************************************************/ 2357 2358 SvxXRectPreview::SvxXRectPreview( Window* pParent, const ResId& rResId ) 2359 : SvxPreviewBase( pParent, rResId ), 2360 mpRectangleObject(0) 2361 { 2362 InitSettings(true, true); 2363 2364 // create RectangleObject 2365 const Rectangle aObjectSize(Point(), GetOutputSize()); 2366 mpRectangleObject = new SdrRectObj(aObjectSize); 2367 mpRectangleObject->SetModel(&getModel()); 2368 } 2369 2370 SvxXRectPreview::~SvxXRectPreview() 2371 { 2372 SdrObject::Free(mpRectangleObject); 2373 } 2374 2375 void SvxXRectPreview::SetAttributes(const SfxItemSet& rItemSet) 2376 { 2377 mpRectangleObject->SetMergedItemSet(rItemSet, true); 2378 mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE)); 2379 } 2380 2381 void SvxXRectPreview::Paint( const Rectangle& ) 2382 { 2383 LocalPrePaint(); 2384 2385 sdr::contact::SdrObjectVector aObjectVector; 2386 2387 aObjectVector.push_back(mpRectangleObject); 2388 2389 sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0); 2390 sdr::contact::DisplayInfo aDisplayInfo; 2391 2392 aPainter.ProcessDisplay(aDisplayInfo); 2393 2394 LocalPostPaint(); 2395 } 2396 2397 /************************************************************************* 2398 |* 2399 |* SvxXShadowPreview::SvxXShadowPreview() 2400 |* 2401 *************************************************************************/ 2402 2403 SvxXShadowPreview::SvxXShadowPreview( Window* pParent, const ResId& rResId ) 2404 : SvxPreviewBase( pParent, rResId ), 2405 mpRectangleObject(0), 2406 mpRectangleShadow(0) 2407 { 2408 InitSettings(true, true); 2409 2410 // prepare size 2411 Size aSize = GetOutputSize(); 2412 aSize.Width() = aSize.Width() / 3; 2413 aSize.Height() = aSize.Height() / 3; 2414 2415 // create RectangleObject 2416 const Rectangle aObjectSize( Point( aSize.Width(), aSize.Height() ), aSize ); 2417 mpRectangleObject = new SdrRectObj(aObjectSize); 2418 mpRectangleObject->SetModel(&getModel()); 2419 2420 // create ShadowObject 2421 const Rectangle aShadowSize( Point( aSize.Width(), aSize.Height() ), aSize ); 2422 mpRectangleShadow = new SdrRectObj(aShadowSize); 2423 mpRectangleShadow->SetModel(&getModel()); 2424 } 2425 2426 SvxXShadowPreview::~SvxXShadowPreview() 2427 { 2428 SdrObject::Free(mpRectangleObject); 2429 SdrObject::Free(mpRectangleShadow); 2430 } 2431 2432 void SvxXShadowPreview::SetRectangleAttributes(const SfxItemSet& rItemSet) 2433 { 2434 mpRectangleObject->SetMergedItemSet(rItemSet, true); 2435 mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE)); 2436 } 2437 2438 void SvxXShadowPreview::SetShadowAttributes(const SfxItemSet& rItemSet) 2439 { 2440 mpRectangleShadow->SetMergedItemSet(rItemSet, true); 2441 mpRectangleShadow->SetMergedItem(XLineStyleItem(XLINE_NONE)); 2442 } 2443 2444 void SvxXShadowPreview::SetShadowPosition(const Point& rPos) 2445 { 2446 Rectangle aObjectPosition(mpRectangleObject->GetSnapRect()); 2447 aObjectPosition.Move(rPos.X(), rPos.Y()); 2448 mpRectangleShadow->SetSnapRect(aObjectPosition); 2449 } 2450 2451 void SvxXShadowPreview::Paint( const Rectangle& ) 2452 { 2453 LocalPrePaint(); 2454 2455 sdr::contact::SdrObjectVector aObjectVector; 2456 2457 aObjectVector.push_back(mpRectangleShadow); 2458 aObjectVector.push_back(mpRectangleObject); 2459 2460 sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0); 2461 sdr::contact::DisplayInfo aDisplayInfo; 2462 2463 aPainter.ProcessDisplay(aDisplayInfo); 2464 2465 LocalPostPaint(); 2466 } 2467 2468 // ----------------------------------------------------------------------- 2469 // eof 2470