1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_vcl.hxx" 26 27 #include <limits.h> 28 29 #include <tools/debug.hxx> 30 #include <tools/poly.hxx> 31 32 #include <vcl/bitmap.hxx> 33 #include <vcl/event.hxx> 34 #include <vcl/timer.hxx> 35 #include <vcl/metric.hxx> 36 #include <vcl/virdev.hxx> 37 #include <vcl/window.hxx> 38 #include <vcl/scrbar.hxx> 39 #include <vcl/dockwin.hxx> 40 41 #include <window.h> 42 #include <outfont.hxx> 43 #include <outdev.h> 44 #include <svdata.hxx> 45 #include <impbmp.hxx> 46 #include <salbmp.hxx> 47 #include <salgdi.hxx> 48 #include <salframe.hxx> 49 #include <scrwnd.hxx> 50 51 52 // ======================================================================= 53 54 DBG_NAMEEX( Window ) 55 56 // ======================================================================= 57 58 #define IMPL_MAXSAVEBACKSIZE (640*480) 59 #define IMPL_MAXALLSAVEBACKSIZE (800*600*2) 60 61 // ======================================================================= 62 63 struct ImplFocusDelData : public ImplDelData 64 { 65 Window* mpFocusWin; 66 }; 67 68 // ======================================================================= 69 70 sal_Bool Window::ImplIsWindowInFront( const Window* pTestWindow ) const 71 { 72 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 73 DBG_CHKOBJ( pTestWindow, Window, ImplDbgCheckWindow ); 74 75 // Testen, ob es Fenster untereinander liegen 76 pTestWindow = pTestWindow->ImplGetFirstOverlapWindow(); 77 const Window* pTempWindow = pTestWindow; 78 const Window* pThisWindow = ImplGetFirstOverlapWindow(); 79 if ( pTempWindow == pThisWindow ) 80 return sal_False; 81 do 82 { 83 if ( pTempWindow == pThisWindow ) 84 return sal_True; 85 if ( pTempWindow->mpWindowImpl->mbFrame ) 86 break; 87 pTempWindow = pTempWindow->mpWindowImpl->mpOverlapWindow; 88 } 89 while ( pTempWindow ); 90 pTempWindow = pThisWindow; 91 do 92 { 93 if ( pTempWindow == pTestWindow ) 94 return sal_False; 95 if ( pTempWindow->mpWindowImpl->mbFrame ) 96 break; 97 pTempWindow = pTempWindow->mpWindowImpl->mpOverlapWindow; 98 } 99 while ( pTempWindow ); 100 101 // Fenster auf gleiche Ebene bringen 102 if ( pThisWindow->mpWindowImpl->mpOverlapWindow != pTestWindow->mpWindowImpl->mpOverlapWindow ) 103 { 104 sal_uInt16 nThisLevel = 0; 105 sal_uInt16 nTestLevel = 0; 106 pTempWindow = pThisWindow; 107 do 108 { 109 nThisLevel++; 110 pTempWindow = pTempWindow->mpWindowImpl->mpOverlapWindow; 111 } 112 while ( !pTempWindow->mpWindowImpl->mbFrame ); 113 pTempWindow = pTestWindow; 114 do 115 { 116 nTestLevel++; 117 pTempWindow = pTempWindow->mpWindowImpl->mpOverlapWindow; 118 } 119 while ( !pTempWindow->mpWindowImpl->mbFrame ); 120 121 if ( nThisLevel < nTestLevel ) 122 { 123 do 124 { 125 if ( pTestWindow->mpWindowImpl->mpOverlapWindow == pThisWindow->mpWindowImpl->mpOverlapWindow ) 126 break; 127 if ( pTestWindow->mpWindowImpl->mbFrame ) 128 break; 129 pTestWindow = pTestWindow->mpWindowImpl->mpOverlapWindow; 130 } 131 while ( pTestWindow ); 132 } 133 else 134 { 135 do 136 { 137 if ( pThisWindow->mpWindowImpl->mpOverlapWindow == pTempWindow->mpWindowImpl->mpOverlapWindow ) 138 break; 139 if ( pThisWindow->mpWindowImpl->mbFrame ) 140 break; 141 pThisWindow = pThisWindow->mpWindowImpl->mpOverlapWindow; 142 } 143 while ( pThisWindow ); 144 } 145 } 146 147 // Wenn TestWindow vor ThisWindow kommt, liegt es vorne 148 pTempWindow = pTestWindow; 149 do 150 { 151 if ( pTempWindow == pThisWindow ) 152 return sal_True; 153 pTempWindow = pTempWindow->mpWindowImpl->mpNext; 154 } 155 while ( pTempWindow ); 156 157 return sal_False; 158 } 159 160 // ======================================================================= 161 162 void Window::ImplSaveOverlapBackground() 163 { 164 DBG_ASSERT( !mpWindowImpl->mpOverlapData->mpSaveBackDev, "Window::ImplSaveOverlapBackground() - Background already saved" ); 165 166 if ( !mpWindowImpl->mbFrame ) 167 { 168 sal_uLong nSaveBackSize = mnOutWidth*mnOutHeight; 169 if ( nSaveBackSize <= IMPL_MAXSAVEBACKSIZE ) 170 { 171 if ( nSaveBackSize+mpWindowImpl->mpFrameData->mnAllSaveBackSize <= IMPL_MAXALLSAVEBACKSIZE ) 172 { 173 Size aOutSize( mnOutWidth, mnOutHeight ); 174 mpWindowImpl->mpOverlapData->mpSaveBackDev = new VirtualDevice( *mpWindowImpl->mpFrameWindow ); 175 if ( mpWindowImpl->mpOverlapData->mpSaveBackDev->SetOutputSizePixel( aOutSize ) ) 176 { 177 mpWindowImpl->mpFrameWindow->ImplUpdateAll(); 178 179 if ( mpWindowImpl->mbInitWinClipRegion ) 180 ImplInitWinClipRegion(); 181 182 mpWindowImpl->mpOverlapData->mnSaveBackSize = nSaveBackSize; 183 mpWindowImpl->mpFrameData->mnAllSaveBackSize += nSaveBackSize; 184 Point aDevPt; 185 mpWindowImpl->mpFrameWindow->ImplGetFrameDev( Point( mnOutOffX, mnOutOffY ), 186 aDevPt, aOutSize, 187 *(mpWindowImpl->mpOverlapData->mpSaveBackDev) ); 188 mpWindowImpl->mpOverlapData->mpNextBackWin = mpWindowImpl->mpFrameData->mpFirstBackWin; 189 mpWindowImpl->mpFrameData->mpFirstBackWin = this; 190 } 191 else 192 { 193 delete mpWindowImpl->mpOverlapData->mpSaveBackDev; 194 mpWindowImpl->mpOverlapData->mpSaveBackDev = NULL; 195 } 196 } 197 } 198 } 199 } 200 201 // ----------------------------------------------------------------------- 202 203 sal_Bool Window::ImplRestoreOverlapBackground( Region& rInvRegion ) 204 { 205 if ( mpWindowImpl->mpOverlapData->mpSaveBackDev ) 206 { 207 if ( mpWindowImpl->mbInitWinClipRegion ) 208 ImplInitWinClipRegion(); 209 210 if ( mpWindowImpl->mpOverlapData->mpSaveBackDev ) 211 { 212 Point aDevPt; 213 Point aDestPt( mnOutOffX, mnOutOffY ); 214 Size aDevSize = mpWindowImpl->mpOverlapData->mpSaveBackDev->GetOutputSizePixel(); 215 if ( mpWindowImpl->mpOverlapData->mpSaveBackRgn ) 216 { 217 mpWindowImpl->mpOverlapData->mpSaveBackRgn->Intersect( mpWindowImpl->maWinClipRegion ); 218 rInvRegion = mpWindowImpl->maWinClipRegion; 219 rInvRegion.Exclude( *mpWindowImpl->mpOverlapData->mpSaveBackRgn ); 220 mpWindowImpl->mpFrameWindow->ImplDrawFrameDev( aDestPt, aDevPt, aDevSize, 221 *(mpWindowImpl->mpOverlapData->mpSaveBackDev), 222 *mpWindowImpl->mpOverlapData->mpSaveBackRgn ); 223 } 224 else 225 { 226 mpWindowImpl->mpFrameWindow->ImplDrawFrameDev( aDestPt, aDevPt, aDevSize, 227 *(mpWindowImpl->mpOverlapData->mpSaveBackDev), 228 mpWindowImpl->maWinClipRegion ); 229 } 230 ImplDeleteOverlapBackground(); 231 } 232 233 return sal_True; 234 } 235 236 return sal_False; 237 } 238 239 // ----------------------------------------------------------------------- 240 241 void Window::ImplDeleteOverlapBackground() 242 { 243 if ( mpWindowImpl->mpOverlapData->mpSaveBackDev ) 244 { 245 mpWindowImpl->mpFrameData->mnAllSaveBackSize -= mpWindowImpl->mpOverlapData->mnSaveBackSize; 246 delete mpWindowImpl->mpOverlapData->mpSaveBackDev; 247 mpWindowImpl->mpOverlapData->mpSaveBackDev = NULL; 248 if ( mpWindowImpl->mpOverlapData->mpSaveBackRgn ) 249 { 250 delete mpWindowImpl->mpOverlapData->mpSaveBackRgn; 251 mpWindowImpl->mpOverlapData->mpSaveBackRgn = NULL; 252 } 253 254 // Fenster aus der Liste entfernen 255 if ( mpWindowImpl->mpFrameData->mpFirstBackWin == this ) 256 mpWindowImpl->mpFrameData->mpFirstBackWin = mpWindowImpl->mpOverlapData->mpNextBackWin; 257 else 258 { 259 Window* pTemp = mpWindowImpl->mpFrameData->mpFirstBackWin; 260 while ( pTemp->mpWindowImpl->mpOverlapData->mpNextBackWin != this ) 261 pTemp = pTemp->mpWindowImpl->mpOverlapData->mpNextBackWin; 262 pTemp->mpWindowImpl->mpOverlapData->mpNextBackWin = mpWindowImpl->mpOverlapData->mpNextBackWin; 263 } 264 mpWindowImpl->mpOverlapData->mpNextBackWin = NULL; 265 } 266 } 267 268 // ----------------------------------------------------------------------- 269 270 void Window::ImplInvalidateAllOverlapBackgrounds() 271 { 272 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 273 274 Window* pWindow = mpWindowImpl->mpFrameData->mpFirstBackWin; 275 while ( pWindow ) 276 { 277 // Naechstes Fenster schon hier merken, da dieses Fenster in 278 // der if-Abfrage aus der Liste entfernt werden kann 279 Window* pNext = pWindow->mpWindowImpl->mpOverlapData->mpNextBackWin; 280 281 if ( ImplIsWindowInFront( pWindow ) ) 282 { 283 Rectangle aRect1( Point( mnOutOffX, mnOutOffY ), 284 Size( mnOutWidth, mnOutHeight ) ); 285 Rectangle aRect2( Point( pWindow->mnOutOffX, pWindow->mnOutOffY ), 286 Size( pWindow->mnOutWidth, pWindow->mnOutHeight ) ); 287 aRect1.Intersection( aRect2 ); 288 if ( !aRect1.IsEmpty() ) 289 { 290 if ( !pWindow->mpWindowImpl->mpOverlapData->mpSaveBackRgn ) 291 pWindow->mpWindowImpl->mpOverlapData->mpSaveBackRgn = new Region( aRect2 ); 292 pWindow->mpWindowImpl->mpOverlapData->mpSaveBackRgn->Exclude( aRect1 ); 293 if ( pWindow->mpWindowImpl->mpOverlapData->mpSaveBackRgn->IsEmpty() ) 294 pWindow->ImplDeleteOverlapBackground(); 295 } 296 297 } 298 299 pWindow = pNext; 300 } 301 } 302 303 // ======================================================================= 304 305 Bitmap Window::SnapShot( sal_Bool bBorder ) const 306 { 307 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 308 309 Bitmap aBmp; 310 311 if ( IsReallyVisible() ) 312 { 313 if ( bBorder && mpWindowImpl->mpBorderWindow ) 314 aBmp = mpWindowImpl->mpBorderWindow->SnapShot(); 315 else 316 { 317 ((Window*)this)->Update(); 318 319 if ( bBorder && mpWindowImpl->mbFrame ) 320 { 321 SalBitmap* pSalBmp = mpWindowImpl->mpFrame->SnapShot(); 322 323 if ( pSalBmp ) 324 { 325 ImpBitmap* pImpBmp = new ImpBitmap; 326 pImpBmp->ImplSetSalBitmap( pSalBmp ); 327 aBmp.ImplSetImpBitmap( pImpBmp ); 328 return aBmp; 329 } 330 } 331 332 mpWindowImpl->mpFrameWindow->ImplGetFrameBitmap( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ), aBmp ); 333 } 334 } 335 336 return aBmp; 337 } 338 339 // ----------------------------------------------------------------------- 340 341 Bitmap Window::SnapShot() const 342 { 343 // Should be merged in the next top level build !!! 344 return SnapShot( sal_True ); 345 } 346 347 // ----------------------------------------------------------------------- 348 349 void Window::ShowFocus( const Rectangle& rRect ) 350 { 351 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 352 353 if( mpWindowImpl->mbInShowFocus ) 354 return; 355 mpWindowImpl->mbInShowFocus = sal_True; 356 357 ImplWinData* pWinData = ImplGetWinData(); 358 359 // native themeing suggest not to use focus rects 360 if( ! ( mpWindowImpl->mbUseNativeFocus && 361 IsNativeWidgetEnabled() ) ) 362 { 363 if ( !mpWindowImpl->mbInPaint ) 364 { 365 if ( mpWindowImpl->mbFocusVisible ) 366 { 367 if ( *(pWinData->mpFocusRect) == rRect ) 368 { 369 mpWindowImpl->mbInShowFocus = sal_False; 370 return; 371 } 372 373 ImplInvertFocus( *(pWinData->mpFocusRect) ); 374 } 375 376 ImplInvertFocus( rRect ); 377 } 378 if ( !pWinData->mpFocusRect ) 379 pWinData->mpFocusRect = new Rectangle( rRect ); 380 else 381 *(pWinData->mpFocusRect) = rRect; 382 mpWindowImpl->mbFocusVisible = sal_True; 383 } 384 else 385 { 386 if( ! mpWindowImpl->mbNativeFocusVisible ) 387 { 388 mpWindowImpl->mbNativeFocusVisible = sal_True; 389 if ( !mpWindowImpl->mbInPaint ) 390 Invalidate(); 391 } 392 } 393 mpWindowImpl->mbInShowFocus = sal_False; 394 } 395 396 // ----------------------------------------------------------------------- 397 398 void Window::HideFocus() 399 { 400 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 401 402 if( mpWindowImpl->mbInHideFocus ) 403 return; 404 mpWindowImpl->mbInHideFocus = sal_True; 405 406 // native themeing can suggest not to use focus rects 407 if( ! ( mpWindowImpl->mbUseNativeFocus && 408 IsNativeWidgetEnabled() ) ) 409 { 410 if ( !mpWindowImpl->mbFocusVisible ) 411 { 412 mpWindowImpl->mbInHideFocus = sal_False; 413 return; 414 } 415 416 if ( !mpWindowImpl->mbInPaint ) 417 ImplInvertFocus( *(ImplGetWinData()->mpFocusRect) ); 418 mpWindowImpl->mbFocusVisible = sal_False; 419 } 420 else 421 { 422 if( mpWindowImpl->mbNativeFocusVisible ) 423 { 424 mpWindowImpl->mbNativeFocusVisible = sal_False; 425 if ( !mpWindowImpl->mbInPaint ) 426 Invalidate(); 427 } 428 } 429 mpWindowImpl->mbInHideFocus = sal_False; 430 } 431 432 // ----------------------------------------------------------------------- 433 434 void Window::Invert( const Rectangle& rRect, sal_uInt16 nFlags ) 435 { 436 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 437 438 if ( !IsDeviceOutputNecessary() ) 439 return; 440 441 Rectangle aRect( ImplLogicToDevicePixel( rRect ) ); 442 443 if ( aRect.IsEmpty() ) 444 return; 445 aRect.Justify(); 446 447 // we need a graphics 448 if ( !mpGraphics ) 449 { 450 if ( !ImplGetGraphics() ) 451 return; 452 } 453 454 if ( mbInitClipRegion ) 455 ImplInitClipRegion(); 456 457 if ( mbOutputClipped ) 458 return; 459 460 SalInvert nSalFlags = 0; 461 if ( nFlags & INVERT_HIGHLIGHT ) 462 nSalFlags |= SAL_INVERT_HIGHLIGHT; 463 if ( nFlags & INVERT_50 ) 464 nSalFlags |= SAL_INVERT_50; 465 mpGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), nSalFlags, this ); 466 } 467 468 // ----------------------------------------------------------------------- 469 470 void Window::Invert( const Polygon& rPoly, sal_uInt16 nFlags ) 471 { 472 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 473 474 if ( !IsDeviceOutputNecessary() ) 475 return; 476 477 sal_uInt16 nPoints = rPoly.GetSize(); 478 479 if ( nPoints < 2 ) 480 return; 481 482 Polygon aPoly( ImplLogicToDevicePixel( rPoly ) ); 483 484 // we need a graphics 485 if ( !mpGraphics ) 486 { 487 if ( !ImplGetGraphics() ) 488 return; 489 } 490 491 if ( mbInitClipRegion ) 492 ImplInitClipRegion(); 493 494 if ( mbOutputClipped ) 495 return; 496 497 SalInvert nSalFlags = 0; 498 if ( nFlags & INVERT_HIGHLIGHT ) 499 nSalFlags |= SAL_INVERT_HIGHLIGHT; 500 if ( nFlags & INVERT_50 ) 501 nSalFlags |= SAL_INVERT_50; 502 const SalPoint* pPtAry = (const SalPoint*)aPoly.GetConstPointAry(); 503 mpGraphics->Invert( nPoints, pPtAry, nSalFlags, this ); 504 } 505 506 // ----------------------------------------------------------------------- 507 508 void Window::ShowTracking( const Rectangle& rRect, sal_uInt16 nFlags ) 509 { 510 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 511 512 ImplWinData* pWinData = ImplGetWinData(); 513 514 if ( !mpWindowImpl->mbInPaint || !(nFlags & SHOWTRACK_WINDOW) ) 515 { 516 if ( mpWindowImpl->mbTrackVisible ) 517 { 518 if ( (*(pWinData->mpTrackRect) == rRect) && 519 (pWinData->mnTrackFlags == nFlags) ) 520 return; 521 522 InvertTracking( *(pWinData->mpTrackRect), pWinData->mnTrackFlags ); 523 } 524 525 InvertTracking( rRect, nFlags ); 526 } 527 528 if ( !pWinData->mpTrackRect ) 529 pWinData->mpTrackRect = new Rectangle( rRect ); 530 else 531 *(pWinData->mpTrackRect) = rRect; 532 pWinData->mnTrackFlags = nFlags; 533 mpWindowImpl->mbTrackVisible = sal_True; 534 } 535 536 // ----------------------------------------------------------------------- 537 538 void Window::HideTracking() 539 { 540 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 541 542 if ( mpWindowImpl->mbTrackVisible ) 543 { 544 ImplWinData* pWinData = ImplGetWinData(); 545 if ( !mpWindowImpl->mbInPaint || !(pWinData->mnTrackFlags & SHOWTRACK_WINDOW) ) 546 InvertTracking( *(pWinData->mpTrackRect), pWinData->mnTrackFlags ); 547 mpWindowImpl->mbTrackVisible = sal_False; 548 } 549 } 550 551 // ----------------------------------------------------------------------- 552 553 void Window::InvertTracking( const Rectangle& rRect, sal_uInt16 nFlags ) 554 { 555 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 556 557 Rectangle aRect( ImplLogicToDevicePixel( rRect ) ); 558 559 if ( aRect.IsEmpty() ) 560 return; 561 aRect.Justify(); 562 563 SalGraphics* pGraphics; 564 565 if ( nFlags & SHOWTRACK_WINDOW ) 566 { 567 if ( !IsDeviceOutputNecessary() ) 568 return; 569 570 // we need a graphics 571 if ( !mpGraphics ) 572 { 573 if ( !ImplGetGraphics() ) 574 return; 575 } 576 577 if ( mbInitClipRegion ) 578 ImplInitClipRegion(); 579 580 if ( mbOutputClipped ) 581 return; 582 583 pGraphics = mpGraphics; 584 } 585 else 586 { 587 pGraphics = ImplGetFrameGraphics(); 588 589 if ( nFlags & SHOWTRACK_CLIP ) 590 { 591 Point aPoint( mnOutOffX, mnOutOffY ); 592 Region aRegion( Rectangle( aPoint, 593 Size( mnOutWidth, mnOutHeight ) ) ); 594 ImplClipBoundaries( aRegion, sal_False, sal_False ); 595 ImplSelectClipRegion( aRegion, pGraphics ); 596 } 597 } 598 599 sal_uInt16 nStyle = nFlags & SHOWTRACK_STYLE; 600 if ( nStyle == SHOWTRACK_OBJECT ) 601 pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), SAL_INVERT_TRACKFRAME, this ); 602 else if ( nStyle == SHOWTRACK_SPLIT ) 603 pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), SAL_INVERT_50, this ); 604 else 605 { 606 long nBorder = 1; 607 if ( nStyle == SHOWTRACK_BIG ) 608 nBorder = 5; 609 pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), nBorder, SAL_INVERT_50, this ); 610 pGraphics->Invert( aRect.Left(), aRect.Bottom()-nBorder+1, aRect.GetWidth(), nBorder, SAL_INVERT_50, this ); 611 pGraphics->Invert( aRect.Left(), aRect.Top()+nBorder, nBorder, aRect.GetHeight()-(nBorder*2), SAL_INVERT_50, this ); 612 pGraphics->Invert( aRect.Right()-nBorder+1, aRect.Top()+nBorder, nBorder, aRect.GetHeight()-(nBorder*2), SAL_INVERT_50, this ); 613 } 614 } 615 616 // ----------------------------------------------------------------------- 617 618 void Window::InvertTracking( const Polygon& rPoly, sal_uInt16 nFlags ) 619 { 620 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 621 622 sal_uInt16 nPoints = rPoly.GetSize(); 623 624 if ( nPoints < 2 ) 625 return; 626 627 Polygon aPoly( ImplLogicToDevicePixel( rPoly ) ); 628 629 SalGraphics* pGraphics; 630 631 if ( nFlags & SHOWTRACK_WINDOW ) 632 { 633 if ( !IsDeviceOutputNecessary() ) 634 return; 635 636 // we need a graphics 637 if ( !mpGraphics ) 638 { 639 if ( !ImplGetGraphics() ) 640 return; 641 } 642 643 if ( mbInitClipRegion ) 644 ImplInitClipRegion(); 645 646 if ( mbOutputClipped ) 647 return; 648 649 pGraphics = mpGraphics; 650 } 651 else 652 { 653 pGraphics = ImplGetFrameGraphics(); 654 655 if ( nFlags & SHOWTRACK_CLIP ) 656 { 657 Point aPoint( mnOutOffX, mnOutOffY ); 658 Region aRegion( Rectangle( aPoint, 659 Size( mnOutWidth, mnOutHeight ) ) ); 660 ImplClipBoundaries( aRegion, sal_False, sal_False ); 661 ImplSelectClipRegion( aRegion, pGraphics ); 662 } 663 } 664 665 const SalPoint* pPtAry = (const SalPoint*)aPoly.GetConstPointAry(); 666 pGraphics->Invert( nPoints, pPtAry, SAL_INVERT_TRACKFRAME, this ); 667 } 668 669 // ----------------------------------------------------------------------- 670 671 IMPL_LINK( Window, ImplTrackTimerHdl, Timer*, pTimer ) 672 { 673 ImplSVData* pSVData = ImplGetSVData(); 674 675 // Bei Button-Repeat muessen wir den Timeout umsetzen 676 if ( pSVData->maWinData.mnTrackFlags & STARTTRACK_BUTTONREPEAT ) 677 pTimer->SetTimeout( GetSettings().GetMouseSettings().GetButtonRepeat() ); 678 679 // Tracking-Event erzeugen 680 Point aMousePos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY ); 681 if( ImplIsAntiparallel() ) 682 { 683 // - RTL - re-mirror frame pos at pChild 684 ImplReMirror( aMousePos ); 685 } 686 MouseEvent aMEvt( ImplFrameToOutput( aMousePos ), 687 mpWindowImpl->mpFrameData->mnClickCount, 0, 688 mpWindowImpl->mpFrameData->mnMouseCode, mpWindowImpl->mpFrameData->mnMouseCode ); 689 TrackingEvent aTEvt( aMEvt, TRACKING_REPEAT ); 690 Tracking( aTEvt ); 691 692 return 0; 693 } 694 695 // ----------------------------------------------------------------------- 696 697 void Window::StartTracking( sal_uInt16 nFlags ) 698 { 699 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 700 701 ImplSVData* pSVData = ImplGetSVData(); 702 703 if ( pSVData->maWinData.mpTrackWin != this ) 704 { 705 if ( pSVData->maWinData.mpTrackWin ) 706 pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL ); 707 } 708 709 if ( nFlags & (STARTTRACK_SCROLLREPEAT | STARTTRACK_BUTTONREPEAT) ) 710 { 711 pSVData->maWinData.mpTrackTimer = new AutoTimer; 712 713 if ( nFlags & STARTTRACK_SCROLLREPEAT ) 714 pSVData->maWinData.mpTrackTimer->SetTimeout( GetSettings().GetMouseSettings().GetScrollRepeat() ); 715 else 716 pSVData->maWinData.mpTrackTimer->SetTimeout( GetSettings().GetMouseSettings().GetButtonStartRepeat() ); 717 pSVData->maWinData.mpTrackTimer->SetTimeoutHdl( LINK( this, Window, ImplTrackTimerHdl ) ); 718 pSVData->maWinData.mpTrackTimer->Start(); 719 } 720 721 pSVData->maWinData.mpTrackWin = this; 722 pSVData->maWinData.mnTrackFlags = nFlags; 723 CaptureMouse(); 724 } 725 726 // ----------------------------------------------------------------------- 727 728 void Window::EndTracking( sal_uInt16 nFlags ) 729 { 730 ImplSVData* pSVData = ImplGetSVData(); 731 732 if ( pSVData->maWinData.mpTrackWin == this ) 733 { 734 // Hier wegen DbgChkThis geklammert, da Window im Handler zerstoert 735 // werden kann 736 { 737 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 738 739 if ( pSVData->maWinData.mpTrackTimer ) 740 { 741 delete pSVData->maWinData.mpTrackTimer; 742 pSVData->maWinData.mpTrackTimer = NULL; 743 } 744 745 pSVData->maWinData.mpTrackWin = NULL; 746 pSVData->maWinData.mnTrackFlags = 0; 747 ReleaseMouse(); 748 } 749 750 // EndTracking rufen, wenn es gerufen werden soll 751 if ( !(nFlags & ENDTRACK_DONTCALLHDL) ) 752 { 753 Point aMousePos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY ); 754 if( ImplIsAntiparallel() ) 755 { 756 // - RTL - re-mirror frame pos at pChild 757 ImplReMirror( aMousePos ); 758 } 759 760 MouseEvent aMEvt( ImplFrameToOutput( aMousePos ), 761 mpWindowImpl->mpFrameData->mnClickCount, 0, 762 mpWindowImpl->mpFrameData->mnMouseCode, mpWindowImpl->mpFrameData->mnMouseCode ); 763 TrackingEvent aTEvt( aMEvt, nFlags | ENDTRACK_END ); 764 Tracking( aTEvt ); 765 } 766 } 767 } 768 769 // ----------------------------------------------------------------------- 770 771 sal_Bool Window::IsTracking() const 772 { 773 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 774 775 return (ImplGetSVData()->maWinData.mpTrackWin == this); 776 } 777 778 // ----------------------------------------------------------------------- 779 780 void Window::StartAutoScroll( sal_uInt16 nFlags ) 781 { 782 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 783 784 ImplSVData* pSVData = ImplGetSVData(); 785 786 if ( pSVData->maWinData.mpAutoScrollWin != this ) 787 { 788 if ( pSVData->maWinData.mpAutoScrollWin ) 789 pSVData->maWinData.mpAutoScrollWin->EndAutoScroll(); 790 } 791 792 pSVData->maWinData.mpAutoScrollWin = this; 793 pSVData->maWinData.mnAutoScrollFlags = nFlags; 794 pSVData->maAppData.mpWheelWindow = new ImplWheelWindow( this ); 795 } 796 797 // ----------------------------------------------------------------------- 798 799 void Window::EndAutoScroll() 800 { 801 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 802 803 ImplSVData* pSVData = ImplGetSVData(); 804 805 if ( pSVData->maWinData.mpAutoScrollWin == this ) 806 { 807 pSVData->maWinData.mpAutoScrollWin = NULL; 808 pSVData->maWinData.mnAutoScrollFlags = 0; 809 pSVData->maAppData.mpWheelWindow->ImplStop(); 810 pSVData->maAppData.mpWheelWindow->doLazyDelete(); 811 pSVData->maAppData.mpWheelWindow = NULL; 812 } 813 } 814 815 // ----------------------------------------------------------------------- 816 817 sal_Bool Window::IsAutoScroll() const 818 { 819 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 820 821 return (ImplGetSVData()->maWinData.mpAutoScrollWin == this); 822 } 823 824 // ----------------------------------------------------------------------- 825 826 void Window::SaveBackground( const Point& rPos, const Size& rSize, 827 const Point& rDestOff, VirtualDevice& rSaveDevice ) 828 { 829 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 830 831 if ( mpWindowImpl->mpPaintRegion ) 832 { 833 Region aClip( *mpWindowImpl->mpPaintRegion ); 834 const Point aPixPos( LogicToPixel( rPos ) ); 835 836 aClip.Move( -mnOutOffX, -mnOutOffY ); 837 aClip.Intersect( Rectangle( aPixPos, LogicToPixel( rSize ) ) ); 838 839 if ( !aClip.IsEmpty() ) 840 { 841 const Region aOldClip( rSaveDevice.GetClipRegion() ); 842 const Point aPixOffset( rSaveDevice.LogicToPixel( rDestOff ) ); 843 const sal_Bool bMap = rSaveDevice.IsMapModeEnabled(); 844 845 // move clip region to have the same distance to DestOffset 846 aClip.Move( aPixOffset.X() - aPixPos.X(), aPixOffset.Y() - aPixPos.Y() ); 847 848 // set pixel clip region 849 rSaveDevice.EnableMapMode( sal_False ); 850 rSaveDevice.SetClipRegion( aClip ); 851 rSaveDevice.EnableMapMode( bMap ); 852 rSaveDevice.DrawOutDev( rDestOff, rSize, rPos, rSize, *this ); 853 rSaveDevice.SetClipRegion( aOldClip ); 854 } 855 } 856 else 857 rSaveDevice.DrawOutDev( rDestOff, rSize, rPos, rSize, *this ); 858 } 859 860 // ----------------------------------------------------------------------- 861 862 sal_uIntPtr Window::SaveFocus() 863 { 864 ImplSVData* pSVData = ImplGetSVData(); 865 if ( pSVData->maWinData.mpFocusWin ) 866 { 867 ImplFocusDelData* pDelData = new ImplFocusDelData; 868 pSVData->maWinData.mpFocusWin->ImplAddDel( pDelData ); 869 pDelData->mpFocusWin = pSVData->maWinData.mpFocusWin; 870 return (sal_uIntPtr)(void*)pDelData; 871 } 872 else 873 return 0; 874 } 875 876 // ----------------------------------------------------------------------- 877 878 sal_Bool Window::EndSaveFocus( sal_uIntPtr nSaveId, sal_Bool bRestore ) 879 { 880 if ( !nSaveId ) 881 return sal_False; 882 else 883 { 884 sal_Bool bOK = sal_True; 885 ImplFocusDelData* pDelData = (ImplFocusDelData*)(void*)nSaveId; 886 if ( !pDelData->IsDelete() ) 887 { 888 pDelData->mpFocusWin->ImplRemoveDel( pDelData ); 889 if ( bRestore ) 890 pDelData->mpFocusWin->GrabFocus(); 891 } 892 else 893 bOK = !bRestore; 894 delete pDelData; 895 return bOK; 896 } 897 } 898 899 // ----------------------------------------------------------------------- 900 901 void Window::SetZoom( const Fraction& rZoom ) 902 { 903 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 904 905 if ( mpWindowImpl->maZoom != rZoom ) 906 { 907 mpWindowImpl->maZoom = rZoom; 908 StateChanged( STATE_CHANGE_ZOOM ); 909 } 910 } 911 912 // ----------------------------------------------------------------------- 913 914 inline long WinFloatRound( double fVal ) 915 { 916 return( fVal > 0.0 ? (long) ( fVal + 0.5 ) : -(long) ( -fVal + 0.5 ) ); 917 } 918 919 // ----------------------------------------------------------------------- 920 921 void Window::SetZoomedPointFont( const Font& rFont ) 922 { 923 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 924 925 const Fraction& rZoom = GetZoom(); 926 if ( rZoom.GetNumerator() != rZoom.GetDenominator() ) 927 { 928 Font aFont( rFont ); 929 Size aSize = aFont.GetSize(); 930 double n = (double)aSize.Width(); 931 n *= (double)rZoom.GetNumerator(); 932 n /= (double)rZoom.GetDenominator(); 933 aSize.Width() = WinFloatRound( n ); 934 n = (double)aSize.Height(); 935 n *= (double)rZoom.GetNumerator(); 936 n /= (double)rZoom.GetDenominator(); 937 aSize.Height() = WinFloatRound( n ); 938 aFont.SetSize( aSize ); 939 SetPointFont( aFont ); 940 941 // Wenn Darstellung skaliert wird, nehmen wir gegebenenfalls 942 // einen anderen Font, wenn der aktuelle nicht skalierbar ist 943 FontMetric aMetric = GetFontMetric(); 944 long nFontDiff = Abs( GetFont().GetSize().Height()-aMetric.GetSize().Height() ); 945 if ( (aMetric.GetType() == TYPE_RASTER) && (nFontDiff >= 2) ) 946 { 947 sal_uInt16 nType; 948 if ( aMetric.GetPitch() == PITCH_FIXED ) 949 nType = DEFAULTFONT_FIXED; 950 else 951 nType = DEFAULTFONT_UI_SANS; 952 Font aTempFont = GetDefaultFont( nType, GetSettings().GetLanguage(), 0 ); 953 aFont.SetName( aTempFont.GetName() ); 954 SetPointFont( aFont ); 955 } 956 } 957 else 958 SetPointFont( rFont ); 959 } 960 961 // ----------------------------------------------------------------------- 962 963 long Window::CalcZoom( long nCalc ) const 964 { 965 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 966 967 const Fraction& rZoom = GetZoom(); 968 if ( rZoom.GetNumerator() != rZoom.GetDenominator() ) 969 { 970 double n = (double)nCalc; 971 n *= (double)rZoom.GetNumerator(); 972 n /= (double)rZoom.GetDenominator(); 973 nCalc = WinFloatRound( n ); 974 } 975 return nCalc; 976 } 977 978 // ----------------------------------------------------------------------- 979 980 void Window::SetControlFont() 981 { 982 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 983 984 if ( mpWindowImpl->mpControlFont ) 985 { 986 delete mpWindowImpl->mpControlFont; 987 mpWindowImpl->mpControlFont = NULL; 988 StateChanged( STATE_CHANGE_CONTROLFONT ); 989 } 990 } 991 992 // ----------------------------------------------------------------------- 993 994 void Window::SetControlFont( const Font& rFont ) 995 { 996 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 997 998 if ( rFont == Font() ) 999 { 1000 SetControlFont(); 1001 return; 1002 } 1003 1004 if ( mpWindowImpl->mpControlFont ) 1005 { 1006 if ( *mpWindowImpl->mpControlFont == rFont ) 1007 return; 1008 *mpWindowImpl->mpControlFont = rFont; 1009 } 1010 else 1011 mpWindowImpl->mpControlFont = new Font( rFont ); 1012 1013 StateChanged( STATE_CHANGE_CONTROLFONT ); 1014 } 1015 1016 // ----------------------------------------------------------------------- 1017 1018 Font Window::GetControlFont() const 1019 { 1020 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 1021 1022 if ( mpWindowImpl->mpControlFont ) 1023 return *mpWindowImpl->mpControlFont; 1024 else 1025 { 1026 Font aFont; 1027 return aFont; 1028 } 1029 } 1030 1031 // ----------------------------------------------------------------------- 1032 1033 void Window::SetControlForeground() 1034 { 1035 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 1036 1037 if ( mpWindowImpl->mbControlForeground ) 1038 { 1039 mpWindowImpl->maControlForeground = Color( COL_TRANSPARENT ); 1040 mpWindowImpl->mbControlForeground = sal_False; 1041 StateChanged( STATE_CHANGE_CONTROLFOREGROUND ); 1042 } 1043 } 1044 1045 // ----------------------------------------------------------------------- 1046 1047 void Window::SetControlForeground( const Color& rColor ) 1048 { 1049 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 1050 1051 if ( rColor.GetTransparency() ) 1052 { 1053 if ( mpWindowImpl->mbControlForeground ) 1054 { 1055 mpWindowImpl->maControlForeground = Color( COL_TRANSPARENT ); 1056 mpWindowImpl->mbControlForeground = sal_False; 1057 StateChanged( STATE_CHANGE_CONTROLFOREGROUND ); 1058 } 1059 } 1060 else 1061 { 1062 if ( mpWindowImpl->maControlForeground != rColor ) 1063 { 1064 mpWindowImpl->maControlForeground = rColor; 1065 mpWindowImpl->mbControlForeground = sal_True; 1066 StateChanged( STATE_CHANGE_CONTROLFOREGROUND ); 1067 } 1068 } 1069 } 1070 1071 // ----------------------------------------------------------------------- 1072 1073 void Window::SetControlBackground() 1074 { 1075 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 1076 1077 if ( mpWindowImpl->mbControlBackground ) 1078 { 1079 mpWindowImpl->maControlBackground = Color( COL_TRANSPARENT ); 1080 mpWindowImpl->mbControlBackground = sal_False; 1081 StateChanged( STATE_CHANGE_CONTROLBACKGROUND ); 1082 } 1083 } 1084 1085 // ----------------------------------------------------------------------- 1086 1087 void Window::SetControlBackground( const Color& rColor ) 1088 { 1089 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 1090 1091 if ( rColor.GetTransparency() ) 1092 { 1093 if ( mpWindowImpl->mbControlBackground ) 1094 { 1095 mpWindowImpl->maControlBackground = Color( COL_TRANSPARENT ); 1096 mpWindowImpl->mbControlBackground = sal_False; 1097 StateChanged( STATE_CHANGE_CONTROLBACKGROUND ); 1098 } 1099 } 1100 else 1101 { 1102 if ( mpWindowImpl->maControlBackground != rColor ) 1103 { 1104 mpWindowImpl->maControlBackground = rColor; 1105 mpWindowImpl->mbControlBackground = sal_True; 1106 StateChanged( STATE_CHANGE_CONTROLBACKGROUND ); 1107 } 1108 } 1109 } 1110 1111 // ----------------------------------------------------------------------- 1112 1113 Size Window::CalcWindowSize( const Size& rOutSz ) const 1114 { 1115 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 1116 1117 Size aSz = rOutSz; 1118 aSz.Width() += mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder; 1119 aSz.Height() += mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder; 1120 return aSz; 1121 } 1122 1123 // ----------------------------------------------------------------------- 1124 1125 Size Window::CalcOutputSize( const Size& rWinSz ) const 1126 { 1127 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 1128 1129 Size aSz = rWinSz; 1130 aSz.Width() -= mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder; 1131 aSz.Height() -= mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder; 1132 return aSz; 1133 } 1134 1135 // ----------------------------------------------------------------------- 1136 1137 Font Window::GetDrawPixelFont( OutputDevice* pDev ) const 1138 { 1139 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 1140 1141 Font aFont = GetPointFont(); 1142 Size aFontSize = aFont.GetSize(); 1143 MapMode aPtMapMode( MAP_POINT ); 1144 aFontSize = pDev->LogicToPixel( aFontSize, aPtMapMode ); 1145 aFont.SetSize( aFontSize ); 1146 return aFont; 1147 } 1148 1149 // ----------------------------------------------------------------------- 1150 1151 long Window::GetDrawPixel( OutputDevice* pDev, long nPixels ) const 1152 { 1153 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 1154 1155 long nP = nPixels; 1156 if ( pDev->GetOutDevType() != OUTDEV_WINDOW ) 1157 { 1158 MapMode aMap( MAP_100TH_MM ); 1159 Size aSz( nP, 0 ); 1160 aSz = PixelToLogic( aSz, aMap ); 1161 aSz = pDev->LogicToPixel( aSz, aMap ); 1162 nP = aSz.Width(); 1163 } 1164 return nP; 1165 } 1166 1167 // ----------------------------------------------------------------------- 1168 1169 sal_Bool Window::HandleScrollCommand( const CommandEvent& rCmd, 1170 ScrollBar* pHScrl, ScrollBar* pVScrl ) 1171 { 1172 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 1173 1174 sal_Bool bRet = sal_False; 1175 1176 if ( pHScrl || pVScrl ) 1177 { 1178 switch( rCmd.GetCommand() ) 1179 { 1180 case COMMAND_STARTAUTOSCROLL: 1181 { 1182 sal_uInt16 nFlags = 0; 1183 if ( pHScrl ) 1184 { 1185 if ( (pHScrl->GetVisibleSize() < pHScrl->GetRangeMax()) && 1186 pHScrl->IsEnabled() && pHScrl->IsInputEnabled() && ! pHScrl->IsInModalMode() ) 1187 nFlags |= AUTOSCROLL_HORZ; 1188 } 1189 if ( pVScrl ) 1190 { 1191 if ( (pVScrl->GetVisibleSize() < pVScrl->GetRangeMax()) && 1192 pVScrl->IsEnabled() && pVScrl->IsInputEnabled() && ! pVScrl->IsInModalMode() ) 1193 nFlags |= AUTOSCROLL_VERT; 1194 } 1195 1196 if ( nFlags ) 1197 { 1198 StartAutoScroll( nFlags ); 1199 bRet = sal_True; 1200 } 1201 } 1202 break; 1203 1204 case COMMAND_WHEEL: 1205 { 1206 const CommandWheelData* pData = rCmd.GetWheelData(); 1207 1208 if ( pData && (COMMAND_WHEEL_SCROLL == pData->GetMode()) ) 1209 { 1210 sal_uLong nScrollLines = pData->GetScrollLines(); 1211 long nLines; 1212 if ( nScrollLines == COMMAND_WHEEL_PAGESCROLL ) 1213 { 1214 if ( pData->GetDelta() < 0 ) 1215 nLines = -LONG_MAX; 1216 else 1217 nLines = LONG_MAX; 1218 } 1219 else 1220 nLines = pData->GetNotchDelta() * (long)nScrollLines; 1221 if ( nLines ) 1222 { 1223 ImplHandleScroll( NULL, 1224 0L, 1225 pData->IsHorz() ? pHScrl : pVScrl, 1226 nLines ); 1227 bRet = sal_True; 1228 } 1229 } 1230 } 1231 break; 1232 1233 case COMMAND_AUTOSCROLL: 1234 { 1235 const CommandScrollData* pData = rCmd.GetAutoScrollData(); 1236 if ( pData && (pData->GetDeltaX() || pData->GetDeltaY()) ) 1237 { 1238 ImplHandleScroll( pHScrl, pData->GetDeltaX(), 1239 pVScrl, pData->GetDeltaY() ); 1240 bRet = sal_True; 1241 } 1242 } 1243 break; 1244 1245 default: 1246 break; 1247 } 1248 } 1249 1250 return bRet; 1251 } 1252 1253 // ----------------------------------------------------------------------- 1254 1255 void Window::ImplHandleScroll( ScrollBar* pHScrl, long nX, 1256 ScrollBar* pVScrl, long nY ) 1257 { 1258 if ( pHScrl && nX && pHScrl->IsEnabled() && pHScrl->IsInputEnabled() && ! pHScrl->IsInModalMode() ) 1259 { 1260 long nNewPos = pHScrl->GetThumbPos(); 1261 1262 if ( nX == -LONG_MAX ) 1263 nNewPos += pHScrl->GetPageSize(); 1264 else if ( nX == LONG_MAX ) 1265 nNewPos -= pHScrl->GetPageSize(); 1266 else 1267 { 1268 const double fVal = (double)nNewPos - ((double)nX * pHScrl->GetLineSize()); 1269 1270 if ( fVal < LONG_MIN ) 1271 nNewPos = LONG_MIN; 1272 else if ( fVal > LONG_MAX ) 1273 nNewPos = LONG_MAX; 1274 else 1275 nNewPos = (long)fVal; 1276 } 1277 1278 pHScrl->DoScroll( nNewPos ); 1279 } 1280 1281 if ( pVScrl && nY && pVScrl->IsEnabled() && pVScrl->IsInputEnabled() && ! pVScrl->IsInModalMode() ) 1282 { 1283 long nNewPos = pVScrl->GetThumbPos(); 1284 1285 if ( nY == -LONG_MAX ) 1286 nNewPos += pVScrl->GetPageSize(); 1287 else if ( nY == LONG_MAX ) 1288 nNewPos -= pVScrl->GetPageSize(); 1289 else 1290 { 1291 const double fVal = (double)nNewPos - ((double)nY * pVScrl->GetLineSize()); 1292 1293 if ( fVal < LONG_MIN ) 1294 nNewPos = LONG_MIN; 1295 else if ( fVal > LONG_MAX ) 1296 nNewPos = LONG_MAX; 1297 else 1298 nNewPos = (long)fVal; 1299 } 1300 1301 pVScrl->DoScroll( nNewPos ); 1302 } 1303 } 1304 1305 // support for docking 1306 // this is currently handled in ImplDockingWindowWrapper 1307 /* 1308 void Window::ImplSetFloatingMode( sal_Bool bFloatMode ) 1309 { 1310 // if the window is docked, put it into a flaoting window 1311 // if it is floating put it back in the old frame 1312 1313 ImplDockingWindowWrapper *pWrapper = pDockingMgr->GetDockingWindowWrapper( this ); 1314 if( !pDockingData ) 1315 return; 1316 1317 if ( pWrapper->IsFloatingMode() != bFloatMode ) 1318 { 1319 if ( pWrapper->PrepareToggleFloatingMode() ) 1320 { 1321 sal_Bool bVisible = IsVisible(); 1322 1323 if ( bFloatMode ) 1324 { 1325 Show( sal_False, SHOW_NOFOCUSCHANGE ); 1326 1327 pWrapper->maDockPos = GetPosPixel(); 1328 1329 Window* pRealParent = mpWindowImpl->mpRealParent; 1330 pWrapper->mpOldBorderWin = mpWindowImpl->mpBorderWindow; 1331 1332 ImplDockFloatWin* pWin = 1333 new ImplDockFloatWin2( 1334 mpWindowImpl->mpParent, 1335 mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ? mnFloatBits | WB_SYSTEMWINDOW : mnFloatBits, 1336 pWrapper ); 1337 pWrapper->mpFloatWin = pWin; 1338 mpWindowImpl->mpBorderWindow = NULL; 1339 mpWindowImpl->mnLeftBorder = 0; 1340 mpWindowImpl->mnTopBorder = 0; 1341 mpWindowImpl->mnRightBorder = 0; 1342 mpWindowImpl->mnBottomBorder = 0; 1343 // Falls Parent zerstoert wird, muessen wir auch vom 1344 // BorderWindow den Parent umsetzen 1345 if ( pWrapper->mpOldBorderWin ) 1346 pWrapper->mpOldBorderWin->SetParent( pWin ); 1347 SetParent( pWin ); 1348 pWin->SetPosPixel( Point() ); 1349 mpWindowImpl->mpBorderWindow = pWin; 1350 pWin->mpWindowImpl->mpClientWindow = this; 1351 mpWindowImpl->mpRealParent = pRealParent; 1352 pWin->SetText( GetText() ); 1353 pWin->SetOutputSizePixel( GetSizePixel() ); 1354 pWin->SetPosPixel( pWrapper->maFloatPos ); 1355 // DockingDaten ans FloatingWindow weiterreichen 1356 pWin->ShowTitleButton( TITLE_BUTTON_DOCKING, pWrapper->mbDockBtn ); 1357 pWin->ShowTitleButton( TITLE_BUTTON_HIDE, pWrapper->mbHideBtn ); 1358 pWin->SetPin( pWrapper->mbPined ); 1359 if ( pWrapper->mbRollUp ) 1360 pWin->RollUp(); 1361 else 1362 pWin->RollDown(); 1363 pWin->SetRollUpOutputSizePixel( pWrapper->maRollUpOutSize ); 1364 pWin->SetMinOutputSizePixel( pWrapper->maMinOutSize ); 1365 1366 pWrapper->ToggleFloatingMode(); 1367 1368 if ( bVisible ) 1369 Show(); 1370 } 1371 else 1372 { 1373 Show( sal_False, SHOW_NOFOCUSCHANGE ); 1374 1375 // FloatingDaten wird im FloatingWindow speichern 1376 pWrapper->maFloatPos = mpFloatWin->GetPosPixel(); 1377 pWrapper->mbDockBtn = mpFloatWin->IsTitleButtonVisible( TITLE_BUTTON_DOCKING ); 1378 pWrapper->mbHideBtn = mpFloatWin->IsTitleButtonVisible( TITLE_BUTTON_HIDE ); 1379 pWrapper->mbPined = mpFloatWin->IsPined(); 1380 pWrapper->mbRollUp = mpFloatWin->IsRollUp(); 1381 pWrapper->maRollUpOutSize = mpFloatWin->GetRollUpOutputSizePixel(); 1382 pWrapper->maMinOutSize = mpFloatWin->GetMinOutputSizePixel(); 1383 1384 Window* pRealParent = mpWindowImpl->mpRealParent; 1385 mpWindowImpl->mpBorderWindow = NULL; 1386 if ( pWrapper->mpOldBorderWin ) 1387 { 1388 SetParent( pWrapper->mpOldBorderWin ); 1389 ((ImplBorderWindow*)pWrapper->mpOldBorderWin)->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder ); 1390 pWrapper->mpOldBorderWin->Resize(); 1391 } 1392 mpWindowImpl->mpBorderWindow = pWrapper->mpOldBorderWin; 1393 SetParent( pRealParent ); 1394 mpWindowImpl->mpRealParent = pRealParent; 1395 delete static_cast<ImplDockFloatWin*>(mpFloatWin); 1396 pWrapper->mpFloatWin = NULL; 1397 SetPosPixel( maDockPos ); 1398 1399 pWrapper->ToggleFloatingMode(); 1400 1401 if ( bVisible ) 1402 Show(); 1403 } 1404 } 1405 } 1406 } 1407 */ 1408 1409 DockingManager* Window::GetDockingManager() 1410 { 1411 return ImplGetDockingManager(); 1412 } 1413 1414 void Window::EnableDocking( sal_Bool bEnable ) 1415 { 1416 // update list of dockable windows 1417 if( bEnable ) 1418 ImplGetDockingManager()->AddWindow( this ); 1419 else 1420 ImplGetDockingManager()->RemoveWindow( this ); 1421 } 1422 1423 1424 // retrieves the list of owner draw decorated windows for this window hiearchy 1425 ::std::vector<Window *>& Window::ImplGetOwnerDrawList() 1426 { 1427 return ImplGetTopmostFrameWindow()->mpWindowImpl->mpFrameData->maOwnerDrawList; 1428 } 1429 1430 Window* Window::ImplGetTopmostFrameWindow() 1431 { 1432 Window *pTopmostParent = this; 1433 while( pTopmostParent->ImplGetParent() ) 1434 pTopmostParent = pTopmostParent->ImplGetParent(); 1435 return pTopmostParent->mpWindowImpl->mpFrameWindow; 1436 } 1437 1438 void Window::SetHelpId( const rtl::OString& rHelpId ) 1439 { 1440 mpWindowImpl->maHelpId = rHelpId; 1441 } 1442 1443 const rtl::OString& Window::GetHelpId() const 1444 { 1445 return mpWindowImpl->maHelpId; 1446 } 1447 1448 void Window::SetUniqueId( const rtl::OString& rUniqueId ) 1449 { 1450 mpWindowImpl->maUniqId = rUniqueId; 1451 } 1452 1453 const rtl::OString& Window::GetUniqueId() const 1454 { 1455 return mpWindowImpl->maUniqId; 1456 } 1457 1458 const rtl::OString& Window::GetUniqueOrHelpId() const 1459 { 1460 return mpWindowImpl->maUniqId.getLength() ? mpWindowImpl->maUniqId : mpWindowImpl->maHelpId; 1461 } 1462 1463 // --------- old inline methods --------------- 1464 1465 Window* Window::ImplGetWindow() 1466 { 1467 if ( mpWindowImpl->mpClientWindow ) 1468 return mpWindowImpl->mpClientWindow; 1469 else 1470 return this; 1471 } 1472 1473 ImplFrameData* Window::ImplGetFrameData() 1474 { 1475 return mpWindowImpl->mpFrameData; 1476 } 1477 1478 SalFrame* Window::ImplGetFrame() const 1479 { 1480 return mpWindowImpl->mpFrame; 1481 } 1482 1483 Window* Window::ImplGetParent() const 1484 { 1485 return mpWindowImpl->mpParent; 1486 } 1487 1488 Window* Window::ImplGetClientWindow() const 1489 { 1490 return mpWindowImpl->mpClientWindow; 1491 } 1492 1493 Window* Window::ImplGetBorderWindow() const 1494 { 1495 return mpWindowImpl->mpBorderWindow; 1496 } 1497 1498 Window* Window::ImplGetFirstOverlapWindow() 1499 { 1500 if ( mpWindowImpl->mbOverlapWin ) 1501 return this; 1502 else 1503 return mpWindowImpl->mpOverlapWindow; 1504 } 1505 1506 const Window* Window::ImplGetFirstOverlapWindow() const 1507 { 1508 if ( mpWindowImpl->mbOverlapWin ) 1509 return this; 1510 else 1511 return mpWindowImpl->mpOverlapWindow; 1512 } 1513 1514 Window* Window::ImplGetFrameWindow() const 1515 { 1516 return mpWindowImpl->mpFrameWindow; 1517 } 1518 1519 sal_Bool Window::ImplIsDockingWindow() const 1520 { 1521 return mpWindowImpl->mbDockWin; 1522 } 1523 1524 sal_Bool Window::ImplIsFloatingWindow() const 1525 { 1526 return mpWindowImpl->mbFloatWin; 1527 } 1528 1529 sal_Bool Window::ImplIsToolbox() const 1530 { 1531 return mpWindowImpl->mbToolBox; 1532 } 1533 1534 sal_Bool Window::ImplIsSplitter() const 1535 { 1536 return mpWindowImpl->mbSplitter; 1537 } 1538 1539 sal_Bool Window::ImplIsPushButton() const 1540 { 1541 return mpWindowImpl->mbPushButton; 1542 } 1543 1544 sal_Bool Window::ImplIsOverlapWindow() const 1545 { 1546 return mpWindowImpl->mbOverlapWin; 1547 } 1548 1549 void Window::ImplSetActive( sal_Bool bActive ) 1550 { 1551 mpWindowImpl->mbActive = bActive; 1552 } 1553 1554 sal_Bool Window::ImplIsMouseTransparent() const 1555 { 1556 return mpWindowImpl->mbMouseTransparent; 1557 } 1558 1559 void Window::ImplSetMouseTransparent( sal_Bool bTransparent ) 1560 { 1561 mpWindowImpl->mbMouseTransparent = bTransparent; 1562 } 1563 1564 Point Window::ImplOutputToFrame( const Point& rPos ) 1565 { 1566 return Point( rPos.X()+mnOutOffX, rPos.Y()+mnOutOffY ); 1567 } 1568 1569 Point Window::ImplFrameToOutput( const Point& rPos ) 1570 { 1571 return Point( rPos.X()-mnOutOffX, rPos.Y()-mnOutOffY ); 1572 } 1573 1574 void Window::ImplOutputToFrame( Rectangle& rRect ) 1575 { 1576 rRect.Left()+=mnOutOffX; 1577 rRect.Top()+=mnOutOffY; 1578 rRect.Right()+=mnOutOffX; 1579 rRect.Bottom()+=mnOutOffY; 1580 } 1581 1582 void Window::ImplFrameToOutput( Rectangle& rRect ) 1583 { 1584 rRect.Left()-=mnOutOffX; 1585 rRect.Top()-=mnOutOffY; 1586 rRect.Right()-=mnOutOffX; 1587 rRect.Bottom()-=mnOutOffY; 1588 } 1589 1590 void Window::SetCompoundControl( sal_Bool bCompound ) 1591 { 1592 mpWindowImpl->mbCompoundControl = bCompound; 1593 } 1594 1595 void Window::IncrementLockCount() 1596 { 1597 mpWindowImpl->mnLockCount++; 1598 } 1599 1600 void Window::DecrementLockCount() 1601 { 1602 mpWindowImpl->mnLockCount--; 1603 } 1604 1605 WinBits Window::GetStyle() const 1606 { 1607 return mpWindowImpl->mnStyle; 1608 } 1609 1610 WinBits Window::GetPrevStyle() const 1611 { 1612 return mpWindowImpl->mnPrevStyle; 1613 } 1614 1615 WinBits Window::GetExtendedStyle() const 1616 { 1617 return mpWindowImpl->mnExtendedStyle; 1618 } 1619 1620 WinBits Window::GetPrevExtendedStyle() const 1621 { 1622 return mpWindowImpl->mnExtendedStyle; 1623 } 1624 1625 void Window::SetType( WindowType nType ) 1626 { 1627 mpWindowImpl->mnType = nType; 1628 } 1629 1630 WindowType Window::GetType() const 1631 { 1632 return mpWindowImpl->mnType; 1633 } 1634 sal_Bool Window::IsSystemWindow() const 1635 { 1636 return mpWindowImpl->mbSysWin; 1637 } 1638 1639 sal_Bool Window::IsDialog() const 1640 { 1641 return mpWindowImpl->mbDialog; 1642 } 1643 1644 sal_Bool Window::IsMenuFloatingWindow() const 1645 { 1646 return mpWindowImpl->mbMenuFloatingWindow; 1647 } 1648 1649 sal_Bool Window::IsToolbarFloatingWindow() const 1650 { 1651 return mpWindowImpl->mbToolbarFloatingWindow; 1652 } 1653 1654 void Window::EnableAllResize( sal_Bool bEnable ) 1655 { 1656 mpWindowImpl->mbAllResize = bEnable; 1657 } 1658 1659 sal_Bool Window::IsAllResizeEnabled() const 1660 { 1661 return mpWindowImpl->mbAllResize; 1662 } 1663 1664 sal_Bool Window::IsClipSiblingsEnabled() const 1665 { 1666 return mpWindowImpl->mbClipSiblings; 1667 } 1668 1669 void Window::EnableChildTransparentMode( sal_Bool bEnable ) 1670 { 1671 mpWindowImpl->mbChildTransparent = bEnable; 1672 } 1673 1674 sal_Bool Window::IsChildTransparentModeEnabled() const 1675 { 1676 return mpWindowImpl->mbChildTransparent; 1677 } 1678 1679 sal_Bool Window::IsMouseTransparent() const 1680 { 1681 return mpWindowImpl->mbMouseTransparent; 1682 } 1683 1684 sal_Bool Window::IsPaintTransparent() const 1685 { 1686 return mpWindowImpl->mbPaintTransparent; 1687 } 1688 1689 void Window::SetDialogControlStart( sal_Bool bStart ) 1690 { 1691 mpWindowImpl->mbDlgCtrlStart = bStart; 1692 } 1693 1694 sal_Bool Window::IsDialogControlStart() const 1695 { 1696 return mpWindowImpl->mbDlgCtrlStart; 1697 } 1698 1699 void Window::SetDialogControlFlags( sal_uInt16 nFlags ) 1700 { 1701 mpWindowImpl->mnDlgCtrlFlags = nFlags; 1702 } 1703 1704 sal_uInt16 Window::GetDialogControlFlags() const 1705 { 1706 return mpWindowImpl->mnDlgCtrlFlags; 1707 } 1708 1709 const InputContext& Window::GetInputContext() const 1710 { 1711 return mpWindowImpl->maInputContext; 1712 } 1713 1714 sal_Bool Window::IsExtTextInput() const 1715 { 1716 return mpWindowImpl->mbExtTextInput; 1717 } 1718 1719 void Window::EnableChildNotify( sal_Bool bEnable ) 1720 { 1721 mpWindowImpl->mbChildNotify = bEnable; 1722 } 1723 1724 sal_Bool Window::IsChildNotify() const 1725 { 1726 return mpWindowImpl->mbChildNotify; 1727 } 1728 1729 sal_Bool Window::IsControlFont() const 1730 { 1731 return (mpWindowImpl->mpControlFont != 0); 1732 } 1733 1734 Color Window::GetControlForeground() const 1735 { 1736 return mpWindowImpl->maControlForeground; 1737 } 1738 1739 sal_Bool Window::IsControlForeground() const 1740 { 1741 return mpWindowImpl->mbControlForeground; 1742 } 1743 1744 Color Window::GetControlBackground() const 1745 { 1746 return mpWindowImpl->maControlBackground; 1747 } 1748 1749 sal_Bool Window::IsControlBackground() const 1750 { 1751 return mpWindowImpl->mbControlBackground; 1752 } 1753 1754 sal_Bool Window::IsInPaint() const 1755 { 1756 return mpWindowImpl->mbInPaint; 1757 } 1758 1759 Window* Window::GetParent() const 1760 { 1761 return mpWindowImpl->mpRealParent; 1762 } 1763 1764 sal_Bool Window::IsVisible() const 1765 { 1766 return mpWindowImpl->mbVisible; 1767 } 1768 1769 sal_Bool Window::IsReallyVisible() const 1770 { 1771 return mpWindowImpl->mbReallyVisible; 1772 } 1773 1774 sal_Bool Window::IsParentPathVisible() const 1775 { 1776 return mpWindowImpl->mbReallyVisible; 1777 } 1778 1779 sal_Bool Window::IsReallyShown() const 1780 { 1781 return mpWindowImpl->mbReallyShown; 1782 } 1783 1784 sal_Bool Window::IsInInitShow() const 1785 { 1786 return mpWindowImpl->mbInInitShow; 1787 } 1788 1789 sal_Bool Window::IsEnabled() const 1790 { 1791 return !mpWindowImpl->mbDisabled; 1792 } 1793 1794 sal_Bool Window::IsInputEnabled() const 1795 { 1796 return !mpWindowImpl->mbInputDisabled; 1797 } 1798 1799 sal_Bool Window::IsAlwaysEnableInput() const 1800 { 1801 return mpWindowImpl->meAlwaysInputMode == AlwaysInputEnabled; 1802 } 1803 1804 sal_Bool Window::IsAlwaysDisableInput() const 1805 { 1806 return mpWindowImpl->meAlwaysInputMode == AlwaysInputDisabled; 1807 } 1808 1809 sal_uInt16 Window::GetActivateMode() const 1810 { 1811 return mpWindowImpl->mnActivateMode; 1812 1813 } 1814 1815 sal_Bool Window::IsAlwaysOnTopEnabled() const 1816 { 1817 return mpWindowImpl->mbAlwaysOnTop; 1818 } 1819 1820 sal_Bool Window::IsDefaultPos() const 1821 { 1822 return mpWindowImpl->mbDefPos; 1823 } 1824 1825 sal_Bool Window::IsDefaultSize() const 1826 { 1827 return mpWindowImpl->mbDefSize; 1828 } 1829 1830 void Window::EnablePaint( sal_Bool bEnable ) 1831 { 1832 mpWindowImpl->mbPaintDisabled = !bEnable; 1833 } 1834 1835 sal_Bool Window::IsPaintEnabled() const 1836 { 1837 return !mpWindowImpl->mbPaintDisabled; 1838 } 1839 1840 sal_Bool Window::IsUpdateMode() const 1841 { 1842 return !mpWindowImpl->mbNoUpdate; 1843 } 1844 1845 void Window::SetParentUpdateMode( sal_Bool bUpdate ) 1846 { 1847 mpWindowImpl->mbNoParentUpdate = !bUpdate; 1848 } 1849 1850 sal_Bool Window::IsParentUpdateMode() const 1851 { 1852 return !mpWindowImpl->mbNoParentUpdate; 1853 } 1854 1855 sal_Bool Window::IsActive() const 1856 { 1857 return mpWindowImpl->mbActive; 1858 } 1859 1860 sal_uInt16 Window::GetGetFocusFlags() const 1861 { 1862 return mpWindowImpl->mnGetFocusFlags; 1863 } 1864 1865 sal_Bool Window::IsCompoundControl() const 1866 { 1867 return mpWindowImpl->mbCompoundControl; 1868 } 1869 1870 sal_Bool Window::HasCompoundControlFocus() const 1871 { 1872 return mpWindowImpl->mbCompoundControlHasFocus; 1873 } 1874 1875 sal_Bool Window::IsChildPointerOverwrite() const 1876 { 1877 return mpWindowImpl->mbChildPtrOverwrite; 1878 } 1879 1880 sal_Bool Window::IsPointerVisible() const 1881 { 1882 return !mpWindowImpl->mbNoPtrVisible; 1883 } 1884 1885 sal_Bool Window::IsWait() const 1886 { 1887 return (mpWindowImpl->mnWaitCount != 0); 1888 } 1889 1890 Cursor* Window::GetCursor() const 1891 { 1892 return mpWindowImpl->mpCursor; 1893 } 1894 1895 const Fraction& Window::GetZoom() const 1896 { 1897 return mpWindowImpl->maZoom; 1898 } 1899 1900 sal_Bool Window::IsZoom() const 1901 { 1902 return mpWindowImpl->maZoom.GetNumerator() != mpWindowImpl->maZoom.GetDenominator(); 1903 } 1904 1905 void Window::SetHelpText( const XubString& rHelpText ) 1906 { 1907 mpWindowImpl->maHelpText = rHelpText; 1908 mpWindowImpl->mbHelpTextDynamic = sal_True; 1909 } 1910 1911 void Window::SetQuickHelpText( const XubString& rHelpText ) 1912 { 1913 mpWindowImpl->maQuickHelpText = rHelpText; 1914 } 1915 1916 const XubString& Window::GetQuickHelpText() const 1917 { 1918 return mpWindowImpl->maQuickHelpText; 1919 } 1920 1921 void Window::SetData( void* pNewData ) 1922 { 1923 mpWindowImpl->mpUserData = pNewData; 1924 } 1925 1926 void* Window::GetData() const 1927 { 1928 return mpWindowImpl->mpUserData; 1929 } 1930 1931 sal_Bool Window::IsCreatedWithToolkit() const 1932 { 1933 return mpWindowImpl->mbCreatedWithToolkit; 1934 } 1935 1936 void Window::SetCreatedWithToolkit( sal_Bool b ) 1937 { 1938 mpWindowImpl->mbCreatedWithToolkit = b; 1939 1940 } 1941 const Pointer& Window::GetPointer() const 1942 { 1943 return mpWindowImpl->maPointer; 1944 } 1945 1946 VCLXWindow* Window::GetWindowPeer() const 1947 { 1948 return mpWindowImpl->mpVCLXWindow; 1949 } 1950 1951 void Window::SetPosPixel( const Point& rNewPos ) 1952 { 1953 SetPosSizePixel( rNewPos.X(), rNewPos.Y(), 0, 0, WINDOW_POSSIZE_POS ); 1954 } 1955 1956 void Window::SetSizePixel( const Size& rNewSize ) 1957 { 1958 SetPosSizePixel( 0, 0, rNewSize.Width(), rNewSize.Height(), 1959 WINDOW_POSSIZE_SIZE ); 1960 } 1961 1962 void Window::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) 1963 { 1964 SetPosSizePixel( rNewPos.X(), rNewPos.Y(), 1965 rNewSize.Width(), rNewSize.Height(), 1966 WINDOW_POSSIZE_POSSIZE ); 1967 } 1968 1969 void Window::SetOutputSizePixel( const Size& rNewSize ) 1970 { 1971 SetSizePixel( Size( rNewSize.Width()+mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder, 1972 rNewSize.Height()+mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder ) ); 1973 } 1974 1975