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_vcl.hxx" 30 #include <vcl/settings.hxx> 31 #include <tools/poly.hxx> 32 #include <vcl/outdev.hxx> 33 #include <vcl/bmpacc.hxx> 34 #include <vcl/decoview.hxx> 35 #include <vcl/window.hxx> 36 #include <vcl/ctrl.hxx> 37 38 // ======================================================================= 39 40 #define BUTTON_DRAW_FLATTEST (BUTTON_DRAW_FLAT | \ 41 BUTTON_DRAW_PRESSED | \ 42 BUTTON_DRAW_CHECKED | \ 43 BUTTON_DRAW_HIGHLIGHT) 44 45 // ======================================================================= 46 47 static void ImplDrawSymbol( OutputDevice* pDev, const Rectangle& rRect, 48 SymbolType eType ) 49 { 50 // Groessen vorberechnen 51 long nMin = Min( rRect.GetWidth(), rRect.GetHeight() ); 52 long nSize = nMin; 53 54 if ( nMin & 0x01 ) 55 nMin--; 56 Point aCenter = rRect.Center(); 57 long nCenterX = aCenter.X(); 58 long nCenterY = aCenter.Y(); 59 long n2 = nMin / 2; 60 long n4 = nMin / 4; 61 long nLeft; 62 long nTop; 63 long nRight; 64 long nBottom; 65 long nTemp; 66 long i; 67 68 switch ( eType ) 69 { 70 case SYMBOL_ARROW_UP: 71 { 72 if ( !(nMin & 0x01) ) 73 { 74 n2--; 75 n4--; 76 } 77 nTop = nCenterY-n2; 78 nBottom = nCenterY; 79 pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) ); 80 i = 1; 81 while ( i <= n2 ) 82 { 83 nTop++; 84 nTemp = nCenterX-i; 85 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) ); 86 nTemp = nCenterX+i; 87 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) ); 88 i++; 89 } 90 pDev->DrawRect( Rectangle( nCenterX-n4, nBottom, 91 nCenterX+n4, nBottom+n2 ) ); 92 } 93 break; 94 95 case SYMBOL_ARROW_DOWN: 96 { 97 if ( !(nMin & 0x01) ) 98 { 99 n2--; 100 n4--; 101 } 102 nTop = nCenterY; 103 nBottom = nCenterY+n2; 104 pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) ); 105 i = 1; 106 while ( i <= n2 ) 107 { 108 nBottom--; 109 nTemp = nCenterX-i; 110 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) ); 111 nTemp = nCenterX+i; 112 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) ); 113 i++; 114 } 115 pDev->DrawRect( Rectangle( nCenterX-n4, nTop-n2, 116 nCenterX+n4, nTop ) ); 117 } 118 break; 119 120 case SYMBOL_ARROW_LEFT: 121 { 122 if ( !(nMin & 0x01) ) 123 { 124 n2--; 125 n4--; 126 } 127 nLeft = nCenterX-n2; 128 nRight = nCenterX; 129 pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) ); 130 i = 1; 131 while ( i <= n2 ) 132 { 133 nLeft++; 134 nTemp = nCenterY-i; 135 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) ); 136 nTemp = nCenterY+i; 137 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) ); 138 i++; 139 } 140 pDev->DrawRect( Rectangle( nRight, nCenterY-n4, 141 nRight+n2, nCenterY+n4 ) ); 142 } 143 break; 144 145 case SYMBOL_ARROW_RIGHT: 146 { 147 if ( !(nMin & 0x01) ) 148 { 149 n2--; 150 n4--; 151 } 152 nLeft = nCenterX; 153 nRight = nCenterX+n2; 154 pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) ); 155 i = 1; 156 while ( i <= n2 ) 157 { 158 nRight--; 159 nTemp = nCenterY-i; 160 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) ); 161 nTemp = nCenterY+i; 162 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) ); 163 i++; 164 } 165 pDev->DrawRect( Rectangle( nLeft-n2, nCenterY-n4, 166 nLeft, nCenterY+n4 ) ); 167 } 168 break; 169 170 171 case SYMBOL_SPIN_UP: 172 { 173 if ( !(nMin & 0x01) ) 174 n2--; 175 nTop = nCenterY-n4; 176 nBottom = nTop+n2; 177 pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) ); 178 i = 1; 179 while ( i <= n2 ) 180 { 181 nTop++; 182 nTemp = nCenterX-i; 183 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) ); 184 nTemp = nCenterX+i; 185 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) ); 186 i++; 187 } 188 } 189 break; 190 191 case SYMBOL_SPIN_DOWN: 192 { 193 if ( !(nMin & 0x01) ) 194 n2--; 195 nTop = nCenterY-n4; 196 nBottom = nTop+n2; 197 pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) ); 198 i = 1; 199 while ( i <= n2 ) 200 { 201 nBottom--; 202 nTemp = nCenterX-i; 203 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) ); 204 nTemp = nCenterX+i; 205 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) ); 206 i++; 207 } 208 } 209 break; 210 211 case SYMBOL_SPIN_LEFT: 212 case SYMBOL_FIRST: 213 case SYMBOL_PREV: 214 case SYMBOL_REVERSEPLAY: 215 { 216 if ( !(nMin & 0x01) ) 217 n2--; 218 nLeft = nCenterX-n4; 219 if ( eType == SYMBOL_FIRST ) 220 nLeft++; 221 nRight = nLeft+n2; 222 pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) ); 223 i = 1; 224 while ( i <= n2 ) 225 { 226 nLeft++; 227 nTemp = nCenterY-i; 228 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) ); 229 nTemp = nCenterY+i; 230 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) ); 231 i++; 232 } 233 if ( eType == SYMBOL_FIRST ) 234 { 235 pDev->DrawRect( Rectangle( nCenterX-n4-1, nCenterY-n2, 236 nCenterX-n4-1, nCenterY+n2 ) ); 237 } 238 } 239 break; 240 241 case SYMBOL_SPIN_RIGHT: 242 case SYMBOL_LAST: 243 case SYMBOL_NEXT: 244 case SYMBOL_PLAY: 245 { 246 if ( !(nMin & 0x01) ) 247 n2--; 248 nLeft = nCenterX-n4; 249 if ( eType == SYMBOL_LAST ) 250 nLeft--; 251 nRight = nLeft+n2; 252 pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) ); 253 i = 1; 254 while ( i <= n2 ) 255 { 256 nRight--; 257 nTemp = nCenterY-i; 258 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) ); 259 nTemp = nCenterY+i; 260 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) ); 261 i++; 262 } 263 if ( eType == SYMBOL_LAST ) 264 { 265 pDev->DrawRect( Rectangle( nCenterX+n4+1, nCenterY-n2, 266 nCenterX+n4+1, nCenterY+n2 ) ); 267 } 268 } 269 break; 270 271 case SYMBOL_PAGEUP: 272 case SYMBOL_PAGEDOWN: 273 { 274 if ( !( nSize & 0x01 )) 275 { 276 // An even rectangle size means we have to use a smaller size for 277 // our arrows as we want to use one pixel for the spearhead! Otherwise 278 // it will be clipped! 279 nCenterX++; 280 n2 = ( nMin-1 ) / 2; 281 n4 = ( nMin-1 ) / 4; 282 } 283 284 nTop = nCenterY-n2; 285 nBottom = nCenterY-1; 286 pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) ); 287 pDev->DrawRect( Rectangle( nCenterX, nTop+n2+1, nCenterX, nBottom+n2+1 ) ); 288 i = 1; 289 while ( i < n2 ) 290 { 291 ( eType == SYMBOL_PAGEUP ) ? nTop++ : nBottom--; 292 nTemp = nCenterX-i; 293 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) ); 294 pDev->DrawRect( Rectangle( nTemp, nTop+n2+1, nTemp, nBottom+n2+1 ) ); 295 nTemp = nCenterX+i; 296 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) ); 297 pDev->DrawRect( Rectangle( nTemp, nTop+n2+1, nTemp, nBottom+n2+1 ) ); 298 i++; 299 } 300 } 301 break; 302 303 case SYMBOL_RADIOCHECKMARK: 304 case SYMBOL_RECORD: 305 { 306 const long nExt = ( n2 << 1 ) + 1; 307 Bitmap aBmp( Size( nExt, nExt ), 1 ); 308 BitmapWriteAccess* pWAcc = aBmp.AcquireWriteAccess(); 309 310 if( pWAcc ) 311 { 312 const Color aWhite( COL_WHITE ); 313 const Color aBlack( COL_BLACK ); 314 315 pWAcc->Erase( aWhite ); 316 pWAcc->SetLineColor( aBlack ); 317 pWAcc->SetFillColor( aBlack ); 318 pWAcc->DrawPolygon( Polygon( Point( n2, n2 ), n2, n2 ) ); 319 aBmp.ReleaseAccess( pWAcc ); 320 pDev->DrawMask( Point( nCenterX - n2, nCenterY - n2 ), aBmp, pDev->GetFillColor() ); 321 } 322 else 323 pDev->DrawPolygon( Polygon( Point( nCenterX, nCenterY ), n2, n2 ) ); 324 } 325 break; 326 327 case SYMBOL_STOP: 328 { 329 nLeft = nCenterX-n2; 330 nRight = nCenterX+n2; 331 nTop = nCenterY-n2; 332 nBottom = nCenterY+n2; 333 pDev->DrawRect( Rectangle( nLeft, nTop, nRight, nBottom ) ); 334 } 335 break; 336 337 case SYMBOL_PAUSE: 338 { 339 nLeft = nCenterX-n2; 340 nRight = nCenterX+n2-1; 341 nTop = nCenterY-n2; 342 nBottom = nCenterY+n2; 343 pDev->DrawRect( Rectangle( nLeft, nTop, nCenterX-2, nBottom ) ); 344 pDev->DrawRect( Rectangle( nCenterX+1, nTop, nRight, nBottom ) ); 345 } 346 break; 347 348 case SYMBOL_WINDSTART: 349 case SYMBOL_WINDBACKWARD: 350 { 351 nLeft = nCenterX-n2+1; 352 nRight = nCenterX; 353 pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) ); 354 pDev->DrawRect( Rectangle( nLeft+n2, nCenterY, nRight+n2, nCenterY ) ); 355 i = 1; 356 while ( i < n2 ) 357 { 358 nLeft++; 359 nTemp = nCenterY-i; 360 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) ); 361 pDev->DrawRect( Rectangle( nLeft+n2, nTemp, nRight+n2, nTemp ) ); 362 nTemp = nCenterY+i; 363 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) ); 364 pDev->DrawRect( Rectangle( nLeft+n2, nTemp, nRight+n2, nTemp ) ); 365 i++; 366 } 367 if ( eType == SYMBOL_WINDSTART ) 368 { 369 pDev->DrawRect( Rectangle( nCenterX-n2, nCenterY-n2, 370 nCenterX-n2, nCenterY+n2 ) ); 371 } 372 } 373 break; 374 375 case SYMBOL_WINDEND: 376 case SYMBOL_WINDFORWARD: 377 { 378 nLeft = nCenterX-n2; 379 nRight = nCenterX-1; 380 pDev->DrawRect( Rectangle( nLeft, nCenterY, nRight, nCenterY ) ); 381 pDev->DrawRect( Rectangle( nLeft+n2, nCenterY, nRight+n2, nCenterY ) ); 382 i = 1; 383 while ( i < n2 ) 384 { 385 nRight--; 386 nTemp = nCenterY-i; 387 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) ); 388 pDev->DrawRect( Rectangle( nLeft+n2, nTemp, nRight+n2, nTemp ) ); 389 nTemp = nCenterY+i; 390 pDev->DrawRect( Rectangle( nLeft, nTemp, nRight, nTemp ) ); 391 pDev->DrawRect( Rectangle( nLeft+n2, nTemp, nRight+n2, nTemp ) ); 392 i++; 393 } 394 if ( eType == SYMBOL_WINDEND ) 395 { 396 pDev->DrawRect( Rectangle( nCenterX+n2, nCenterY-n2, 397 nCenterX+n2, nCenterY+n2 ) ); 398 } 399 } 400 break; 401 402 case SYMBOL_CLOSE: 403 { 404 Size aRectSize( 2, 1 ); 405 if ( nMin < 8 ) 406 aRectSize.Width() = 1; 407 else if ( nMin > 20 ) 408 aRectSize.Width() = nMin/10; 409 nLeft = nCenterX-n2+1; 410 nTop = nCenterY-n2+1; 411 nBottom = nCenterY-n2+nMin-aRectSize.Width()+1; 412 i = 0; 413 while ( i < nMin-aRectSize.Width()+1 ) 414 { 415 pDev->DrawRect( Rectangle( Point( nLeft+i, nTop+i ), aRectSize ) ); 416 pDev->DrawRect( Rectangle( Point( nLeft+i, nBottom-i ), aRectSize ) ); 417 i++; 418 } 419 } 420 break; 421 422 case SYMBOL_ROLLUP: 423 case SYMBOL_ROLLDOWN: 424 { 425 Rectangle aRect( nCenterX-n2, nCenterY-n2, 426 nCenterX+n2, nCenterY-n2+1 ); 427 pDev->DrawRect( aRect ); 428 if ( eType == SYMBOL_ROLLDOWN ) 429 { 430 Rectangle aTempRect = aRect; 431 aTempRect.Bottom() = nCenterY+n2; 432 aTempRect.Right() = aRect.Left(); 433 pDev->DrawRect( aTempRect ); 434 aTempRect.Left() = aRect.Right(); 435 aTempRect.Right() = aRect.Right(); 436 pDev->DrawRect( aTempRect ); 437 aTempRect.Top() = aTempRect.Bottom(); 438 aTempRect.Left() = aRect.Left(); 439 pDev->DrawRect( aTempRect ); 440 } 441 } 442 break; 443 case SYMBOL_CHECKMARK: 444 { 445 // #106953# never mirror checkmarks 446 sal_Bool bRTL = pDev->ImplHasMirroredGraphics() && pDev->IsRTLEnabled(); 447 Point aPos1( bRTL ? rRect.Right() : rRect.Left(), 448 rRect.Bottom() - rRect.GetHeight() / 3 ); 449 Point aPos2( bRTL ? rRect.Right() - rRect.GetWidth()/3 : rRect.Left() + rRect.GetWidth()/3, 450 rRect.Bottom() ); 451 Point aPos3( bRTL ? rRect.TopLeft() : rRect.TopRight() ); 452 Size aRectSize( 1, 2 ); 453 long nStepsY = aPos2.Y()-aPos1.Y(); 454 long nX = aPos1.X(); 455 long nY = aPos1.Y(); 456 long n; 457 for ( n = 0; n <= nStepsY; n++ ) 458 { 459 if( bRTL ) 460 nX--; 461 pDev->DrawRect( Rectangle( Point( nX, nY++ ), aRectSize ) ); 462 if( !bRTL ) 463 nX++; 464 } 465 nStepsY = aPos2.Y()-aPos3.Y(); 466 nX = aPos2.X(); 467 nY = aPos2.Y(); 468 for ( n = 0; n <= nStepsY; n++ ) 469 { 470 if( bRTL ) 471 if ( --nX < rRect.Left() ) 472 break; 473 pDev->DrawRect( Rectangle( Point( nX, nY-- ), aRectSize ) ); 474 if( !bRTL ) 475 if ( ++nX > rRect.Right() ) 476 break; 477 } 478 } 479 break; 480 481 case SYMBOL_SPIN_UPDOWN: 482 { 483 nTop = nCenterY-n2-1; 484 nBottom = nTop+n2; 485 pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) ); 486 i = 1; 487 while ( i <= n2 ) 488 { 489 nTop++; 490 nTemp = nCenterX-i; 491 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) ); 492 nTemp = nCenterX+i; 493 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) ); 494 i++; 495 } 496 nTop = nCenterY+1; 497 nBottom = nTop+n2; 498 pDev->DrawRect( Rectangle( nCenterX, nTop, nCenterX, nBottom ) ); 499 i = 1; 500 while ( i <= n2 ) 501 { 502 nBottom--; 503 nTemp = nCenterX-i; 504 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) ); 505 nTemp = nCenterX+i; 506 pDev->DrawRect( Rectangle( nTemp, nTop, nTemp, nBottom ) ); 507 i++; 508 } 509 } 510 break; 511 512 513 case SYMBOL_FLOAT: 514 { 515 Rectangle aRect( nCenterX-n2, nCenterY-n2+3, 516 nCenterX+n2-2, nCenterY-n2+4 ); 517 pDev->DrawRect( aRect ); 518 Rectangle aTempRect = aRect; 519 aTempRect.Bottom() = nCenterY+n2; 520 aTempRect.Right() = aRect.Left(); 521 pDev->DrawRect( aTempRect ); 522 aTempRect.Left() = aRect.Right(); 523 aTempRect.Right() = aRect.Right(); 524 pDev->DrawRect( aTempRect ); 525 aTempRect.Top() = aTempRect.Bottom(); 526 aTempRect.Left() = aRect.Left(); 527 pDev->DrawRect( aTempRect ); 528 aRect = Rectangle( nCenterX-n2+2, nCenterY-n2, 529 nCenterX+n2, nCenterY-n2+1 ); 530 pDev->DrawRect( aRect ); 531 aTempRect = aRect; 532 aTempRect.Bottom() = nCenterY+n2-3; 533 aTempRect.Right() = aRect.Left(); 534 pDev->DrawRect( aTempRect ); 535 aTempRect.Left() = aRect.Right(); 536 aTempRect.Right() = aRect.Right(); 537 pDev->DrawRect( aTempRect ); 538 aTempRect.Top() = aTempRect.Bottom(); 539 aTempRect.Left() = aRect.Left(); 540 pDev->DrawRect( aTempRect ); 541 } 542 break; 543 case SYMBOL_DOCK: 544 { 545 Rectangle aRect( nCenterX-n2, nCenterY-n2, 546 nCenterX+n2, nCenterY-n2 ); 547 pDev->DrawRect( aRect ); 548 Rectangle aTempRect = aRect; 549 aTempRect.Bottom() = nCenterY+n2; 550 aTempRect.Right() = aRect.Left(); 551 pDev->DrawRect( aTempRect ); 552 aTempRect.Left() = aRect.Right(); 553 aTempRect.Right() = aRect.Right(); 554 pDev->DrawRect( aTempRect ); 555 aTempRect.Top() = aTempRect.Bottom(); 556 aTempRect.Left() = aRect.Left(); 557 pDev->DrawRect( aTempRect ); 558 } 559 break; 560 case SYMBOL_HIDE: 561 { 562 long nExtra = nMin / 8; 563 Rectangle aRect( nCenterX-n2+nExtra, nCenterY+n2-1, 564 nCenterX+n2-nExtra, nCenterY+n2 ); 565 pDev->DrawRect( aRect ); 566 } 567 break; 568 } 569 } 570 571 // ----------------------------------------------------------------------- 572 573 void DecorationView::DrawSymbol( const Rectangle& rRect, SymbolType eType, 574 const Color& rColor, sal_uInt16 nStyle ) 575 { 576 const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings(); 577 Rectangle aRect = mpOutDev->LogicToPixel( rRect ); 578 Color aOldLineColor = mpOutDev->GetLineColor(); 579 Color aOldFillColor = mpOutDev->GetFillColor(); 580 sal_Bool bOldMapMode = mpOutDev->IsMapModeEnabled(); 581 mpOutDev->SetLineColor(); 582 mpOutDev->SetFillColor( rColor ); 583 mpOutDev->EnableMapMode( sal_False ); 584 585 if ( (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) || 586 (mpOutDev->GetOutDevType() == OUTDEV_PRINTER) ) 587 nStyle |= BUTTON_DRAW_MONO; 588 589 if ( nStyle & SYMBOL_DRAW_MONO ) 590 { 591 if ( nStyle & SYMBOL_DRAW_DISABLE ) 592 mpOutDev->SetFillColor( Color( COL_GRAY ) ); 593 else 594 mpOutDev->SetFillColor( Color( COL_BLACK ) ); 595 } 596 else 597 { 598 if ( nStyle & SYMBOL_DRAW_DISABLE ) 599 { 600 // Als Embosed ausgeben 601 mpOutDev->SetFillColor( rStyleSettings.GetLightColor() ); 602 Rectangle aTempRect = aRect; 603 aTempRect.Move( 1, 1 ); 604 ImplDrawSymbol( mpOutDev, aTempRect, eType ); 605 mpOutDev->SetFillColor( rStyleSettings.GetShadowColor() ); 606 } 607 else 608 mpOutDev->SetFillColor( rColor ); 609 } 610 611 ImplDrawSymbol( mpOutDev, aRect, eType ); 612 613 mpOutDev->SetLineColor( aOldLineColor ); 614 mpOutDev->SetFillColor( aOldFillColor ); 615 mpOutDev->EnableMapMode( bOldMapMode ); 616 } 617 618 // ======================================================================= 619 620 void DecorationView::DrawFrame( const Rectangle& rRect, 621 const Color& rLeftTopColor, 622 const Color& rRightBottomColor ) 623 { 624 Rectangle aRect = mpOutDev->LogicToPixel( rRect ); 625 Color aOldLineColor = mpOutDev->GetLineColor(); 626 Color aOldFillColor = mpOutDev->GetFillColor(); 627 sal_Bool bOldMapMode = mpOutDev->IsMapModeEnabled(); 628 mpOutDev->EnableMapMode( sal_False ); 629 mpOutDev->SetLineColor(); 630 mpOutDev->ImplDraw2ColorFrame( aRect, rLeftTopColor, rRightBottomColor ); 631 mpOutDev->SetLineColor( aOldLineColor ); 632 mpOutDev->SetFillColor( aOldFillColor ); 633 mpOutDev->EnableMapMode( bOldMapMode ); 634 } 635 636 // ======================================================================= 637 638 void DecorationView::DrawHighlightFrame( const Rectangle& rRect, 639 sal_uInt16 nStyle ) 640 { 641 const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings(); 642 Color aLightColor = rStyleSettings.GetLightColor(); 643 Color aShadowColor = rStyleSettings.GetShadowColor(); 644 645 if ( (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) || 646 (mpOutDev->GetOutDevType() == OUTDEV_PRINTER) ) 647 { 648 aLightColor = Color( COL_BLACK ); 649 aShadowColor = Color( COL_BLACK ); 650 } 651 else if ( nStyle & FRAME_HIGHLIGHT_TESTBACKGROUND ) 652 { 653 Wallpaper aBackground = mpOutDev->GetBackground(); 654 if ( aBackground.IsBitmap() || aBackground.IsGradient() ) 655 { 656 aLightColor = rStyleSettings.GetFaceColor(); 657 aShadowColor = Color( COL_BLACK ); 658 } 659 else 660 { 661 Color aBackColor = aBackground.GetColor(); 662 if ( (aLightColor.GetColorError( aBackColor ) < 32) || 663 (aShadowColor.GetColorError( aBackColor ) < 32) ) 664 { 665 aLightColor = Color( COL_WHITE ); 666 aShadowColor = Color( COL_BLACK ); 667 668 if ( aLightColor.GetColorError( aBackColor ) < 32 ) 669 aLightColor.DecreaseLuminance( 64 ); 670 if ( aShadowColor.GetColorError( aBackColor ) < 32 ) 671 aShadowColor.IncreaseLuminance( 64 ); 672 } 673 } 674 } 675 676 if ( (nStyle & FRAME_HIGHLIGHT_STYLE) == FRAME_HIGHLIGHT_IN ) 677 { 678 Color aTempColor = aLightColor; 679 aLightColor = aShadowColor; 680 aShadowColor = aTempColor; 681 } 682 683 DrawFrame( rRect, aLightColor, aShadowColor ); 684 } 685 686 // ======================================================================= 687 688 static void ImplDrawDPILineRect( OutputDevice* pDev, Rectangle& rRect, 689 const Color* pColor, sal_Bool bRound = sal_False ) 690 { 691 long nLineWidth = pDev->ImplGetDPIX()/300; 692 long nLineHeight = pDev->ImplGetDPIY()/300; 693 if ( !nLineWidth ) 694 nLineWidth = 1; 695 if ( !nLineHeight ) 696 nLineHeight = 1; 697 698 if ( pColor ) 699 { 700 if ( (nLineWidth == 1) && (nLineHeight == 1) ) 701 { 702 pDev->SetLineColor( *pColor ); 703 pDev->SetFillColor(); 704 if( bRound ) 705 { 706 pDev->DrawLine( Point( rRect.Left()+1, rRect.Top()), Point( rRect.Right()-1, rRect.Top()) ); 707 pDev->DrawLine( Point( rRect.Left()+1, rRect.Bottom()), Point( rRect.Right()-1, rRect.Bottom()) ); 708 pDev->DrawLine( Point( rRect.Left(), rRect.Top()+1), Point( rRect.Left(), rRect.Bottom()-1) ); 709 pDev->DrawLine( Point( rRect.Right(), rRect.Top()+1), Point( rRect.Right(), rRect.Bottom()-1) ); 710 } 711 else 712 pDev->DrawRect( rRect ); 713 } 714 else 715 { 716 long nWidth = rRect.GetWidth(); 717 long nHeight = rRect.GetHeight(); 718 pDev->SetLineColor(); 719 pDev->SetFillColor( *pColor ); 720 pDev->DrawRect( Rectangle( rRect.TopLeft(), Size( nWidth, nLineHeight ) ) ); 721 pDev->DrawRect( Rectangle( rRect.TopLeft(), Size( nLineWidth, nHeight ) ) ); 722 pDev->DrawRect( Rectangle( Point( rRect.Left(), rRect.Bottom()-nLineHeight ), 723 Size( nWidth, nLineHeight ) ) ); 724 pDev->DrawRect( Rectangle( Point( rRect.Right()-nLineWidth, rRect.Top() ), 725 Size( nLineWidth, nHeight ) ) ); 726 } 727 } 728 729 rRect.Left() += nLineWidth; 730 rRect.Top() += nLineHeight; 731 rRect.Right() -= nLineWidth; 732 rRect.Bottom() -= nLineHeight; 733 } 734 735 // ======================================================================= 736 737 static void ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect, 738 const StyleSettings& rStyleSettings, sal_uInt16 nStyle ) 739 { 740 // mask menu style 741 sal_Bool bMenuStyle = (nStyle & FRAME_DRAW_MENU) ? sal_True : sal_False; 742 nStyle &= ~FRAME_DRAW_MENU; 743 744 Window *pWin = NULL; 745 if( pDev->GetOutDevType() == OUTDEV_WINDOW ) 746 pWin = (Window*) pDev; 747 748 // UseFlatBorders disables 3D style for all frames except menus 749 // menus may use different border colors (eg on XP) 750 // normal frames will be drawn using the shadow color 751 // whereas window frame borders will use black 752 sal_Bool bFlatBorders = ( !bMenuStyle && rStyleSettings.GetUseFlatBorders() ); 753 754 // no flat borders for standard VCL controls (ie formcontrols that keep their classic look) 755 // will not affect frame windows (like dropdowns) 756 if( bFlatBorders && pWin && pWin->GetType() == WINDOW_BORDERWINDOW && (pWin != pWin->ImplGetFrameWindow()) ) 757 { 758 // check for formcontrol, i.e., a control without NWF enabled 759 Control *pControl = dynamic_cast< Control* >( pWin->GetWindow( WINDOW_CLIENT ) ); 760 if( pControl && pControl->IsNativeWidgetEnabled() ) 761 bFlatBorders = sal_True; 762 else 763 bFlatBorders = sal_False; 764 } 765 766 // no round corners for window frame borders 767 sal_Bool bRound = (bFlatBorders && !(nStyle & FRAME_DRAW_WINDOWBORDER)); 768 769 if ( (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) || 770 (pDev->GetOutDevType() == OUTDEV_PRINTER) || 771 bFlatBorders ) 772 nStyle |= FRAME_DRAW_MONO; 773 774 if ( nStyle & FRAME_DRAW_NODRAW ) 775 { 776 sal_uInt16 nValueStyle = bMenuStyle ? nStyle | FRAME_DRAW_MENU : nStyle; 777 if( pWin->GetType() == WINDOW_BORDERWINDOW ) 778 nValueStyle |= FRAME_DRAW_BORDERWINDOWBORDER; 779 ImplControlValue aControlValue( nValueStyle ); 780 Rectangle aBound, aContent; 781 Rectangle aNatRgn( rRect ); 782 if(pWin && pWin->GetNativeControlRegion(CTRL_FRAME, PART_BORDER, 783 aNatRgn, 0, aControlValue, rtl::OUString(), aBound, aContent) ) 784 { 785 rRect = aContent; 786 } 787 else if ( nStyle & FRAME_DRAW_MONO ) 788 ImplDrawDPILineRect( pDev, rRect, NULL, bRound ); 789 else 790 { 791 sal_uInt16 nFrameStyle = nStyle & FRAME_DRAW_STYLE; 792 793 if ( nFrameStyle == FRAME_DRAW_GROUP ) 794 { 795 rRect.Left() += 2; 796 rRect.Top() += 2; 797 rRect.Right() -= 2; 798 rRect.Bottom() -= 2; 799 } 800 else if ( (nFrameStyle == FRAME_DRAW_IN) || 801 (nFrameStyle == FRAME_DRAW_OUT) ) 802 { 803 rRect.Left()++; 804 rRect.Top()++; 805 rRect.Right()--; 806 rRect.Bottom()--; 807 } 808 else // FRAME_DRAW_DOUBLEIN || FRAME_DRAW_DOUBLEOUT 809 { 810 rRect.Left() += 2; 811 rRect.Top() += 2; 812 rRect.Right() -= 2; 813 rRect.Bottom() -= 2; 814 } 815 } 816 } 817 else 818 { 819 if( pWin && pWin->IsNativeControlSupported(CTRL_FRAME, PART_BORDER) ) 820 { 821 sal_uInt16 nValueStyle = bMenuStyle ? nStyle | FRAME_DRAW_MENU : nStyle; 822 if( pWin->GetType() == WINDOW_BORDERWINDOW ) 823 nValueStyle |= FRAME_DRAW_BORDERWINDOWBORDER; 824 ImplControlValue aControlValue( nValueStyle ); 825 Rectangle aBound, aContent; 826 Rectangle aNatRgn( rRect ); 827 if( pWin->GetNativeControlRegion(CTRL_FRAME, PART_BORDER, 828 aNatRgn, 0, aControlValue, rtl::OUString(), aBound, aContent) ) 829 { 830 if( pWin->DrawNativeControl( CTRL_FRAME, PART_BORDER, aContent, CTRL_STATE_ENABLED, 831 aControlValue, rtl::OUString()) ) 832 { 833 rRect = aContent; 834 return; 835 } 836 } 837 } 838 839 if ( nStyle & FRAME_DRAW_MONO ) 840 { 841 Color aColor = bRound ? rStyleSettings.GetShadowColor() 842 : pDev->GetSettings().GetStyleSettings().GetMonoColor(); 843 // when the MonoColor wasn't set, check face color 844 if ( 845 (bRound && aColor.IsDark()) || 846 ( 847 (aColor == Color(COL_BLACK)) && 848 (pDev->GetSettings().GetStyleSettings().GetFaceColor().IsDark()) 849 ) 850 ) 851 { 852 aColor = Color( COL_WHITE ); 853 } 854 ImplDrawDPILineRect( pDev, rRect, &aColor, bRound ); 855 } 856 else 857 { 858 sal_uInt16 nFrameStyle = nStyle & FRAME_DRAW_STYLE; 859 if ( nFrameStyle == FRAME_DRAW_GROUP ) 860 { 861 pDev->SetFillColor(); 862 pDev->SetLineColor( rStyleSettings.GetLightColor() ); 863 rRect.Top()++; 864 rRect.Left()++; 865 pDev->DrawRect( rRect ); 866 rRect.Top()--; 867 rRect.Left()--; 868 pDev->SetLineColor( rStyleSettings.GetShadowColor() ); 869 rRect.Right()--; 870 rRect.Bottom()--; 871 pDev->DrawRect( rRect ); 872 rRect.Right()++; 873 rRect.Bottom()++; 874 } 875 else 876 { 877 pDev->SetLineColor(); 878 879 if ( (nFrameStyle == FRAME_DRAW_IN) || 880 (nFrameStyle == FRAME_DRAW_OUT) ) 881 { 882 if ( nFrameStyle == FRAME_DRAW_IN ) 883 { 884 pDev->ImplDraw2ColorFrame( rRect, 885 rStyleSettings.GetShadowColor(), 886 rStyleSettings.GetLightColor() ); 887 } 888 else 889 { 890 pDev->ImplDraw2ColorFrame( rRect, 891 rStyleSettings.GetLightColor(), 892 rStyleSettings.GetShadowColor() ); 893 } 894 895 rRect.Left()++; 896 rRect.Top()++; 897 rRect.Right()--; 898 rRect.Bottom()--; 899 } 900 else // FRAME_DRAW_DOUBLEIN || FRAME_DRAW_DOUBLEOUT 901 { 902 if ( nFrameStyle == FRAME_DRAW_DOUBLEIN ) 903 { 904 if( bFlatBorders ) // no 3d effect 905 pDev->ImplDraw2ColorFrame( rRect, 906 rStyleSettings.GetShadowColor(), 907 rStyleSettings.GetShadowColor() ); 908 else 909 pDev->ImplDraw2ColorFrame( rRect, 910 rStyleSettings.GetShadowColor(), 911 rStyleSettings.GetLightColor() ); 912 } 913 else 914 { 915 if( bMenuStyle ) 916 pDev->ImplDraw2ColorFrame( rRect, 917 rStyleSettings.GetMenuBorderColor(), 918 rStyleSettings.GetDarkShadowColor() ); 919 else 920 pDev->ImplDraw2ColorFrame( rRect, 921 bFlatBorders ? // no 3d effect 922 rStyleSettings.GetDarkShadowColor() : 923 rStyleSettings.GetLightBorderColor(), 924 rStyleSettings.GetDarkShadowColor() ); 925 926 } 927 928 rRect.Left()++; 929 rRect.Top()++; 930 rRect.Right()--; 931 rRect.Bottom()--; 932 933 sal_Bool bDrawn = sal_True; 934 if ( nFrameStyle == FRAME_DRAW_DOUBLEIN ) 935 { 936 if( bFlatBorders ) // no 3d effect 937 pDev->ImplDraw2ColorFrame( rRect, 938 rStyleSettings.GetFaceColor(), 939 rStyleSettings.GetFaceColor() ); 940 else 941 pDev->ImplDraw2ColorFrame( rRect, 942 rStyleSettings.GetDarkShadowColor(), 943 rStyleSettings.GetLightBorderColor() ); 944 } 945 else 946 { 947 // flat menues have no shadow border 948 if( !bMenuStyle || !rStyleSettings.GetUseFlatMenues() ) 949 pDev->ImplDraw2ColorFrame( rRect, 950 rStyleSettings.GetLightColor(), 951 rStyleSettings.GetShadowColor() ); 952 else 953 bDrawn = sal_False; 954 } 955 if( bDrawn ) 956 { 957 rRect.Left()++; 958 rRect.Top()++; 959 rRect.Right()--; 960 rRect.Bottom()--; 961 } 962 } 963 } 964 } 965 } 966 } 967 968 // ----------------------------------------------------------------------- 969 970 Rectangle DecorationView::DrawFrame( const Rectangle& rRect, sal_uInt16 nStyle ) 971 { 972 Rectangle aRect = rRect; 973 sal_Bool bOldMap = mpOutDev->IsMapModeEnabled(); 974 if ( bOldMap ) 975 { 976 aRect = mpOutDev->LogicToPixel( aRect ); 977 mpOutDev->EnableMapMode( sal_False ); 978 } 979 980 if ( !rRect.IsEmpty() ) 981 { 982 if ( nStyle & FRAME_DRAW_NODRAW ) 983 ImplDrawFrame( mpOutDev, aRect, mpOutDev->GetSettings().GetStyleSettings(), nStyle ); 984 else 985 { 986 Color maOldLineColor = mpOutDev->GetLineColor(); 987 Color maOldFillColor = mpOutDev->GetFillColor(); 988 ImplDrawFrame( mpOutDev, aRect, mpOutDev->GetSettings().GetStyleSettings(), nStyle ); 989 mpOutDev->SetLineColor( maOldLineColor ); 990 mpOutDev->SetFillColor( maOldFillColor ); 991 } 992 } 993 994 if ( bOldMap ) 995 { 996 mpOutDev->EnableMapMode( bOldMap ); 997 aRect = mpOutDev->PixelToLogic( aRect ); 998 } 999 1000 return aRect; 1001 } 1002 1003 // ======================================================================= 1004 1005 static void ImplDrawButton( OutputDevice* pDev, Rectangle& rRect, 1006 const StyleSettings& rStyleSettings, sal_uInt16 nStyle ) 1007 { 1008 Rectangle aFillRect = rRect; 1009 1010 if ( nStyle & BUTTON_DRAW_MONO ) 1011 { 1012 if ( !(nStyle & BUTTON_DRAW_NODRAW) ) 1013 { 1014 Color aBlackColor( COL_BLACK ); 1015 1016 if ( nStyle & BUTTON_DRAW_DEFAULT ) 1017 ImplDrawDPILineRect( pDev, aFillRect, &aBlackColor ); 1018 1019 ImplDrawDPILineRect( pDev, aFillRect, &aBlackColor ); 1020 1021 Size aBrdSize( 1, 1 ); 1022 if ( pDev->GetOutDevType() == OUTDEV_PRINTER ) 1023 { 1024 MapMode aResMapMode( MAP_100TH_MM ); 1025 aBrdSize = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode ); 1026 if ( !aBrdSize.Width() ) 1027 aBrdSize.Width() = 1; 1028 if ( !aBrdSize.Height() ) 1029 aBrdSize.Height() = 1; 1030 } 1031 pDev->SetLineColor(); 1032 pDev->SetFillColor( aBlackColor ); 1033 Rectangle aRect1; 1034 Rectangle aRect2; 1035 aRect1.Left() = aFillRect.Left(); 1036 aRect1.Right() = aFillRect.Right(), 1037 aRect2.Top() = aFillRect.Top(); 1038 aRect2.Bottom() = aFillRect.Bottom(); 1039 if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) ) 1040 { 1041 aRect1.Top() = aFillRect.Top(); 1042 aRect1.Bottom() = aBrdSize.Height()-1; 1043 aRect2.Left() = aFillRect.Left(); 1044 aRect2.Right() = aFillRect.Left()+aBrdSize.Width()-1; 1045 aFillRect.Left() += aBrdSize.Width(); 1046 aFillRect.Top() += aBrdSize.Height(); 1047 } 1048 else 1049 { 1050 aRect1.Top() = aFillRect.Bottom()-aBrdSize.Height()+1; 1051 aRect1.Bottom() = aFillRect.Bottom(); 1052 aRect2.Left() = aFillRect.Right()-aBrdSize.Width()+1; 1053 aRect2.Right() = aFillRect.Right(), 1054 aFillRect.Right() -= aBrdSize.Width(); 1055 aFillRect.Bottom() -= aBrdSize.Height(); 1056 } 1057 pDev->DrawRect( aRect1 ); 1058 pDev->DrawRect( aRect2 ); 1059 } 1060 } 1061 else 1062 { 1063 if ( !(nStyle & BUTTON_DRAW_NODRAW) ) 1064 { 1065 if ( nStyle & BUTTON_DRAW_DEFAULT ) 1066 { 1067 Color aDefBtnColor = rStyleSettings.GetDarkShadowColor(); 1068 ImplDrawDPILineRect( pDev, aFillRect, &aDefBtnColor ); 1069 } 1070 } 1071 1072 if ( !(nStyle & BUTTON_DRAW_NODRAW) ) 1073 { 1074 pDev->SetLineColor(); 1075 if ( nStyle & BUTTON_DRAW_NOLEFTLIGHTBORDER ) 1076 { 1077 pDev->SetFillColor( rStyleSettings.GetLightBorderColor() ); 1078 pDev->DrawRect( Rectangle( aFillRect.Left(), aFillRect.Top(), 1079 aFillRect.Left(), aFillRect.Bottom() ) ); 1080 aFillRect.Left()++; 1081 } 1082 if ( (nStyle & BUTTON_DRAW_NOTOPLIGHTBORDER) && 1083 !(nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED)) ) 1084 { 1085 pDev->SetFillColor( rStyleSettings.GetLightBorderColor() ); 1086 pDev->DrawRect( Rectangle( aFillRect.Left(), aFillRect.Top(), 1087 aFillRect.Right(), aFillRect.Top() ) ); 1088 aFillRect.Top()++; 1089 } 1090 if ( (( (nStyle & BUTTON_DRAW_NOBOTTOMSHADOWBORDER) | BUTTON_DRAW_FLAT) == (BUTTON_DRAW_NOBOTTOMSHADOWBORDER | BUTTON_DRAW_FLAT)) && 1091 !(nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED | BUTTON_DRAW_HIGHLIGHT)) ) 1092 { 1093 pDev->SetFillColor( rStyleSettings.GetDarkShadowColor() ); 1094 pDev->DrawRect( Rectangle( aFillRect.Left(), aFillRect.Bottom(), 1095 aFillRect.Right(), aFillRect.Bottom() ) ); 1096 aFillRect.Bottom()--; 1097 } 1098 1099 Color aColor1; 1100 Color aColor2; 1101 if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) ) 1102 { 1103 aColor1 = rStyleSettings.GetDarkShadowColor(); 1104 aColor2 = rStyleSettings.GetLightColor(); 1105 } 1106 else 1107 { 1108 if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER ) 1109 aColor1 = rStyleSettings.GetLightBorderColor(); 1110 else 1111 aColor1 = rStyleSettings.GetLightColor(); 1112 if ( (nStyle & BUTTON_DRAW_FLATTEST) == BUTTON_DRAW_FLAT ) 1113 aColor2 = rStyleSettings.GetShadowColor(); 1114 else 1115 aColor2 = rStyleSettings.GetDarkShadowColor(); 1116 } 1117 pDev->ImplDraw2ColorFrame( aFillRect, aColor1, aColor2 ); 1118 aFillRect.Left()++; 1119 aFillRect.Top()++; 1120 aFillRect.Right()--; 1121 aFillRect.Bottom()--; 1122 1123 if ( !((nStyle & BUTTON_DRAW_FLATTEST) == BUTTON_DRAW_FLAT) ) 1124 { 1125 if ( nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED) ) 1126 { 1127 aColor1 = rStyleSettings.GetShadowColor(); 1128 aColor2 = rStyleSettings.GetLightBorderColor(); 1129 } 1130 else 1131 { 1132 if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER ) 1133 aColor1 = rStyleSettings.GetLightColor(); 1134 else 1135 aColor1 = rStyleSettings.GetLightBorderColor(); 1136 aColor2 = rStyleSettings.GetShadowColor(); 1137 } 1138 pDev->ImplDraw2ColorFrame( aFillRect, aColor1, aColor2 ); 1139 aFillRect.Left()++; 1140 aFillRect.Top()++; 1141 aFillRect.Right()--; 1142 aFillRect.Bottom()--; 1143 } 1144 } 1145 } 1146 1147 if ( !(nStyle & (BUTTON_DRAW_NOFILL | BUTTON_DRAW_NODRAW)) ) 1148 { 1149 pDev->SetLineColor(); 1150 if ( nStyle & BUTTON_DRAW_MONO ) 1151 { 1152 // Hack: Auf Druckern wollen wir im MonoChrom-Modus trotzdem 1153 // erstmal graue Buttons haben 1154 if ( pDev->GetOutDevType() == OUTDEV_PRINTER ) 1155 pDev->SetFillColor( Color( COL_LIGHTGRAY ) ); 1156 else 1157 pDev->SetFillColor( Color( COL_WHITE ) ); 1158 } 1159 else 1160 { 1161 if ( nStyle & (BUTTON_DRAW_CHECKED | BUTTON_DRAW_DONTKNOW) ) 1162 pDev->SetFillColor( rStyleSettings.GetCheckedColor() ); 1163 else 1164 pDev->SetFillColor( rStyleSettings.GetFaceColor() ); 1165 } 1166 pDev->DrawRect( aFillRect ); 1167 } 1168 1169 // Ein Border freilassen, der jedoch bei Default-Darstellung 1170 // mitbenutzt wird 1171 rRect.Left()++; 1172 rRect.Top()++; 1173 rRect.Right()--; 1174 rRect.Bottom()--; 1175 1176 if ( nStyle & BUTTON_DRAW_NOLIGHTBORDER ) 1177 { 1178 rRect.Left()++; 1179 rRect.Top()++; 1180 } 1181 else if ( nStyle & BUTTON_DRAW_NOLEFTLIGHTBORDER ) 1182 rRect.Left()++; 1183 1184 if ( nStyle & BUTTON_DRAW_PRESSED ) 1185 { 1186 if ( (rRect.GetHeight() > 10) && (rRect.GetWidth() > 10) ) 1187 { 1188 rRect.Left() += 4; 1189 rRect.Top() += 4; 1190 rRect.Right() -= 1; 1191 rRect.Bottom() -= 1; 1192 } 1193 else 1194 { 1195 rRect.Left() += 3; 1196 rRect.Top() += 3; 1197 rRect.Right() -= 2; 1198 rRect.Bottom() -= 2; 1199 } 1200 } 1201 else if ( nStyle & BUTTON_DRAW_CHECKED ) 1202 { 1203 rRect.Left() += 3; 1204 rRect.Top() += 3; 1205 rRect.Right() -= 2; 1206 rRect.Bottom() -= 2; 1207 } 1208 else 1209 { 1210 rRect.Left() += 2; 1211 rRect.Top() += 2; 1212 rRect.Right() -= 3; 1213 rRect.Bottom() -= 3; 1214 } 1215 } 1216 1217 // ----------------------------------------------------------------------- 1218 1219 Rectangle DecorationView::DrawButton( const Rectangle& rRect, sal_uInt16 nStyle ) 1220 { 1221 Rectangle aRect = rRect; 1222 sal_Bool bOldMap = mpOutDev->IsMapModeEnabled(); 1223 if ( bOldMap ) 1224 { 1225 aRect = mpOutDev->LogicToPixel( aRect ); 1226 mpOutDev->EnableMapMode( sal_False ); 1227 } 1228 1229 if ( !rRect.IsEmpty() ) 1230 { 1231 const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings(); 1232 1233 if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO ) 1234 nStyle |= BUTTON_DRAW_MONO; 1235 1236 if ( nStyle & BUTTON_DRAW_NODRAW ) 1237 ImplDrawButton( mpOutDev, aRect, rStyleSettings, nStyle ); 1238 else 1239 { 1240 Color maOldLineColor = mpOutDev->GetLineColor(); 1241 Color maOldFillColor = mpOutDev->GetFillColor(); 1242 ImplDrawButton( mpOutDev, aRect, rStyleSettings, nStyle ); 1243 mpOutDev->SetLineColor( maOldLineColor ); 1244 mpOutDev->SetFillColor( maOldFillColor ); 1245 } 1246 } 1247 1248 if ( bOldMap ) 1249 { 1250 mpOutDev->EnableMapMode( bOldMap ); 1251 aRect = mpOutDev->PixelToLogic( aRect ); 1252 } 1253 1254 return aRect; 1255 } 1256 1257 // ----------------------------------------------------------------------- 1258 1259 void DecorationView::DrawSeparator( const Point& rStart, const Point& rStop, bool bVertical ) 1260 { 1261 Point aStart( rStart ), aStop( rStop ); 1262 const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings(); 1263 1264 mpOutDev->Push( PUSH_LINECOLOR ); 1265 if ( rStyleSettings.GetOptions() & STYLE_OPTION_MONO ) 1266 mpOutDev->SetLineColor( Color( COL_BLACK ) ); 1267 else 1268 mpOutDev->SetLineColor( rStyleSettings.GetShadowColor() ); 1269 1270 mpOutDev->DrawLine( aStart, aStop ); 1271 if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) ) 1272 { 1273 mpOutDev->SetLineColor( rStyleSettings.GetLightColor() ); 1274 if( bVertical ) 1275 { 1276 aStart.X()++; 1277 aStop.X()++; 1278 } 1279 else 1280 { 1281 aStart.Y()++; 1282 aStop.Y()++; 1283 } 1284 mpOutDev->DrawLine( aStart, aStop ); 1285 } 1286 mpOutDev->Pop(); 1287 } 1288 1289