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