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 "tools/time.hxx" 28 #include "tools/debug.hxx" 29 #include "tools/rc.h" 30 31 #include "unotools/fontcfg.hxx" 32 #include "unotools/confignode.hxx" 33 34 #include "vcl/unohelp.hxx" 35 #include "vcl/salgtype.hxx" 36 #include "vcl/event.hxx" 37 #include "vcl/help.hxx" 38 #include "vcl/cursor.hxx" 39 #include "vcl/svapp.hxx" 40 #include "vcl/window.hxx" 41 #include "vcl/syswin.hxx" 42 #include "vcl/syschild.hxx" 43 #include "vcl/dockwin.hxx" 44 #include "vcl/menu.hxx" 45 #include "vcl/wrkwin.hxx" 46 #include "vcl/wall.hxx" 47 #include "vcl/gradient.hxx" 48 #include "vcl/salctype.hxx" 49 #include "vcl/button.hxx" 50 #include "vcl/taskpanelist.hxx" 51 #include "vcl/dialog.hxx" 52 #include "vcl/unowrap.hxx" 53 #include "vcl/gdimtf.hxx" 54 #include "vcl/pdfextoutdevdata.hxx" 55 #include "vcl/lazydelete.hxx" 56 57 // declare system types in sysdata.hxx 58 #include "svsys.h" 59 #include "vcl/sysdata.hxx" 60 61 #include "salframe.hxx" 62 #include "salobj.hxx" 63 #include "salinst.hxx" 64 #include "salgdi.hxx" 65 #include "svdata.hxx" 66 #include "dbggui.hxx" 67 #include "outfont.hxx" 68 #include "window.h" 69 #include "toolbox.h" 70 #include "outdev.h" 71 #include "region.h" 72 #include "brdwin.hxx" 73 #include "helpwin.hxx" 74 #include "sallayout.hxx" 75 #include "dndlcon.hxx" 76 #include "dndevdis.hxx" 77 78 #include "com/sun/star/awt/XWindowPeer.hpp" 79 #include "com/sun/star/rendering/XCanvas.hpp" 80 #include "com/sun/star/rendering/XSpriteCanvas.hpp" 81 #include "com/sun/star/awt/XWindow.hpp" 82 #include "comphelper/processfactory.hxx" 83 #include "com/sun/star/datatransfer/dnd/XDragSource.hpp" 84 #include "com/sun/star/datatransfer/dnd/XDropTarget.hpp" 85 #include "com/sun/star/datatransfer/clipboard/XClipboard.hpp" 86 #include "com/sun/star/awt/XTopWindow.hpp" 87 #include "com/sun/star/awt/XDisplayConnection.hpp" 88 #include "com/sun/star/lang/XInitialization.hpp" 89 #include "com/sun/star/lang/XComponent.hpp" 90 #include "com/sun/star/lang/XServiceName.hpp" 91 #include "com/sun/star/accessibility/XAccessible.hpp" 92 #include "com/sun/star/accessibility/AccessibleRole.hpp" 93 94 #include <set> 95 #include <typeinfo> 96 97 using namespace rtl; 98 using namespace ::com::sun::star::uno; 99 using namespace ::com::sun::star::lang; 100 using namespace ::com::sun::star::datatransfer::clipboard; 101 using namespace ::com::sun::star::datatransfer::dnd; 102 using namespace ::com::sun::star; 103 using namespace com::sun; 104 105 using ::com::sun::star::awt::XTopWindow; 106 107 // ======================================================================= 108 109 DBG_NAME( Window ) 110 111 // ======================================================================= 112 113 #define IMPL_PAINT_PAINT ((sal_uInt16)0x0001) 114 #define IMPL_PAINT_PAINTALL ((sal_uInt16)0x0002) 115 #define IMPL_PAINT_PAINTALLCHILDS ((sal_uInt16)0x0004) 116 #define IMPL_PAINT_PAINTCHILDS ((sal_uInt16)0x0008) 117 #define IMPL_PAINT_ERASE ((sal_uInt16)0x0010) 118 #define IMPL_PAINT_CHECKRTL ((sal_uInt16)0x0020) 119 120 // ----------------------------------------------------------------------- 121 122 typedef Window* PWINDOW; 123 124 // ----------------------------------------------------------------------- 125 126 struct ImplCalcToTopData 127 { 128 ImplCalcToTopData* mpNext; 129 Window* mpWindow; 130 Region* mpInvalidateRegion; 131 }; 132 133 ImplAccessibleInfos::ImplAccessibleInfos() 134 { 135 nAccessibleRole = 0xFFFF; 136 pAccessibleName = NULL; 137 pAccessibleDescription = NULL; 138 pLabeledByWindow = NULL; 139 pLabelForWindow = NULL; 140 pMemberOfWindow = NULL; 141 } 142 143 ImplAccessibleInfos::~ImplAccessibleInfos() 144 { 145 delete pAccessibleName; 146 delete pAccessibleDescription; 147 } 148 149 // ----------------------------------------------------------------------- 150 151 WindowImpl::WindowImpl() 152 { 153 } 154 155 WindowImpl::~WindowImpl() 156 { 157 } 158 159 160 // ----------------------------------------------------------------------- 161 162 // helper method to allow inline constructor even for pWindow!=NULL case 163 void ImplDelData::AttachToWindow( const Window* pWindow ) 164 { 165 if( pWindow ) 166 const_cast<Window*>(pWindow)->ImplAddDel( this ); 167 } 168 169 // ----------------------------------------------------------------------- 170 171 // define dtor for ImplDelData 172 ImplDelData::~ImplDelData() 173 { 174 // #112873# auto remove of ImplDelData 175 // due to this code actively calling ImplRemoveDel() is not mandatory anymore 176 if( !mbDel && mpWindow ) 177 { 178 // the window still exists but we were not removed 179 const_cast<Window*>(mpWindow)->ImplRemoveDel( this ); 180 mpWindow = NULL; 181 } 182 } 183 184 // ----------------------------------------------------------------------- 185 186 #ifdef DBG_UTIL 187 const char* ImplDbgCheckWindow( const void* pObj ) 188 { 189 DBG_TESTSOLARMUTEX(); 190 191 const Window* pWindow = (Window*)pObj; 192 193 if ( (pWindow->GetType() < WINDOW_FIRST) || (pWindow->GetType() > WINDOW_LAST) ) 194 return "Window data overwrite"; 195 196 // Fenster-Verkettung ueberpruefen 197 Window* pChild = pWindow->mpWindowImpl->mpFirstChild; 198 while ( pChild ) 199 { 200 if ( pChild->mpWindowImpl->mpParent != pWindow ) 201 return "Child-Window-Parent wrong"; 202 pChild = pChild->mpWindowImpl->mpNext; 203 } 204 205 return NULL; 206 } 207 #endif 208 209 // ======================================================================= 210 211 void Window::ImplInitAppFontData( Window* pWindow ) 212 { 213 ImplSVData* pSVData = ImplGetSVData(); 214 long nTextHeight = pWindow->GetTextHeight(); 215 long nTextWidth = pWindow->GetTextWidth( XubString( RTL_CONSTASCII_USTRINGPARAM( "aemnnxEM" ) ) ); 216 long nSymHeight = nTextHeight*4; 217 // Falls Font zu schmal ist, machen wir die Basis breiter, 218 // damit die Dialoge symetrisch aussehen und nicht zu schmal 219 // werden. Wenn der Dialog die gleiche breite hat, geben wir 220 // noch etwas Spielraum dazu, da etwas mehr Platz besser ist. 221 if ( nSymHeight > nTextWidth ) 222 nTextWidth = nSymHeight; 223 else if ( nSymHeight+5 > nTextWidth ) 224 nTextWidth = nSymHeight+5; 225 pSVData->maGDIData.mnAppFontX = nTextWidth * 10 / 8; 226 pSVData->maGDIData.mnAppFontY = nTextHeight * 10; 227 228 // FIXME: this is currently only on aqua, check with other 229 // platforms 230 if( pSVData->maNWFData.mbNoFocusRects ) 231 { 232 // try to find out wether there is a large correction 233 // of control sizes, if yes, make app font scalings larger 234 // so dialog positioning is not completely off 235 ImplControlValue aControlValue; 236 Rectangle aCtrlRegion( Point(), Size( nTextWidth < 10 ? 10 : nTextWidth, nTextHeight < 10 ? 10 : nTextHeight ) ); 237 Rectangle aBoundingRgn( aCtrlRegion ); 238 Rectangle aContentRgn( aCtrlRegion ); 239 if( pWindow->GetNativeControlRegion( CTRL_EDITBOX, PART_ENTIRE_CONTROL, aCtrlRegion, 240 CTRL_STATE_ENABLED, aControlValue, rtl::OUString(), 241 aBoundingRgn, aContentRgn ) ) 242 { 243 // comment: the magical +6 is for the extra border in bordered 244 // (which is the standard) edit fields 245 if( aContentRgn.GetHeight() - nTextHeight > (nTextHeight+4)/4 ) 246 pSVData->maGDIData.mnAppFontY = (aContentRgn.GetHeight()-4) * 10; 247 } 248 } 249 250 251 pSVData->maGDIData.mnRealAppFontX = pSVData->maGDIData.mnAppFontX; 252 if ( pSVData->maAppData.mnDialogScaleX ) 253 pSVData->maGDIData.mnAppFontX += (pSVData->maGDIData.mnAppFontX*pSVData->maAppData.mnDialogScaleX)/100; 254 } 255 256 // ----------------------------------------------------------------------- 257 258 bool Window::ImplCheckUIFont( const Font& rFont ) 259 { 260 if( ImplGetSVData()->maGDIData.mbNativeFontConfig ) 261 return true; 262 263 // create a text string using the localized text of important buttons 264 String aTestText; 265 static const StandardButtonType aTestButtons[] = 266 { 267 BUTTON_OK, BUTTON_CANCEL, BUTTON_CLOSE, BUTTON_ABORT, 268 BUTTON_YES, BUTTON_NO, BUTTON_MORE, BUTTON_IGNORE, 269 BUTTON_RETRY, BUTTON_HELP 270 }; 271 272 const int nTestButtonCount = sizeof(aTestButtons)/sizeof(*aTestButtons); 273 for( int n = 0; n < nTestButtonCount; ++n ) 274 { 275 String aButtonStr = Button::GetStandardText( aTestButtons[n] ); 276 // #i115432# ignore mnemonic+accelerator part of each string 277 // TODO: use a string filtering method when it becomes available 278 const int nLen = aButtonStr.Len(); 279 bool bInside = false; 280 for( int i = 0; i < nLen; ++i ) { 281 const sal_Unicode c = aButtonStr.GetChar( i ); 282 if( (c == '(')) 283 bInside = true; 284 if( (c == ')')) 285 bInside = false; 286 if( (c == '~') 287 || (c == '(') || (c == ')') 288 || ((c >= 'A') && (c <= 'Z') && bInside) ) 289 aButtonStr.SetChar( i, ' ' ); 290 } 291 // append sanitized button text to test string 292 aTestText.Append( aButtonStr ); 293 } 294 295 const int nFirstChar = HasGlyphs( rFont, aTestText ); 296 const bool bUIFontOk = (nFirstChar >= aTestText.Len()); 297 return bUIFontOk; 298 } 299 300 // ----------------------------------------------------------------------- 301 302 void Window::ImplUpdateGlobalSettings( AllSettings& rSettings, sal_Bool bCallHdl ) 303 { 304 // reset high contrast to false, so the system can either update it 305 // or AutoDetectSystemHC can kick in (see below) 306 StyleSettings aTmpSt( rSettings.GetStyleSettings() ); 307 aTmpSt.SetHighContrastMode( sal_False ); 308 rSettings.SetStyleSettings( aTmpSt ); 309 ImplGetFrame()->UpdateSettings( rSettings ); 310 // reset default border width for layouters 311 ImplGetSVData()->maAppData.mnDefaultLayoutBorder = -1; 312 313 // Verify availability of the configured UI font, otherwise choose "Andale Sans UI" 314 String aUserInterfaceFont; 315 bool bUseSystemFont = rSettings.GetStyleSettings().GetUseSystemUIFonts(); 316 317 // check whether system UI font can display a typical UI text 318 if( bUseSystemFont ) 319 bUseSystemFont = ImplCheckUIFont( rSettings.GetStyleSettings().GetAppFont() ); 320 321 if ( !bUseSystemFont ) 322 { 323 ImplInitFontList(); 324 String aConfigFont = utl::DefaultFontConfiguration::get()->getUserInterfaceFont( rSettings.GetUILocale() ); 325 xub_StrLen nIndex = 0; 326 while( nIndex != STRING_NOTFOUND ) 327 { 328 String aName( aConfigFont.GetToken( 0, ';', nIndex ) ); 329 if ( aName.Len() && mpWindowImpl->mpFrameData->mpFontList->FindFontFamily( aName ) ) 330 { 331 aUserInterfaceFont = aConfigFont; 332 break; 333 } 334 } 335 336 if ( ! aUserInterfaceFont.Len() ) 337 { 338 String aFallbackFont (RTL_CONSTASCII_USTRINGPARAM( "Andale Sans UI" )); 339 if ( mpWindowImpl->mpFrameData->mpFontList->FindFontFamily( aFallbackFont ) ) 340 aUserInterfaceFont = aFallbackFont; 341 } 342 } 343 344 if ( !bUseSystemFont && aUserInterfaceFont.Len() ) 345 { 346 StyleSettings aStyleSettings = rSettings.GetStyleSettings(); 347 Font aFont = aStyleSettings.GetAppFont(); 348 aFont.SetName( aUserInterfaceFont ); 349 aStyleSettings.SetAppFont( aFont ); 350 aFont = aStyleSettings.GetHelpFont(); 351 aFont.SetName( aUserInterfaceFont ); 352 aStyleSettings.SetHelpFont( aFont ); 353 aFont = aStyleSettings.GetTitleFont(); 354 aFont.SetName( aUserInterfaceFont ); 355 aStyleSettings.SetTitleFont( aFont ); 356 aFont = aStyleSettings.GetFloatTitleFont(); 357 aFont.SetName( aUserInterfaceFont ); 358 aStyleSettings.SetFloatTitleFont( aFont ); 359 aFont = aStyleSettings.GetMenuFont(); 360 aFont.SetName( aUserInterfaceFont ); 361 aStyleSettings.SetMenuFont( aFont ); 362 aFont = aStyleSettings.GetToolFont(); 363 aFont.SetName( aUserInterfaceFont ); 364 aStyleSettings.SetToolFont( aFont ); 365 aFont = aStyleSettings.GetLabelFont(); 366 aFont.SetName( aUserInterfaceFont ); 367 aStyleSettings.SetLabelFont( aFont ); 368 aFont = aStyleSettings.GetInfoFont(); 369 aFont.SetName( aUserInterfaceFont ); 370 aStyleSettings.SetInfoFont( aFont ); 371 aFont = aStyleSettings.GetRadioCheckFont(); 372 aFont.SetName( aUserInterfaceFont ); 373 aStyleSettings.SetRadioCheckFont( aFont ); 374 aFont = aStyleSettings.GetPushButtonFont(); 375 aFont.SetName( aUserInterfaceFont ); 376 aStyleSettings.SetPushButtonFont( aFont ); 377 aFont = aStyleSettings.GetFieldFont(); 378 aFont.SetName( aUserInterfaceFont ); 379 aStyleSettings.SetFieldFont( aFont ); 380 aFont = aStyleSettings.GetIconFont(); 381 aFont.SetName( aUserInterfaceFont ); 382 aStyleSettings.SetIconFont( aFont ); 383 aFont = aStyleSettings.GetGroupFont(); 384 aFont.SetName( aUserInterfaceFont ); 385 aStyleSettings.SetGroupFont( aFont ); 386 rSettings.SetStyleSettings( aStyleSettings ); 387 } 388 389 StyleSettings aStyleSettings = rSettings.GetStyleSettings(); 390 // #97047: Force all fonts except Menu and Help to a fixed height 391 // to avoid UI scaling due to large fonts 392 // - but allow bigger fonts on bigger screens (i16682, i21238) 393 // dialogs were designed to fit 800x600 with an 8pt font, so scale accordingly 394 int maxFontheight = 9; // #107886#: 9 is default for some asian systems, so always allow if requested 395 if( GetDesktopRectPixel().getHeight() > 600 ) 396 maxFontheight = (int) ((( 8.0 * (double) GetDesktopRectPixel().getHeight()) / 600.0) + 1.5); 397 398 Font aFont = aStyleSettings.GetMenuFont(); 399 int defFontheight = aFont.GetHeight(); 400 if( defFontheight > maxFontheight ) 401 defFontheight = maxFontheight; 402 403 // if the UI is korean, chinese or another locale 404 // where the system font size is kown to be often too small to 405 // generate readable fonts enforce a minimum font size of 9 points 406 bool bBrokenLangFontHeight = false; 407 static const LanguageType eBrokenSystemFontSizeLanguages[] = 408 { LANGUAGE_KOREAN, LANGUAGE_KOREAN_JOHAB, 409 LANGUAGE_CHINESE_HONGKONG, LANGUAGE_CHINESE_MACAU, LANGUAGE_CHINESE_SIMPLIFIED, LANGUAGE_CHINESE_SINGAPORE, LANGUAGE_CHINESE_TRADITIONAL 410 }; 411 static std::set< LanguageType > aBrokenSystemFontSizeLanguagesSet( 412 eBrokenSystemFontSizeLanguages, 413 eBrokenSystemFontSizeLanguages + 414 (sizeof(eBrokenSystemFontSizeLanguages)/sizeof(eBrokenSystemFontSizeLanguages[0])) 415 ); 416 LanguageType aLang = Application::GetSettings().GetUILanguage(); 417 if( aBrokenSystemFontSizeLanguagesSet.find( aLang ) != aBrokenSystemFontSizeLanguagesSet.end() ) 418 { 419 defFontheight = Max(9, defFontheight); 420 bBrokenLangFontHeight = true; 421 } 422 423 // i22098, toolfont will be scaled differently to avoid bloated rulers and status bars for big fonts 424 int toolfontheight = defFontheight; 425 if( toolfontheight > 9 ) 426 toolfontheight = (defFontheight+8) / 2; 427 428 aFont = aStyleSettings.GetAppFont(); 429 aFont.SetHeight( defFontheight ); 430 aStyleSettings.SetAppFont( aFont ); 431 aFont = aStyleSettings.GetTitleFont(); 432 aFont.SetHeight( defFontheight ); 433 aStyleSettings.SetTitleFont( aFont ); 434 aFont = aStyleSettings.GetFloatTitleFont(); 435 aFont.SetHeight( defFontheight ); 436 aStyleSettings.SetFloatTitleFont( aFont ); 437 // keep menu and help font size from system unless in broken locale size 438 if( bBrokenLangFontHeight ) 439 { 440 aFont = aStyleSettings.GetMenuFont(); 441 if( aFont.GetHeight() < defFontheight ) 442 { 443 aFont.SetHeight( defFontheight ); 444 aStyleSettings.SetMenuFont( aFont ); 445 } 446 aFont = aStyleSettings.GetHelpFont(); 447 if( aFont.GetHeight() < defFontheight ) 448 { 449 aFont.SetHeight( defFontheight ); 450 aStyleSettings.SetHelpFont( aFont ); 451 } 452 } 453 454 // use different height for toolfont 455 aFont = aStyleSettings.GetToolFont(); 456 aFont.SetHeight( toolfontheight ); 457 aStyleSettings.SetToolFont( aFont ); 458 459 aFont = aStyleSettings.GetLabelFont(); 460 aFont.SetHeight( defFontheight ); 461 aStyleSettings.SetLabelFont( aFont ); 462 aFont = aStyleSettings.GetInfoFont(); 463 aFont.SetHeight( defFontheight ); 464 aStyleSettings.SetInfoFont( aFont ); 465 aFont = aStyleSettings.GetRadioCheckFont(); 466 aFont.SetHeight( defFontheight ); 467 aStyleSettings.SetRadioCheckFont( aFont ); 468 aFont = aStyleSettings.GetPushButtonFont(); 469 aFont.SetHeight( defFontheight ); 470 aStyleSettings.SetPushButtonFont( aFont ); 471 aFont = aStyleSettings.GetFieldFont(); 472 aFont.SetHeight( defFontheight ); 473 aStyleSettings.SetFieldFont( aFont ); 474 aFont = aStyleSettings.GetIconFont(); 475 aFont.SetHeight( defFontheight ); 476 aStyleSettings.SetIconFont( aFont ); 477 aFont = aStyleSettings.GetGroupFont(); 478 aFont.SetHeight( defFontheight ); 479 aStyleSettings.SetGroupFont( aFont ); 480 481 // set workspace gradient to black in dark themes 482 if( aStyleSettings.GetWindowColor().IsDark() ) 483 aStyleSettings.SetWorkspaceGradient( Wallpaper( Color( COL_BLACK ) ) ); 484 else 485 { 486 Gradient aGrad( GRADIENT_LINEAR, DEFAULT_WORKSPACE_GRADIENT_START_COLOR, DEFAULT_WORKSPACE_GRADIENT_END_COLOR ); 487 aStyleSettings.SetWorkspaceGradient( Wallpaper( aGrad ) ); 488 } 489 490 rSettings.SetStyleSettings( aStyleSettings ); 491 492 493 // auto detect HC mode; if the system already set it to "yes" 494 // (see above) then accept that 495 if( !rSettings.GetStyleSettings().GetHighContrastMode() ) 496 { 497 sal_Bool bTmp = sal_False, bAutoHCMode = sal_True; 498 utl::OConfigurationNode aNode = utl::OConfigurationTreeRoot::tryCreateWithServiceFactory( 499 vcl::unohelper::GetMultiServiceFactory(), 500 OUString::createFromAscii( "org.openoffice.Office.Common/Accessibility" ) ); // note: case sensisitive ! 501 if ( aNode.isValid() ) 502 { 503 ::com::sun::star::uno::Any aValue = aNode.getNodeValue( OUString::createFromAscii( "AutoDetectSystemHC" ) ); 504 if( aValue >>= bTmp ) 505 bAutoHCMode = bTmp; 506 } 507 if( bAutoHCMode ) 508 { 509 if( rSettings.GetStyleSettings().GetFaceColor().IsDark() 510 || rSettings.GetStyleSettings().GetWindowColor().IsDark() ) 511 { 512 aStyleSettings = rSettings.GetStyleSettings(); 513 aStyleSettings.SetHighContrastMode( sal_True ); 514 rSettings.SetStyleSettings( aStyleSettings ); 515 } 516 } 517 } 518 519 static const char* pEnvHC = getenv( "SAL_FORCE_HC" ); 520 if( pEnvHC && *pEnvHC ) 521 { 522 aStyleSettings.SetHighContrastMode( sal_True ); 523 rSettings.SetStyleSettings( aStyleSettings ); 524 } 525 526 #ifdef DBG_UTIL 527 // Evt. AppFont auf Fett schalten, damit man feststellen kann, 528 // ob fuer die Texte auf anderen Systemen genuegend Platz 529 // vorhanden ist 530 if ( DbgIsBoldAppFont() ) 531 { 532 aStyleSettings = rSettings.GetStyleSettings(); 533 aFont = aStyleSettings.GetAppFont(); 534 aFont.SetWeight( WEIGHT_BOLD ); 535 aStyleSettings.SetAppFont( aFont ); 536 aFont = aStyleSettings.GetGroupFont(); 537 aFont.SetWeight( WEIGHT_BOLD ); 538 aStyleSettings.SetGroupFont( aFont ); 539 aFont = aStyleSettings.GetLabelFont(); 540 aFont.SetWeight( WEIGHT_BOLD ); 541 aStyleSettings.SetLabelFont( aFont ); 542 aFont = aStyleSettings.GetRadioCheckFont(); 543 aFont.SetWeight( WEIGHT_BOLD ); 544 aStyleSettings.SetRadioCheckFont( aFont ); 545 aFont = aStyleSettings.GetPushButtonFont(); 546 aFont.SetWeight( WEIGHT_BOLD ); 547 aStyleSettings.SetPushButtonFont( aFont ); 548 aFont = aStyleSettings.GetFieldFont(); 549 aFont.SetWeight( WEIGHT_BOLD ); 550 aStyleSettings.SetFieldFont( aFont ); 551 aFont = aStyleSettings.GetIconFont(); 552 aFont.SetWeight( WEIGHT_BOLD ); 553 aStyleSettings.SetIconFont( aFont ); 554 rSettings.SetStyleSettings( aStyleSettings ); 555 } 556 #endif 557 558 if ( bCallHdl ) 559 GetpApp()->SystemSettingsChanging( rSettings, this ); 560 } 561 562 // ----------------------------------------------------------------------- 563 564 MouseEvent ImplTranslateMouseEvent( const MouseEvent& rE, Window* pSource, Window* pDest ) 565 { 566 Point aPos = pSource->OutputToScreenPixel( rE.GetPosPixel() ); 567 aPos = pDest->ScreenToOutputPixel( aPos ); 568 return MouseEvent( aPos, rE.GetClicks(), rE.GetMode(), rE.GetButtons(), rE.GetModifier() ); 569 } 570 571 // ----------------------------------------------------------------------- 572 573 CommandEvent ImplTranslateCommandEvent( const CommandEvent& rCEvt, Window* pSource, Window* pDest ) 574 { 575 if ( !rCEvt.IsMouseEvent() ) 576 return rCEvt; 577 578 Point aPos = pSource->OutputToScreenPixel( rCEvt.GetMousePosPixel() ); 579 aPos = pDest->ScreenToOutputPixel( aPos ); 580 return CommandEvent( aPos, rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetData() ); 581 } 582 583 // ======================================================================= 584 585 void Window::ImplInitWindowData( WindowType nType ) 586 { 587 mpWindowImpl = new WindowImpl; 588 589 meOutDevType = OUTDEV_WINDOW; 590 591 mpWindowImpl->maZoom = Fraction( 1, 1 ); 592 mpWindowImpl->maWinRegion = Region( REGION_NULL ); 593 mpWindowImpl->maWinClipRegion = Region( REGION_NULL ); 594 mpWindowImpl->mpWinData = NULL; // Extra Window Data, that we dont need for all windows 595 mpWindowImpl->mpOverlapData = NULL; // Overlap Data 596 mpWindowImpl->mpFrameData = NULL; // Frame Data 597 mpWindowImpl->mpFrame = NULL; // Pointer to frame window 598 mpWindowImpl->mpSysObj = NULL; 599 mpWindowImpl->mpFrameWindow = NULL; // window to top level parent (same as frame window) 600 mpWindowImpl->mpOverlapWindow = NULL; // first overlap parent 601 mpWindowImpl->mpBorderWindow = NULL; // Border-Window 602 mpWindowImpl->mpClientWindow = NULL; // Client-Window of a FrameWindow 603 mpWindowImpl->mpParent = NULL; // parent (inkl. BorderWindow) 604 mpWindowImpl->mpRealParent = NULL; // real parent (exkl. BorderWindow) 605 mpWindowImpl->mpFirstChild = NULL; // first child window 606 mpWindowImpl->mpLastChild = NULL; // last child window 607 mpWindowImpl->mpFirstOverlap = NULL; // first overlap window (only set in overlap windows) 608 mpWindowImpl->mpLastOverlap = NULL; // last overlap window (only set in overlap windows) 609 mpWindowImpl->mpPrev = NULL; // prev window 610 mpWindowImpl->mpNext = NULL; // next window 611 mpWindowImpl->mpNextOverlap = NULL; // next overlap window of frame 612 mpWindowImpl->mpLastFocusWindow = NULL; // window for focus restore 613 mpWindowImpl->mpDlgCtrlDownWindow = NULL; // window for dialog control 614 mpWindowImpl->mpFirstDel = NULL; // Dtor notification list 615 mpWindowImpl->mpUserData = NULL; // user data 616 mpWindowImpl->mpExtImpl = NULL; // extended implementation data 617 mpWindowImpl->mpCursor = NULL; // cursor 618 mpWindowImpl->mpControlFont = NULL; // font propertie 619 mpWindowImpl->mpVCLXWindow = NULL; 620 mpWindowImpl->mpAccessibleInfos = NULL; 621 mpWindowImpl->maControlForeground = Color( COL_TRANSPARENT ); // kein Foreground gesetzt 622 mpWindowImpl->maControlBackground = Color( COL_TRANSPARENT ); // kein Background gesetzt 623 mpWindowImpl->mnLeftBorder = 0; // left border 624 mpWindowImpl->mnTopBorder = 0; // top border 625 mpWindowImpl->mnRightBorder = 0; // right border 626 mpWindowImpl->mnBottomBorder = 0; // bottom border 627 mpWindowImpl->mnX = 0; // X-Position to Parent 628 mpWindowImpl->mnY = 0; // Y-Position to Parent 629 mpWindowImpl->mnAbsScreenX = 0; // absolute X-position on screen, used for RTL window positioning 630 mpWindowImpl->mpChildClipRegion = NULL; // Child-Clip-Region when ClipChildren 631 mpWindowImpl->mpPaintRegion = NULL; // Paint-ClipRegion 632 mpWindowImpl->mnStyle = 0; // style (init in ImplInitWindow) 633 mpWindowImpl->mnPrevStyle = 0; // prevstyle (set in SetStyle) 634 mpWindowImpl->mnExtendedStyle = 0; // extended style (init in ImplInitWindow) 635 mpWindowImpl->mnPrevExtendedStyle = 0; // prevstyle (set in SetExtendedStyle) 636 mpWindowImpl->mnType = nType; // type 637 mpWindowImpl->mnGetFocusFlags = 0; // Flags fuer GetFocus()-Aufruf 638 mpWindowImpl->mnWaitCount = 0; // Wait-Count (>1 == Warte-MousePointer) 639 mpWindowImpl->mnPaintFlags = 0; // Flags for ImplCallPaint 640 mpWindowImpl->mnParentClipMode = 0; // Flags for Parent-ClipChildren-Mode 641 mpWindowImpl->mnActivateMode = 0; // Wird bei System/Overlap-Windows umgesetzt 642 mpWindowImpl->mnDlgCtrlFlags = 0; // DialogControl-Flags 643 mpWindowImpl->mnLockCount = 0; // LockCount 644 mpWindowImpl->meAlwaysInputMode = AlwaysInputNone; // neither AlwaysEnableInput nor AlwaysDisableInput called 645 mpWindowImpl->mbFrame = sal_False; // sal_True: Window is a frame window 646 mpWindowImpl->mbBorderWin = sal_False; // sal_True: Window is a border window 647 mpWindowImpl->mbOverlapWin = sal_False; // sal_True: Window is a overlap window 648 mpWindowImpl->mbSysWin = sal_False; // sal_True: SystemWindow is the base class 649 mpWindowImpl->mbDialog = sal_False; // sal_True: Dialog is the base class 650 mpWindowImpl->mbDockWin = sal_False; // sal_True: DockingWindow is the base class 651 mpWindowImpl->mbFloatWin = sal_False; // sal_True: FloatingWindow is the base class 652 mpWindowImpl->mbPushButton = sal_False; // sal_True: PushButton is the base class 653 mpWindowImpl->mbToolBox = sal_False; // sal_True: ToolBox is the base class 654 mpWindowImpl->mbMenuFloatingWindow= sal_False; // sal_True: MenuFloatingWindow is the base class 655 mpWindowImpl->mbToolbarFloatingWindow= sal_False; // sal_True: ImplPopupFloatWin is the base class, used for subtoolbars 656 mpWindowImpl->mbSplitter = sal_False; // sal_True: Splitter is the base class 657 mpWindowImpl->mbVisible = sal_False; // sal_True: Show( sal_True ) called 658 mpWindowImpl->mbOverlapVisible = sal_False; // sal_True: Hide called for visible window from ImplHideAllOverlapWindow() 659 mpWindowImpl->mbDisabled = sal_False; // sal_True: Enable( sal_False ) called 660 mpWindowImpl->mbInputDisabled = sal_False; // sal_True: EnableInput( sal_False ) called 661 mpWindowImpl->mbDropDisabled = sal_False; // sal_True: Drop is enabled 662 mpWindowImpl->mbNoUpdate = sal_False; // sal_True: SetUpdateMode( sal_False ) called 663 mpWindowImpl->mbNoParentUpdate = sal_False; // sal_True: SetParentUpdateMode( sal_False ) called 664 mpWindowImpl->mbActive = sal_False; // sal_True: Window Active 665 mpWindowImpl->mbParentActive = sal_False; // sal_True: OverlapActive from Parent 666 mpWindowImpl->mbReallyVisible = sal_False; // sal_True: this and all parents to an overlaped window are visible 667 mpWindowImpl->mbReallyShown = sal_False; // sal_True: this and all parents to an overlaped window are shown 668 mpWindowImpl->mbInInitShow = sal_False; // sal_True: we are in InitShow 669 mpWindowImpl->mbChildNotify = sal_False; // sal_True: ChildNotify 670 mpWindowImpl->mbChildPtrOverwrite = sal_False; // sal_True: PointerStyle overwrites Child-Pointer 671 mpWindowImpl->mbNoPtrVisible = sal_False; // sal_True: ShowPointer( sal_False ) called 672 mpWindowImpl->mbMouseMove = sal_False; // sal_True: BaseMouseMove called 673 mpWindowImpl->mbPaintFrame = sal_False; // sal_True: Paint is visible, but not painted 674 mpWindowImpl->mbInPaint = sal_False; // sal_True: Inside PaintHdl 675 mpWindowImpl->mbMouseButtonDown = sal_False; // sal_True: BaseMouseButtonDown called 676 mpWindowImpl->mbMouseButtonUp = sal_False; // sal_True: BaseMouseButtonUp called 677 mpWindowImpl->mbKeyInput = sal_False; // sal_True: BaseKeyInput called 678 mpWindowImpl->mbKeyUp = sal_False; // sal_True: BaseKeyUp called 679 mpWindowImpl->mbCommand = sal_False; // sal_True: BaseCommand called 680 mpWindowImpl->mbDefPos = sal_True; // sal_True: Position is not Set 681 mpWindowImpl->mbDefSize = sal_True; // sal_True: Size is not Set 682 mpWindowImpl->mbCallMove = sal_True; // sal_True: Move must be called by Show 683 mpWindowImpl->mbCallResize = sal_True; // sal_True: Resize must be called by Show 684 mpWindowImpl->mbWaitSystemResize = sal_True; // sal_True: Wait for System-Resize 685 mpWindowImpl->mbInitWinClipRegion = sal_True; // sal_True: Calc Window Clip Region 686 mpWindowImpl->mbInitChildRegion = sal_False; // sal_True: InitChildClipRegion 687 mpWindowImpl->mbWinRegion = sal_False; // sal_True: Window Region 688 mpWindowImpl->mbClipChildren = sal_False; // sal_True: Child-Fenster muessen evt. geclippt werden 689 mpWindowImpl->mbClipSiblings = sal_False; // sal_True: Nebeneinanderliegende Child-Fenster muessen evt. geclippt werden 690 mpWindowImpl->mbChildTransparent = sal_False; // sal_True: Child-Fenster duerfen transparent einschalten (inkl. Parent-CLIPCHILDREN) 691 mpWindowImpl->mbPaintTransparent = sal_False; // sal_True: Paints muessen auf Parent ausgeloest werden 692 mpWindowImpl->mbMouseTransparent = sal_False; // sal_True: Window is transparent for Mouse 693 mpWindowImpl->mbDlgCtrlStart = sal_False; // sal_True: Ab hier eigenes Dialog-Control 694 mpWindowImpl->mbFocusVisible = sal_False; // sal_True: Focus Visible 695 mpWindowImpl->mbUseNativeFocus = sal_False; 696 mpWindowImpl->mbNativeFocusVisible= sal_False; // sal_True: native Focus Visible 697 mpWindowImpl->mbInShowFocus = sal_False; // prevent recursion 698 mpWindowImpl->mbInHideFocus = sal_False; // prevent recursion 699 mpWindowImpl->mbTrackVisible = sal_False; // sal_True: Tracking Visible 700 mpWindowImpl->mbControlForeground = sal_False; // sal_True: Foreground-Property set 701 mpWindowImpl->mbControlBackground = sal_False; // sal_True: Background-Property set 702 mpWindowImpl->mbAlwaysOnTop = sal_False; // sal_True: immer vor allen anderen normalen Fenstern sichtbar 703 mpWindowImpl->mbCompoundControl = sal_False; // sal_True: Zusammengesetztes Control => Listener... 704 mpWindowImpl->mbCompoundControlHasFocus = sal_False; // sal_True: Zusammengesetztes Control hat irgendwo den Focus 705 mpWindowImpl->mbPaintDisabled = sal_False; // sal_True: Paint soll nicht ausgefuehrt werden 706 mpWindowImpl->mbAllResize = sal_False; // sal_True: Auch ResizeEvents mit 0,0 schicken 707 mpWindowImpl->mbInDtor = sal_False; // sal_True: Wir befinden uns im Window-Dtor 708 mpWindowImpl->mbExtTextInput = sal_False; // sal_True: ExtTextInput-Mode is active 709 mpWindowImpl->mbInFocusHdl = sal_False; // sal_True: Innerhalb vom GetFocus-Handler 710 mpWindowImpl->mbCreatedWithToolkit = sal_False; 711 mpWindowImpl->mbSuppressAccessibilityEvents = sal_False; // sal_True: do not send any accessibility events 712 mpWindowImpl->mbDrawSelectionBackground = sal_False; // sal_True: draws transparent window background to indicate (toolbox) selection 713 mpWindowImpl->mbIsInTaskPaneList = sal_False; // sal_True: window was added to the taskpanelist in the topmost system window 714 mpWindowImpl->mnNativeBackground = 0; // initialize later, depends on type 715 mpWindowImpl->mbCallHandlersDuringInputDisabled = sal_False; // sal_True: call event handlers even if input is disabled 716 mpWindowImpl->mbDisableAccessibleLabelForRelation = sal_False; // sal_True: do not set LabelFor relation on accessible objects 717 mpWindowImpl->mbDisableAccessibleLabeledByRelation = sal_False; // sal_True: do not set LabeledBy relation on accessible objects 718 mpWindowImpl->mbHelpTextDynamic = sal_False; // sal_True: append help id in HELP_DEBUG case 719 mpWindowImpl->mbFakeFocusSet = sal_False; // sal_True: pretend as if the window has focus. 720 721 mbEnableRTL = Application::GetSettings().GetLayoutRTL(); // sal_True: this outdev will be mirrored if RTL window layout (UI mirroring) is globally active 722 } 723 724 // ----------------------------------------------------------------------- 725 726 void Window::ImplInit( Window* pParent, WinBits nStyle, const ::com::sun::star::uno::Any& /*aSystemWorkWindowToken*/ ) 727 { 728 ImplInit( pParent, nStyle, NULL ); 729 } 730 731 // ----------------------------------------------------------------------- 732 733 void Window::ImplInit( Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData ) 734 { 735 DBG_ASSERT( mpWindowImpl->mbFrame || pParent, "Window::Window(): pParent == NULL" ); 736 737 ImplSVData* pSVData = ImplGetSVData(); 738 Window* pRealParent = pParent; 739 740 // 3D-Look vererben 741 if ( !mpWindowImpl->mbOverlapWin && pParent && (pParent->GetStyle() & WB_3DLOOK) ) 742 nStyle |= WB_3DLOOK; 743 744 // create border window if necessary 745 if ( !mpWindowImpl->mbFrame && !mpWindowImpl->mbBorderWin && !mpWindowImpl->mpBorderWindow 746 && (nStyle & (WB_BORDER | WB_SYSTEMCHILDWINDOW) ) ) 747 { 748 sal_uInt16 nBorderTypeStyle = 0; 749 if( (nStyle & WB_SYSTEMCHILDWINDOW) ) 750 { 751 // handle WB_SYSTEMCHILDWINDOW 752 // these should be analogous to a top level frame; meaning they 753 // should have a border window with style BORDERWINDOW_STYLE_FRAME 754 // which controls their size 755 nBorderTypeStyle |= BORDERWINDOW_STYLE_FRAME; 756 nStyle |= WB_BORDER; 757 } 758 ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, nStyle & (WB_BORDER | WB_DIALOGCONTROL | WB_NODIALOGCONTROL | WB_NEEDSFOCUS), nBorderTypeStyle ); 759 ((Window*)pBorderWin)->mpWindowImpl->mpClientWindow = this; 760 pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder ); 761 mpWindowImpl->mpBorderWindow = pBorderWin; 762 pParent = mpWindowImpl->mpBorderWindow; 763 } 764 else if( !mpWindowImpl->mbFrame && ! pParent ) 765 { 766 mpWindowImpl->mbOverlapWin = sal_True; 767 mpWindowImpl->mbFrame = sal_True; 768 } 769 770 // insert window in list 771 ImplInsertWindow( pParent ); 772 mpWindowImpl->mnStyle = nStyle; 773 774 // Overlap-Window-Daten 775 if ( mpWindowImpl->mbOverlapWin ) 776 { 777 mpWindowImpl->mpOverlapData = new ImplOverlapData; 778 mpWindowImpl->mpOverlapData->mpSaveBackDev = NULL; 779 mpWindowImpl->mpOverlapData->mpSaveBackRgn = NULL; 780 mpWindowImpl->mpOverlapData->mpNextBackWin = NULL; 781 mpWindowImpl->mpOverlapData->mnSaveBackSize = 0; 782 mpWindowImpl->mpOverlapData->mbSaveBack = sal_False; 783 mpWindowImpl->mpOverlapData->mnTopLevel = 1; 784 } 785 786 if( pParent && ! mpWindowImpl->mbFrame ) 787 mbEnableRTL = pParent->mbEnableRTL; 788 789 // test for frame creation 790 if ( mpWindowImpl->mbFrame ) 791 { 792 // create frame 793 sal_uLong nFrameStyle = 0; 794 795 if ( nStyle & WB_MOVEABLE ) 796 nFrameStyle |= SAL_FRAME_STYLE_MOVEABLE; 797 if ( nStyle & WB_SIZEABLE ) 798 nFrameStyle |= SAL_FRAME_STYLE_SIZEABLE; 799 if ( nStyle & WB_CLOSEABLE ) 800 nFrameStyle |= SAL_FRAME_STYLE_CLOSEABLE; 801 if ( nStyle & WB_APP ) 802 nFrameStyle |= SAL_FRAME_STYLE_DEFAULT; 803 // check for undecorated floating window 804 if( // 1. floating windows that are not moveable/sizeable (only closeable allowed) 805 ( !(nFrameStyle & ~SAL_FRAME_STYLE_CLOSEABLE) && 806 ( mpWindowImpl->mbFloatWin || ((GetType() == WINDOW_BORDERWINDOW) && ((ImplBorderWindow*)this)->mbFloatWindow) || (nStyle & WB_SYSTEMFLOATWIN) ) ) || 807 // 2. borderwindows of floaters with ownerdraw decoration 808 ( ((GetType() == WINDOW_BORDERWINDOW) && ((ImplBorderWindow*)this)->mbFloatWindow && (nStyle & WB_OWNERDRAWDECORATION) ) ) ) 809 { 810 nFrameStyle = SAL_FRAME_STYLE_FLOAT; 811 if( nStyle & WB_OWNERDRAWDECORATION ) 812 nFrameStyle |= (SAL_FRAME_STYLE_OWNERDRAWDECORATION | SAL_FRAME_STYLE_NOSHADOW); 813 if( nStyle & WB_NEEDSFOCUS ) 814 nFrameStyle |= SAL_FRAME_STYLE_FLOAT_FOCUSABLE; 815 } 816 else if( mpWindowImpl->mbFloatWin ) 817 nFrameStyle |= SAL_FRAME_STYLE_TOOLWINDOW; 818 819 if( nStyle & WB_INTROWIN ) 820 nFrameStyle |= SAL_FRAME_STYLE_INTRO; 821 if( nStyle & WB_TOOLTIPWIN ) 822 nFrameStyle |= SAL_FRAME_STYLE_TOOLTIP; 823 824 if( nStyle & WB_NOSHADOW ) 825 nFrameStyle |= SAL_FRAME_STYLE_NOSHADOW; 826 827 if( nStyle & WB_SYSTEMCHILDWINDOW ) 828 nFrameStyle |= SAL_FRAME_STYLE_SYSTEMCHILD; 829 830 switch (mpWindowImpl->mnType) 831 { 832 case WINDOW_DIALOG: 833 case WINDOW_TABDIALOG: 834 case WINDOW_MODALDIALOG: 835 case WINDOW_MODELESSDIALOG: 836 case WINDOW_MESSBOX: 837 case WINDOW_INFOBOX: 838 case WINDOW_WARNINGBOX: 839 case WINDOW_ERRORBOX: 840 case WINDOW_QUERYBOX: 841 nFrameStyle |= SAL_FRAME_STYLE_DIALOG; 842 default: 843 break; 844 } 845 846 SalFrame* pParentFrame = NULL; 847 if ( pParent ) 848 pParentFrame = pParent->mpWindowImpl->mpFrame; 849 SalFrame* pFrame; 850 if ( pSystemParentData ) 851 pFrame = pSVData->mpDefInst->CreateChildFrame( pSystemParentData, nFrameStyle | SAL_FRAME_STYLE_PLUG ); 852 else 853 pFrame = pSVData->mpDefInst->CreateFrame( pParentFrame, nFrameStyle ); 854 if ( !pFrame ) 855 { 856 // do not abort but throw an exception, may be the current thread terminates anyway (plugin-scenario) 857 throw ::com::sun::star::uno::RuntimeException( 858 OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not create system window!" ) ), 859 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() ); 860 //GetpApp()->Exception( EXC_SYSOBJNOTCREATED ); 861 } 862 863 pFrame->SetCallback( this, ImplWindowFrameProc ); 864 865 // set window frame data 866 mpWindowImpl->mpFrameData = new ImplFrameData; 867 mpWindowImpl->mpFrame = pFrame; 868 mpWindowImpl->mpFrameWindow = this; 869 mpWindowImpl->mpOverlapWindow = this; 870 871 // set frame data 872 mpWindowImpl->mpFrameData->mpNextFrame = pSVData->maWinData.mpFirstFrame; 873 pSVData->maWinData.mpFirstFrame = this; 874 mpWindowImpl->mpFrameData->mpFirstOverlap = NULL; 875 mpWindowImpl->mpFrameData->mpFocusWin = NULL; 876 mpWindowImpl->mpFrameData->mpMouseMoveWin = NULL; 877 mpWindowImpl->mpFrameData->mpMouseDownWin = NULL; 878 mpWindowImpl->mpFrameData->mpFirstBackWin = NULL; 879 mpWindowImpl->mpFrameData->mpFontList = pSVData->maGDIData.mpScreenFontList; 880 mpWindowImpl->mpFrameData->mpFontCache = pSVData->maGDIData.mpScreenFontCache; 881 mpWindowImpl->mpFrameData->mnAllSaveBackSize = 0; 882 mpWindowImpl->mpFrameData->mnFocusId = 0; 883 mpWindowImpl->mpFrameData->mnMouseMoveId = 0; 884 mpWindowImpl->mpFrameData->mnLastMouseX = -1; 885 mpWindowImpl->mpFrameData->mnLastMouseY = -1; 886 mpWindowImpl->mpFrameData->mnBeforeLastMouseX = -1; 887 mpWindowImpl->mpFrameData->mnBeforeLastMouseY = -1; 888 mpWindowImpl->mpFrameData->mnFirstMouseX = -1; 889 mpWindowImpl->mpFrameData->mnFirstMouseY = -1; 890 mpWindowImpl->mpFrameData->mnLastMouseWinX = -1; 891 mpWindowImpl->mpFrameData->mnLastMouseWinY = -1; 892 mpWindowImpl->mpFrameData->mnModalMode = 0; 893 mpWindowImpl->mpFrameData->mnMouseDownTime = 0; 894 mpWindowImpl->mpFrameData->mnClickCount = 0; 895 mpWindowImpl->mpFrameData->mnFirstMouseCode = 0; 896 mpWindowImpl->mpFrameData->mnMouseCode = 0; 897 mpWindowImpl->mpFrameData->mnMouseMode = 0; 898 mpWindowImpl->mpFrameData->meMapUnit = MAP_PIXEL; 899 mpWindowImpl->mpFrameData->mbHasFocus = sal_False; 900 mpWindowImpl->mpFrameData->mbInMouseMove = sal_False; 901 mpWindowImpl->mpFrameData->mbMouseIn = sal_False; 902 mpWindowImpl->mpFrameData->mbStartDragCalled = sal_False; 903 mpWindowImpl->mpFrameData->mbNeedSysWindow = sal_False; 904 mpWindowImpl->mpFrameData->mbMinimized = sal_False; 905 mpWindowImpl->mpFrameData->mbStartFocusState = sal_False; 906 mpWindowImpl->mpFrameData->mbInSysObjFocusHdl = sal_False; 907 mpWindowImpl->mpFrameData->mbInSysObjToTopHdl = sal_False; 908 mpWindowImpl->mpFrameData->mbSysObjFocus = sal_False; 909 mpWindowImpl->mpFrameData->maPaintTimer.SetTimeout( 30 ); 910 mpWindowImpl->mpFrameData->maPaintTimer.SetTimeoutHdl( LINK( this, Window, ImplHandlePaintHdl ) ); 911 mpWindowImpl->mpFrameData->maResizeTimer.SetTimeout( 50 ); 912 mpWindowImpl->mpFrameData->maResizeTimer.SetTimeoutHdl( LINK( this, Window, ImplHandleResizeTimerHdl ) ); 913 mpWindowImpl->mpFrameData->mbInternalDragGestureRecognizer = sal_False; 914 915 if ( pRealParent && IsTopWindow() ) 916 { 917 ImplWinData* pParentWinData = pRealParent->ImplGetWinData(); 918 pParentWinData->maTopWindowChildren.push_back( this ); 919 } 920 } 921 922 // init data 923 mpWindowImpl->mpRealParent = pRealParent; 924 925 // #99318: make sure fontcache and list is available before call to SetSettings 926 mpFontList = mpWindowImpl->mpFrameData->mpFontList; 927 mpFontCache = mpWindowImpl->mpFrameData->mpFontCache; 928 929 if ( mpWindowImpl->mbFrame ) 930 { 931 if ( pParent ) 932 { 933 mpWindowImpl->mpFrameData->mnDPIX = pParent->mpWindowImpl->mpFrameData->mnDPIX; 934 mpWindowImpl->mpFrameData->mnDPIY = pParent->mpWindowImpl->mpFrameData->mnDPIY; 935 } 936 else 937 { 938 if ( ImplGetGraphics() ) 939 { 940 mpGraphics->GetResolution( mpWindowImpl->mpFrameData->mnDPIX, mpWindowImpl->mpFrameData->mnDPIY ); 941 } 942 } 943 944 // add ownerdraw decorated frame windows to list in the top-most frame window 945 // so they can be hidden on lose focus 946 if( nStyle & WB_OWNERDRAWDECORATION ) 947 ImplGetOwnerDrawList().push_back( this ); 948 949 // delay settings initialization until first "real" frame 950 // this relies on the IntroWindow not needing any system settings 951 if ( !pSVData->maAppData.mbSettingsInit && 952 ! (nStyle & (WB_INTROWIN|WB_DEFAULTWIN)) 953 ) 954 { 955 // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings 956 ImplUpdateGlobalSettings( *pSVData->maAppData.mpSettings ); 957 OutputDevice::SetSettings( *pSVData->maAppData.mpSettings ); 958 pSVData->maAppData.mbSettingsInit = sal_True; 959 } 960 961 // If we create a Window with default size, query this 962 // size directly, because we want resize all Controls to 963 // the correct size before we display the window 964 if ( nStyle & (WB_MOVEABLE | WB_SIZEABLE | WB_APP) ) 965 mpWindowImpl->mpFrame->GetClientSize( mnOutWidth, mnOutHeight ); 966 } 967 else 968 { 969 if ( pParent ) 970 { 971 if ( !ImplIsOverlapWindow() ) 972 { 973 mpWindowImpl->mbDisabled = pParent->mpWindowImpl->mbDisabled; 974 mpWindowImpl->mbInputDisabled = pParent->mpWindowImpl->mbInputDisabled; 975 mpWindowImpl->meAlwaysInputMode = pParent->mpWindowImpl->meAlwaysInputMode; 976 } 977 978 OutputDevice::SetSettings( pParent->GetSettings() ); 979 } 980 981 } 982 983 const StyleSettings& rStyleSettings = maSettings.GetStyleSettings(); 984 sal_uInt16 nScreenZoom = rStyleSettings.GetScreenZoom(); 985 mnDPIX = (mpWindowImpl->mpFrameData->mnDPIX*nScreenZoom)/100; 986 mnDPIY = (mpWindowImpl->mpFrameData->mnDPIY*nScreenZoom)/100; 987 maFont = rStyleSettings.GetAppFont(); 988 ImplPointToLogic( maFont ); 989 990 if ( nStyle & WB_3DLOOK ) 991 { 992 SetTextColor( rStyleSettings.GetButtonTextColor() ); 993 SetBackground( Wallpaper( rStyleSettings.GetFaceColor() ) ); 994 } 995 else 996 { 997 SetTextColor( rStyleSettings.GetWindowTextColor() ); 998 SetBackground( Wallpaper( rStyleSettings.GetWindowColor() ) ); 999 } 1000 1001 ImplUpdatePos(); 1002 1003 // calculate app font res (except for the Intro Window or the default window) 1004 if ( mpWindowImpl->mbFrame && !pSVData->maGDIData.mnAppFontX && ! (nStyle & (WB_INTROWIN|WB_DEFAULTWIN)) ) 1005 ImplInitAppFontData( this ); 1006 1007 if ( GetAccessibleParentWindow() && GetParent() != Application::GetDefDialogParent() ) 1008 GetAccessibleParentWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_CHILDCREATED, this ); 1009 } 1010 1011 // ----------------------------------------------------------------------- 1012 1013 void Window::ImplSetFrameParent( const Window* pParent ) 1014 { 1015 Window* pFrameWindow = ImplGetSVData()->maWinData.mpFirstFrame; 1016 while( pFrameWindow ) 1017 { 1018 // search all frames that are children of this window 1019 // and reparent them 1020 if( ImplIsRealParentPath( pFrameWindow ) ) 1021 { 1022 DBG_ASSERT( mpWindowImpl->mpFrame != pFrameWindow->mpWindowImpl->mpFrame, "SetFrameParent to own" ); 1023 DBG_ASSERT( mpWindowImpl->mpFrame, "no frame" ); 1024 SalFrame* pParentFrame = pParent ? pParent->mpWindowImpl->mpFrame : NULL; 1025 pFrameWindow->mpWindowImpl->mpFrame->SetParent( pParentFrame ); 1026 } 1027 pFrameWindow = pFrameWindow->mpWindowImpl->mpFrameData->mpNextFrame; 1028 } 1029 } 1030 1031 // ----------------------------------------------------------------------- 1032 1033 void Window::ImplInsertWindow( Window* pParent ) 1034 { 1035 mpWindowImpl->mpParent = pParent; 1036 mpWindowImpl->mpRealParent = pParent; 1037 1038 if ( pParent && !mpWindowImpl->mbFrame ) 1039 { 1040 // search frame window and set window frame data 1041 Window* pFrameParent = pParent->mpWindowImpl->mpFrameWindow; 1042 mpWindowImpl->mpFrameData = pFrameParent->mpWindowImpl->mpFrameData; 1043 mpWindowImpl->mpFrame = pFrameParent->mpWindowImpl->mpFrame; 1044 mpWindowImpl->mpFrameWindow = pFrameParent; 1045 mpWindowImpl->mbFrame = sal_False; 1046 1047 // search overlap window and insert window in list 1048 if ( ImplIsOverlapWindow() ) 1049 { 1050 Window* pFirstOverlapParent = pParent; 1051 while ( !pFirstOverlapParent->ImplIsOverlapWindow() ) 1052 pFirstOverlapParent = pFirstOverlapParent->ImplGetParent(); 1053 mpWindowImpl->mpOverlapWindow = pFirstOverlapParent; 1054 1055 mpWindowImpl->mpNextOverlap = mpWindowImpl->mpFrameData->mpFirstOverlap; 1056 mpWindowImpl->mpFrameData->mpFirstOverlap = this; 1057 1058 // Overlap-Windows sind per default die obersten 1059 mpWindowImpl->mpNext = pFirstOverlapParent->mpWindowImpl->mpFirstOverlap; 1060 pFirstOverlapParent->mpWindowImpl->mpFirstOverlap = this; 1061 if ( !pFirstOverlapParent->mpWindowImpl->mpLastOverlap ) 1062 pFirstOverlapParent->mpWindowImpl->mpLastOverlap = this; 1063 else 1064 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = this; 1065 } 1066 else 1067 { 1068 if ( pParent->ImplIsOverlapWindow() ) 1069 mpWindowImpl->mpOverlapWindow = pParent; 1070 else 1071 mpWindowImpl->mpOverlapWindow = pParent->mpWindowImpl->mpOverlapWindow; 1072 mpWindowImpl->mpPrev = pParent->mpWindowImpl->mpLastChild; 1073 pParent->mpWindowImpl->mpLastChild = this; 1074 if ( !pParent->mpWindowImpl->mpFirstChild ) 1075 pParent->mpWindowImpl->mpFirstChild = this; 1076 else 1077 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this; 1078 } 1079 } 1080 } 1081 1082 // ----------------------------------------------------------------------- 1083 1084 void Window::ImplRemoveWindow( sal_Bool bRemoveFrameData ) 1085 { 1086 // Fenster aus den Listen austragen 1087 if ( !mpWindowImpl->mbFrame ) 1088 { 1089 if ( ImplIsOverlapWindow() ) 1090 { 1091 if ( mpWindowImpl->mpFrameData->mpFirstOverlap == this ) 1092 mpWindowImpl->mpFrameData->mpFirstOverlap = mpWindowImpl->mpNextOverlap; 1093 else 1094 { 1095 Window* pTempWin = mpWindowImpl->mpFrameData->mpFirstOverlap; 1096 while ( pTempWin->mpWindowImpl->mpNextOverlap != this ) 1097 pTempWin = pTempWin->mpWindowImpl->mpNextOverlap; 1098 pTempWin->mpWindowImpl->mpNextOverlap = mpWindowImpl->mpNextOverlap; 1099 } 1100 1101 if ( mpWindowImpl->mpPrev ) 1102 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext; 1103 else 1104 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap = mpWindowImpl->mpNext; 1105 if ( mpWindowImpl->mpNext ) 1106 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev; 1107 else 1108 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = mpWindowImpl->mpPrev; 1109 } 1110 else 1111 { 1112 if ( mpWindowImpl->mpPrev ) 1113 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext; 1114 else 1115 mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext; 1116 if ( mpWindowImpl->mpNext ) 1117 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev; 1118 else 1119 mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = mpWindowImpl->mpPrev; 1120 } 1121 1122 mpWindowImpl->mpPrev = NULL; 1123 mpWindowImpl->mpNext = NULL; 1124 } 1125 1126 if ( bRemoveFrameData ) 1127 { 1128 // Graphic freigeben 1129 ImplReleaseGraphics(); 1130 } 1131 } 1132 1133 // ----------------------------------------------------------------------- 1134 1135 void Window::ImplCallResize() 1136 { 1137 mpWindowImpl->mbCallResize = sal_False; 1138 1139 if( GetBackground().IsGradient() ) 1140 Invalidate(); 1141 1142 Resize(); 1143 1144 // #88419# Most classes don't call the base class in Resize() and Move(), 1145 // => Call ImpleResize/Move instead of Resize/Move directly... 1146 ImplCallEventListeners( VCLEVENT_WINDOW_RESIZE ); 1147 1148 ImplExtResize(); 1149 } 1150 1151 // ----------------------------------------------------------------------- 1152 1153 void Window::ImplCallMove() 1154 { 1155 mpWindowImpl->mbCallMove = sal_False; 1156 1157 if( mpWindowImpl->mbFrame ) 1158 { 1159 // update frame position 1160 SalFrame *pParentFrame = NULL; 1161 Window *pParent = ImplGetParent(); 1162 while( pParent ) 1163 { 1164 if( pParent->mpWindowImpl->mpFrame != mpWindowImpl->mpFrame ) 1165 { 1166 pParentFrame = pParent->mpWindowImpl->mpFrame; 1167 break; 1168 } 1169 pParent = pParent->GetParent(); 1170 } 1171 1172 SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry(); 1173 mpWindowImpl->maPos = Point( g.nX, g.nY ); 1174 if( pParentFrame ) 1175 { 1176 g = pParentFrame->GetGeometry(); 1177 mpWindowImpl->maPos -= Point( g.nX, g.nY ); 1178 } 1179 // the client window and and all its subclients have the same position as the borderframe 1180 // this is important for floating toolbars where the borderwindow is a floating window 1181 // which has another borderwindow (ie the system floating window) 1182 Window *pClientWin = mpWindowImpl->mpClientWindow; 1183 while( pClientWin ) 1184 { 1185 pClientWin->mpWindowImpl->maPos = mpWindowImpl->maPos; 1186 pClientWin = pClientWin->mpWindowImpl->mpClientWindow; 1187 } 1188 } 1189 1190 Move(); 1191 1192 ImplCallEventListeners( VCLEVENT_WINDOW_MOVE ); 1193 } 1194 1195 // ----------------------------------------------------------------------- 1196 1197 static rtl::OString ImplAutoHelpID( ResMgr* pResMgr ) 1198 { 1199 rtl::OString aRet; 1200 1201 if( pResMgr && Application::IsAutoHelpIdEnabled() ) 1202 aRet = pResMgr->GetAutoHelpId(); 1203 1204 return aRet; 1205 } 1206 1207 // ----------------------------------------------------------------------- 1208 1209 WinBits Window::ImplInitRes( const ResId& rResId ) 1210 { 1211 GetRes( rResId ); 1212 1213 char* pRes = (char*)GetClassRes(); 1214 pRes += 8; 1215 sal_uInt32 nStyle = (sal_uInt32)GetLongRes( (void*)pRes ); 1216 rResId.SetWinBits( nStyle ); 1217 return nStyle; 1218 } 1219 1220 // ----------------------------------------------------------------------- 1221 1222 void Window::ImplLoadRes( const ResId& rResId ) 1223 { 1224 sal_uLong nObjMask = ReadLongRes(); 1225 1226 // we need to calculate auto helpids before the resource gets closed 1227 // if the resource only contains flags, it will be closed before we try to read a help id 1228 // so we always create an auto help id that might be overwritten later 1229 // HelpId 1230 rtl::OString aHelpId = ImplAutoHelpID( rResId.GetResMgr() ); 1231 1232 // ResourceStyle 1233 sal_uLong nRSStyle = ReadLongRes(); 1234 // WinBits 1235 ReadLongRes(); 1236 1237 if( nObjMask & WINDOW_HELPID ) 1238 aHelpId = ReadByteStringRes(); 1239 1240 SetHelpId( aHelpId ); 1241 1242 sal_Bool bPos = sal_False; 1243 sal_Bool bSize = sal_False; 1244 Point aPos; 1245 Size aSize; 1246 1247 if ( nObjMask & (WINDOW_XYMAPMODE | WINDOW_X | WINDOW_Y) ) 1248 { 1249 // Groessenangabe aus der Resource verwenden 1250 MapUnit ePosMap = MAP_PIXEL; 1251 1252 bPos = sal_True; 1253 1254 if ( nObjMask & WINDOW_XYMAPMODE ) 1255 ePosMap = (MapUnit)ReadLongRes(); 1256 if ( nObjMask & WINDOW_X ) 1257 aPos.X() = ImplLogicUnitToPixelX( ReadLongRes(), ePosMap ); 1258 if ( nObjMask & WINDOW_Y ) 1259 aPos.Y() = ImplLogicUnitToPixelY( ReadLongRes(), ePosMap ); 1260 } 1261 1262 if ( nObjMask & (WINDOW_WHMAPMODE | WINDOW_WIDTH | WINDOW_HEIGHT) ) 1263 { 1264 // Groessenangabe aus der Resource verwenden 1265 MapUnit eSizeMap = MAP_PIXEL; 1266 1267 bSize = sal_True; 1268 1269 if ( nObjMask & WINDOW_WHMAPMODE ) 1270 eSizeMap = (MapUnit)ReadLongRes(); 1271 if ( nObjMask & WINDOW_WIDTH ) 1272 aSize.Width() = ImplLogicUnitToPixelX( ReadLongRes(), eSizeMap ); 1273 if ( nObjMask & WINDOW_HEIGHT ) 1274 aSize.Height() = ImplLogicUnitToPixelY( ReadLongRes(), eSizeMap ); 1275 } 1276 1277 // Wegen Optimierung so schlimm aussehend 1278 if ( nRSStyle & RSWND_CLIENTSIZE ) 1279 { 1280 if ( bPos ) 1281 SetPosPixel( aPos ); 1282 if ( bSize ) 1283 SetOutputSizePixel( aSize ); 1284 } 1285 else if ( bPos && bSize ) 1286 SetPosSizePixel( aPos, aSize ); 1287 else if ( bPos ) 1288 SetPosPixel( aPos ); 1289 else if ( bSize ) 1290 SetSizePixel( aSize ); 1291 1292 if ( nRSStyle & RSWND_DISABLED ) 1293 Enable( sal_False ); 1294 1295 if ( nObjMask & WINDOW_TEXT ) 1296 SetText( ReadStringRes() ); 1297 if ( nObjMask & WINDOW_HELPTEXT ) 1298 { 1299 SetHelpText( ReadStringRes() ); 1300 mpWindowImpl->mbHelpTextDynamic = sal_True; 1301 } 1302 if ( nObjMask & WINDOW_QUICKTEXT ) 1303 SetQuickHelpText( ReadStringRes() ); 1304 if ( nObjMask & WINDOW_EXTRALONG ) 1305 SetData( (void*)ReadLongRes() ); 1306 if ( nObjMask & WINDOW_UNIQUEID ) 1307 SetUniqueId( ReadByteStringRes() ); 1308 1309 if ( nObjMask & WINDOW_BORDER_STYLE ) 1310 { 1311 sal_uInt16 nBorderStyle = (sal_uInt16)ReadLongRes(); 1312 SetBorderStyle( nBorderStyle ); 1313 } 1314 } 1315 1316 // ----------------------------------------------------------------------- 1317 1318 ImplWinData* Window::ImplGetWinData() const 1319 { 1320 if ( !mpWindowImpl->mpWinData ) 1321 { 1322 static const char* pNoNWF = getenv( "SAL_NO_NWF" ); 1323 1324 ((Window*)this)->mpWindowImpl->mpWinData = new ImplWinData; 1325 mpWindowImpl->mpWinData->mpExtOldText = NULL; 1326 mpWindowImpl->mpWinData->mpExtOldAttrAry = NULL; 1327 mpWindowImpl->mpWinData->mpCursorRect = 0; 1328 mpWindowImpl->mpWinData->mnCursorExtWidth = 0; 1329 mpWindowImpl->mpWinData->mpFocusRect = NULL; 1330 mpWindowImpl->mpWinData->mpTrackRect = NULL; 1331 mpWindowImpl->mpWinData->mnTrackFlags = 0; 1332 mpWindowImpl->mpWinData->mnIsTopWindow = (sal_uInt16) ~0; // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow()) 1333 mpWindowImpl->mpWinData->mbMouseOver = sal_False; 1334 mpWindowImpl->mpWinData->mbEnableNativeWidget = (pNoNWF && *pNoNWF) ? sal_False : sal_True; // sal_True: try to draw this control with native theme API 1335 } 1336 1337 return mpWindowImpl->mpWinData; 1338 } 1339 1340 // ----------------------------------------------------------------------- 1341 1342 SalGraphics* Window::ImplGetFrameGraphics() const 1343 { 1344 if ( mpWindowImpl->mpFrameWindow->mpGraphics ) 1345 mpWindowImpl->mpFrameWindow->mbInitClipRegion = sal_True; 1346 else 1347 mpWindowImpl->mpFrameWindow->ImplGetGraphics(); 1348 mpWindowImpl->mpFrameWindow->mpGraphics->ResetClipRegion(); 1349 return mpWindowImpl->mpFrameWindow->mpGraphics; 1350 } 1351 1352 // ----------------------------------------------------------------------- 1353 1354 Window* Window::ImplFindWindow( const Point& rFramePos ) 1355 { 1356 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 1357 1358 Window* pTempWindow; 1359 Window* pFindWindow; 1360 1361 // Zuerst alle ueberlappenden Fenster ueberpruefen 1362 pTempWindow = mpWindowImpl->mpFirstOverlap; 1363 while ( pTempWindow ) 1364 { 1365 pFindWindow = pTempWindow->ImplFindWindow( rFramePos ); 1366 if ( pFindWindow ) 1367 return pFindWindow; 1368 pTempWindow = pTempWindow->mpWindowImpl->mpNext; 1369 } 1370 1371 // dann testen wir unser Fenster 1372 if ( !mpWindowImpl->mbVisible ) 1373 return NULL; 1374 1375 sal_uInt16 nHitTest = ImplHitTest( rFramePos ); 1376 if ( nHitTest & WINDOW_HITTEST_INSIDE ) 1377 { 1378 // und danach gehen wir noch alle Child-Fenster durch 1379 pTempWindow = mpWindowImpl->mpFirstChild; 1380 while ( pTempWindow ) 1381 { 1382 pFindWindow = pTempWindow->ImplFindWindow( rFramePos ); 1383 if ( pFindWindow ) 1384 return pFindWindow; 1385 pTempWindow = pTempWindow->mpWindowImpl->mpNext; 1386 } 1387 1388 if ( nHitTest & WINDOW_HITTEST_TRANSPARENT ) 1389 return NULL; 1390 else 1391 return this; 1392 } 1393 1394 return NULL; 1395 } 1396 1397 // ----------------------------------------------------------------------- 1398 1399 sal_uInt16 Window::ImplHitTest( const Point& rFramePos ) 1400 { 1401 Point aFramePos( rFramePos ); 1402 if( ImplIsAntiparallel() ) 1403 { 1404 // - RTL - re-mirror frame pos at this window 1405 ImplReMirror( aFramePos ); 1406 } 1407 Rectangle aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ); 1408 if ( !aRect.IsInside( aFramePos ) ) 1409 return 0; 1410 if ( mpWindowImpl->mbWinRegion ) 1411 { 1412 Point aTempPos = aFramePos; 1413 aTempPos.X() -= mnOutOffX; 1414 aTempPos.Y() -= mnOutOffY; 1415 if ( !mpWindowImpl->maWinRegion.IsInside( aTempPos ) ) 1416 return 0; 1417 } 1418 1419 sal_uInt16 nHitTest = WINDOW_HITTEST_INSIDE; 1420 if ( mpWindowImpl->mbMouseTransparent ) 1421 nHitTest |= WINDOW_HITTEST_TRANSPARENT; 1422 return nHitTest; 1423 } 1424 1425 // ----------------------------------------------------------------------- 1426 1427 sal_Bool Window::ImplIsRealParentPath( const Window* pWindow ) const 1428 { 1429 pWindow = pWindow->GetParent(); 1430 while ( pWindow ) 1431 { 1432 if ( pWindow == this ) 1433 return sal_True; 1434 pWindow = pWindow->GetParent(); 1435 } 1436 1437 return sal_False; 1438 } 1439 1440 // ----------------------------------------------------------------------- 1441 1442 sal_Bool Window::ImplIsChild( const Window* pWindow, sal_Bool bSystemWindow ) const 1443 { 1444 do 1445 { 1446 if ( !bSystemWindow && pWindow->ImplIsOverlapWindow() ) 1447 break; 1448 1449 pWindow = pWindow->ImplGetParent(); 1450 1451 if ( pWindow == this ) 1452 return sal_True; 1453 } 1454 while ( pWindow ); 1455 1456 return sal_False; 1457 } 1458 1459 // ----------------------------------------------------------------------- 1460 1461 sal_Bool Window::ImplIsWindowOrChild( const Window* pWindow, sal_Bool bSystemWindow ) const 1462 { 1463 if ( this == pWindow ) 1464 return sal_True; 1465 return ImplIsChild( pWindow, bSystemWindow ); 1466 } 1467 1468 // ----------------------------------------------------------------------- 1469 1470 Window* Window::ImplGetSameParent( const Window* pWindow ) const 1471 { 1472 if ( mpWindowImpl->mpFrameWindow != pWindow->mpWindowImpl->mpFrameWindow ) 1473 return NULL; 1474 else 1475 { 1476 if ( pWindow->ImplIsChild( this ) ) 1477 return (Window*)pWindow; 1478 else 1479 { 1480 Window* pTestWindow = (Window*)this; 1481 while ( (pTestWindow == pWindow) || pTestWindow->ImplIsChild( pWindow ) ) 1482 pTestWindow = pTestWindow->ImplGetParent(); 1483 return pTestWindow; 1484 } 1485 } 1486 } 1487 1488 // ----------------------------------------------------------------------- 1489 1490 int Window::ImplTestMousePointerSet() 1491 { 1492 // Wenn Mouse gecaptured ist, dann soll MousePointer umgeschaltet werden 1493 if ( IsMouseCaptured() ) 1494 return sal_True; 1495 1496 // Wenn sich Mouse ueber dem Fenster befindet, dann soll MousePointer 1497 // umgeschaltet werden 1498 Rectangle aClientRect( Point( 0, 0 ), GetOutputSizePixel() ); 1499 if ( aClientRect.IsInside( GetPointerPosPixel() ) ) 1500 return sal_True; 1501 1502 return sal_False; 1503 } 1504 1505 // ----------------------------------------------------------------------- 1506 1507 PointerStyle Window::ImplGetMousePointer() const 1508 { 1509 PointerStyle ePointerStyle; 1510 sal_Bool bWait = sal_False; 1511 1512 if ( IsEnabled() && IsInputEnabled() && ! IsInModalMode() ) 1513 ePointerStyle = GetPointer().GetStyle(); 1514 else 1515 ePointerStyle = POINTER_ARROW; 1516 1517 const Window* pWindow = this; 1518 do 1519 { 1520 // Wenn Pointer nicht sichtbar, dann wird suche abgebrochen, da 1521 // dieser Status nicht ueberschrieben werden darf 1522 if ( pWindow->mpWindowImpl->mbNoPtrVisible ) 1523 return POINTER_NULL; 1524 1525 if ( !bWait ) 1526 { 1527 if ( pWindow->mpWindowImpl->mnWaitCount ) 1528 { 1529 ePointerStyle = POINTER_WAIT; 1530 bWait = sal_True; 1531 } 1532 else 1533 { 1534 if ( pWindow->mpWindowImpl->mbChildPtrOverwrite ) 1535 ePointerStyle = pWindow->GetPointer().GetStyle(); 1536 } 1537 } 1538 1539 if ( pWindow->ImplIsOverlapWindow() ) 1540 break; 1541 1542 pWindow = pWindow->ImplGetParent(); 1543 } 1544 while ( pWindow ); 1545 1546 return ePointerStyle; 1547 } 1548 1549 // ----------------------------------------------------------------------- 1550 1551 void Window::ImplResetReallyVisible() 1552 { 1553 sal_Bool bBecameReallyInvisible = mpWindowImpl->mbReallyVisible; 1554 1555 mbDevOutput = sal_False; 1556 mpWindowImpl->mbReallyVisible = sal_False; 1557 mpWindowImpl->mbReallyShown = sal_False; 1558 1559 // the SHOW/HIDE events serve as indicators to send child creation/destroy events to the access bridge. 1560 // For this, the data member of the event must not be NULL. 1561 // Previously, we did this in Window::Show, but there some events got lost in certain situations. 1562 // #104887# - 2004-08-10 - fs@openoffice.org 1563 if( bBecameReallyInvisible && ImplIsAccessibleCandidate() ) 1564 ImplCallEventListeners( VCLEVENT_WINDOW_HIDE, this ); 1565 // TODO. It's kind of a hack that we're re-using the VCLEVENT_WINDOW_HIDE. Normally, we should 1566 // introduce another event which explicitly triggers the Accessibility implementations. 1567 1568 Window* pWindow = mpWindowImpl->mpFirstOverlap; 1569 while ( pWindow ) 1570 { 1571 if ( pWindow->mpWindowImpl->mbReallyVisible ) 1572 pWindow->ImplResetReallyVisible(); 1573 pWindow = pWindow->mpWindowImpl->mpNext; 1574 } 1575 1576 pWindow = mpWindowImpl->mpFirstChild; 1577 while ( pWindow ) 1578 { 1579 if ( pWindow->mpWindowImpl->mbReallyVisible ) 1580 pWindow->ImplResetReallyVisible(); 1581 pWindow = pWindow->mpWindowImpl->mpNext; 1582 } 1583 } 1584 1585 // ----------------------------------------------------------------------- 1586 1587 void Window::ImplSetReallyVisible() 1588 { 1589 // #i43594# it is possible that INITSHOW was never send, because the visibility state changed between 1590 // ImplCallInitShow() and ImplSetReallyVisible() when called from Show() 1591 // mbReallyShown is a useful indicator 1592 if( !mpWindowImpl->mbReallyShown ) 1593 ImplCallInitShow(); 1594 1595 sal_Bool bBecameReallyVisible = !mpWindowImpl->mbReallyVisible; 1596 1597 mbDevOutput = sal_True; 1598 mpWindowImpl->mbReallyVisible = sal_True; 1599 mpWindowImpl->mbReallyShown = sal_True; 1600 1601 // the SHOW/HIDE events serve as indicators to send child creation/destroy events to the access bridge. 1602 // For this, the data member of the event must not be NULL. 1603 // Previously, we did this in Window::Show, but there some events got lost in certain situations. Now 1604 // we're doing it when the visibility really changes 1605 // #104887# - 2004-08-10 - fs@openoffice.org 1606 if( bBecameReallyVisible && ImplIsAccessibleCandidate() ) 1607 ImplCallEventListeners( VCLEVENT_WINDOW_SHOW, this ); 1608 // TODO. It's kind of a hack that we're re-using the VCLEVENT_WINDOW_SHOW. Normally, we should 1609 // introduce another event which explicitly triggers the Accessibility implementations. 1610 1611 Window* pWindow = mpWindowImpl->mpFirstOverlap; 1612 while ( pWindow ) 1613 { 1614 if ( pWindow->mpWindowImpl->mbVisible ) 1615 pWindow->ImplSetReallyVisible(); 1616 pWindow = pWindow->mpWindowImpl->mpNext; 1617 } 1618 1619 pWindow = mpWindowImpl->mpFirstChild; 1620 while ( pWindow ) 1621 { 1622 if ( pWindow->mpWindowImpl->mbVisible ) 1623 pWindow->ImplSetReallyVisible(); 1624 pWindow = pWindow->mpWindowImpl->mpNext; 1625 } 1626 } 1627 1628 // ----------------------------------------------------------------------- 1629 1630 void Window::ImplCallInitShow() 1631 { 1632 mpWindowImpl->mbReallyShown = sal_True; 1633 mpWindowImpl->mbInInitShow = sal_True; 1634 StateChanged( STATE_CHANGE_INITSHOW ); 1635 mpWindowImpl->mbInInitShow = sal_False; 1636 1637 Window* pWindow = mpWindowImpl->mpFirstOverlap; 1638 while ( pWindow ) 1639 { 1640 if ( pWindow->mpWindowImpl->mbVisible ) 1641 pWindow->ImplCallInitShow(); 1642 pWindow = pWindow->mpWindowImpl->mpNext; 1643 } 1644 1645 pWindow = mpWindowImpl->mpFirstChild; 1646 while ( pWindow ) 1647 { 1648 if ( pWindow->mpWindowImpl->mbVisible ) 1649 pWindow->ImplCallInitShow(); 1650 pWindow = pWindow->mpWindowImpl->mpNext; 1651 } 1652 } 1653 1654 // ----------------------------------------------------------------------- 1655 1656 void Window::ImplAddDel( ImplDelData* pDel ) // TODO: make "const" when incompatiblity ok 1657 { 1658 DBG_ASSERT( !pDel->mpWindow, "Window::ImplAddDel(): cannot add ImplDelData twice !" ); 1659 if( !pDel->mpWindow ) 1660 { 1661 pDel->mpWindow = this; // #112873# store ref to this window, so pDel can remove itself 1662 pDel->mpNext = mpWindowImpl->mpFirstDel; 1663 mpWindowImpl->mpFirstDel = pDel; 1664 } 1665 } 1666 1667 // ----------------------------------------------------------------------- 1668 1669 void Window::ImplRemoveDel( ImplDelData* pDel ) // TODO: make "const" when incompatiblity ok 1670 { 1671 pDel->mpWindow = NULL; // #112873# pDel is not associated with a Window anymore 1672 if ( mpWindowImpl->mpFirstDel == pDel ) 1673 mpWindowImpl->mpFirstDel = pDel->mpNext; 1674 else 1675 { 1676 ImplDelData* pData = mpWindowImpl->mpFirstDel; 1677 while ( pData->mpNext != pDel ) 1678 pData = pData->mpNext; 1679 pData->mpNext = pDel->mpNext; 1680 } 1681 } 1682 1683 // ----------------------------------------------------------------------- 1684 1685 void Window::ImplInitResolutionSettings() 1686 { 1687 // AppFont-Aufloesung und DPI-Aufloesung neu berechnen 1688 if ( mpWindowImpl->mbFrame ) 1689 { 1690 const StyleSettings& rStyleSettings = maSettings.GetStyleSettings(); 1691 sal_uInt16 nScreenZoom = rStyleSettings.GetScreenZoom(); 1692 mnDPIX = (mpWindowImpl->mpFrameData->mnDPIX*nScreenZoom)/100; 1693 mnDPIY = (mpWindowImpl->mpFrameData->mnDPIY*nScreenZoom)/100; 1694 SetPointFont( rStyleSettings.GetAppFont() ); 1695 } 1696 else if ( mpWindowImpl->mpParent ) 1697 { 1698 mnDPIX = mpWindowImpl->mpParent->mnDPIX; 1699 mnDPIY = mpWindowImpl->mpParent->mnDPIY; 1700 } 1701 1702 // Vorberechnete Werte fuer logische Einheiten updaten und auch 1703 // die entsprechenden Tools dazu 1704 if ( IsMapMode() ) 1705 { 1706 MapMode aMapMode = GetMapMode(); 1707 SetMapMode(); 1708 SetMapMode( aMapMode ); 1709 } 1710 } 1711 1712 // ----------------------------------------------------------------------- 1713 1714 void Window::ImplPointToLogic( Font& rFont ) const 1715 { 1716 Size aSize = rFont.GetSize(); 1717 sal_uInt16 nScreenFontZoom = maSettings.GetStyleSettings().GetScreenFontZoom(); 1718 1719 if ( aSize.Width() ) 1720 { 1721 aSize.Width() *= mpWindowImpl->mpFrameData->mnDPIX; 1722 aSize.Width() += 72/2; 1723 aSize.Width() /= 72; 1724 aSize.Width() *= nScreenFontZoom; 1725 aSize.Width() /= 100; 1726 } 1727 aSize.Height() *= mpWindowImpl->mpFrameData->mnDPIY; 1728 aSize.Height() += 72/2; 1729 aSize.Height() /= 72; 1730 aSize.Height() *= nScreenFontZoom; 1731 aSize.Height() /= 100; 1732 1733 if ( IsMapModeEnabled() ) 1734 aSize = PixelToLogic( aSize ); 1735 1736 rFont.SetSize( aSize ); 1737 } 1738 1739 // ----------------------------------------------------------------------- 1740 1741 void Window::ImplLogicToPoint( Font& rFont ) const 1742 { 1743 Size aSize = rFont.GetSize(); 1744 sal_uInt16 nScreenFontZoom = maSettings.GetStyleSettings().GetScreenFontZoom(); 1745 1746 if ( IsMapModeEnabled() ) 1747 aSize = LogicToPixel( aSize ); 1748 1749 if ( aSize.Width() ) 1750 { 1751 aSize.Width() *= 100; 1752 aSize.Width() /= nScreenFontZoom; 1753 aSize.Width() *= 72; 1754 aSize.Width() += mpWindowImpl->mpFrameData->mnDPIX/2; 1755 aSize.Width() /= mpWindowImpl->mpFrameData->mnDPIX; 1756 } 1757 aSize.Height() *= 100; 1758 aSize.Height() /= nScreenFontZoom; 1759 aSize.Height() *= 72; 1760 aSize.Height() += mpWindowImpl->mpFrameData->mnDPIY/2; 1761 aSize.Height() /= mpWindowImpl->mpFrameData->mnDPIY; 1762 1763 rFont.SetSize( aSize ); 1764 } 1765 1766 // ----------------------------------------------------------------------- 1767 1768 sal_Bool Window::ImplSysObjClip( const Region* pOldRegion ) 1769 { 1770 sal_Bool bUpdate = sal_True; 1771 1772 if ( mpWindowImpl->mpSysObj ) 1773 { 1774 sal_Bool bVisibleState = mpWindowImpl->mbReallyVisible; 1775 1776 if ( bVisibleState ) 1777 { 1778 Region* pWinChildClipRegion = ImplGetWinChildClipRegion(); 1779 1780 if ( !pWinChildClipRegion->IsEmpty() ) 1781 { 1782 if ( pOldRegion ) 1783 { 1784 Region aNewRegion = *pWinChildClipRegion; 1785 pWinChildClipRegion->Intersect( *pOldRegion ); 1786 bUpdate = aNewRegion == *pWinChildClipRegion; 1787 } 1788 1789 if ( mpWindowImpl->mpFrameData->mpFirstBackWin ) 1790 ImplInvalidateAllOverlapBackgrounds(); 1791 1792 Region aRegion = *pWinChildClipRegion; 1793 Rectangle aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ); 1794 Region aWinRectRegion( aWinRect ); 1795 sal_uInt16 nClipFlags = mpWindowImpl->mpSysObj->GetClipRegionType(); 1796 1797 if ( aRegion == aWinRectRegion ) 1798 mpWindowImpl->mpSysObj->ResetClipRegion(); 1799 else 1800 { 1801 if ( nClipFlags & SAL_OBJECT_CLIP_EXCLUDERECTS ) 1802 { 1803 aWinRectRegion.Exclude( aRegion ); 1804 aRegion = aWinRectRegion; 1805 } 1806 if ( !(nClipFlags & SAL_OBJECT_CLIP_ABSOLUTE) ) 1807 aRegion.Move( -mnOutOffX, -mnOutOffY ); 1808 1809 // ClipRegion setzen/updaten 1810 long nX; 1811 long nY; 1812 long nWidth; 1813 long nHeight; 1814 sal_uLong nRectCount; 1815 ImplRegionInfo aInfo; 1816 sal_Bool bRegionRect; 1817 1818 nRectCount = aRegion.GetRectCount(); 1819 mpWindowImpl->mpSysObj->BeginSetClipRegion( nRectCount ); 1820 bRegionRect = aRegion.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight ); 1821 while ( bRegionRect ) 1822 { 1823 mpWindowImpl->mpSysObj->UnionClipRegion( nX, nY, nWidth, nHeight ); 1824 bRegionRect = aRegion.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight ); 1825 } 1826 mpWindowImpl->mpSysObj->EndSetClipRegion(); 1827 } 1828 } 1829 else 1830 bVisibleState = sal_False; 1831 } 1832 1833 // Visible-Status updaten 1834 mpWindowImpl->mpSysObj->Show( bVisibleState ); 1835 } 1836 1837 return bUpdate; 1838 } 1839 1840 // ----------------------------------------------------------------------- 1841 1842 void Window::ImplUpdateSysObjChildsClip() 1843 { 1844 if ( mpWindowImpl->mpSysObj && mpWindowImpl->mbInitWinClipRegion ) 1845 ImplSysObjClip( NULL ); 1846 1847 Window* pWindow = mpWindowImpl->mpFirstChild; 1848 while ( pWindow ) 1849 { 1850 pWindow->ImplUpdateSysObjChildsClip(); 1851 pWindow = pWindow->mpWindowImpl->mpNext; 1852 } 1853 } 1854 1855 // ----------------------------------------------------------------------- 1856 1857 void Window::ImplUpdateSysObjOverlapsClip() 1858 { 1859 ImplUpdateSysObjChildsClip(); 1860 1861 Window* pWindow = mpWindowImpl->mpFirstOverlap; 1862 while ( pWindow ) 1863 { 1864 pWindow->ImplUpdateSysObjOverlapsClip(); 1865 pWindow = pWindow->mpWindowImpl->mpNext; 1866 } 1867 } 1868 1869 // ----------------------------------------------------------------------- 1870 1871 void Window::ImplUpdateSysObjClip() 1872 { 1873 if ( !ImplIsOverlapWindow() ) 1874 { 1875 ImplUpdateSysObjChildsClip(); 1876 1877 // Schwestern muessen ihre ClipRegion auch neu berechnen 1878 if ( mpWindowImpl->mbClipSiblings ) 1879 { 1880 Window* pWindow = mpWindowImpl->mpNext; 1881 while ( pWindow ) 1882 { 1883 pWindow->ImplUpdateSysObjChildsClip(); 1884 pWindow = pWindow->mpWindowImpl->mpNext; 1885 } 1886 } 1887 } 1888 else 1889 mpWindowImpl->mpFrameWindow->ImplUpdateSysObjOverlapsClip(); 1890 } 1891 1892 // ----------------------------------------------------------------------- 1893 1894 sal_Bool Window::ImplSetClipFlagChilds( sal_Bool bSysObjOnlySmaller ) 1895 { 1896 sal_Bool bUpdate = sal_True; 1897 if ( mpWindowImpl->mpSysObj ) 1898 { 1899 Region* pOldRegion = NULL; 1900 if ( bSysObjOnlySmaller && !mpWindowImpl->mbInitWinClipRegion ) 1901 pOldRegion = new Region( mpWindowImpl->maWinClipRegion ); 1902 1903 mbInitClipRegion = sal_True; 1904 mpWindowImpl->mbInitWinClipRegion = sal_True; 1905 1906 Window* pWindow = mpWindowImpl->mpFirstChild; 1907 while ( pWindow ) 1908 { 1909 if ( !pWindow->ImplSetClipFlagChilds( bSysObjOnlySmaller ) ) 1910 bUpdate = sal_False; 1911 pWindow = pWindow->mpWindowImpl->mpNext; 1912 } 1913 1914 if ( !ImplSysObjClip( pOldRegion ) ) 1915 { 1916 mbInitClipRegion = sal_True; 1917 mpWindowImpl->mbInitWinClipRegion = sal_True; 1918 bUpdate = sal_False; 1919 } 1920 1921 if ( pOldRegion ) 1922 delete pOldRegion; 1923 } 1924 else 1925 { 1926 mbInitClipRegion = sal_True; 1927 mpWindowImpl->mbInitWinClipRegion = sal_True; 1928 1929 Window* pWindow = mpWindowImpl->mpFirstChild; 1930 while ( pWindow ) 1931 { 1932 if ( !pWindow->ImplSetClipFlagChilds( bSysObjOnlySmaller ) ) 1933 bUpdate = sal_False; 1934 pWindow = pWindow->mpWindowImpl->mpNext; 1935 } 1936 } 1937 return bUpdate; 1938 } 1939 1940 // ----------------------------------------------------------------------- 1941 1942 sal_Bool Window::ImplSetClipFlagOverlapWindows( sal_Bool bSysObjOnlySmaller ) 1943 { 1944 sal_Bool bUpdate = ImplSetClipFlagChilds( bSysObjOnlySmaller ); 1945 1946 Window* pWindow = mpWindowImpl->mpFirstOverlap; 1947 while ( pWindow ) 1948 { 1949 if ( !pWindow->ImplSetClipFlagOverlapWindows( bSysObjOnlySmaller ) ) 1950 bUpdate = sal_False; 1951 pWindow = pWindow->mpWindowImpl->mpNext; 1952 } 1953 1954 return bUpdate; 1955 } 1956 1957 // ----------------------------------------------------------------------- 1958 1959 sal_Bool Window::ImplSetClipFlag( sal_Bool bSysObjOnlySmaller ) 1960 { 1961 if ( !ImplIsOverlapWindow() ) 1962 { 1963 sal_Bool bUpdate = ImplSetClipFlagChilds( bSysObjOnlySmaller ); 1964 1965 Window* pParent = ImplGetParent(); 1966 if ( pParent && 1967 ((pParent->GetStyle() & WB_CLIPCHILDREN) || (mpWindowImpl->mnParentClipMode & PARENTCLIPMODE_CLIP)) ) 1968 { 1969 pParent->mbInitClipRegion = sal_True; 1970 pParent->mpWindowImpl->mbInitChildRegion = sal_True; 1971 } 1972 1973 // Schwestern muessen ihre ClipRegion auch neu berechnen 1974 if ( mpWindowImpl->mbClipSiblings ) 1975 { 1976 Window* pWindow = mpWindowImpl->mpNext; 1977 while ( pWindow ) 1978 { 1979 if ( !pWindow->ImplSetClipFlagChilds( bSysObjOnlySmaller ) ) 1980 bUpdate = sal_False; 1981 pWindow = pWindow->mpWindowImpl->mpNext; 1982 } 1983 } 1984 1985 return bUpdate; 1986 } 1987 else 1988 return mpWindowImpl->mpFrameWindow->ImplSetClipFlagOverlapWindows( bSysObjOnlySmaller ); 1989 } 1990 1991 // ----------------------------------------------------------------------- 1992 1993 void Window::ImplIntersectWindowClipRegion( Region& rRegion ) 1994 { 1995 if ( mpWindowImpl->mbInitWinClipRegion ) 1996 ImplInitWinClipRegion(); 1997 1998 rRegion.Intersect( mpWindowImpl->maWinClipRegion ); 1999 } 2000 2001 // ----------------------------------------------------------------------- 2002 2003 void Window::ImplIntersectWindowRegion( Region& rRegion ) 2004 { 2005 rRegion.Intersect( Rectangle( Point( mnOutOffX, mnOutOffY ), 2006 Size( mnOutWidth, mnOutHeight ) ) ); 2007 if ( mpWindowImpl->mbWinRegion ) 2008 rRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) ); 2009 } 2010 2011 // ----------------------------------------------------------------------- 2012 2013 void Window::ImplExcludeWindowRegion( Region& rRegion ) 2014 { 2015 if ( mpWindowImpl->mbWinRegion ) 2016 { 2017 Point aPoint( mnOutOffX, mnOutOffY ); 2018 Region aRegion( Rectangle( aPoint, 2019 Size( mnOutWidth, mnOutHeight ) ) ); 2020 aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) ); 2021 rRegion.Exclude( aRegion ); 2022 } 2023 else 2024 { 2025 Point aPoint( mnOutOffX, mnOutOffY ); 2026 rRegion.Exclude( Rectangle( aPoint, 2027 Size( mnOutWidth, mnOutHeight ) ) ); 2028 } 2029 } 2030 2031 // ----------------------------------------------------------------------- 2032 2033 void Window::ImplExcludeOverlapWindows( Region& rRegion ) 2034 { 2035 Window* pWindow = mpWindowImpl->mpFirstOverlap; 2036 while ( pWindow ) 2037 { 2038 if ( pWindow->mpWindowImpl->mbReallyVisible ) 2039 { 2040 pWindow->ImplExcludeWindowRegion( rRegion ); 2041 pWindow->ImplExcludeOverlapWindows( rRegion ); 2042 } 2043 2044 pWindow = pWindow->mpWindowImpl->mpNext; 2045 } 2046 } 2047 2048 // ----------------------------------------------------------------------- 2049 2050 void Window::ImplExcludeOverlapWindows2( Region& rRegion ) 2051 { 2052 if ( mpWindowImpl->mbReallyVisible ) 2053 ImplExcludeWindowRegion( rRegion ); 2054 2055 ImplExcludeOverlapWindows( rRegion ); 2056 } 2057 2058 // ----------------------------------------------------------------------- 2059 2060 void Window::ImplClipBoundaries( Region& rRegion, sal_Bool bThis, sal_Bool bOverlaps ) 2061 { 2062 if ( bThis ) 2063 ImplIntersectWindowClipRegion( rRegion ); 2064 else if ( ImplIsOverlapWindow() ) 2065 { 2066 // Evt. noch am Frame clippen 2067 if ( !mpWindowImpl->mbFrame ) 2068 rRegion.Intersect( Rectangle( Point( 0, 0 ), Size( mpWindowImpl->mpFrameWindow->mnOutWidth, mpWindowImpl->mpFrameWindow->mnOutHeight ) ) ); 2069 2070 if ( bOverlaps && !rRegion.IsEmpty() ) 2071 { 2072 // Clip Overlap Siblings 2073 Window* pStartOverlapWindow = this; 2074 while ( !pStartOverlapWindow->mpWindowImpl->mbFrame ) 2075 { 2076 Window* pOverlapWindow = pStartOverlapWindow->mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap; 2077 while ( pOverlapWindow && (pOverlapWindow != pStartOverlapWindow) ) 2078 { 2079 pOverlapWindow->ImplExcludeOverlapWindows2( rRegion ); 2080 pOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext; 2081 } 2082 pStartOverlapWindow = pStartOverlapWindow->mpWindowImpl->mpOverlapWindow; 2083 } 2084 2085 // Clip Child Overlap Windows 2086 ImplExcludeOverlapWindows( rRegion ); 2087 } 2088 } 2089 else 2090 ImplGetParent()->ImplIntersectWindowClipRegion( rRegion ); 2091 } 2092 2093 // ----------------------------------------------------------------------- 2094 2095 sal_Bool Window::ImplClipChilds( Region& rRegion ) 2096 { 2097 sal_Bool bOtherClip = sal_False; 2098 Window* pWindow = mpWindowImpl->mpFirstChild; 2099 while ( pWindow ) 2100 { 2101 if ( pWindow->mpWindowImpl->mbReallyVisible ) 2102 { 2103 // ParentClipMode-Flags auswerten 2104 sal_uInt16 nClipMode = pWindow->GetParentClipMode(); 2105 if ( !(nClipMode & PARENTCLIPMODE_NOCLIP) && 2106 ((nClipMode & PARENTCLIPMODE_CLIP) || (GetStyle() & WB_CLIPCHILDREN)) ) 2107 pWindow->ImplExcludeWindowRegion( rRegion ); 2108 else 2109 bOtherClip = sal_True; 2110 } 2111 2112 pWindow = pWindow->mpWindowImpl->mpNext; 2113 } 2114 2115 return bOtherClip; 2116 } 2117 2118 // ----------------------------------------------------------------------- 2119 2120 void Window::ImplClipAllChilds( Region& rRegion ) 2121 { 2122 Window* pWindow = mpWindowImpl->mpFirstChild; 2123 while ( pWindow ) 2124 { 2125 if ( pWindow->mpWindowImpl->mbReallyVisible ) 2126 pWindow->ImplExcludeWindowRegion( rRegion ); 2127 pWindow = pWindow->mpWindowImpl->mpNext; 2128 } 2129 } 2130 2131 // ----------------------------------------------------------------------- 2132 2133 void Window::ImplClipSiblings( Region& rRegion ) 2134 { 2135 Window* pWindow = ImplGetParent()->mpWindowImpl->mpFirstChild; 2136 while ( pWindow ) 2137 { 2138 if ( pWindow == this ) 2139 break; 2140 2141 if ( pWindow->mpWindowImpl->mbReallyVisible ) 2142 pWindow->ImplExcludeWindowRegion( rRegion ); 2143 2144 pWindow = pWindow->mpWindowImpl->mpNext; 2145 } 2146 } 2147 2148 // ----------------------------------------------------------------------- 2149 2150 void Window::ImplInitWinClipRegion() 2151 { 2152 // Build Window Region 2153 mpWindowImpl->maWinClipRegion = Rectangle( Point( mnOutOffX, mnOutOffY ), 2154 Size( mnOutWidth, mnOutHeight ) ); 2155 if ( mpWindowImpl->mbWinRegion ) 2156 mpWindowImpl->maWinClipRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) ); 2157 2158 // ClipSiblings 2159 if ( mpWindowImpl->mbClipSiblings && !ImplIsOverlapWindow() ) 2160 ImplClipSiblings( mpWindowImpl->maWinClipRegion ); 2161 2162 // Clip Parent Boundaries 2163 ImplClipBoundaries( mpWindowImpl->maWinClipRegion, sal_False, sal_True ); 2164 2165 // Clip Children 2166 if ( (GetStyle() & WB_CLIPCHILDREN) || mpWindowImpl->mbClipChildren ) 2167 mpWindowImpl->mbInitChildRegion = sal_True; 2168 2169 mpWindowImpl->mbInitWinClipRegion = sal_False; 2170 } 2171 2172 // ----------------------------------------------------------------------- 2173 2174 void Window::ImplInitWinChildClipRegion() 2175 { 2176 if ( !mpWindowImpl->mpFirstChild ) 2177 { 2178 if ( mpWindowImpl->mpChildClipRegion ) 2179 { 2180 delete mpWindowImpl->mpChildClipRegion; 2181 mpWindowImpl->mpChildClipRegion = NULL; 2182 } 2183 } 2184 else 2185 { 2186 if ( !mpWindowImpl->mpChildClipRegion ) 2187 mpWindowImpl->mpChildClipRegion = new Region( mpWindowImpl->maWinClipRegion ); 2188 else 2189 *mpWindowImpl->mpChildClipRegion = mpWindowImpl->maWinClipRegion; 2190 2191 ImplClipChilds( *mpWindowImpl->mpChildClipRegion ); 2192 } 2193 2194 mpWindowImpl->mbInitChildRegion = sal_False; 2195 } 2196 2197 // ----------------------------------------------------------------------- 2198 2199 Region* Window::ImplGetWinChildClipRegion() 2200 { 2201 if ( mpWindowImpl->mbInitWinClipRegion ) 2202 ImplInitWinClipRegion(); 2203 if ( mpWindowImpl->mbInitChildRegion ) 2204 ImplInitWinChildClipRegion(); 2205 if ( mpWindowImpl->mpChildClipRegion ) 2206 return mpWindowImpl->mpChildClipRegion; 2207 else 2208 return &mpWindowImpl->maWinClipRegion; 2209 } 2210 2211 // ----------------------------------------------------------------------- 2212 2213 void Window::ImplIntersectAndUnionOverlapWindows( const Region& rInterRegion, Region& rRegion ) 2214 { 2215 Window* pWindow = mpWindowImpl->mpFirstOverlap; 2216 while ( pWindow ) 2217 { 2218 if ( pWindow->mpWindowImpl->mbReallyVisible ) 2219 { 2220 Region aTempRegion( rInterRegion ); 2221 pWindow->ImplIntersectWindowRegion( aTempRegion ); 2222 rRegion.Union( aTempRegion ); 2223 pWindow->ImplIntersectAndUnionOverlapWindows( rInterRegion, rRegion ); 2224 } 2225 2226 pWindow = pWindow->mpWindowImpl->mpNext; 2227 } 2228 } 2229 2230 // ----------------------------------------------------------------------- 2231 2232 void Window::ImplIntersectAndUnionOverlapWindows2( const Region& rInterRegion, Region& rRegion ) 2233 { 2234 if ( mpWindowImpl->mbReallyVisible ) 2235 { 2236 Region aTempRegion( rInterRegion ); 2237 ImplIntersectWindowRegion( aTempRegion ); 2238 rRegion.Union( aTempRegion ); 2239 } 2240 2241 ImplIntersectAndUnionOverlapWindows( rInterRegion, rRegion ); 2242 } 2243 2244 // ----------------------------------------------------------------------- 2245 2246 void Window::ImplCalcOverlapRegionOverlaps( const Region& rInterRegion, Region& rRegion ) 2247 { 2248 // Clip Overlap Siblings 2249 Window* pStartOverlapWindow; 2250 if ( !ImplIsOverlapWindow() ) 2251 pStartOverlapWindow = mpWindowImpl->mpOverlapWindow; 2252 else 2253 pStartOverlapWindow = this; 2254 while ( !pStartOverlapWindow->mpWindowImpl->mbFrame ) 2255 { 2256 Window* pOverlapWindow = pStartOverlapWindow->mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap; 2257 while ( pOverlapWindow && (pOverlapWindow != pStartOverlapWindow) ) 2258 { 2259 pOverlapWindow->ImplIntersectAndUnionOverlapWindows2( rInterRegion, rRegion ); 2260 pOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext; 2261 } 2262 pStartOverlapWindow = pStartOverlapWindow->mpWindowImpl->mpOverlapWindow; 2263 } 2264 2265 // Clip Child Overlap Windows 2266 if ( !ImplIsOverlapWindow() ) 2267 mpWindowImpl->mpOverlapWindow->ImplIntersectAndUnionOverlapWindows( rInterRegion, rRegion ); 2268 else 2269 ImplIntersectAndUnionOverlapWindows( rInterRegion, rRegion ); 2270 } 2271 2272 // ----------------------------------------------------------------------- 2273 2274 void Window::ImplCalcOverlapRegion( const Rectangle& rSourceRect, Region& rRegion, 2275 sal_Bool bChilds, sal_Bool bParent, sal_Bool bSiblings ) 2276 { 2277 Region aRegion( rSourceRect ); 2278 if ( mpWindowImpl->mbWinRegion ) 2279 rRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) ); 2280 Region aTempRegion; 2281 Window* pWindow; 2282 2283 ImplCalcOverlapRegionOverlaps( aRegion, rRegion ); 2284 2285 // Parent-Boundaries 2286 if ( bParent ) 2287 { 2288 pWindow = this; 2289 if ( !ImplIsOverlapWindow() ) 2290 { 2291 pWindow = ImplGetParent(); 2292 do 2293 { 2294 aTempRegion = aRegion; 2295 pWindow->ImplExcludeWindowRegion( aTempRegion ); 2296 rRegion.Union( aTempRegion ); 2297 if ( pWindow->ImplIsOverlapWindow() ) 2298 break; 2299 pWindow = pWindow->ImplGetParent(); 2300 } 2301 while ( pWindow ); 2302 } 2303 if ( !pWindow->mpWindowImpl->mbFrame ) 2304 { 2305 aTempRegion = aRegion; 2306 aTempRegion.Exclude( Rectangle( Point( 0, 0 ), Size( mpWindowImpl->mpFrameWindow->mnOutWidth, mpWindowImpl->mpFrameWindow->mnOutHeight ) ) ); 2307 rRegion.Union( aTempRegion ); 2308 } 2309 } 2310 2311 // Siblings 2312 if ( bSiblings && !ImplIsOverlapWindow() ) 2313 { 2314 pWindow = mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild; 2315 do 2316 { 2317 if ( pWindow->mpWindowImpl->mbReallyVisible && (pWindow != this) ) 2318 { 2319 aTempRegion = aRegion; 2320 pWindow->ImplIntersectWindowRegion( aTempRegion ); 2321 rRegion.Union( aTempRegion ); 2322 } 2323 pWindow = pWindow->mpWindowImpl->mpNext; 2324 } 2325 while ( pWindow ); 2326 } 2327 2328 // Childs 2329 if ( bChilds ) 2330 { 2331 pWindow = mpWindowImpl->mpFirstChild; 2332 while ( pWindow ) 2333 { 2334 if ( pWindow->mpWindowImpl->mbReallyVisible ) 2335 { 2336 aTempRegion = aRegion; 2337 pWindow->ImplIntersectWindowRegion( aTempRegion ); 2338 rRegion.Union( aTempRegion ); 2339 } 2340 pWindow = pWindow->mpWindowImpl->mpNext; 2341 } 2342 } 2343 } 2344 2345 // ----------------------------------------------------------------------- 2346 2347 void Window::ImplCallPaint( const Region* pRegion, sal_uInt16 nPaintFlags ) 2348 { 2349 // call PrePaint. PrePaint may add to the invalidate region as well as 2350 // other parameters used below. 2351 PrePaint(); 2352 2353 mpWindowImpl->mbPaintFrame = sal_False; 2354 2355 if ( nPaintFlags & IMPL_PAINT_PAINTALLCHILDS ) 2356 mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINT | IMPL_PAINT_PAINTALLCHILDS | (nPaintFlags & IMPL_PAINT_PAINTALL); 2357 if ( nPaintFlags & IMPL_PAINT_PAINTCHILDS ) 2358 mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTCHILDS; 2359 if ( nPaintFlags & IMPL_PAINT_ERASE ) 2360 mpWindowImpl->mnPaintFlags |= IMPL_PAINT_ERASE; 2361 if ( nPaintFlags & IMPL_PAINT_CHECKRTL ) 2362 mpWindowImpl->mnPaintFlags |= IMPL_PAINT_CHECKRTL; 2363 if ( !mpWindowImpl->mpFirstChild ) 2364 mpWindowImpl->mnPaintFlags &= ~IMPL_PAINT_PAINTALLCHILDS; 2365 2366 if ( mpWindowImpl->mbPaintDisabled ) 2367 { 2368 if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL ) 2369 Invalidate( INVALIDATE_NOCHILDREN | INVALIDATE_NOERASE | INVALIDATE_NOTRANSPARENT | INVALIDATE_NOCLIPCHILDREN ); 2370 else if ( pRegion ) 2371 Invalidate( *pRegion, INVALIDATE_NOCHILDREN | INVALIDATE_NOERASE | INVALIDATE_NOTRANSPARENT | INVALIDATE_NOCLIPCHILDREN ); 2372 return; 2373 } 2374 2375 nPaintFlags = mpWindowImpl->mnPaintFlags & ~(IMPL_PAINT_PAINT); 2376 2377 Region* pChildRegion = NULL; 2378 Rectangle aSelectionRect; 2379 if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINT ) 2380 { 2381 Region* pWinChildClipRegion = ImplGetWinChildClipRegion(); 2382 if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL ) 2383 mpWindowImpl->maInvalidateRegion = *pWinChildClipRegion; 2384 else 2385 { 2386 if ( pRegion ) 2387 mpWindowImpl->maInvalidateRegion.Union( *pRegion ); 2388 2389 if( mpWindowImpl->mpWinData && mpWindowImpl->mbTrackVisible ) 2390 /* #98602# need to repaint all children within the 2391 * tracking rectangle, so the following invert 2392 * operation takes places without traces of the previous 2393 * one. 2394 */ 2395 mpWindowImpl->maInvalidateRegion.Union( *mpWindowImpl->mpWinData->mpTrackRect ); 2396 2397 if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALLCHILDS ) 2398 pChildRegion = new Region( mpWindowImpl->maInvalidateRegion ); 2399 mpWindowImpl->maInvalidateRegion.Intersect( *pWinChildClipRegion ); 2400 } 2401 mpWindowImpl->mnPaintFlags = 0; 2402 if ( !mpWindowImpl->maInvalidateRegion.IsEmpty() ) 2403 { 2404 bool bRestoreCursor = false; 2405 if ( mpWindowImpl->mpCursor ) 2406 bRestoreCursor = mpWindowImpl->mpCursor->ImplHide( false ); 2407 2408 mbInitClipRegion = sal_True; 2409 mpWindowImpl->mbInPaint = sal_True; 2410 2411 // Paint-Region zuruecksetzen 2412 Region aPaintRegion( mpWindowImpl->maInvalidateRegion ); 2413 Rectangle aPaintRect = aPaintRegion.GetBoundRect(); 2414 2415 // - RTL - re-mirror paint rect and region at this window 2416 if( ImplIsAntiparallel() ) 2417 { 2418 ImplReMirror( aPaintRect ); 2419 ImplReMirror( aPaintRegion ); 2420 } 2421 aPaintRect = ImplDevicePixelToLogic( aPaintRect); 2422 mpWindowImpl->mpPaintRegion = &aPaintRegion; 2423 mpWindowImpl->maInvalidateRegion.SetEmpty(); 2424 2425 if ( (nPaintFlags & IMPL_PAINT_ERASE) && IsBackground() ) 2426 { 2427 if ( IsClipRegion() ) 2428 { 2429 Region aOldRegion = GetClipRegion(); 2430 SetClipRegion(); 2431 Erase(); 2432 SetClipRegion( aOldRegion ); 2433 } 2434 else 2435 Erase(); 2436 } 2437 2438 // #98943# trigger drawing of toolbox selection after all childern are painted 2439 if( mpWindowImpl->mbDrawSelectionBackground ) 2440 aSelectionRect = aPaintRect; 2441 2442 Paint( aPaintRect ); 2443 2444 if ( mpWindowImpl->mpWinData ) 2445 { 2446 if ( mpWindowImpl->mbFocusVisible ) 2447 ImplInvertFocus( *(mpWindowImpl->mpWinData->mpFocusRect) ); 2448 } 2449 mpWindowImpl->mbInPaint = sal_False; 2450 mbInitClipRegion = sal_True; 2451 mpWindowImpl->mpPaintRegion = NULL; 2452 if ( mpWindowImpl->mpCursor ) 2453 mpWindowImpl->mpCursor->ImplShow( false, bRestoreCursor ); 2454 } 2455 } 2456 else 2457 mpWindowImpl->mnPaintFlags = 0; 2458 2459 if ( nPaintFlags & (IMPL_PAINT_PAINTALLCHILDS | IMPL_PAINT_PAINTCHILDS) ) 2460 { 2461 // die Childfenster ausgeben 2462 Window* pTempWindow = mpWindowImpl->mpFirstChild; 2463 while ( pTempWindow ) 2464 { 2465 if ( pTempWindow->mpWindowImpl->mbVisible ) 2466 pTempWindow->ImplCallPaint( pChildRegion, nPaintFlags ); 2467 pTempWindow = pTempWindow->mpWindowImpl->mpNext; 2468 } 2469 } 2470 2471 if ( mpWindowImpl->mpWinData && mpWindowImpl->mbTrackVisible && (mpWindowImpl->mpWinData->mnTrackFlags & SHOWTRACK_WINDOW) ) 2472 /* #98602# need to invert the tracking rect AFTER 2473 * the children have painted 2474 */ 2475 InvertTracking( *(mpWindowImpl->mpWinData->mpTrackRect), mpWindowImpl->mpWinData->mnTrackFlags ); 2476 2477 // #98943# draw toolbox selection 2478 if( !aSelectionRect.IsEmpty() ) 2479 DrawSelectionBackground( aSelectionRect, 3, sal_False, sal_True, sal_False ); 2480 2481 if ( pChildRegion ) 2482 delete pChildRegion; 2483 } 2484 2485 // ----------------------------------------------------------------------- 2486 2487 void Window::ImplCallOverlapPaint() 2488 { 2489 // Zuerst geben wir die ueberlappenden Fenster aus 2490 Window* pTempWindow = mpWindowImpl->mpFirstOverlap; 2491 while ( pTempWindow ) 2492 { 2493 if ( pTempWindow->mpWindowImpl->mbReallyVisible ) 2494 pTempWindow->ImplCallOverlapPaint(); 2495 pTempWindow = pTempWindow->mpWindowImpl->mpNext; 2496 } 2497 2498 // und dann erst uns selber 2499 if ( mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINT | IMPL_PAINT_PAINTCHILDS) ) 2500 { 2501 // - RTL - notify ImplCallPaint to check for re-mirroring (CHECKRTL) 2502 // because we were called from the Sal layer 2503 ImplCallPaint( NULL, mpWindowImpl->mnPaintFlags /*| IMPL_PAINT_CHECKRTL */); 2504 } 2505 } 2506 2507 // ----------------------------------------------------------------------- 2508 2509 void Window::ImplPostPaint() 2510 { 2511 if ( !mpWindowImpl->mpFrameData->maPaintTimer.IsActive() ) 2512 mpWindowImpl->mpFrameData->maPaintTimer.Start(); 2513 } 2514 2515 // ----------------------------------------------------------------------- 2516 2517 IMPL_LINK( Window, ImplHandlePaintHdl, void*, EMPTYARG ) 2518 { 2519 // save paint events until resizing is done 2520 if( mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData->maResizeTimer.IsActive() ) 2521 mpWindowImpl->mpFrameData->maPaintTimer.Start(); 2522 else if ( mpWindowImpl->mbReallyVisible ) 2523 ImplCallOverlapPaint(); 2524 return 0; 2525 } 2526 2527 // ----------------------------------------------------------------------- 2528 2529 IMPL_LINK( Window, ImplHandleResizeTimerHdl, void*, EMPTYARG ) 2530 { 2531 if( mpWindowImpl->mbReallyVisible ) 2532 { 2533 ImplCallResize(); 2534 if( mpWindowImpl->mpFrameData->maPaintTimer.IsActive() ) 2535 { 2536 mpWindowImpl->mpFrameData->maPaintTimer.Stop(); 2537 mpWindowImpl->mpFrameData->maPaintTimer.GetTimeoutHdl().Call( NULL ); 2538 } 2539 } 2540 2541 return 0; 2542 } 2543 2544 // ----------------------------------------------------------------------- 2545 2546 void Window::ImplInvalidateFrameRegion( const Region* pRegion, sal_uInt16 nFlags ) 2547 { 2548 // PAINTCHILDS bei allen Parent-Fenster bis zum ersten OverlapWindow 2549 // setzen 2550 if ( !ImplIsOverlapWindow() ) 2551 { 2552 Window* pTempWindow = this; 2553 sal_uInt16 nTranspPaint = IsPaintTransparent() ? IMPL_PAINT_PAINT : 0; 2554 do 2555 { 2556 pTempWindow = pTempWindow->ImplGetParent(); 2557 if ( pTempWindow->mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTCHILDS ) 2558 break; 2559 pTempWindow->mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTCHILDS | nTranspPaint; 2560 if( ! pTempWindow->IsPaintTransparent() ) 2561 nTranspPaint = 0; 2562 } 2563 while ( !pTempWindow->ImplIsOverlapWindow() ); 2564 } 2565 2566 // Paint-Flags setzen 2567 mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINT; 2568 if ( nFlags & INVALIDATE_CHILDREN ) 2569 mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTALLCHILDS; 2570 if ( !(nFlags & INVALIDATE_NOERASE) ) 2571 mpWindowImpl->mnPaintFlags |= IMPL_PAINT_ERASE; 2572 if ( !pRegion ) 2573 mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTALL; 2574 2575 // Wenn nicht alles neu ausgegeben werden muss, dann die Region 2576 // dazupacken 2577 if ( !(mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL) ) 2578 mpWindowImpl->maInvalidateRegion.Union( *pRegion ); 2579 2580 // Handle transparent windows correctly: invalidate must be done on the first opaque parent 2581 if( ((IsPaintTransparent() && !(nFlags & INVALIDATE_NOTRANSPARENT)) || (nFlags & INVALIDATE_TRANSPARENT) ) 2582 && ImplGetParent() ) 2583 { 2584 Window *pParent = ImplGetParent(); 2585 while( pParent && pParent->IsPaintTransparent() ) 2586 pParent = pParent->ImplGetParent(); 2587 if( pParent ) 2588 { 2589 Region *pChildRegion; 2590 if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL ) 2591 // invalidate the whole child window region in the parent 2592 pChildRegion = ImplGetWinChildClipRegion(); 2593 else 2594 // invalidate the same region in the parent that has to be repainted in the child 2595 pChildRegion = &mpWindowImpl->maInvalidateRegion; 2596 2597 nFlags |= INVALIDATE_CHILDREN; // paint should also be done on all children 2598 nFlags &= ~INVALIDATE_NOERASE; // parent should paint and erase to create proper background 2599 pParent->ImplInvalidateFrameRegion( pChildRegion, nFlags ); 2600 } 2601 } 2602 ImplPostPaint(); 2603 } 2604 2605 // ----------------------------------------------------------------------- 2606 2607 void Window::ImplInvalidateOverlapFrameRegion( const Region& rRegion ) 2608 { 2609 Region aRegion = rRegion; 2610 2611 ImplClipBoundaries( aRegion, sal_True, sal_True ); 2612 if ( !aRegion.IsEmpty() ) 2613 ImplInvalidateFrameRegion( &aRegion, INVALIDATE_CHILDREN ); 2614 2615 // Dann invalidieren wir die ueberlappenden Fenster 2616 Window* pTempWindow = mpWindowImpl->mpFirstOverlap; 2617 while ( pTempWindow ) 2618 { 2619 if ( pTempWindow->IsVisible() ) 2620 pTempWindow->ImplInvalidateOverlapFrameRegion( rRegion ); 2621 2622 pTempWindow = pTempWindow->mpWindowImpl->mpNext; 2623 } 2624 } 2625 2626 // ----------------------------------------------------------------------- 2627 2628 void Window::ImplInvalidateParentFrameRegion( Region& rRegion ) 2629 { 2630 if ( mpWindowImpl->mbOverlapWin ) 2631 mpWindowImpl->mpFrameWindow->ImplInvalidateOverlapFrameRegion( rRegion ); 2632 else 2633 { 2634 if( ImplGetParent() ) 2635 ImplGetParent()->ImplInvalidateFrameRegion( &rRegion, INVALIDATE_CHILDREN ); 2636 } 2637 } 2638 2639 // ----------------------------------------------------------------------- 2640 2641 void Window::ImplInvalidate( const Region* pRegion, sal_uInt16 nFlags ) 2642 { 2643 2644 // Hintergrund-Sicherung zuruecksetzen 2645 if ( mpWindowImpl->mpFrameData->mpFirstBackWin ) 2646 ImplInvalidateAllOverlapBackgrounds(); 2647 2648 // Feststellen, was neu ausgegeben werden muss 2649 sal_Bool bInvalidateAll = !pRegion; 2650 2651 // Transparent-Invalidate beruecksichtigen 2652 Window* pOpaqueWindow = this; 2653 if ( (mpWindowImpl->mbPaintTransparent && !(nFlags & INVALIDATE_NOTRANSPARENT)) || (nFlags & INVALIDATE_TRANSPARENT) ) 2654 { 2655 Window* pTempWindow = pOpaqueWindow->ImplGetParent(); 2656 while ( pTempWindow ) 2657 { 2658 if ( !pTempWindow->IsPaintTransparent() ) 2659 { 2660 pOpaqueWindow = pTempWindow; 2661 nFlags |= INVALIDATE_CHILDREN; 2662 bInvalidateAll = sal_False; 2663 break; 2664 } 2665 2666 if ( pTempWindow->ImplIsOverlapWindow() ) 2667 break; 2668 2669 pTempWindow = pTempWindow->ImplGetParent(); 2670 } 2671 } 2672 2673 // Region zusammenbauen 2674 sal_uInt16 nOrgFlags = nFlags; 2675 if ( !(nFlags & (INVALIDATE_CHILDREN | INVALIDATE_NOCHILDREN)) ) 2676 { 2677 if ( GetStyle() & WB_CLIPCHILDREN ) 2678 nFlags |= INVALIDATE_NOCHILDREN; 2679 else 2680 nFlags |= INVALIDATE_CHILDREN; 2681 } 2682 if ( (nFlags & INVALIDATE_NOCHILDREN) && mpWindowImpl->mpFirstChild ) 2683 bInvalidateAll = sal_False; 2684 if ( bInvalidateAll ) 2685 ImplInvalidateFrameRegion( NULL, nFlags ); 2686 else 2687 { 2688 Rectangle aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ); 2689 Region aRegion( aRect ); 2690 if ( pRegion ) 2691 { 2692 // --- RTL --- remirror region before intersecting it 2693 if ( ImplIsAntiparallel() ) 2694 { 2695 Region aRgn( *pRegion ); 2696 ImplReMirror( aRgn ); 2697 aRegion.Intersect( aRgn ); 2698 } 2699 else 2700 aRegion.Intersect( *pRegion ); 2701 } 2702 ImplClipBoundaries( aRegion, sal_True, sal_True ); 2703 if ( nFlags & INVALIDATE_NOCHILDREN ) 2704 { 2705 nFlags &= ~INVALIDATE_CHILDREN; 2706 if ( !(nFlags & INVALIDATE_NOCLIPCHILDREN) ) 2707 { 2708 if ( nOrgFlags & INVALIDATE_NOCHILDREN ) 2709 ImplClipAllChilds( aRegion ); 2710 else 2711 { 2712 if ( ImplClipChilds( aRegion ) ) 2713 nFlags |= INVALIDATE_CHILDREN; 2714 } 2715 } 2716 } 2717 if ( !aRegion.IsEmpty() ) 2718 ImplInvalidateFrameRegion( &aRegion, nFlags ); // transparency is handled here, pOpaqueWindow not required 2719 } 2720 2721 if ( nFlags & INVALIDATE_UPDATE ) 2722 pOpaqueWindow->Update(); // start painting at the opaque parent 2723 } 2724 2725 // ----------------------------------------------------------------------- 2726 2727 void Window::ImplMoveInvalidateRegion( const Rectangle& rRect, 2728 long nHorzScroll, long nVertScroll, 2729 sal_Bool bChilds ) 2730 { 2731 if ( (mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINT | IMPL_PAINT_PAINTALL)) == IMPL_PAINT_PAINT ) 2732 { 2733 Region aTempRegion = mpWindowImpl->maInvalidateRegion; 2734 aTempRegion.Intersect( rRect ); 2735 aTempRegion.Move( nHorzScroll, nVertScroll ); 2736 mpWindowImpl->maInvalidateRegion.Union( aTempRegion ); 2737 } 2738 2739 if ( bChilds && (mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTCHILDS) ) 2740 { 2741 Window* pWindow = mpWindowImpl->mpFirstChild; 2742 while ( pWindow ) 2743 { 2744 pWindow->ImplMoveInvalidateRegion( rRect, nHorzScroll, nVertScroll, sal_True ); 2745 pWindow = pWindow->mpWindowImpl->mpNext; 2746 } 2747 } 2748 } 2749 2750 // ----------------------------------------------------------------------- 2751 2752 void Window::ImplMoveAllInvalidateRegions( const Rectangle& rRect, 2753 long nHorzScroll, long nVertScroll, 2754 sal_Bool bChilds ) 2755 { 2756 // Paint-Region auch verschieben, wenn noch Paints anstehen 2757 ImplMoveInvalidateRegion( rRect, nHorzScroll, nVertScroll, bChilds ); 2758 // Paint-Region muss bei uns verschoben gesetzt werden, die durch 2759 // die Parents gezeichnet werden 2760 if ( !ImplIsOverlapWindow() ) 2761 { 2762 Region aPaintAllRegion; 2763 Window* pPaintAllWindow = this; 2764 do 2765 { 2766 pPaintAllWindow = pPaintAllWindow->ImplGetParent(); 2767 if ( pPaintAllWindow->mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALLCHILDS ) 2768 { 2769 if ( pPaintAllWindow->mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL ) 2770 { 2771 aPaintAllRegion.SetEmpty(); 2772 break; 2773 } 2774 else 2775 aPaintAllRegion.Union( pPaintAllWindow->mpWindowImpl->maInvalidateRegion ); 2776 } 2777 } 2778 while ( !pPaintAllWindow->ImplIsOverlapWindow() ); 2779 if ( !aPaintAllRegion.IsEmpty() ) 2780 { 2781 aPaintAllRegion.Move( nHorzScroll, nVertScroll ); 2782 sal_uInt16 nPaintFlags = 0; 2783 if ( bChilds ) 2784 mpWindowImpl->mnPaintFlags |= INVALIDATE_CHILDREN; 2785 ImplInvalidateFrameRegion( &aPaintAllRegion, nPaintFlags ); 2786 } 2787 } 2788 } 2789 2790 // ----------------------------------------------------------------------- 2791 2792 void Window::ImplValidateFrameRegion( const Region* pRegion, sal_uInt16 nFlags ) 2793 { 2794 if ( !pRegion ) 2795 mpWindowImpl->maInvalidateRegion.SetEmpty(); 2796 else 2797 { 2798 // Wenn alle Childfenster neu ausgegeben werden muessen, 2799 // dann invalidieren wir diese vorher 2800 if ( (mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALLCHILDS) && mpWindowImpl->mpFirstChild ) 2801 { 2802 Region aChildRegion = mpWindowImpl->maInvalidateRegion; 2803 if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL ) 2804 { 2805 Rectangle aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ); 2806 aChildRegion = aRect; 2807 } 2808 Window* pChild = mpWindowImpl->mpFirstChild; 2809 while ( pChild ) 2810 { 2811 pChild->Invalidate( aChildRegion, INVALIDATE_CHILDREN | INVALIDATE_NOTRANSPARENT ); 2812 pChild = pChild->mpWindowImpl->mpNext; 2813 } 2814 } 2815 if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL ) 2816 { 2817 Rectangle aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ); 2818 mpWindowImpl->maInvalidateRegion = aRect; 2819 } 2820 mpWindowImpl->maInvalidateRegion.Exclude( *pRegion ); 2821 } 2822 mpWindowImpl->mnPaintFlags &= ~IMPL_PAINT_PAINTALL; 2823 2824 if ( nFlags & VALIDATE_CHILDREN ) 2825 { 2826 Window* pChild = mpWindowImpl->mpFirstChild; 2827 while ( pChild ) 2828 { 2829 pChild->ImplValidateFrameRegion( pRegion, nFlags ); 2830 pChild = pChild->mpWindowImpl->mpNext; 2831 } 2832 } 2833 } 2834 2835 // ----------------------------------------------------------------------- 2836 2837 void Window::ImplValidate( const Region* pRegion, sal_uInt16 nFlags ) 2838 { 2839 // Region zusammenbauen 2840 sal_Bool bValidateAll = !pRegion; 2841 sal_uInt16 nOrgFlags = nFlags; 2842 if ( !(nFlags & (VALIDATE_CHILDREN | VALIDATE_NOCHILDREN)) ) 2843 { 2844 if ( GetStyle() & WB_CLIPCHILDREN ) 2845 nFlags |= VALIDATE_NOCHILDREN; 2846 else 2847 nFlags |= VALIDATE_CHILDREN; 2848 } 2849 if ( (nFlags & VALIDATE_NOCHILDREN) && mpWindowImpl->mpFirstChild ) 2850 bValidateAll = sal_False; 2851 if ( bValidateAll ) 2852 ImplValidateFrameRegion( NULL, nFlags ); 2853 else 2854 { 2855 Rectangle aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ); 2856 Region aRegion( aRect ); 2857 if ( pRegion ) 2858 aRegion.Intersect( *pRegion ); 2859 ImplClipBoundaries( aRegion, sal_True, sal_True ); 2860 if ( nFlags & VALIDATE_NOCHILDREN ) 2861 { 2862 nFlags &= ~VALIDATE_CHILDREN; 2863 if ( nOrgFlags & VALIDATE_NOCHILDREN ) 2864 ImplClipAllChilds( aRegion ); 2865 else 2866 { 2867 if ( ImplClipChilds( aRegion ) ) 2868 nFlags |= VALIDATE_CHILDREN; 2869 } 2870 } 2871 if ( !aRegion.IsEmpty() ) 2872 ImplValidateFrameRegion( &aRegion, nFlags ); 2873 } 2874 } 2875 2876 // ----------------------------------------------------------------------- 2877 2878 void Window::ImplScroll( const Rectangle& rRect, 2879 long nHorzScroll, long nVertScroll, sal_uInt16 nFlags ) 2880 { 2881 if ( !IsDeviceOutputNecessary() ) 2882 return; 2883 2884 nHorzScroll = ImplLogicWidthToDevicePixel( nHorzScroll ); 2885 nVertScroll = ImplLogicHeightToDevicePixel( nVertScroll ); 2886 2887 if ( !nHorzScroll && !nVertScroll ) 2888 return; 2889 2890 // Hintergrund-Sicherung zuruecksetzen 2891 if ( mpWindowImpl->mpFrameData->mpFirstBackWin ) 2892 ImplInvalidateAllOverlapBackgrounds(); 2893 2894 if ( mpWindowImpl->mpCursor ) 2895 mpWindowImpl->mpCursor->ImplHide( false ); 2896 2897 sal_uInt16 nOrgFlags = nFlags; 2898 if ( !(nFlags & (SCROLL_CHILDREN | SCROLL_NOCHILDREN)) ) 2899 { 2900 if ( GetStyle() & WB_CLIPCHILDREN ) 2901 nFlags |= SCROLL_NOCHILDREN; 2902 else 2903 nFlags |= SCROLL_CHILDREN; 2904 } 2905 2906 Region aInvalidateRegion; 2907 sal_Bool bScrollChilds = (nFlags & SCROLL_CHILDREN) != 0; 2908 sal_Bool bErase = (nFlags & SCROLL_NOERASE) == 0; 2909 2910 if ( !mpWindowImpl->mpFirstChild ) 2911 bScrollChilds = sal_False; 2912 2913 // --- RTL --- check if this window requires special action 2914 sal_Bool bReMirror = ( ImplIsAntiparallel() ); 2915 2916 Rectangle aRectMirror( rRect ); 2917 if( bReMirror ) 2918 { 2919 // --- RTL --- make sure the invalidate region of this window is 2920 // computed in the same coordinate space as the one from the overlap windows 2921 ImplReMirror( aRectMirror ); 2922 } 2923 2924 // Paint-Bereiche anpassen 2925 ImplMoveAllInvalidateRegions( aRectMirror, nHorzScroll, nVertScroll, bScrollChilds ); 2926 2927 if ( !(nFlags & SCROLL_NOINVALIDATE) ) 2928 { 2929 ImplCalcOverlapRegion( aRectMirror, aInvalidateRegion, !bScrollChilds, sal_True, sal_False ); 2930 2931 // --- RTL --- 2932 // if the scrolling on the device is performed in the opposite direction 2933 // then move the overlaps in that direction to compute the invalidate region 2934 // on the correct side, i.e., revert nHorzScroll 2935 2936 if ( !aInvalidateRegion.IsEmpty() ) 2937 { 2938 aInvalidateRegion.Move( bReMirror ? -nHorzScroll : nHorzScroll, nVertScroll ); 2939 bErase = sal_True; 2940 } 2941 if ( !(nFlags & SCROLL_NOWINDOWINVALIDATE) ) 2942 { 2943 Rectangle aDestRect( aRectMirror ); 2944 aDestRect.Move( bReMirror ? -nHorzScroll : nHorzScroll, nVertScroll ); 2945 Region aWinInvalidateRegion( aRectMirror ); 2946 aWinInvalidateRegion.Exclude( aDestRect ); 2947 2948 aInvalidateRegion.Union( aWinInvalidateRegion ); 2949 } 2950 } 2951 2952 Point aPoint( mnOutOffX, mnOutOffY ); 2953 Region aRegion( Rectangle( aPoint, Size( mnOutWidth, mnOutHeight ) ) ); 2954 if ( nFlags & SCROLL_CLIP ) 2955 aRegion.Intersect( rRect ); 2956 if ( mpWindowImpl->mbWinRegion ) 2957 aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) ); 2958 2959 aRegion.Exclude( aInvalidateRegion ); 2960 2961 ImplClipBoundaries( aRegion, sal_False, sal_True ); 2962 if ( !bScrollChilds ) 2963 { 2964 if ( nOrgFlags & SCROLL_NOCHILDREN ) 2965 ImplClipAllChilds( aRegion ); 2966 else 2967 ImplClipChilds( aRegion ); 2968 } 2969 if ( mbClipRegion && (nFlags & SCROLL_USECLIPREGION) ) 2970 aRegion.Intersect( maRegion ); 2971 if ( !aRegion.IsEmpty() ) 2972 { 2973 if ( mpWindowImpl->mpWinData ) 2974 { 2975 if ( mpWindowImpl->mbFocusVisible ) 2976 ImplInvertFocus( *(mpWindowImpl->mpWinData->mpFocusRect) ); 2977 if ( mpWindowImpl->mbTrackVisible && (mpWindowImpl->mpWinData->mnTrackFlags & SHOWTRACK_WINDOW) ) 2978 InvertTracking( *(mpWindowImpl->mpWinData->mpTrackRect), mpWindowImpl->mpWinData->mnTrackFlags ); 2979 } 2980 2981 SalGraphics* pGraphics = ImplGetFrameGraphics(); 2982 if ( pGraphics ) 2983 { 2984 if( bReMirror ) 2985 { 2986 // --- RTL --- frame coordinates require re-mirroring 2987 ImplReMirror( aRegion ); 2988 } 2989 2990 ImplSelectClipRegion( aRegion, pGraphics ); 2991 pGraphics->CopyArea( rRect.Left()+nHorzScroll, rRect.Top()+nVertScroll, 2992 rRect.Left(), rRect.Top(), 2993 rRect.GetWidth(), rRect.GetHeight(), 2994 SAL_COPYAREA_WINDOWINVALIDATE, this ); 2995 } 2996 2997 if ( mpWindowImpl->mpWinData ) 2998 { 2999 if ( mpWindowImpl->mbFocusVisible ) 3000 ImplInvertFocus( *(mpWindowImpl->mpWinData->mpFocusRect) ); 3001 if ( mpWindowImpl->mbTrackVisible && (mpWindowImpl->mpWinData->mnTrackFlags & SHOWTRACK_WINDOW) ) 3002 InvertTracking( *(mpWindowImpl->mpWinData->mpTrackRect), mpWindowImpl->mpWinData->mnTrackFlags ); 3003 } 3004 } 3005 3006 if ( !aInvalidateRegion.IsEmpty() ) 3007 { 3008 // --- RTL --- the invalidate region for this windows is already computed in frame coordinates 3009 // so it has to be re-mirrored before calling the Paint-handler 3010 mpWindowImpl->mnPaintFlags |= IMPL_PAINT_CHECKRTL; 3011 3012 sal_uInt16 nPaintFlags = INVALIDATE_CHILDREN; 3013 if ( !bErase ) 3014 nPaintFlags |= INVALIDATE_NOERASE; 3015 if ( !bScrollChilds ) 3016 { 3017 if ( nOrgFlags & SCROLL_NOCHILDREN ) 3018 ImplClipAllChilds( aInvalidateRegion ); 3019 else 3020 ImplClipChilds( aInvalidateRegion ); 3021 } 3022 ImplInvalidateFrameRegion( &aInvalidateRegion, nPaintFlags ); 3023 } 3024 3025 if ( bScrollChilds ) 3026 { 3027 Window* pWindow = mpWindowImpl->mpFirstChild; 3028 while ( pWindow ) 3029 { 3030 Point aPos = pWindow->GetPosPixel(); 3031 aPos += Point( nHorzScroll, nVertScroll ); 3032 pWindow->SetPosPixel( aPos ); 3033 3034 pWindow = pWindow->mpWindowImpl->mpNext; 3035 } 3036 } 3037 3038 if ( nFlags & SCROLL_UPDATE ) 3039 Update(); 3040 3041 if ( mpWindowImpl->mpCursor ) 3042 mpWindowImpl->mpCursor->ImplShow( false ); 3043 } 3044 3045 // ----------------------------------------------------------------------- 3046 3047 void Window::ImplUpdateAll( sal_Bool bOverlapWindows ) 3048 { 3049 if ( !mpWindowImpl->mbReallyVisible ) 3050 return; 3051 3052 sal_Bool bFlush = sal_False; 3053 if ( mpWindowImpl->mpFrameWindow->mpWindowImpl->mbPaintFrame ) 3054 { 3055 Point aPoint( 0, 0 ); 3056 Region aRegion( Rectangle( aPoint, Size( mnOutWidth, mnOutHeight ) ) ); 3057 ImplInvalidateOverlapFrameRegion( aRegion ); 3058 if ( mpWindowImpl->mbFrame || (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame) ) 3059 bFlush = sal_True; 3060 } 3061 3062 // Ein Update wirkt immer auf das OverlapWindow, damit bei spaeteren 3063 // Paints nicht zuviel gemalt wird, wenn dort ALLCHILDREN usw. gesetzt 3064 // ist 3065 Window* pWindow = ImplGetFirstOverlapWindow(); 3066 if ( bOverlapWindows ) 3067 pWindow->ImplCallOverlapPaint(); 3068 else 3069 { 3070 if ( pWindow->mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINT | IMPL_PAINT_PAINTCHILDS) ) 3071 pWindow->ImplCallPaint( NULL, pWindow->mpWindowImpl->mnPaintFlags ); 3072 } 3073 3074 if ( bFlush ) 3075 Flush(); 3076 } 3077 3078 // ----------------------------------------------------------------------- 3079 3080 void Window::ImplUpdateWindowPtr( Window* pWindow ) 3081 { 3082 if ( mpWindowImpl->mpFrameWindow != pWindow->mpWindowImpl->mpFrameWindow ) 3083 { 3084 // Graphic freigeben 3085 ImplReleaseGraphics(); 3086 } 3087 3088 mpWindowImpl->mpFrameData = pWindow->mpWindowImpl->mpFrameData; 3089 mpWindowImpl->mpFrame = pWindow->mpWindowImpl->mpFrame; 3090 mpWindowImpl->mpFrameWindow = pWindow->mpWindowImpl->mpFrameWindow; 3091 if ( pWindow->ImplIsOverlapWindow() ) 3092 mpWindowImpl->mpOverlapWindow = pWindow; 3093 else 3094 mpWindowImpl->mpOverlapWindow = pWindow->mpWindowImpl->mpOverlapWindow; 3095 3096 Window* pChild = mpWindowImpl->mpFirstChild; 3097 while ( pChild ) 3098 { 3099 pChild->ImplUpdateWindowPtr( pWindow ); 3100 pChild = pChild->mpWindowImpl->mpNext; 3101 } 3102 } 3103 3104 // ----------------------------------------------------------------------- 3105 3106 void Window::ImplUpdateWindowPtr() 3107 { 3108 Window* pChild = mpWindowImpl->mpFirstChild; 3109 while ( pChild ) 3110 { 3111 pChild->ImplUpdateWindowPtr( this ); 3112 pChild = pChild->mpWindowImpl->mpNext; 3113 } 3114 } 3115 3116 // ----------------------------------------------------------------------- 3117 3118 void Window::ImplUpdateOverlapWindowPtr( sal_Bool bNewFrame ) 3119 { 3120 sal_Bool bVisible = IsVisible(); 3121 Show( sal_False ); 3122 ImplRemoveWindow( bNewFrame ); 3123 Window* pRealParent = mpWindowImpl->mpRealParent; 3124 ImplInsertWindow( ImplGetParent() ); 3125 mpWindowImpl->mpRealParent = pRealParent; 3126 ImplUpdateWindowPtr(); 3127 if ( ImplUpdatePos() ) 3128 ImplUpdateSysObjPos(); 3129 3130 if ( bNewFrame ) 3131 { 3132 Window* pOverlapWindow = mpWindowImpl->mpFirstOverlap; 3133 while ( pOverlapWindow ) 3134 { 3135 Window* pNextOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext; 3136 pOverlapWindow->ImplUpdateOverlapWindowPtr( bNewFrame ); 3137 pOverlapWindow = pNextOverlapWindow; 3138 } 3139 } 3140 3141 if ( bVisible ) 3142 Show( sal_True ); 3143 } 3144 3145 // ----------------------------------------------------------------------- 3146 3147 sal_Bool Window::ImplUpdatePos() 3148 { 3149 sal_Bool bSysChild = sal_False; 3150 3151 if ( ImplIsOverlapWindow() ) 3152 { 3153 mnOutOffX = mpWindowImpl->mnX; 3154 mnOutOffY = mpWindowImpl->mnY; 3155 } 3156 else 3157 { 3158 Window* pParent = ImplGetParent(); 3159 3160 mnOutOffX = mpWindowImpl->mnX + pParent->mnOutOffX; 3161 mnOutOffY = mpWindowImpl->mnY + pParent->mnOutOffY; 3162 } 3163 3164 Window* pChild = mpWindowImpl->mpFirstChild; 3165 while ( pChild ) 3166 { 3167 if ( pChild->ImplUpdatePos() ) 3168 bSysChild = sal_True; 3169 pChild = pChild->mpWindowImpl->mpNext; 3170 } 3171 3172 if ( mpWindowImpl->mpSysObj ) 3173 bSysChild = sal_True; 3174 3175 return bSysChild; 3176 } 3177 3178 // ----------------------------------------------------------------------- 3179 3180 void Window::ImplUpdateSysObjPos() 3181 { 3182 if ( mpWindowImpl->mpSysObj ) 3183 mpWindowImpl->mpSysObj->SetPosSize( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight ); 3184 3185 Window* pChild = mpWindowImpl->mpFirstChild; 3186 while ( pChild ) 3187 { 3188 pChild->ImplUpdateSysObjPos(); 3189 pChild = pChild->mpWindowImpl->mpNext; 3190 } 3191 } 3192 // ----------------------------------------------------------------------- 3193 3194 void Window::ImplPosSizeWindow( long nX, long nY, 3195 long nWidth, long nHeight, sal_uInt16 nFlags ) 3196 { 3197 sal_Bool bNewPos = sal_False; 3198 sal_Bool bNewSize = sal_False; 3199 sal_Bool bNewWidth = sal_False; 3200 sal_Bool bCopyBits = sal_False; 3201 long nOldOutOffX = mnOutOffX; 3202 long nOldOutOffY = mnOutOffY; 3203 long nOldOutWidth = mnOutWidth; 3204 long nOldOutHeight = mnOutHeight; 3205 Region* pOverlapRegion = NULL; 3206 Region* pOldRegion = NULL; 3207 3208 if ( IsReallyVisible() ) 3209 { 3210 if ( mpWindowImpl->mpFrameData->mpFirstBackWin ) 3211 ImplInvalidateAllOverlapBackgrounds(); 3212 3213 Rectangle aOldWinRect( Point( nOldOutOffX, nOldOutOffY ), 3214 Size( nOldOutWidth, nOldOutHeight ) ); 3215 pOldRegion = new Region( aOldWinRect ); 3216 if ( mpWindowImpl->mbWinRegion ) 3217 pOldRegion->Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) ); 3218 3219 if ( mnOutWidth && mnOutHeight && !mpWindowImpl->mbPaintTransparent && 3220 !mpWindowImpl->mbInitWinClipRegion && !mpWindowImpl->maWinClipRegion.IsEmpty() && 3221 !HasPaintEvent() ) 3222 bCopyBits = sal_True; 3223 } 3224 3225 sal_Bool bnXRecycled = sal_False; // avoid duplicate mirroring in RTL case 3226 if ( nFlags & WINDOW_POSSIZE_WIDTH ) 3227 { 3228 if(!( nFlags & WINDOW_POSSIZE_X )) 3229 { 3230 nX = mpWindowImpl->mnX; 3231 nFlags |= WINDOW_POSSIZE_X; 3232 bnXRecycled = sal_True; // we're using a mnX which was already mirrored in RTL case 3233 } 3234 3235 if ( nWidth < 0 ) 3236 nWidth = 0; 3237 if ( nWidth != mnOutWidth ) 3238 { 3239 mnOutWidth = nWidth; 3240 bNewSize = sal_True; 3241 bCopyBits = sal_False; 3242 bNewWidth = sal_True; 3243 } 3244 } 3245 if ( nFlags & WINDOW_POSSIZE_HEIGHT ) 3246 { 3247 if ( nHeight < 0 ) 3248 nHeight = 0; 3249 if ( nHeight != mnOutHeight ) 3250 { 3251 mnOutHeight = nHeight; 3252 bNewSize = sal_True; 3253 bCopyBits = sal_False; 3254 } 3255 } 3256 3257 if ( nFlags & WINDOW_POSSIZE_X ) 3258 { 3259 long nOrgX = nX; 3260 // --- RTL --- (compare the screen coordinates) 3261 Point aPtDev( Point( nX+mnOutOffX, 0 ) ); 3262 if( ImplHasMirroredGraphics() ) 3263 { 3264 mpGraphics->mirror( aPtDev.X(), this ); 3265 3266 // #106948# always mirror our pos if our parent is not mirroring, even 3267 // if we are also not mirroring 3268 // --- RTL --- check if parent is in different coordinates 3269 if( !bnXRecycled && mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->ImplIsAntiparallel() ) 3270 { 3271 // --- RTL --- (re-mirror at parent window) 3272 nX = mpWindowImpl->mpParent->mnOutWidth - mnOutWidth - nX; 3273 } 3274 /* #i99166# An LTR window in RTL UI that gets sized only would be 3275 expected to not moved its upper left point 3276 */ 3277 if( bnXRecycled ) 3278 { 3279 if( ImplIsAntiparallel() ) 3280 { 3281 aPtDev.X() = mpWindowImpl->mnAbsScreenX; 3282 nOrgX = mpWindowImpl->maPos.X(); 3283 } 3284 } 3285 } 3286 else if( !bnXRecycled && mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->ImplIsAntiparallel() ) 3287 { 3288 // mirrored window in LTR UI 3289 { 3290 // --- RTL --- (re-mirror at parent window) 3291 nX = mpWindowImpl->mpParent->mnOutWidth - mnOutWidth - nX; 3292 } 3293 } 3294 3295 // check maPos as well, as it could have been changed for client windows (ImplCallMove()) 3296 if ( mpWindowImpl->mnAbsScreenX != aPtDev.X() || nX != mpWindowImpl->mnX || nOrgX != mpWindowImpl->maPos.X() ) 3297 { 3298 if ( bCopyBits && !pOverlapRegion ) 3299 { 3300 pOverlapRegion = new Region(); 3301 ImplCalcOverlapRegion( Rectangle( Point( mnOutOffX, mnOutOffY ), 3302 Size( mnOutWidth, mnOutHeight ) ), 3303 *pOverlapRegion, sal_False, sal_True, sal_True ); 3304 } 3305 mpWindowImpl->mnX = nX; 3306 mpWindowImpl->maPos.X() = nOrgX; 3307 mpWindowImpl->mnAbsScreenX = aPtDev.X(); // --- RTL --- (store real screen pos) 3308 bNewPos = sal_True; 3309 } 3310 } 3311 if ( nFlags & WINDOW_POSSIZE_Y ) 3312 { 3313 // check maPos as well, as it could have been changed for client windows (ImplCallMove()) 3314 if ( nY != mpWindowImpl->mnY || nY != mpWindowImpl->maPos.Y() ) 3315 { 3316 if ( bCopyBits && !pOverlapRegion ) 3317 { 3318 pOverlapRegion = new Region(); 3319 ImplCalcOverlapRegion( Rectangle( Point( mnOutOffX, mnOutOffY ), 3320 Size( mnOutWidth, mnOutHeight ) ), 3321 *pOverlapRegion, sal_False, sal_True, sal_True ); 3322 } 3323 mpWindowImpl->mnY = nY; 3324 mpWindowImpl->maPos.Y() = nY; 3325 bNewPos = sal_True; 3326 } 3327 } 3328 3329 /* if ( nFlags & (WINDOW_POSSIZE_X|WINDOW_POSSIZE_Y) ) 3330 { 3331 POINT aPt; 3332 aPt.x = mpWindowImpl->maPos.X(); 3333 aPt.y = mpWindowImpl->maPos.Y(); 3334 ClientToScreen( mpWindowImpl->mpFrame->maFrameData.mhWnd , &aPt ); 3335 mpWindowImpl->maPos.X() = aPt.x; 3336 mpWindowImpl->maPos.Y() = aPt.y; 3337 } 3338 */ 3339 if ( bNewPos || bNewSize ) 3340 { 3341 sal_Bool bUpdateSysObjPos = sal_False; 3342 if ( bNewPos ) 3343 bUpdateSysObjPos = ImplUpdatePos(); 3344 3345 // the borderwindow always specifies the position for its client window 3346 if ( mpWindowImpl->mpBorderWindow ) 3347 mpWindowImpl->maPos = mpWindowImpl->mpBorderWindow->mpWindowImpl->maPos; 3348 3349 if ( mpWindowImpl->mpClientWindow ) 3350 { 3351 mpWindowImpl->mpClientWindow->ImplPosSizeWindow( mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder, 3352 mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder, 3353 mnOutWidth-mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnRightBorder, 3354 mnOutHeight-mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnBottomBorder, 3355 WINDOW_POSSIZE_X | WINDOW_POSSIZE_Y | 3356 WINDOW_POSSIZE_WIDTH | WINDOW_POSSIZE_HEIGHT ); 3357 // Wenn wir ein ClientWindow haben, dann hat dieses fuer die 3358 // Applikation auch die Position des FloatingWindows 3359 mpWindowImpl->mpClientWindow->mpWindowImpl->maPos = mpWindowImpl->maPos; 3360 if ( bNewPos ) 3361 { 3362 if ( mpWindowImpl->mpClientWindow->IsVisible() ) 3363 { 3364 mpWindowImpl->mpClientWindow->ImplCallMove(); 3365 } 3366 else 3367 { 3368 mpWindowImpl->mpClientWindow->mpWindowImpl->mbCallMove = sal_True; 3369 } 3370 } 3371 } 3372 // else 3373 // { 3374 // if ( mpWindowImpl->mpBorderWindow ) 3375 // mpWindowImpl->maPos = mpWindowImpl->mpBorderWindow->mpWindowImpl->maPos; 3376 // } 3377 3378 // Move()/Resize() werden erst bei Show() gerufen, damit min. eins vor 3379 // einem Show() kommt 3380 if ( IsVisible() ) 3381 { 3382 if ( bNewPos ) 3383 { 3384 ImplCallMove(); 3385 } 3386 if ( bNewSize ) 3387 { 3388 ImplCallResize(); 3389 } 3390 } 3391 else 3392 { 3393 if ( bNewPos ) 3394 mpWindowImpl->mbCallMove = sal_True; 3395 if ( bNewSize ) 3396 mpWindowImpl->mbCallResize = sal_True; 3397 } 3398 3399 sal_Bool bUpdateSysObjClip = sal_False; 3400 if ( IsReallyVisible() ) 3401 { 3402 if ( bNewPos || bNewSize ) 3403 { 3404 // Hintergrund-Sicherung zuruecksetzen 3405 if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mpSaveBackDev ) 3406 ImplDeleteOverlapBackground(); 3407 if ( mpWindowImpl->mpFrameData->mpFirstBackWin ) 3408 ImplInvalidateAllOverlapBackgrounds(); 3409 // Clip-Flag neu setzen 3410 bUpdateSysObjClip = !ImplSetClipFlag( sal_True ); 3411 } 3412 3413 // Fensterinhalt invalidieren ? 3414 if ( bNewPos || (mnOutWidth > nOldOutWidth) || (mnOutHeight > nOldOutHeight) ) 3415 { 3416 if ( bNewPos ) 3417 { 3418 sal_Bool bInvalidate = sal_False; 3419 sal_Bool bParentPaint = sal_True; 3420 if ( !ImplIsOverlapWindow() ) 3421 bParentPaint = mpWindowImpl->mpParent->IsPaintEnabled(); 3422 if ( bCopyBits && bParentPaint && !HasPaintEvent() ) 3423 { 3424 Point aPoint( mnOutOffX, mnOutOffY ); 3425 Region aRegion( Rectangle( aPoint, 3426 Size( mnOutWidth, mnOutHeight ) ) ); 3427 if ( mpWindowImpl->mbWinRegion ) 3428 aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) ); 3429 ImplClipBoundaries( aRegion, sal_False, sal_True ); 3430 if ( !pOverlapRegion->IsEmpty() ) 3431 { 3432 pOverlapRegion->Move( mnOutOffX-nOldOutOffX, mnOutOffY-nOldOutOffY ); 3433 aRegion.Exclude( *pOverlapRegion ); 3434 } 3435 if ( !aRegion.IsEmpty() ) 3436 { 3437 // Paint-Bereiche anpassen 3438 ImplMoveAllInvalidateRegions( Rectangle( Point( nOldOutOffX, nOldOutOffY ), 3439 Size( nOldOutWidth, nOldOutHeight ) ), 3440 mnOutOffX-nOldOutOffX, mnOutOffY-nOldOutOffY, 3441 sal_True ); 3442 SalGraphics* pGraphics = ImplGetFrameGraphics(); 3443 if ( pGraphics ) 3444 { 3445 const bool bSelectClipRegion = ImplSelectClipRegion( aRegion, pGraphics ); 3446 if ( bSelectClipRegion ) 3447 { 3448 pGraphics->CopyArea( mnOutOffX, mnOutOffY, 3449 nOldOutOffX, nOldOutOffY, 3450 nOldOutWidth, nOldOutHeight, 3451 SAL_COPYAREA_WINDOWINVALIDATE, this ); 3452 } 3453 else 3454 bInvalidate = sal_True; 3455 } 3456 else 3457 bInvalidate = sal_True; 3458 if ( !bInvalidate ) 3459 { 3460 if ( !pOverlapRegion->IsEmpty() ) 3461 ImplInvalidateFrameRegion( pOverlapRegion, INVALIDATE_CHILDREN ); 3462 } 3463 } 3464 else 3465 bInvalidate = sal_True; 3466 } 3467 else 3468 bInvalidate = sal_True; 3469 if ( bInvalidate ) 3470 ImplInvalidateFrameRegion( NULL, INVALIDATE_CHILDREN ); 3471 } 3472 else 3473 { 3474 Point aPoint( mnOutOffX, mnOutOffY ); 3475 Region aRegion( Rectangle( aPoint, 3476 Size( mnOutWidth, mnOutHeight ) ) ); 3477 aRegion.Exclude( *pOldRegion ); 3478 if ( mpWindowImpl->mbWinRegion ) 3479 aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) ); 3480 ImplClipBoundaries( aRegion, sal_False, sal_True ); 3481 if ( !aRegion.IsEmpty() ) 3482 ImplInvalidateFrameRegion( &aRegion, INVALIDATE_CHILDREN ); 3483 } 3484 } 3485 3486 // Parent oder Overlaps invalidieren 3487 if ( bNewPos || 3488 (mnOutWidth < nOldOutWidth) || (mnOutHeight < nOldOutHeight) ) 3489 { 3490 Region aRegion( *pOldRegion ); 3491 if ( !mpWindowImpl->mbPaintTransparent ) 3492 ImplExcludeWindowRegion( aRegion ); 3493 ImplClipBoundaries( aRegion, sal_False, sal_True ); 3494 if ( !aRegion.IsEmpty() && !mpWindowImpl->mpBorderWindow ) 3495 ImplInvalidateParentFrameRegion( aRegion ); 3496 } 3497 } 3498 3499 // System-Objekte anpassen 3500 if ( bUpdateSysObjClip ) 3501 ImplUpdateSysObjClip(); 3502 if ( bUpdateSysObjPos ) 3503 ImplUpdateSysObjPos(); 3504 if ( bNewSize && mpWindowImpl->mpSysObj ) 3505 mpWindowImpl->mpSysObj->SetPosSize( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight ); 3506 } 3507 3508 if ( pOverlapRegion ) 3509 delete pOverlapRegion; 3510 if ( pOldRegion ) 3511 delete pOldRegion; 3512 } 3513 3514 // ----------------------------------------------------------------------- 3515 3516 void Window::ImplToBottomChild() 3517 { 3518 if ( !ImplIsOverlapWindow() && !mpWindowImpl->mbReallyVisible && (mpWindowImpl->mpParent->mpWindowImpl->mpLastChild != this) ) 3519 { 3520 // Fenster an das Ende der Liste setzen 3521 if ( mpWindowImpl->mpPrev ) 3522 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext; 3523 else 3524 mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext; 3525 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev; 3526 mpWindowImpl->mpPrev = mpWindowImpl->mpParent->mpWindowImpl->mpLastChild; 3527 mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = this; 3528 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this; 3529 mpWindowImpl->mpNext = NULL; 3530 } 3531 } 3532 3533 // ----------------------------------------------------------------------- 3534 3535 void Window::ImplCalcToTop( ImplCalcToTopData* pPrevData ) 3536 { 3537 DBG_ASSERT( ImplIsOverlapWindow(), "Window::ImplCalcToTop(): Is not a OverlapWindow" ); 3538 3539 if ( !mpWindowImpl->mbFrame ) 3540 { 3541 if ( IsReallyVisible() ) 3542 { 3543 // Region berechnen, wo das Fenster mit anderen Fenstern ueberlappt 3544 Point aPoint( mnOutOffX, mnOutOffY ); 3545 Region aRegion( Rectangle( aPoint, 3546 Size( mnOutWidth, mnOutHeight ) ) ); 3547 Region aInvalidateRegion; 3548 ImplCalcOverlapRegionOverlaps( aRegion, aInvalidateRegion ); 3549 3550 if ( !aInvalidateRegion.IsEmpty() ) 3551 { 3552 ImplCalcToTopData* pData = new ImplCalcToTopData; 3553 pPrevData->mpNext = pData; 3554 pData->mpNext = NULL; 3555 pData->mpWindow = this; 3556 pData->mpInvalidateRegion = new Region( aInvalidateRegion ); 3557 } 3558 } 3559 } 3560 } 3561 3562 // ----------------------------------------------------------------------- 3563 3564 void Window::ImplCalcChildOverlapToTop( ImplCalcToTopData* pPrevData ) 3565 { 3566 DBG_ASSERT( ImplIsOverlapWindow(), "Window::ImplCalcChildOverlapToTop(): Is not a OverlapWindow" ); 3567 3568 ImplCalcToTop( pPrevData ); 3569 if ( pPrevData->mpNext ) 3570 pPrevData = pPrevData->mpNext; 3571 3572 Window* pOverlap = mpWindowImpl->mpFirstOverlap; 3573 while ( pOverlap ) 3574 { 3575 pOverlap->ImplCalcToTop( pPrevData ); 3576 if ( pPrevData->mpNext ) 3577 pPrevData = pPrevData->mpNext; 3578 pOverlap = pOverlap->mpWindowImpl->mpNext; 3579 } 3580 } 3581 3582 // ----------------------------------------------------------------------- 3583 3584 void Window::ImplToTop( sal_uInt16 nFlags ) 3585 { 3586 DBG_ASSERT( ImplIsOverlapWindow(), "Window::ImplToTop(): Is not a OverlapWindow" ); 3587 3588 if ( mpWindowImpl->mbFrame ) 3589 { 3590 // Wenn in das externe Fenster geklickt wird, ist dieses 3591 // dafuer zustaendig dafuer zu sorgen, das unser Frame 3592 // nach vorne kommt 3593 if ( !mpWindowImpl->mpFrameData->mbHasFocus && 3594 !mpWindowImpl->mpFrameData->mbSysObjFocus && 3595 !mpWindowImpl->mpFrameData->mbInSysObjFocusHdl && 3596 !mpWindowImpl->mpFrameData->mbInSysObjToTopHdl ) 3597 { 3598 // do not bring floating windows on the client to top 3599 if( !ImplGetClientWindow() || !(ImplGetClientWindow()->GetStyle() & WB_SYSTEMFLOATWIN) ) 3600 { 3601 sal_uInt16 nSysFlags = 0; 3602 if ( nFlags & TOTOP_RESTOREWHENMIN ) 3603 nSysFlags |= SAL_FRAME_TOTOP_RESTOREWHENMIN; 3604 if ( nFlags & TOTOP_FOREGROUNDTASK ) 3605 nSysFlags |= SAL_FRAME_TOTOP_FOREGROUNDTASK; 3606 if ( nFlags & TOTOP_GRABFOCUSONLY ) 3607 nSysFlags |= SAL_FRAME_TOTOP_GRABFOCUS_ONLY; 3608 mpWindowImpl->mpFrame->ToTop( nSysFlags ); 3609 } 3610 } 3611 } 3612 else 3613 { 3614 if ( mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap != this ) 3615 { 3616 // Fenster aus der Liste entfernen 3617 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext; 3618 if ( mpWindowImpl->mpNext ) 3619 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev; 3620 else 3621 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = mpWindowImpl->mpPrev; 3622 3623 // AlwaysOnTop beruecksichtigen 3624 sal_Bool bOnTop = IsAlwaysOnTopEnabled(); 3625 Window* pNextWin = mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap; 3626 if ( !bOnTop ) 3627 { 3628 while ( pNextWin ) 3629 { 3630 if ( !pNextWin->IsAlwaysOnTopEnabled() ) 3631 break; 3632 pNextWin = pNextWin->mpWindowImpl->mpNext; 3633 } 3634 } 3635 3636 // TopLevel abpruefen 3637 sal_uInt8 nTopLevel = mpWindowImpl->mpOverlapData->mnTopLevel; 3638 while ( pNextWin ) 3639 { 3640 if ( (bOnTop != pNextWin->IsAlwaysOnTopEnabled()) || 3641 (nTopLevel <= pNextWin->mpWindowImpl->mpOverlapData->mnTopLevel) ) 3642 break; 3643 pNextWin = pNextWin->mpWindowImpl->mpNext; 3644 } 3645 3646 // Fenster in die Liste wieder eintragen 3647 mpWindowImpl->mpNext = pNextWin; 3648 if ( pNextWin ) 3649 { 3650 mpWindowImpl->mpPrev = pNextWin->mpWindowImpl->mpPrev; 3651 pNextWin->mpWindowImpl->mpPrev = this; 3652 } 3653 else 3654 { 3655 mpWindowImpl->mpPrev = mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap; 3656 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = this; 3657 } 3658 if ( mpWindowImpl->mpPrev ) 3659 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this; 3660 else 3661 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap = this; 3662 3663 // ClipRegion muss von diesem Fenster und allen weiteren 3664 // ueberlappenden Fenstern neu berechnet werden. 3665 if ( IsReallyVisible() ) 3666 { 3667 // Hintergrund-Sicherung zuruecksetzen 3668 if ( mpWindowImpl->mpFrameData->mpFirstBackWin ) 3669 ImplInvalidateAllOverlapBackgrounds(); 3670 mpWindowImpl->mpOverlapWindow->ImplSetClipFlagOverlapWindows(); 3671 } 3672 } 3673 } 3674 } 3675 3676 // ----------------------------------------------------------------------- 3677 3678 void Window::ImplStartToTop( sal_uInt16 nFlags ) 3679 { 3680 ImplCalcToTopData aStartData; 3681 ImplCalcToTopData* pCurData; 3682 ImplCalcToTopData* pNextData; 3683 Window* pOverlapWindow; 3684 if ( ImplIsOverlapWindow() ) 3685 pOverlapWindow = this; 3686 else 3687 pOverlapWindow = mpWindowImpl->mpOverlapWindow; 3688 3689 // Zuerst die Paint-Bereiche berechnen 3690 Window* pTempOverlapWindow = pOverlapWindow; 3691 aStartData.mpNext = NULL; 3692 pCurData = &aStartData; 3693 do 3694 { 3695 pTempOverlapWindow->ImplCalcToTop( pCurData ); 3696 if ( pCurData->mpNext ) 3697 pCurData = pCurData->mpNext; 3698 pTempOverlapWindow = pTempOverlapWindow->mpWindowImpl->mpOverlapWindow; 3699 } 3700 while ( !pTempOverlapWindow->mpWindowImpl->mbFrame ); 3701 // Dann die Paint-Bereiche der ChildOverlap-Windows berechnen 3702 pTempOverlapWindow = mpWindowImpl->mpFirstOverlap; 3703 while ( pTempOverlapWindow ) 3704 { 3705 pTempOverlapWindow->ImplCalcToTop( pCurData ); 3706 if ( pCurData->mpNext ) 3707 pCurData = pCurData->mpNext; 3708 pTempOverlapWindow = pTempOverlapWindow->mpWindowImpl->mpNext; 3709 } 3710 3711 // Dann die Fenster-Verkettung aendern 3712 pTempOverlapWindow = pOverlapWindow; 3713 do 3714 { 3715 pTempOverlapWindow->ImplToTop( nFlags ); 3716 pTempOverlapWindow = pTempOverlapWindow->mpWindowImpl->mpOverlapWindow; 3717 } 3718 while ( !pTempOverlapWindow->mpWindowImpl->mbFrame ); 3719 // Und zum Schluss invalidieren wir die ungueltigen Bereiche 3720 pCurData = aStartData.mpNext; 3721 while ( pCurData ) 3722 { 3723 pCurData->mpWindow->ImplInvalidateFrameRegion( pCurData->mpInvalidateRegion, INVALIDATE_CHILDREN ); 3724 pNextData = pCurData->mpNext; 3725 delete pCurData->mpInvalidateRegion; 3726 delete pCurData; 3727 pCurData = pNextData; 3728 } 3729 } 3730 3731 // ----------------------------------------------------------------------- 3732 3733 void Window::ImplFocusToTop( sal_uInt16 nFlags, sal_Bool bReallyVisible ) 3734 { 3735 // Soll Focus auch geholt werden? 3736 if ( !(nFlags & TOTOP_NOGRABFOCUS) ) 3737 { 3738 // Erstes Fenster mit GrabFocus-Activate bekommt den Focus 3739 Window* pFocusWindow = this; 3740 while ( !pFocusWindow->ImplIsOverlapWindow() ) 3741 { 3742 // Nur wenn Fenster kein Border-Fenster hat, da wir 3743 // immer das dazugehoerende BorderFenster finden wollen 3744 if ( !pFocusWindow->mpWindowImpl->mpBorderWindow ) 3745 { 3746 if ( pFocusWindow->mpWindowImpl->mnActivateMode & ACTIVATE_MODE_GRABFOCUS ) 3747 break; 3748 } 3749 pFocusWindow = pFocusWindow->ImplGetParent(); 3750 } 3751 if ( (pFocusWindow->mpWindowImpl->mnActivateMode & ACTIVATE_MODE_GRABFOCUS) && 3752 !pFocusWindow->HasChildPathFocus( sal_True ) ) 3753 pFocusWindow->GrabFocus(); 3754 } 3755 3756 if ( bReallyVisible ) 3757 ImplGenerateMouseMove(); 3758 } 3759 3760 // ----------------------------------------------------------------------- 3761 3762 void Window::ImplShowAllOverlaps() 3763 { 3764 Window* pOverlapWindow = mpWindowImpl->mpFirstOverlap; 3765 while ( pOverlapWindow ) 3766 { 3767 if ( pOverlapWindow->mpWindowImpl->mbOverlapVisible ) 3768 { 3769 pOverlapWindow->Show( sal_True, SHOW_NOACTIVATE ); 3770 pOverlapWindow->mpWindowImpl->mbOverlapVisible = sal_False; 3771 } 3772 3773 pOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext; 3774 } 3775 } 3776 3777 // ----------------------------------------------------------------------- 3778 3779 void Window::ImplHideAllOverlaps() 3780 { 3781 Window* pOverlapWindow = mpWindowImpl->mpFirstOverlap; 3782 while ( pOverlapWindow ) 3783 { 3784 if ( pOverlapWindow->IsVisible() ) 3785 { 3786 pOverlapWindow->mpWindowImpl->mbOverlapVisible = sal_True; 3787 pOverlapWindow->Show( sal_False ); 3788 } 3789 3790 pOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext; 3791 } 3792 } 3793 3794 // ----------------------------------------------------------------------- 3795 3796 void Window::ImplCallMouseMove( sal_uInt16 nMouseCode, sal_Bool bModChanged ) 3797 { 3798 if ( mpWindowImpl->mpFrameData->mbMouseIn && mpWindowImpl->mpFrameWindow->mpWindowImpl->mbReallyVisible ) 3799 { 3800 sal_uLong nTime = Time::GetSystemTicks(); 3801 long nX = mpWindowImpl->mpFrameData->mnLastMouseX; 3802 long nY = mpWindowImpl->mpFrameData->mnLastMouseY; 3803 sal_uInt16 nCode = nMouseCode; 3804 sal_uInt16 nMode = mpWindowImpl->mpFrameData->mnMouseMode; 3805 sal_Bool bLeave; 3806 // Auf MouseLeave testen 3807 if ( ((nX < 0) || (nY < 0) || 3808 (nX >= mpWindowImpl->mpFrameWindow->mnOutWidth) || 3809 (nY >= mpWindowImpl->mpFrameWindow->mnOutHeight)) && 3810 !ImplGetSVData()->maWinData.mpCaptureWin ) 3811 bLeave = sal_True; 3812 else 3813 bLeave = sal_False; 3814 nMode |= MOUSE_SYNTHETIC; 3815 if ( bModChanged ) 3816 nMode |= MOUSE_MODIFIERCHANGED; 3817 ImplHandleMouseEvent( mpWindowImpl->mpFrameWindow, EVENT_MOUSEMOVE, bLeave, nX, nY, nTime, nCode, nMode ); 3818 } 3819 } 3820 3821 // ----------------------------------------------------------------------- 3822 3823 void Window::ImplGenerateMouseMove() 3824 { 3825 if ( !mpWindowImpl->mpFrameData->mnMouseMoveId ) 3826 Application::PostUserEvent( mpWindowImpl->mpFrameData->mnMouseMoveId, LINK( mpWindowImpl->mpFrameWindow, Window, ImplGenerateMouseMoveHdl ) ); 3827 } 3828 3829 // ----------------------------------------------------------------------- 3830 3831 IMPL_LINK( Window, ImplGenerateMouseMoveHdl, void*, EMPTYARG ) 3832 { 3833 mpWindowImpl->mpFrameData->mnMouseMoveId = 0; 3834 Window* pCaptureWin = ImplGetSVData()->maWinData.mpCaptureWin; 3835 if( ! pCaptureWin || 3836 (pCaptureWin->mpWindowImpl && pCaptureWin->mpWindowImpl->mpFrame == mpWindowImpl->mpFrame) 3837 ) 3838 { 3839 ImplCallMouseMove( mpWindowImpl->mpFrameData->mnMouseCode ); 3840 } 3841 return 0; 3842 } 3843 3844 // ----------------------------------------------------------------------- 3845 3846 void Window::ImplInvertFocus( const Rectangle& rRect ) 3847 { 3848 InvertTracking( rRect, SHOWTRACK_SMALL | SHOWTRACK_WINDOW ); 3849 } 3850 3851 // ----------------------------------------------------------------------- 3852 3853 void Window::ImplCallFocusChangeActivate( Window* pNewOverlapWindow, 3854 Window* pOldOverlapWindow ) 3855 { 3856 ImplSVData* pSVData = ImplGetSVData(); 3857 Window* pNewRealWindow; 3858 Window* pOldRealWindow; 3859 Window* pLastRealWindow; 3860 sal_Bool bCallActivate = sal_True; 3861 sal_Bool bCallDeactivate = sal_True; 3862 3863 pOldRealWindow = pOldOverlapWindow->ImplGetWindow(); 3864 pNewRealWindow = pNewOverlapWindow->ImplGetWindow(); 3865 if ( (pOldRealWindow->GetType() != WINDOW_FLOATINGWINDOW) || 3866 pOldRealWindow->GetActivateMode() ) 3867 { 3868 if ( (pNewRealWindow->GetType() == WINDOW_FLOATINGWINDOW) && 3869 !pNewRealWindow->GetActivateMode() ) 3870 { 3871 pSVData->maWinData.mpLastDeacWin = pOldOverlapWindow; 3872 bCallDeactivate = sal_False; 3873 } 3874 } 3875 else if ( (pNewRealWindow->GetType() != WINDOW_FLOATINGWINDOW) || 3876 pNewRealWindow->GetActivateMode() ) 3877 { 3878 if ( pSVData->maWinData.mpLastDeacWin ) 3879 { 3880 if ( pSVData->maWinData.mpLastDeacWin == pNewOverlapWindow ) 3881 bCallActivate = sal_False; 3882 else 3883 { 3884 pLastRealWindow = pSVData->maWinData.mpLastDeacWin->ImplGetWindow(); 3885 pSVData->maWinData.mpLastDeacWin->mpWindowImpl->mbActive = sal_False; 3886 pSVData->maWinData.mpLastDeacWin->Deactivate(); 3887 if ( pLastRealWindow != pSVData->maWinData.mpLastDeacWin ) 3888 { 3889 pLastRealWindow->mpWindowImpl->mbActive = sal_True; 3890 pLastRealWindow->Activate(); 3891 } 3892 } 3893 pSVData->maWinData.mpLastDeacWin = NULL; 3894 } 3895 } 3896 3897 if ( bCallDeactivate ) 3898 { 3899 if( pOldOverlapWindow->mpWindowImpl->mbActive ) 3900 { 3901 pOldOverlapWindow->mpWindowImpl->mbActive = sal_False; 3902 pOldOverlapWindow->Deactivate(); 3903 } 3904 if ( pOldRealWindow != pOldOverlapWindow ) 3905 { 3906 if( pOldRealWindow->mpWindowImpl->mbActive ) 3907 { 3908 pOldRealWindow->mpWindowImpl->mbActive = sal_False; 3909 pOldRealWindow->Deactivate(); 3910 } 3911 } 3912 } 3913 if ( bCallActivate && ! pNewOverlapWindow->mpWindowImpl->mbActive ) 3914 { 3915 if( ! pNewOverlapWindow->mpWindowImpl->mbActive ) 3916 { 3917 pNewOverlapWindow->mpWindowImpl->mbActive = sal_True; 3918 pNewOverlapWindow->Activate(); 3919 } 3920 if ( pNewRealWindow != pNewOverlapWindow ) 3921 { 3922 if( ! pNewRealWindow->mpWindowImpl->mbActive ) 3923 { 3924 pNewRealWindow->mpWindowImpl->mbActive = sal_True; 3925 pNewRealWindow->Activate(); 3926 } 3927 } 3928 } 3929 } 3930 3931 static bool IsWindowFocused(const WindowImpl& rWinImpl) 3932 { 3933 if (rWinImpl.mpSysObj) 3934 return true; 3935 3936 if (rWinImpl.mpFrameData->mbHasFocus) 3937 return true; 3938 3939 if (rWinImpl.mbFakeFocusSet) 3940 return true; 3941 3942 return false; 3943 } 3944 3945 // ----------------------------------------------------------------------- 3946 void Window::ImplGrabFocus( sal_uInt16 nFlags ) 3947 { 3948 // #143570# no focus for destructing windows 3949 if( mpWindowImpl->mbInDtor ) 3950 return; 3951 3952 // some event listeners do really bad stuff 3953 // => prepare for the worst 3954 ImplDelData aDogTag( this ); 3955 3956 // Currently the client window should always get the focus 3957 // Should the border window at some point be focusable 3958 // we need to change all GrabFocus() instances in VCL, 3959 // e.g. in ToTop() 3960 3961 if ( mpWindowImpl->mpClientWindow ) 3962 { 3963 // For a lack of design we need a little hack here to 3964 // ensure that dialogs on close pass the focus back to 3965 // the correct window 3966 if ( mpWindowImpl->mpLastFocusWindow && (mpWindowImpl->mpLastFocusWindow != this) && 3967 !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) && 3968 mpWindowImpl->mpLastFocusWindow->IsEnabled() && 3969 mpWindowImpl->mpLastFocusWindow->IsInputEnabled() && 3970 ! mpWindowImpl->mpLastFocusWindow->IsInModalMode() 3971 ) 3972 mpWindowImpl->mpLastFocusWindow->GrabFocus(); 3973 else 3974 mpWindowImpl->mpClientWindow->GrabFocus(); 3975 return; 3976 } 3977 else if ( mpWindowImpl->mbFrame ) 3978 { 3979 // For a lack of design we need a little hack here to 3980 // ensure that dialogs on close pass the focus back to 3981 // the correct window 3982 if ( mpWindowImpl->mpLastFocusWindow && (mpWindowImpl->mpLastFocusWindow != this) && 3983 !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) && 3984 mpWindowImpl->mpLastFocusWindow->IsEnabled() && 3985 mpWindowImpl->mpLastFocusWindow->IsInputEnabled() && 3986 ! mpWindowImpl->mpLastFocusWindow->IsInModalMode() 3987 ) 3988 { 3989 mpWindowImpl->mpLastFocusWindow->GrabFocus(); 3990 return; 3991 } 3992 } 3993 3994 // If the Window is disabled, then we don't change the focus 3995 if ( !IsEnabled() || !IsInputEnabled() || IsInModalMode() ) 3996 return; 3997 3998 // we only need to set the focus if it is not already set 3999 // note: if some other frame is waiting for an asynchrounous focus event 4000 // we also have to post an asynchronous focus event for this frame 4001 // which is done using ToTop 4002 ImplSVData* pSVData = ImplGetSVData(); 4003 4004 sal_Bool bAsyncFocusWaiting = sal_False; 4005 Window *pFrame = pSVData->maWinData.mpFirstFrame; 4006 while( pFrame ) 4007 { 4008 if( pFrame != mpWindowImpl->mpFrameWindow && pFrame->mpWindowImpl->mpFrameData->mnFocusId ) 4009 { 4010 bAsyncFocusWaiting = sal_True; 4011 break; 4012 } 4013 pFrame = pFrame->mpWindowImpl->mpFrameData->mpNextFrame; 4014 } 4015 4016 bool bHasFocus = IsWindowFocused(*mpWindowImpl); 4017 4018 sal_Bool bMustNotGrabFocus = sal_False; 4019 // #100242#, check parent hierarchy if some floater prohibits grab focus 4020 4021 Window *pParent = this; 4022 while( pParent ) 4023 { 4024 // #102158#, ignore grabfocus only if the floating parent grabs keyboard focus by itself (GrabsFocus()) 4025 // otherwise we cannot set the focus in a floating toolbox 4026 if( ( (pParent->mpWindowImpl->mbFloatWin && ((FloatingWindow*)pParent)->GrabsFocus()) || ( pParent->GetStyle() & WB_SYSTEMFLOATWIN ) ) && !( pParent->GetStyle() & WB_MOVEABLE ) ) 4027 { 4028 bMustNotGrabFocus = sal_True; 4029 break; 4030 } 4031 pParent = pParent->mpWindowImpl->mpParent; 4032 } 4033 4034 4035 if ( ( pSVData->maWinData.mpFocusWin != this && ! mpWindowImpl->mbInDtor ) || ( bAsyncFocusWaiting && !bHasFocus && !bMustNotGrabFocus ) ) 4036 { 4037 // EndExtTextInput if it is not the same window 4038 if ( pSVData->maWinData.mpExtTextInputWin && 4039 (pSVData->maWinData.mpExtTextInputWin != this) ) 4040 pSVData->maWinData.mpExtTextInputWin->EndExtTextInput( EXTTEXTINPUT_END_COMPLETE ); 4041 4042 // Dieses Fenster als letztes FocusWindow merken 4043 Window* pOverlapWindow = ImplGetFirstOverlapWindow(); 4044 pOverlapWindow->mpWindowImpl->mpLastFocusWindow = this; 4045 mpWindowImpl->mpFrameData->mpFocusWin = this; 4046 4047 if( !bHasFocus ) 4048 { 4049 // menue windows never get the system focus 4050 // the application will keep the focus 4051 if( bMustNotGrabFocus ) 4052 return; 4053 else 4054 { 4055 // Hier setzen wir schon den Focus um, da ToTop() den Focus 4056 // nicht auf ein anderes Fenster setzen darf 4057 //DBG_WARNING( "Window::GrabFocus() - Frame doesn't have the focus" ); 4058 mpWindowImpl->mpFrame->ToTop( SAL_FRAME_TOTOP_GRABFOCUS | SAL_FRAME_TOTOP_GRABFOCUS_ONLY ); 4059 return; 4060 } 4061 } 4062 4063 Window* pOldFocusWindow = pSVData->maWinData.mpFocusWin; 4064 ImplDelData aOldFocusDel( pOldFocusWindow ); 4065 4066 pSVData->maWinData.mpFocusWin = this; 4067 4068 if ( pOldFocusWindow ) 4069 { 4070 // Cursor hiden 4071 if ( pOldFocusWindow->mpWindowImpl->mpCursor ) 4072 pOldFocusWindow->mpWindowImpl->mpCursor->ImplHide( true ); 4073 } 4074 4075 // !!!!! Wegen altem SV-Office Activate/Deavtivate Handling 4076 // !!!!! erstmal so wie frueher 4077 if ( pOldFocusWindow ) 4078 { 4079 // Focus merken 4080 Window* pOldOverlapWindow = pOldFocusWindow->ImplGetFirstOverlapWindow(); 4081 Window* pNewOverlapWindow = ImplGetFirstOverlapWindow(); 4082 if ( pOldOverlapWindow != pNewOverlapWindow ) 4083 ImplCallFocusChangeActivate( pNewOverlapWindow, pOldOverlapWindow ); 4084 } 4085 else 4086 { 4087 Window* pNewOverlapWindow = ImplGetFirstOverlapWindow(); 4088 Window* pNewRealWindow = pNewOverlapWindow->ImplGetWindow(); 4089 pNewOverlapWindow->mpWindowImpl->mbActive = sal_True; 4090 pNewOverlapWindow->Activate(); 4091 if ( pNewRealWindow != pNewOverlapWindow ) 4092 { 4093 pNewRealWindow->mpWindowImpl->mbActive = sal_True; 4094 pNewRealWindow->Activate(); 4095 } 4096 } 4097 /* 4098 // call Deactivate and Activate 4099 Window* pDeactivateParent; 4100 Window* pActivateParent; 4101 Window* pParent; 4102 Window* pLastParent; 4103 pDeactivateParent = pOldFocusWindow; 4104 while ( pDeactivateParent ) 4105 { 4106 pParent = pDeactivateParent; 4107 if ( pParent->ImplIsChild( this ) ) 4108 break; 4109 4110 if ( pDeactivateParent->ImplIsOverlapWindow() ) 4111 { 4112 if ( !pDeactivateParent->mpWindowImpl->mbParentActive ) 4113 break; 4114 } 4115 4116 pDeactivateParent = pDeactivateParent->ImplGetParent(); 4117 } 4118 if ( pOldFocusWindow ) 4119 { 4120 pActivateParent = this; 4121 while ( pActivateParent ) 4122 { 4123 pParent = pActivateParent; 4124 if ( pParent->ImplIsChild( pOldFocusWindow ) ) 4125 break; 4126 4127 if ( pActivateParent->ImplIsOverlapWindow() ) 4128 { 4129 if ( !pActivateParent->mpWindowImpl->mbParentActive ) 4130 break; 4131 } 4132 4133 pActivateParent = pActivateParent->ImplGetParent(); 4134 } 4135 } 4136 else 4137 { 4138 if ( ImplIsOverlapWindow() ) 4139 pActivateParent = this; 4140 else 4141 pActivateParent = mpWindowImpl->mpOverlapWindow; 4142 while ( pActivateParent ) 4143 { 4144 if ( pActivateParent->ImplIsOverlapWindow() ) 4145 { 4146 if ( !pActivateParent->mpWindowImpl->mbParentActive ) 4147 break; 4148 } 4149 4150 pActivateParent = pActivateParent->ImplGetParent(); 4151 } 4152 } 4153 if ( pDeactivateParent ) 4154 { 4155 do 4156 { 4157 pLastParent = pOldFocusWindow; 4158 if ( pLastParent != pDeactivateParent ) 4159 { 4160 pParent = pLastParent->ImplGetParent(); 4161 while ( pParent ) 4162 { 4163 if ( pParent == pDeactivateParent ) 4164 break; 4165 pLastParent = pParent; 4166 pParent = pParent->ImplGetParent(); 4167 } 4168 } 4169 else 4170 pParent = pLastParent; 4171 4172 pParent->mpWindowImpl->mbActive = sal_False; 4173 pParent->Deactivate(); 4174 pDeactivateParent = pLastParent; 4175 } 4176 while ( pDeactivateParent != pOldFocusWindow ); 4177 } 4178 do 4179 { 4180 pLastParent = this; 4181 if ( pLastParent != pActivateParent ) 4182 { 4183 pParent = pLastParent->ImplGetParent(); 4184 while ( pParent ) 4185 { 4186 if ( pParent == pActivateParent ) 4187 break; 4188 pLastParent = pParent; 4189 pParent = pParent->ImplGetParent(); 4190 } 4191 } 4192 else 4193 pParent = pLastParent; 4194 4195 pParent->mpWindowImpl->mbActive = sal_True; 4196 pParent->Activate(); 4197 pActivateParent = pLastParent; 4198 } 4199 while ( pActivateParent != this ); 4200 */ 4201 // call Get- and LoseFocus 4202 if ( pOldFocusWindow && ! aOldFocusDel.IsDelete() ) 4203 { 4204 if ( pOldFocusWindow->IsTracking() && 4205 (pSVData->maWinData.mnTrackFlags & STARTTRACK_FOCUSCANCEL) ) 4206 pOldFocusWindow->EndTracking( ENDTRACK_CANCEL | ENDTRACK_FOCUS ); 4207 NotifyEvent aNEvt( EVENT_LOSEFOCUS, pOldFocusWindow ); 4208 if ( !ImplCallPreNotify( aNEvt ) ) 4209 pOldFocusWindow->LoseFocus(); 4210 pOldFocusWindow->ImplCallDeactivateListeners( this ); 4211 } 4212 4213 if ( pSVData->maWinData.mpFocusWin == this ) 4214 { 4215 if ( mpWindowImpl->mpSysObj ) 4216 { 4217 mpWindowImpl->mpFrameData->mpFocusWin = this; 4218 if ( !mpWindowImpl->mpFrameData->mbInSysObjFocusHdl ) 4219 mpWindowImpl->mpSysObj->GrabFocus(); 4220 } 4221 4222 if ( pSVData->maWinData.mpFocusWin == this ) 4223 { 4224 if ( mpWindowImpl->mpCursor ) 4225 mpWindowImpl->mpCursor->ImplShow(); 4226 mpWindowImpl->mbInFocusHdl = sal_True; 4227 mpWindowImpl->mnGetFocusFlags = nFlags; 4228 // if we're changing focus due to closing a popup floating window 4229 // notify the new focus window so it can restore the inner focus 4230 // eg, toolboxes can select their recent active item 4231 if( pOldFocusWindow && 4232 ! aOldFocusDel.IsDelete() && 4233 ( pOldFocusWindow->GetDialogControlFlags() & WINDOW_DLGCTRL_FLOATWIN_POPUPMODEEND_CANCEL ) ) 4234 mpWindowImpl->mnGetFocusFlags |= GETFOCUS_FLOATWIN_POPUPMODEEND_CANCEL; 4235 NotifyEvent aNEvt( EVENT_GETFOCUS, this ); 4236 if ( !ImplCallPreNotify( aNEvt ) && !aDogTag.IsDelete() ) 4237 GetFocus(); 4238 if( !aDogTag.IsDelete() ) 4239 ImplCallActivateListeners( (pOldFocusWindow && ! aOldFocusDel.IsDelete()) ? pOldFocusWindow : NULL ); 4240 if( !aDogTag.IsDelete() ) 4241 { 4242 mpWindowImpl->mnGetFocusFlags = 0; 4243 mpWindowImpl->mbInFocusHdl = sal_False; 4244 } 4245 } 4246 } 4247 4248 GetpApp()->FocusChanged(); 4249 ImplNewInputContext(); 4250 } 4251 } 4252 4253 // ----------------------------------------------------------------------- 4254 4255 void Window::ImplNewInputContext() 4256 { 4257 ImplSVData* pSVData = ImplGetSVData(); 4258 Window* pFocusWin = pSVData->maWinData.mpFocusWin; 4259 if ( !pFocusWin ) 4260 return; 4261 4262 // Is InputContext changed? 4263 const InputContext& rInputContext = pFocusWin->GetInputContext(); 4264 if ( rInputContext == pFocusWin->mpWindowImpl->mpFrameData->maOldInputContext ) 4265 return; 4266 4267 pFocusWin->mpWindowImpl->mpFrameData->maOldInputContext = rInputContext; 4268 4269 SalInputContext aNewContext; 4270 const Font& rFont = rInputContext.GetFont(); 4271 const XubString& rFontName = rFont.GetName(); 4272 ImplFontEntry* pFontEntry = NULL; 4273 aNewContext.mpFont = NULL; 4274 if ( rFontName.Len() ) 4275 { 4276 Size aSize = pFocusWin->ImplLogicToDevicePixel( rFont.GetSize() ); 4277 if ( !aSize.Height() ) 4278 { 4279 // Nur dann Defaultgroesse setzen, wenn Fonthoehe auch in logischen 4280 // Koordinaaten 0 ist 4281 if ( rFont.GetSize().Height() ) 4282 aSize.Height() = 1; 4283 else 4284 aSize.Height() = (12*pFocusWin->mnDPIY)/72; 4285 } 4286 // TODO: No display device uses ImplDirectFontSubstitution thingy, right? => remove it 4287 ImplDirectFontSubstitution* pFontSubst = NULL; 4288 //if( pFocusWin->mpOutDevData ) 4289 // pFontSubst = &pFocusWin->mpOutDevData->maDevFontSubst; 4290 pFontEntry = pFocusWin->mpFontCache->GetFontEntry( pFocusWin->mpFontList, 4291 rFont, aSize, static_cast<float>(aSize.Height()), pFontSubst ); 4292 if ( pFontEntry ) 4293 aNewContext.mpFont = &pFontEntry->maFontSelData; 4294 } 4295 aNewContext.meLanguage = rFont.GetLanguage(); 4296 aNewContext.mnOptions = rInputContext.GetOptions(); 4297 pFocusWin->ImplGetFrame()->SetInputContext( &aNewContext ); 4298 4299 if ( pFontEntry ) 4300 pFocusWin->mpFontCache->Release( pFontEntry ); 4301 } 4302 4303 // ----------------------------------------------------------------------- 4304 4305 Window::Window( WindowType nType ) 4306 { 4307 DBG_CTOR( Window, ImplDbgCheckWindow ); 4308 4309 ImplInitWindowData( nType ); 4310 } 4311 4312 // ----------------------------------------------------------------------- 4313 4314 Window::Window( Window* pParent, WinBits nStyle ) 4315 { 4316 DBG_CTOR( Window, ImplDbgCheckWindow ); 4317 4318 ImplInitWindowData( WINDOW_WINDOW ); 4319 ImplInit( pParent, nStyle, NULL ); 4320 } 4321 4322 // ----------------------------------------------------------------------- 4323 4324 Window::Window( Window* pParent, const ResId& rResId ) 4325 { 4326 DBG_CTOR( Window, ImplDbgCheckWindow ); 4327 4328 ImplInitWindowData( WINDOW_WINDOW ); 4329 rResId.SetRT( RSC_WINDOW ); 4330 WinBits nStyle = ImplInitRes( rResId ); 4331 ImplInit( pParent, nStyle, NULL ); 4332 ImplLoadRes( rResId ); 4333 4334 if ( !(nStyle & WB_HIDE) ) 4335 Show(); 4336 } 4337 4338 // ----------------------------------------------------------------------- 4339 #if OSL_DEBUG_LEVEL > 0 4340 namespace 4341 { 4342 void lcl_appendWindowInfo( ByteString& io_rErrorString, const Window& i_rWindow ) 4343 { 4344 // skip border windows, they don't carry information which helps diagnosing the problem 4345 const Window* pWindow( &i_rWindow ); 4346 while ( pWindow && ( pWindow->GetType() == WINDOW_BORDERWINDOW ) ) 4347 pWindow = pWindow->GetWindow( WINDOW_FIRSTCHILD ); 4348 if ( !pWindow ) 4349 pWindow = &i_rWindow; 4350 4351 io_rErrorString += char(13); 4352 io_rErrorString += typeid( *pWindow ).name(); 4353 io_rErrorString += " (window text: '"; 4354 io_rErrorString += ByteString( pWindow->GetText(), RTL_TEXTENCODING_UTF8 ); 4355 io_rErrorString += "')"; 4356 } 4357 } 4358 #endif 4359 // ----------------------------------------------------------------------- 4360 4361 Window::~Window() 4362 { 4363 ImplFreeExtWindowImpl(); 4364 4365 vcl::LazyDeletor<Window>::Undelete( this ); 4366 4367 DBG_DTOR( Window, ImplDbgCheckWindow ); 4368 DBG_ASSERT( !mpWindowImpl->mbInDtor, "~Window - already in DTOR!" ); 4369 4370 4371 // remove Key and Mouse events issued by Application::PostKey/MouseEvent 4372 Application::RemoveMouseAndKeyEvents( this ); 4373 4374 // Dispose of the canvas implementation (which, currently, has an 4375 // own wrapper window as a child to this one. 4376 uno::Reference< rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas ); 4377 if( xCanvas.is() ) 4378 { 4379 uno::Reference < lang::XComponent > xCanvasComponent( xCanvas, 4380 uno::UNO_QUERY ); 4381 if( xCanvasComponent.is() ) 4382 xCanvasComponent->dispose(); 4383 } 4384 4385 mpWindowImpl->mbInDtor = sal_True; 4386 4387 ImplCallEventListeners( VCLEVENT_OBJECT_DYING ); 4388 4389 // do not send child events for frames that were registered as native frames 4390 if( !ImplIsAccessibleNativeFrame() && mpWindowImpl->mbReallyVisible ) 4391 if ( ImplIsAccessibleCandidate() && GetAccessibleParentWindow() ) 4392 GetAccessibleParentWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_CHILDDESTROYED, this ); 4393 4394 // remove associated data structures from dockingmanager 4395 ImplGetDockingManager()->RemoveWindow( this ); 4396 4397 4398 // remove ownerdraw decorated windows from list in the top-most frame window 4399 if( (GetStyle() & WB_OWNERDRAWDECORATION) && mpWindowImpl->mbFrame ) 4400 { 4401 ::std::vector< Window* >& rList = ImplGetOwnerDrawList(); 4402 ::std::vector< Window* >::iterator p; 4403 p = ::std::find( rList.begin(), rList.end(), this ); 4404 if( p != rList.end() ) 4405 rList.erase( p ); 4406 } 4407 4408 // shutdown drag and drop 4409 ::com::sun::star::uno::Reference < ::com::sun::star::lang::XComponent > xDnDComponent( mpWindowImpl->mxDNDListenerContainer, ::com::sun::star::uno::UNO_QUERY ); 4410 4411 if( xDnDComponent.is() ) 4412 xDnDComponent->dispose(); 4413 4414 if( mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData ) 4415 { 4416 try 4417 { 4418 // deregister drop target listener 4419 if( mpWindowImpl->mpFrameData->mxDropTargetListener.is() ) 4420 { 4421 uno::Reference< XDragGestureRecognizer > xDragGestureRecognizer = 4422 uno::Reference< XDragGestureRecognizer > (mpWindowImpl->mpFrameData->mxDragSource, UNO_QUERY); 4423 if( xDragGestureRecognizer.is() ) 4424 { 4425 xDragGestureRecognizer->removeDragGestureListener( 4426 uno::Reference< XDragGestureListener > (mpWindowImpl->mpFrameData->mxDropTargetListener, UNO_QUERY)); 4427 } 4428 4429 mpWindowImpl->mpFrameData->mxDropTarget->removeDropTargetListener( mpWindowImpl->mpFrameData->mxDropTargetListener ); 4430 mpWindowImpl->mpFrameData->mxDropTargetListener.clear(); 4431 } 4432 4433 // shutdown drag and drop for this frame window 4434 uno::Reference< XComponent > xComponent( mpWindowImpl->mpFrameData->mxDropTarget, UNO_QUERY ); 4435 4436 // DNDEventDispatcher does not hold a reference of the DropTarget, 4437 // so it's ok if it does not support XComponent 4438 if( xComponent.is() ) 4439 xComponent->dispose(); 4440 } 4441 4442 catch ( Exception&) 4443 { 4444 // can be safely ignored here. 4445 } 4446 } 4447 4448 UnoWrapperBase* pWrapper = Application::GetUnoWrapper( sal_False ); 4449 if ( pWrapper ) 4450 pWrapper->WindowDestroyed( this ); 4451 4452 // MT: Must be called after WindowDestroyed! 4453 // Otherwise, if the accessible is a VCLXWindow, it will try to destroy this window again! 4454 // But accessibility implementations from applications need this dispose. 4455 if ( mpWindowImpl->mxAccessible.is() ) 4456 { 4457 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent> xC( mpWindowImpl->mxAccessible, ::com::sun::star::uno::UNO_QUERY ); 4458 if ( xC.is() ) 4459 xC->dispose(); 4460 } 4461 4462 ImplSVData* pSVData = ImplGetSVData(); 4463 4464 if ( pSVData->maHelpData.mpHelpWin && (pSVData->maHelpData.mpHelpWin->GetParent() == this) ) 4465 ImplDestroyHelpWindow( true ); 4466 4467 DBG_ASSERT( pSVData->maWinData.mpTrackWin != this, 4468 "Window::~Window(): Window is in TrackingMode" ); 4469 DBG_ASSERT( pSVData->maWinData.mpCaptureWin != this, 4470 "Window::~Window(): Window has the mouse captured" ); 4471 // #103442# DefModalDialogParent is now determined on-the-fly, so this pointer is unimportant now 4472 //DBG_ASSERT( pSVData->maWinData.mpDefDialogParent != this, 4473 // "Window::~Window(): Window is DefModalDialogParent" ); 4474 4475 // Wegen alter kompatibilitaet 4476 if ( pSVData->maWinData.mpTrackWin == this ) 4477 EndTracking(); 4478 if ( pSVData->maWinData.mpCaptureWin == this ) 4479 ReleaseMouse(); 4480 if ( pSVData->maWinData.mpDefDialogParent == this ) 4481 pSVData->maWinData.mpDefDialogParent = NULL; 4482 4483 #ifdef DBG_UTIL 4484 if ( sal_True ) // always perform these tests in non-pro versions 4485 { 4486 ByteString aErrorStr; 4487 sal_Bool bError = sal_False; 4488 Window* pTempWin = mpWindowImpl->mpFrameData->mpFirstOverlap; 4489 while ( pTempWin ) 4490 { 4491 if ( ImplIsRealParentPath( pTempWin ) ) 4492 { 4493 bError = sal_True; 4494 lcl_appendWindowInfo( aErrorStr, *pTempWin ); 4495 } 4496 pTempWin = pTempWin->mpWindowImpl->mpNextOverlap; 4497 } 4498 if ( bError ) 4499 { 4500 ByteString aTempStr( "Window (" ); 4501 aTempStr += ByteString( GetText(), RTL_TEXTENCODING_UTF8 ); 4502 aTempStr += ") with living SystemWindow(s) destroyed: "; 4503 aTempStr += aErrorStr; 4504 DBG_ERROR( aTempStr.GetBuffer() ); 4505 GetpApp()->Abort( String( aTempStr, RTL_TEXTENCODING_UTF8 ) ); // abort in non-pro version, this must be fixed! 4506 } 4507 4508 bError = sal_False; 4509 pTempWin = pSVData->maWinData.mpFirstFrame; 4510 while ( pTempWin ) 4511 { 4512 if ( ImplIsRealParentPath( pTempWin ) ) 4513 { 4514 bError = sal_True; 4515 lcl_appendWindowInfo( aErrorStr, *pTempWin ); 4516 } 4517 pTempWin = pTempWin->mpWindowImpl->mpFrameData->mpNextFrame; 4518 } 4519 if ( bError ) 4520 { 4521 ByteString aTempStr( "Window (" ); 4522 aTempStr += ByteString( GetText(), RTL_TEXTENCODING_UTF8 ); 4523 aTempStr += ") with living SystemWindow(s) destroyed: "; 4524 aTempStr += aErrorStr; 4525 DBG_ERROR( aTempStr.GetBuffer() ); 4526 GetpApp()->Abort( String( aTempStr, RTL_TEXTENCODING_UTF8 ) ); // abort in non-pro version, this must be fixed! 4527 } 4528 4529 if ( mpWindowImpl->mpFirstChild ) 4530 { 4531 ByteString aTempStr( "Window (" ); 4532 aTempStr += ByteString( GetText(), RTL_TEXTENCODING_UTF8 ); 4533 aTempStr += ") with living Child(s) destroyed: "; 4534 pTempWin = mpWindowImpl->mpFirstChild; 4535 while ( pTempWin ) 4536 { 4537 lcl_appendWindowInfo( aTempStr, *pTempWin ); 4538 pTempWin = pTempWin->mpWindowImpl->mpNext; 4539 } 4540 DBG_ERROR( aTempStr.GetBuffer() ); 4541 GetpApp()->Abort( String( aTempStr, RTL_TEXTENCODING_UTF8 ) ); // abort in non-pro version, this must be fixed! 4542 } 4543 4544 if ( mpWindowImpl->mpFirstOverlap ) 4545 { 4546 ByteString aTempStr( "Window (" ); 4547 aTempStr += ByteString( GetText(), RTL_TEXTENCODING_UTF8 ); 4548 aTempStr += ") with living SystemWindow(s) destroyed: "; 4549 pTempWin = mpWindowImpl->mpFirstOverlap; 4550 while ( pTempWin ) 4551 { 4552 lcl_appendWindowInfo( aTempStr, *pTempWin ); 4553 pTempWin = pTempWin->mpWindowImpl->mpNext; 4554 } 4555 DBG_ERROR( aTempStr.GetBuffer() ); 4556 GetpApp()->Abort( String( aTempStr, RTL_TEXTENCODING_UTF8 ) ); // abort in non-pro version, this must be fixed! 4557 } 4558 4559 Window* pMyParent = this; 4560 SystemWindow* pMySysWin = NULL; 4561 4562 while ( pMyParent ) 4563 { 4564 if ( pMyParent->IsSystemWindow() ) 4565 pMySysWin = (SystemWindow*)pMyParent; 4566 pMyParent = pMyParent->GetParent(); 4567 } 4568 if ( pMySysWin && pMySysWin->ImplIsInTaskPaneList( this ) ) 4569 { 4570 ByteString aTempStr( "Window (" ); 4571 aTempStr += ByteString( GetText(), RTL_TEXTENCODING_UTF8 ); 4572 aTempStr += ") still in TaskPanelList!"; 4573 DBG_ERROR( aTempStr.GetBuffer() ); 4574 GetpApp()->Abort( String( aTempStr, RTL_TEXTENCODING_UTF8 ) ); // abort in non-pro version, this must be fixed! 4575 } 4576 } 4577 #endif 4578 4579 if( mpWindowImpl->mbIsInTaskPaneList ) 4580 { 4581 Window* pMyParent = this; 4582 SystemWindow* pMySysWin = NULL; 4583 4584 while ( pMyParent ) 4585 { 4586 if ( pMyParent->IsSystemWindow() ) 4587 pMySysWin = (SystemWindow*)pMyParent; 4588 pMyParent = pMyParent->GetParent(); 4589 } 4590 if ( pMySysWin && pMySysWin->ImplIsInTaskPaneList( this ) ) 4591 { 4592 pMySysWin->GetTaskPaneList()->RemoveWindow( this ); 4593 } 4594 else 4595 { 4596 ByteString aTempStr( "Window (" ); 4597 aTempStr += ByteString( GetText(), RTL_TEXTENCODING_UTF8 ); 4598 aTempStr += ") not found in TaskPanelList!"; 4599 DBG_ERROR( aTempStr.GetBuffer() ); 4600 } 4601 } 4602 4603 // Fenster hiden, um das entsprechende Paint-Handling auszuloesen 4604 Hide(); 4605 4606 // Mitteilen, das Fenster zerstoert wird 4607 { 4608 NotifyEvent aNEvt( EVENT_DESTROY, this ); 4609 Notify( aNEvt ); 4610 } 4611 4612 // EndExtTextInputMode 4613 if ( pSVData->maWinData.mpExtTextInputWin == this ) 4614 { 4615 EndExtTextInput( EXTTEXTINPUT_END_COMPLETE ); 4616 if ( pSVData->maWinData.mpExtTextInputWin == this ) 4617 pSVData->maWinData.mpExtTextInputWin = NULL; 4618 } 4619 4620 // check if the focus window is our child 4621 sal_Bool bHasFocussedChild = sal_False; 4622 if( pSVData->maWinData.mpFocusWin && ImplIsRealParentPath( pSVData->maWinData.mpFocusWin ) ) 4623 { 4624 // #122232#, this must not happen and is an application bug ! but we try some cleanup to hopefully avoid crashes, see below 4625 bHasFocussedChild = sal_True; 4626 #ifdef DBG_UTIL 4627 ByteString aTempStr( "Window (" ); 4628 aTempStr += ByteString( GetText(), RTL_TEXTENCODING_UTF8 ); 4629 aTempStr += ") with focussed child window destroyed ! THIS WILL LEAD TO CRASHES AND MUST BE FIXED !"; 4630 DBG_ERROR( aTempStr.GetBuffer() ); 4631 GetpApp()->Abort( String( aTempStr, RTL_TEXTENCODING_UTF8 ) ); // abort in non-pro version, this must be fixed! 4632 #endif 4633 } 4634 4635 // Wenn wir den Focus haben, dann den Focus auf ein anderes Fenster setzen 4636 Window* pOverlapWindow = ImplGetFirstOverlapWindow(); 4637 if ( pSVData->maWinData.mpFocusWin == this 4638 || bHasFocussedChild ) // #122232#, see above, try some cleanup 4639 { 4640 if ( mpWindowImpl->mbFrame ) 4641 { 4642 pSVData->maWinData.mpFocusWin = NULL; 4643 pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL; 4644 GetpApp()->FocusChanged(); 4645 } 4646 else 4647 { 4648 Window* pParent = GetParent(); 4649 Window* pBorderWindow = mpWindowImpl->mpBorderWindow; 4650 // Bei ueberlappenden Fenstern wird der Focus auf den 4651 // Parent vom naechsten FrameWindow gesetzt 4652 if ( pBorderWindow ) 4653 { 4654 if ( pBorderWindow->ImplIsOverlapWindow() ) 4655 pParent = pBorderWindow->mpWindowImpl->mpOverlapWindow; 4656 } 4657 else if ( ImplIsOverlapWindow() ) 4658 pParent = mpWindowImpl->mpOverlapWindow; 4659 4660 if ( pParent && pParent->IsEnabled() && pParent->IsInputEnabled() && ! pParent->IsInModalMode() ) 4661 pParent->GrabFocus(); 4662 else 4663 mpWindowImpl->mpFrameWindow->GrabFocus(); 4664 4665 // If the focus was set back to 'this' set it to nothing 4666 if ( pSVData->maWinData.mpFocusWin == this ) 4667 { 4668 pSVData->maWinData.mpFocusWin = NULL; 4669 pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL; 4670 GetpApp()->FocusChanged(); 4671 } 4672 } 4673 } 4674 4675 4676 if ( pOverlapWindow->mpWindowImpl->mpLastFocusWindow == this ) 4677 pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL; 4678 4679 // reset hint for DefModalDialogParent 4680 if( pSVData->maWinData.mpActiveApplicationFrame == this ) 4681 pSVData->maWinData.mpActiveApplicationFrame = NULL; 4682 4683 // gemerkte Fenster zuruecksetzen 4684 if ( mpWindowImpl->mpFrameData->mpFocusWin == this ) 4685 mpWindowImpl->mpFrameData->mpFocusWin = NULL; 4686 if ( mpWindowImpl->mpFrameData->mpMouseMoveWin == this ) 4687 mpWindowImpl->mpFrameData->mpMouseMoveWin = NULL; 4688 if ( mpWindowImpl->mpFrameData->mpMouseDownWin == this ) 4689 mpWindowImpl->mpFrameData->mpMouseDownWin = NULL; 4690 4691 // Deactivate-Window zuruecksetzen 4692 if ( pSVData->maWinData.mpLastDeacWin == this ) 4693 pSVData->maWinData.mpLastDeacWin = NULL; 4694 4695 if ( mpWindowImpl->mbFrame ) 4696 { 4697 if ( mpWindowImpl->mpFrameData->mnFocusId ) 4698 Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnFocusId ); 4699 if ( mpWindowImpl->mpFrameData->mnMouseMoveId ) 4700 Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnMouseMoveId ); 4701 } 4702 4703 // Graphic freigeben 4704 ImplReleaseGraphics(); 4705 4706 // Evt. anderen Funktion mitteilen, das das Fenster geloescht 4707 // wurde 4708 ImplDelData* pDelData = mpWindowImpl->mpFirstDel; 4709 while ( pDelData ) 4710 { 4711 pDelData->mbDel = sal_True; 4712 pDelData->mpWindow = NULL; // #112873# pDel is not associated with a Window anymore 4713 pDelData = pDelData->mpNext; 4714 } 4715 4716 // Fenster aus den Listen austragen 4717 ImplRemoveWindow( sal_True ); 4718 4719 // de-register as "top window child" at our parent, if necessary 4720 if ( mpWindowImpl->mbFrame ) 4721 { 4722 sal_Bool bIsTopWindow = mpWindowImpl->mpWinData && ( mpWindowImpl->mpWinData->mnIsTopWindow == 1 ); 4723 if ( mpWindowImpl->mpRealParent && bIsTopWindow ) 4724 { 4725 ImplWinData* pParentWinData = mpWindowImpl->mpRealParent->ImplGetWinData(); 4726 4727 ::std::list< Window* >::iterator myPos = ::std::find( pParentWinData->maTopWindowChildren.begin(), 4728 pParentWinData->maTopWindowChildren.end(), this ); 4729 DBG_ASSERT( myPos != pParentWinData->maTopWindowChildren.end(), "Window::~Window: inconsistency in top window chain!" ); 4730 if ( myPos != pParentWinData->maTopWindowChildren.end() ) 4731 pParentWinData->maTopWindowChildren.erase( myPos ); 4732 } 4733 } 4734 4735 // Extra Window Daten loeschen 4736 if ( mpWindowImpl->mpWinData ) 4737 { 4738 if ( mpWindowImpl->mpWinData->mpExtOldText ) 4739 delete mpWindowImpl->mpWinData->mpExtOldText; 4740 if ( mpWindowImpl->mpWinData->mpExtOldAttrAry ) 4741 delete mpWindowImpl->mpWinData->mpExtOldAttrAry; 4742 if ( mpWindowImpl->mpWinData->mpCursorRect ) 4743 delete mpWindowImpl->mpWinData->mpCursorRect; 4744 if ( mpWindowImpl->mpWinData->mpFocusRect ) 4745 delete mpWindowImpl->mpWinData->mpFocusRect; 4746 if ( mpWindowImpl->mpWinData->mpTrackRect ) 4747 delete mpWindowImpl->mpWinData->mpTrackRect; 4748 4749 delete mpWindowImpl->mpWinData; 4750 } 4751 4752 4753 // Overlap-Window-Daten loeschen 4754 if ( mpWindowImpl->mpOverlapData ) 4755 { 4756 delete mpWindowImpl->mpOverlapData; 4757 } 4758 4759 // Evt. noch BorderWindow oder Frame zerstoeren 4760 if ( mpWindowImpl->mpBorderWindow ) 4761 delete mpWindowImpl->mpBorderWindow; 4762 else if ( mpWindowImpl->mbFrame ) 4763 { 4764 if ( pSVData->maWinData.mpFirstFrame == this ) 4765 pSVData->maWinData.mpFirstFrame = mpWindowImpl->mpFrameData->mpNextFrame; 4766 else 4767 { 4768 Window* pSysWin = pSVData->maWinData.mpFirstFrame; 4769 while ( pSysWin->mpWindowImpl->mpFrameData->mpNextFrame != this ) 4770 pSysWin = pSysWin->mpWindowImpl->mpFrameData->mpNextFrame; 4771 pSysWin->mpWindowImpl->mpFrameData->mpNextFrame = mpWindowImpl->mpFrameData->mpNextFrame; 4772 } 4773 mpWindowImpl->mpFrame->SetCallback( NULL, NULL ); 4774 pSVData->mpDefInst->DestroyFrame( mpWindowImpl->mpFrame ); 4775 delete mpWindowImpl->mpFrameData; 4776 } 4777 4778 if ( mpWindowImpl->mpChildClipRegion ) 4779 delete mpWindowImpl->mpChildClipRegion; 4780 4781 delete mpWindowImpl->mpAccessibleInfos; 4782 delete mpWindowImpl->mpControlFont; 4783 4784 // should be the last statements 4785 delete mpWindowImpl; mpWindowImpl = NULL; 4786 } 4787 4788 // ----------------------------------------------------------------------- 4789 void Window::doLazyDelete() 4790 { 4791 SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(this); 4792 DockingWindow* pDockWin = dynamic_cast<DockingWindow*>(this); 4793 if( pSysWin || ( pDockWin && pDockWin->IsFloatingMode() ) ) 4794 { 4795 Show( sal_False ); 4796 SetParent( ImplGetDefaultWindow() ); 4797 } 4798 vcl::LazyDeletor<Window>::Delete( this ); 4799 } 4800 4801 // ----------------------------------------------------------------------- 4802 void Window::InterceptChildWindowKeyDown( sal_Bool bIntercept ) 4803 { 4804 if( mpWindowImpl->mpSysObj ) 4805 mpWindowImpl->mpSysObj->InterceptChildWindowKeyDown( bIntercept ); 4806 } 4807 4808 // ----------------------------------------------------------------------- 4809 4810 void Window::MouseMove( const MouseEvent& rMEvt ) 4811 { 4812 { // Klammerung, da in diesem Handler das Window zerstoert werden darf 4813 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 4814 } 4815 4816 NotifyEvent aNEvt( EVENT_MOUSEMOVE, this, &rMEvt ); 4817 if ( !Notify( aNEvt ) ) 4818 mpWindowImpl->mbMouseMove = sal_True; 4819 } 4820 4821 // ----------------------------------------------------------------------- 4822 4823 void Window::MouseButtonDown( const MouseEvent& rMEvt ) 4824 { 4825 { // Klammerung, da in diesem Handler das Window zerstoert werden darf 4826 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 4827 } 4828 4829 NotifyEvent aNEvt( EVENT_MOUSEBUTTONDOWN, this, &rMEvt ); 4830 if ( !Notify( aNEvt ) ) 4831 mpWindowImpl->mbMouseButtonDown = sal_True; 4832 } 4833 4834 // ----------------------------------------------------------------------- 4835 4836 void Window::MouseButtonUp( const MouseEvent& rMEvt ) 4837 { 4838 { // Klammerung, da in diesem Handler das Window zerstoert werden darf 4839 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 4840 } 4841 4842 NotifyEvent aNEvt( EVENT_MOUSEBUTTONUP, this, &rMEvt ); 4843 if ( !Notify( aNEvt ) ) 4844 mpWindowImpl->mbMouseButtonUp = sal_True; 4845 } 4846 4847 // ----------------------------------------------------------------------- 4848 4849 void Window::KeyInput( const KeyEvent& rKEvt ) 4850 { 4851 { // Klammerung, da in diesem Handler das Window zerstoert werden darf 4852 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 4853 } 4854 4855 NotifyEvent aNEvt( EVENT_KEYINPUT, this, &rKEvt ); 4856 if ( !Notify( aNEvt ) ) 4857 mpWindowImpl->mbKeyInput = sal_True; 4858 } 4859 4860 // ----------------------------------------------------------------------- 4861 4862 void Window::KeyUp( const KeyEvent& rKEvt ) 4863 { 4864 { // Klammerung, da in diesem Handler das Window zerstoert werden darf 4865 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 4866 } 4867 4868 NotifyEvent aNEvt( EVENT_KEYUP, this, &rKEvt ); 4869 if ( !Notify( aNEvt ) ) 4870 mpWindowImpl->mbKeyUp = sal_True; 4871 } 4872 4873 // ----------------------------------------------------------------------- 4874 4875 void Window::PrePaint() 4876 { 4877 } 4878 4879 // ----------------------------------------------------------------------- 4880 4881 void Window::Paint( const Rectangle& rRect ) 4882 { 4883 { // Klammerung, da in diesem Handler das Window zerstoert werden darf 4884 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 4885 } 4886 4887 ImplCallEventListeners( VCLEVENT_WINDOW_PAINT, (void*)&rRect ); 4888 } 4889 4890 // ----------------------------------------------------------------------- 4891 4892 void Window::PostPaint() 4893 { 4894 } 4895 4896 // ----------------------------------------------------------------------- 4897 4898 void Window::Draw( OutputDevice*, const Point&, const Size&, sal_uLong ) 4899 { 4900 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 4901 } 4902 4903 // ----------------------------------------------------------------------- 4904 4905 void Window::Move() 4906 { 4907 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 4908 } 4909 4910 // ----------------------------------------------------------------------- 4911 4912 void Window::Resize() 4913 { 4914 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 4915 } 4916 4917 // ----------------------------------------------------------------------- 4918 4919 void Window::Activate() 4920 { 4921 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 4922 } 4923 4924 // ----------------------------------------------------------------------- 4925 4926 void Window::Deactivate() 4927 { 4928 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 4929 } 4930 4931 // ----------------------------------------------------------------------- 4932 4933 void Window::GetFocus() 4934 { 4935 { // Klammerung, da in diesem Handler das Window zerstoert werden darf 4936 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 4937 } 4938 4939 if ( HasFocus() && mpWindowImpl->mpLastFocusWindow && !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) ) 4940 { 4941 ImplDelData aDogtag( this ); 4942 mpWindowImpl->mpLastFocusWindow->GrabFocus(); 4943 if( aDogtag.IsDelete() ) 4944 return; 4945 } 4946 4947 NotifyEvent aNEvt( EVENT_GETFOCUS, this ); 4948 Notify( aNEvt ); 4949 } 4950 4951 // ----------------------------------------------------------------------- 4952 4953 void Window::LoseFocus() 4954 { 4955 { // Klammerung, da in diesem Handler das Window zerstoert werden darf 4956 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 4957 } 4958 4959 NotifyEvent aNEvt( EVENT_LOSEFOCUS, this ); 4960 Notify( aNEvt ); 4961 } 4962 4963 // ----------------------------------------------------------------------- 4964 4965 void Window::RequestHelp( const HelpEvent& rHEvt ) 4966 { 4967 { // Klammerung, da in diesem Handler das Window zerstoert werden darf 4968 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 4969 } 4970 4971 // Wenn Balloon-Help angefordert wird, dann den Balloon mit dem 4972 // gesetzten Hilfetext anzeigen 4973 if ( rHEvt.GetMode() & HELPMODE_BALLOON ) 4974 { 4975 const XubString* pStr = &(GetHelpText()); 4976 if ( !pStr->Len() ) 4977 pStr = &(GetQuickHelpText()); 4978 if ( !pStr->Len() && ImplGetParent() && !ImplIsOverlapWindow() ) 4979 ImplGetParent()->RequestHelp( rHEvt ); 4980 else 4981 Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), *pStr ); 4982 } 4983 else if ( rHEvt.GetMode() & HELPMODE_QUICK ) 4984 { 4985 const XubString* pStr = &(GetQuickHelpText()); 4986 if ( !pStr->Len() && ImplGetParent() && !ImplIsOverlapWindow() ) 4987 ImplGetParent()->RequestHelp( rHEvt ); 4988 else 4989 { 4990 Point aPos = GetPosPixel(); 4991 if ( ImplGetParent() && !ImplIsOverlapWindow() ) 4992 aPos = ImplGetParent()->OutputToScreenPixel( aPos ); 4993 Rectangle aRect( aPos, GetSizePixel() ); 4994 String aHelpText; 4995 if ( pStr->Len() ) 4996 aHelpText = GetHelpText(); 4997 Help::ShowQuickHelp( this, aRect, *pStr, aHelpText, QUICKHELP_CTRLTEXT ); 4998 } 4999 } 5000 else 5001 { 5002 String aStrHelpId( rtl::OStringToOUString( GetHelpId(), RTL_TEXTENCODING_UTF8 ) ); 5003 if ( aStrHelpId.Len() == 0 && ImplGetParent() ) 5004 ImplGetParent()->RequestHelp( rHEvt ); 5005 else 5006 { 5007 Help* pHelp = Application::GetHelp(); 5008 if ( pHelp ) 5009 { 5010 if( aStrHelpId.Len() > 0 ) 5011 pHelp->Start( aStrHelpId, this ); 5012 else 5013 pHelp->Start( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OOO_HELP_INDEX ) ), this ); 5014 } 5015 } 5016 } 5017 } 5018 5019 // ----------------------------------------------------------------------- 5020 5021 void Window::Command( const CommandEvent& rCEvt ) 5022 { 5023 { // Klammerung, da in diesem Handler das Window zerstoert werden darf 5024 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5025 } 5026 5027 ImplCallEventListeners( VCLEVENT_WINDOW_COMMAND, (void*)&rCEvt ); 5028 5029 NotifyEvent aNEvt( EVENT_COMMAND, this, &rCEvt ); 5030 if ( !Notify( aNEvt ) ) 5031 mpWindowImpl->mbCommand = sal_True; 5032 } 5033 5034 // ----------------------------------------------------------------------- 5035 5036 void Window::Tracking( const TrackingEvent& rTEvt ) 5037 { 5038 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5039 5040 ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this ); 5041 if( pWrapper ) 5042 pWrapper->Tracking( rTEvt ); 5043 } 5044 5045 // ----------------------------------------------------------------------- 5046 5047 void Window::UserEvent( sal_uLong, void* ) 5048 { 5049 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5050 } 5051 5052 // ----------------------------------------------------------------------- 5053 5054 void Window::StateChanged( StateChangedType ) 5055 { 5056 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5057 } 5058 5059 // ----------------------------------------------------------------------- 5060 5061 void Window::DataChanged( const DataChangedEvent& ) 5062 { 5063 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5064 } 5065 5066 // ----------------------------------------------------------------------- 5067 5068 void Window::ImplNotifyKeyMouseCommandEventListeners( NotifyEvent& rNEvt ) 5069 { 5070 if( rNEvt.GetType() == EVENT_COMMAND ) 5071 { 5072 const CommandEvent* pCEvt = rNEvt.GetCommandEvent(); 5073 if ( pCEvt->GetCommand() != COMMAND_CONTEXTMENU ) 5074 // non context menu events are not to be notified up the chain 5075 // so we return immediately 5076 return; 5077 5078 if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) ) 5079 { 5080 if ( rNEvt.GetWindow() == this ) 5081 // not interested in: The event listeners are already called in ::Command, 5082 // and calling them here a second time doesn't make sense 5083 ; 5084 else 5085 { 5086 CommandEvent aCommandEvent = ImplTranslateCommandEvent( *pCEvt, rNEvt.GetWindow(), this ); 5087 ImplCallEventListeners( VCLEVENT_WINDOW_COMMAND, &aCommandEvent ); 5088 } 5089 } 5090 } 5091 5092 // #82968# notify event listeners for mouse and key events seperately and 5093 // not in PreNotify ( as for focus listeners ) 5094 // this allows for procesing those events internally first and pass it to 5095 // the toolkit later 5096 5097 ImplDelData aDelData; 5098 ImplAddDel( &aDelData ); 5099 5100 if( rNEvt.GetType() == EVENT_MOUSEMOVE ) 5101 { 5102 if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) ) 5103 { 5104 if ( rNEvt.GetWindow() == this ) 5105 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEMOVE, (void*)rNEvt.GetMouseEvent() ); 5106 else 5107 { 5108 MouseEvent aMouseEvent = ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this ); 5109 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEMOVE, &aMouseEvent ); 5110 } 5111 } 5112 } 5113 else if( rNEvt.GetType() == EVENT_MOUSEBUTTONUP ) 5114 { 5115 if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) ) 5116 { 5117 if ( rNEvt.GetWindow() == this ) 5118 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, (void*)rNEvt.GetMouseEvent() ); 5119 else 5120 { 5121 MouseEvent aMouseEvent = ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this ); 5122 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, &aMouseEvent ); 5123 } 5124 } 5125 } 5126 else if( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN ) 5127 { 5128 if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) ) 5129 { 5130 if ( rNEvt.GetWindow() == this ) 5131 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, (void*)rNEvt.GetMouseEvent() ); 5132 else 5133 { 5134 MouseEvent aMouseEvent = ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this ); 5135 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, &aMouseEvent ); 5136 } 5137 } 5138 } 5139 else if( rNEvt.GetType() == EVENT_KEYINPUT ) 5140 { 5141 if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) ) 5142 ImplCallEventListeners( VCLEVENT_WINDOW_KEYINPUT, (void*)rNEvt.GetKeyEvent() ); 5143 } 5144 else if( rNEvt.GetType() == EVENT_KEYUP ) 5145 { 5146 if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) ) 5147 ImplCallEventListeners( VCLEVENT_WINDOW_KEYUP, (void*)rNEvt.GetKeyEvent() ); 5148 } 5149 5150 if ( aDelData.IsDelete() ) 5151 return; 5152 ImplRemoveDel( &aDelData ); 5153 5154 // #106721# check if we're part of a compound control and notify 5155 Window *pParent = ImplGetParent(); 5156 while( pParent ) 5157 { 5158 if( pParent->IsCompoundControl() ) 5159 { 5160 pParent->ImplNotifyKeyMouseCommandEventListeners( rNEvt ); 5161 break; 5162 } 5163 pParent = pParent->ImplGetParent(); 5164 } 5165 } 5166 5167 // ----------------------------------------------------------------------- 5168 5169 long Window::PreNotify( NotifyEvent& rNEvt ) 5170 { 5171 { // Klammerung, da in diesem Handler das Window zerstoert werden darf 5172 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5173 } 5174 5175 long bDone = sal_False; 5176 if ( mpWindowImpl->mpParent && !ImplIsOverlapWindow() ) 5177 bDone = mpWindowImpl->mpParent->PreNotify( rNEvt ); 5178 5179 if ( !bDone ) 5180 { 5181 if( rNEvt.GetType() == EVENT_GETFOCUS ) 5182 { 5183 sal_Bool bCompoundFocusChanged = sal_False; 5184 if ( mpWindowImpl->mbCompoundControl && !mpWindowImpl->mbCompoundControlHasFocus && HasChildPathFocus() ) 5185 { 5186 mpWindowImpl->mbCompoundControlHasFocus = sal_True; 5187 bCompoundFocusChanged = sal_True; 5188 } 5189 5190 if ( bCompoundFocusChanged || ( rNEvt.GetWindow() == this ) ) 5191 ImplCallEventListeners( VCLEVENT_WINDOW_GETFOCUS ); 5192 } 5193 else if( rNEvt.GetType() == EVENT_LOSEFOCUS ) 5194 { 5195 sal_Bool bCompoundFocusChanged = sal_False; 5196 if ( mpWindowImpl->mbCompoundControl && mpWindowImpl->mbCompoundControlHasFocus && !HasChildPathFocus() ) 5197 { 5198 mpWindowImpl->mbCompoundControlHasFocus = sal_False ; 5199 bCompoundFocusChanged = sal_True; 5200 } 5201 5202 if ( bCompoundFocusChanged || ( rNEvt.GetWindow() == this ) ) 5203 ImplCallEventListeners( VCLEVENT_WINDOW_LOSEFOCUS ); 5204 } 5205 5206 // #82968# mouse and key events will be notified after processing ( in ImplNotifyKeyMouseCommandEventListeners() )! 5207 // see also ImplHandleMouseEvent(), ImplHandleKey() 5208 5209 /* 5210 else if( rNEvt.GetType() == EVENT_MOUSEMOVE ) 5211 { 5212 if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) ) 5213 { 5214 if ( rNEvt.GetWindow() == this ) 5215 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEMOVE, (void*)rNEvt.GetMouseEvent() ); 5216 else 5217 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEMOVE, &ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this ) ); 5218 } 5219 } 5220 else if( rNEvt.GetType() == EVENT_MOUSEBUTTONUP ) 5221 { 5222 if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) ) 5223 { 5224 if ( rNEvt.GetWindow() == this ) 5225 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, (void*)rNEvt.GetMouseEvent() ); 5226 else 5227 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, &ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this ) ); 5228 } 5229 } 5230 else if( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN ) 5231 { 5232 if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) ) 5233 { 5234 if ( rNEvt.GetWindow() == this ) 5235 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, (void*)rNEvt.GetMouseEvent() ); 5236 else 5237 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, &ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this ) ); 5238 } 5239 } 5240 else if( rNEvt.GetType() == EVENT_KEYINPUT ) 5241 { 5242 if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) ) 5243 ImplCallEventListeners( VCLEVENT_WINDOW_KEYINPUT, (void*)rNEvt.GetKeyEvent() ); 5244 } 5245 else if( rNEvt.GetType() == EVENT_KEYUP ) 5246 { 5247 if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) ) 5248 ImplCallEventListeners( VCLEVENT_WINDOW_KEYUP, (void*)rNEvt.GetKeyEvent() ); 5249 } 5250 */ 5251 } 5252 5253 return bDone; 5254 } 5255 5256 // ----------------------------------------------------------------------- 5257 5258 long Window::Notify( NotifyEvent& rNEvt ) 5259 { 5260 { // Klammerung, da in diesem Handler das Window zerstoert werden darf 5261 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5262 } 5263 5264 long nRet = sal_False; 5265 5266 // check for docking window 5267 // but do nothing if window is docked and locked 5268 ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this ); 5269 if( pWrapper && !( !pWrapper->IsFloatingMode() && pWrapper->IsLocked() ) ) 5270 { 5271 if ( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN ) 5272 { 5273 const MouseEvent* pMEvt = rNEvt.GetMouseEvent(); 5274 sal_Bool bHit = pWrapper->GetDragArea().IsInside( pMEvt->GetPosPixel() ); 5275 if ( pMEvt->IsLeft() ) 5276 { 5277 if ( pMEvt->IsMod1() && (pMEvt->GetClicks() == 2) ) 5278 { 5279 // ctrl double click toggles floating mode 5280 pWrapper->SetFloatingMode( !pWrapper->IsFloatingMode() ); 5281 return sal_True; 5282 } 5283 else if ( pMEvt->GetClicks() == 1 && bHit) 5284 { 5285 // allow start docking during mouse move 5286 pWrapper->ImplEnableStartDocking(); 5287 return sal_True; 5288 } 5289 } 5290 } 5291 else if ( rNEvt.GetType() == EVENT_MOUSEMOVE ) 5292 { 5293 const MouseEvent* pMEvt = rNEvt.GetMouseEvent(); 5294 sal_Bool bHit = pWrapper->GetDragArea().IsInside( pMEvt->GetPosPixel() ); 5295 if ( pMEvt->IsLeft() ) 5296 { 5297 // check if a single click initiated this sequence ( ImplStartDockingEnabled() ) 5298 // check if window is docked and 5299 if( pWrapper->ImplStartDockingEnabled() && !pWrapper->IsFloatingMode() && 5300 !pWrapper->IsDocking() && bHit ) 5301 { 5302 Point aPos = pMEvt->GetPosPixel(); 5303 Window* pWindow = rNEvt.GetWindow(); 5304 if ( pWindow != this ) 5305 { 5306 aPos = pWindow->OutputToScreenPixel( aPos ); 5307 aPos = ScreenToOutputPixel( aPos ); 5308 } 5309 pWrapper->ImplStartDocking( aPos ); 5310 } 5311 return sal_True; 5312 } 5313 } 5314 else if( rNEvt.GetType() == EVENT_KEYINPUT ) 5315 { 5316 const KeyCode& rKey = rNEvt.GetKeyEvent()->GetKeyCode(); 5317 if( rKey.GetCode() == KEY_F10 && rKey.GetModifier() && 5318 rKey.IsShift() && rKey.IsMod1() ) 5319 { 5320 pWrapper->SetFloatingMode( !pWrapper->IsFloatingMode() ); 5321 /* At this point the floating toolbar frame does not have the 5322 * input focus since these frames don't get the focus per default 5323 * To enable keyboard handling of this toolbar set the input focus 5324 * to the frame. This needs to be done with ToTop since GrabFocus 5325 * would not notice any change since "this" already has the focus. 5326 */ 5327 if( pWrapper->IsFloatingMode() ) 5328 ToTop( TOTOP_GRABFOCUSONLY ); 5329 return sal_True; 5330 } 5331 } 5332 } 5333 5334 // Dialog-Steuerung 5335 if ( (GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL)) == WB_DIALOGCONTROL ) 5336 { 5337 // Wenn Parent auch DialogSteuerung aktiviert hat, uebernimmt dieser die Steuerung 5338 if ( (rNEvt.GetType() == EVENT_KEYINPUT) || (rNEvt.GetType() == EVENT_KEYUP) ) 5339 { 5340 if ( ImplIsOverlapWindow() || 5341 ((ImplGetParent()->GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL)) != WB_DIALOGCONTROL) ) 5342 { 5343 nRet = ImplDlgCtrl( *rNEvt.GetKeyEvent(), rNEvt.GetType() == EVENT_KEYINPUT ); 5344 } 5345 } 5346 else if ( (rNEvt.GetType() == EVENT_GETFOCUS) || (rNEvt.GetType() == EVENT_LOSEFOCUS) ) 5347 { 5348 ImplDlgCtrlFocusChanged( rNEvt.GetWindow(), rNEvt.GetType() == EVENT_GETFOCUS ); 5349 if ( (rNEvt.GetWindow() == this) && (rNEvt.GetType() == EVENT_GETFOCUS) && 5350 !(GetStyle() & WB_TABSTOP) && !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) ) 5351 { 5352 sal_uInt16 n = 0; 5353 Window* pFirstChild = ImplGetDlgWindow( n, DLGWINDOW_FIRST ); 5354 if ( pFirstChild ) 5355 pFirstChild->ImplControlFocus(); 5356 } 5357 } 5358 } 5359 5360 if ( !nRet ) 5361 { 5362 if ( mpWindowImpl->mpParent && !ImplIsOverlapWindow() ) 5363 nRet = mpWindowImpl->mpParent->Notify( rNEvt ); 5364 } 5365 5366 return nRet; 5367 } 5368 5369 // ----------------------------------------------------------------------- 5370 5371 void Window::ImplCallEventListeners( sal_uLong nEvent, void* pData ) 5372 { 5373 // The implementation was moved to CallEventListeners(), 5374 // because derived classes in svtools must be able to 5375 // call the event listeners and ImplCallEventListeners() 5376 // is not exported. 5377 // TODO: replace ImplCallEventListeners() by CallEventListeners() in vcl 5378 5379 CallEventListeners( nEvent, pData ); 5380 } 5381 5382 // ----------------------------------------------------------------------- 5383 5384 void Window::CallEventListeners( sal_uLong nEvent, void* pData ) 5385 { 5386 VclWindowEvent aEvent( this, nEvent, pData ); 5387 5388 ImplDelData aDelData; 5389 ImplAddDel( &aDelData ); 5390 5391 ImplGetSVData()->mpApp->ImplCallEventListeners( &aEvent ); 5392 5393 if ( aDelData.IsDelete() ) 5394 return; 5395 5396 if ( !mpWindowImpl->maEventListeners.empty() ) 5397 mpWindowImpl->maEventListeners.Call( &aEvent ); 5398 5399 if ( aDelData.IsDelete() ) 5400 return; 5401 5402 ImplRemoveDel( &aDelData ); 5403 5404 Window* pWindow = this; 5405 while ( pWindow ) 5406 { 5407 pWindow->ImplAddDel( &aDelData ); 5408 5409 if ( !pWindow->mpWindowImpl->maChildEventListeners.empty() ) 5410 pWindow->mpWindowImpl->maChildEventListeners.Call( &aEvent ); 5411 5412 if ( aDelData.IsDelete() ) 5413 return; 5414 5415 pWindow->ImplRemoveDel( &aDelData ); 5416 5417 pWindow = pWindow->GetParent(); 5418 } 5419 } 5420 5421 void Window::FireVclEvent( VclSimpleEvent* pEvent ) 5422 { 5423 ImplGetSVData()->mpApp->ImplCallEventListeners(pEvent); 5424 } 5425 5426 // ----------------------------------------------------------------------- 5427 5428 void Window::AddEventListener( const Link& rEventListener ) 5429 { 5430 mpWindowImpl->maEventListeners.push_back( rEventListener ); 5431 } 5432 5433 // ----------------------------------------------------------------------- 5434 5435 void Window::RemoveEventListener( const Link& rEventListener ) 5436 { 5437 mpWindowImpl->maEventListeners.remove( rEventListener ); 5438 } 5439 5440 // ----------------------------------------------------------------------- 5441 5442 void Window::AddChildEventListener( const Link& rEventListener ) 5443 { 5444 mpWindowImpl->maChildEventListeners.push_back( rEventListener ); 5445 } 5446 5447 // ----------------------------------------------------------------------- 5448 5449 void Window::RemoveChildEventListener( const Link& rEventListener ) 5450 { 5451 mpWindowImpl->maChildEventListeners.remove( rEventListener ); 5452 } 5453 5454 // ----------------------------------------------------------------------- 5455 5456 sal_uLong Window::PostUserEvent( sal_uLong nEvent, void* pEventData ) 5457 { 5458 sal_uLong nEventId; 5459 PostUserEvent( nEventId, nEvent, pEventData ); 5460 return nEventId; 5461 } 5462 5463 // ----------------------------------------------------------------------- 5464 5465 sal_uLong Window::PostUserEvent( const Link& rLink, void* pCaller ) 5466 { 5467 sal_uLong nEventId; 5468 PostUserEvent( nEventId, rLink, pCaller ); 5469 return nEventId; 5470 } 5471 5472 // ----------------------------------------------------------------------- 5473 5474 sal_Bool Window::PostUserEvent( sal_uLong& rEventId, sal_uLong nEvent, void* pEventData ) 5475 { 5476 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5477 5478 ImplSVEvent* pSVEvent = new ImplSVEvent; 5479 pSVEvent->mnEvent = nEvent; 5480 pSVEvent->mpData = pEventData; 5481 pSVEvent->mpLink = NULL; 5482 pSVEvent->mpWindow = this; 5483 pSVEvent->mbCall = sal_True; 5484 ImplAddDel( &(pSVEvent->maDelData) ); 5485 rEventId = (sal_uLong)pSVEvent; 5486 if ( mpWindowImpl->mpFrame->PostEvent( pSVEvent ) ) 5487 return sal_True; 5488 else 5489 { 5490 rEventId = 0; 5491 ImplRemoveDel( &(pSVEvent->maDelData) ); 5492 delete pSVEvent; 5493 return sal_False; 5494 } 5495 } 5496 5497 // ----------------------------------------------------------------------- 5498 5499 sal_Bool Window::PostUserEvent( sal_uLong& rEventId, const Link& rLink, void* pCaller ) 5500 { 5501 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5502 5503 ImplSVEvent* pSVEvent = new ImplSVEvent; 5504 pSVEvent->mnEvent = 0; 5505 pSVEvent->mpData = pCaller; 5506 pSVEvent->mpLink = new Link( rLink ); 5507 pSVEvent->mpWindow = this; 5508 pSVEvent->mbCall = sal_True; 5509 ImplAddDel( &(pSVEvent->maDelData) ); 5510 rEventId = (sal_uLong)pSVEvent; 5511 if ( mpWindowImpl->mpFrame->PostEvent( pSVEvent ) ) 5512 return sal_True; 5513 else 5514 { 5515 rEventId = 0; 5516 ImplRemoveDel( &(pSVEvent->maDelData) ); 5517 delete pSVEvent; 5518 return sal_False; 5519 } 5520 } 5521 5522 // ----------------------------------------------------------------------- 5523 5524 void Window::RemoveUserEvent( sal_uLong nUserEvent ) 5525 { 5526 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5527 5528 ImplSVEvent* pSVEvent = (ImplSVEvent*)nUserEvent; 5529 5530 DBG_ASSERT( pSVEvent->mpWindow == this, 5531 "Window::RemoveUserEvent(): Event doesn't send to this window or is already removed" ); 5532 DBG_ASSERT( pSVEvent->mbCall, 5533 "Window::RemoveUserEvent(): Event is already removed" ); 5534 5535 if ( pSVEvent->mpWindow ) 5536 { 5537 pSVEvent->mpWindow->ImplRemoveDel( &(pSVEvent->maDelData) ); 5538 pSVEvent->mpWindow = NULL; 5539 } 5540 5541 pSVEvent->mbCall = sal_False; 5542 } 5543 5544 // ----------------------------------------------------------------------- 5545 5546 IMPL_LINK( Window, ImplAsyncStateChangedHdl, void*, pState ) 5547 { 5548 StateChanged( (StateChangedType)(sal_uLong)pState ); 5549 return 0; 5550 } 5551 5552 // ----------------------------------------------------------------------- 5553 5554 void Window::PostStateChanged( StateChangedType nState ) 5555 { 5556 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5557 5558 PostUserEvent( LINK( this, Window, ImplAsyncStateChangedHdl ), (void*)(sal_uLong)nState ); 5559 } 5560 5561 // ----------------------------------------------------------------------- 5562 5563 sal_Bool Window::IsLocked( sal_Bool bChilds ) const 5564 { 5565 if ( mpWindowImpl->mnLockCount != 0 ) 5566 return sal_True; 5567 5568 if ( bChilds || mpWindowImpl->mbChildNotify ) 5569 { 5570 Window* pChild = mpWindowImpl->mpFirstChild; 5571 while ( pChild ) 5572 { 5573 if ( pChild->IsLocked( sal_True ) ) 5574 return sal_True; 5575 pChild = pChild->mpWindowImpl->mpNext; 5576 } 5577 } 5578 5579 return sal_False; 5580 } 5581 5582 // ----------------------------------------------------------------------- 5583 5584 void Window::SetStyle( WinBits nStyle ) 5585 { 5586 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5587 5588 if ( mpWindowImpl->mnStyle != nStyle ) 5589 { 5590 mpWindowImpl->mnPrevStyle = mpWindowImpl->mnStyle; 5591 mpWindowImpl->mnStyle = nStyle; 5592 StateChanged( STATE_CHANGE_STYLE ); 5593 } 5594 } 5595 5596 // ----------------------------------------------------------------------- 5597 5598 void Window::SetExtendedStyle( WinBits nExtendedStyle ) 5599 { 5600 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5601 5602 if ( mpWindowImpl->mnExtendedStyle != nExtendedStyle ) 5603 { 5604 Window* pWindow = ImplGetBorderWindow(); 5605 if( ! pWindow ) 5606 pWindow = this; 5607 if( pWindow->mpWindowImpl->mbFrame ) 5608 { 5609 SalExtStyle nExt = 0; 5610 if( (nExtendedStyle & WB_EXT_DOCUMENT) ) 5611 nExt |= SAL_FRAME_EXT_STYLE_DOCUMENT; 5612 if( (nExtendedStyle & WB_EXT_DOCMODIFIED) ) 5613 nExt |= SAL_FRAME_EXT_STYLE_DOCMODIFIED; 5614 5615 pWindow->ImplGetFrame()->SetExtendedFrameStyle( nExt ); 5616 } 5617 mpWindowImpl->mnPrevExtendedStyle = mpWindowImpl->mnExtendedStyle; 5618 mpWindowImpl->mnExtendedStyle = nExtendedStyle; 5619 StateChanged( STATE_CHANGE_EXTENDEDSTYLE ); 5620 } 5621 } 5622 5623 // ----------------------------------------------------------------------- 5624 5625 SystemWindow* Window::GetSystemWindow() const 5626 { 5627 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5628 5629 const Window* pWin = this; 5630 while ( pWin && !pWin->IsSystemWindow() ) 5631 pWin = pWin->GetParent(); 5632 return (SystemWindow*)pWin; 5633 } 5634 5635 // ----------------------------------------------------------------------- 5636 5637 void Window::SetBorderStyle( sal_uInt16 nBorderStyle ) 5638 { 5639 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5640 5641 if ( mpWindowImpl->mpBorderWindow ) 5642 { 5643 if( nBorderStyle == WINDOW_BORDER_REMOVEBORDER && 5644 ! mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame && 5645 mpWindowImpl->mpBorderWindow->mpWindowImpl->mpParent 5646 ) 5647 { 5648 // this is a little awkward: some controls (e.g. svtools ProgressBar) 5649 // cannot avoid getting constructed with WB_BORDER but want to disable 5650 // borders in case of NWF drawing. So they need a method to remove their border window 5651 Window* pBorderWin = mpWindowImpl->mpBorderWindow; 5652 // remove us as border window's client 5653 pBorderWin->mpWindowImpl->mpClientWindow = NULL; 5654 mpWindowImpl->mpBorderWindow = NULL; 5655 mpWindowImpl->mpRealParent = pBorderWin->mpWindowImpl->mpParent; 5656 // reparent us above the border window 5657 SetParent( pBorderWin->mpWindowImpl->mpParent ); 5658 // set us to the position and size of our previous border 5659 Point aBorderPos( pBorderWin->GetPosPixel() ); 5660 Size aBorderSize( pBorderWin->GetSizePixel() ); 5661 SetPosSizePixel( aBorderPos.X(), aBorderPos.Y(), aBorderSize.Width(), aBorderSize.Height() ); 5662 // release border window 5663 delete pBorderWin; 5664 5665 // set new style bits 5666 SetStyle( GetStyle() & (~WB_BORDER) ); 5667 } 5668 else 5669 { 5670 if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW ) 5671 ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetBorderStyle( nBorderStyle ); 5672 else 5673 mpWindowImpl->mpBorderWindow->SetBorderStyle( nBorderStyle ); 5674 } 5675 } 5676 } 5677 5678 // ----------------------------------------------------------------------- 5679 5680 sal_uInt16 Window::GetBorderStyle() const 5681 { 5682 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5683 5684 if ( mpWindowImpl->mpBorderWindow ) 5685 { 5686 if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW ) 5687 return ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->GetBorderStyle(); 5688 else 5689 return mpWindowImpl->mpBorderWindow->GetBorderStyle(); 5690 } 5691 5692 return 0; 5693 } 5694 5695 // ----------------------------------------------------------------------- 5696 5697 long Window::CalcTitleWidth() const 5698 { 5699 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5700 5701 if ( mpWindowImpl->mpBorderWindow ) 5702 { 5703 if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW ) 5704 return ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->CalcTitleWidth(); 5705 else 5706 return mpWindowImpl->mpBorderWindow->CalcTitleWidth(); 5707 } 5708 else if ( mpWindowImpl->mbFrame && (mpWindowImpl->mnStyle & WB_MOVEABLE) ) 5709 { 5710 // Fuer Frame-Fenster raten wir die Breite, da wir den Border fuer 5711 // externe Dialoge nicht kennen 5712 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 5713 Font aFont = GetFont(); 5714 ((Window*)this)->SetPointFont( rStyleSettings.GetTitleFont() ); 5715 long nTitleWidth = GetTextWidth( GetText() ); 5716 ((Window*)this)->SetFont( aFont ); 5717 nTitleWidth += rStyleSettings.GetTitleHeight() * 3; 5718 nTitleWidth += rStyleSettings.GetBorderSize() * 2; 5719 nTitleWidth += 10; 5720 return nTitleWidth; 5721 } 5722 5723 return 0; 5724 } 5725 5726 // ----------------------------------------------------------------------- 5727 5728 void Window::EnableClipSiblings( sal_Bool bClipSiblings ) 5729 { 5730 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5731 5732 if ( mpWindowImpl->mpBorderWindow ) 5733 mpWindowImpl->mpBorderWindow->EnableClipSiblings( bClipSiblings ); 5734 5735 mpWindowImpl->mbClipSiblings = bClipSiblings; 5736 } 5737 5738 // ----------------------------------------------------------------------- 5739 5740 void Window::SetMouseTransparent( sal_Bool bTransparent ) 5741 { 5742 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5743 5744 if ( mpWindowImpl->mpBorderWindow ) 5745 mpWindowImpl->mpBorderWindow->SetMouseTransparent( bTransparent ); 5746 5747 if( mpWindowImpl->mpSysObj ) 5748 mpWindowImpl->mpSysObj->SetMouseTransparent( bTransparent ); 5749 5750 mpWindowImpl->mbMouseTransparent = bTransparent; 5751 } 5752 5753 // ----------------------------------------------------------------------- 5754 5755 void Window::SetPaintTransparent( sal_Bool bTransparent ) 5756 { 5757 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5758 5759 // transparency is not useful for frames as the background would have to be provided by a different frame 5760 if( bTransparent && mpWindowImpl->mbFrame ) 5761 return; 5762 5763 if ( mpWindowImpl->mpBorderWindow ) 5764 mpWindowImpl->mpBorderWindow->SetPaintTransparent( bTransparent ); 5765 5766 mpWindowImpl->mbPaintTransparent = bTransparent; 5767 } 5768 5769 // ----------------------------------------------------------------------- 5770 5771 void Window::SetInputContext( const InputContext& rInputContext ) 5772 { 5773 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5774 5775 mpWindowImpl->maInputContext = rInputContext; 5776 if ( !mpWindowImpl->mbInFocusHdl && HasFocus() ) 5777 ImplNewInputContext(); 5778 } 5779 5780 // ----------------------------------------------------------------------- 5781 5782 void Window::EndExtTextInput( sal_uInt16 nFlags ) 5783 { 5784 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5785 5786 if ( mpWindowImpl->mbExtTextInput ) 5787 ImplGetFrame()->EndExtTextInput( nFlags ); 5788 } 5789 5790 // ----------------------------------------------------------------------- 5791 5792 void Window::SetCursorRect( const Rectangle* pRect, long nExtTextInputWidth ) 5793 { 5794 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5795 5796 ImplWinData* pWinData = ImplGetWinData(); 5797 if ( pWinData->mpCursorRect ) 5798 { 5799 if ( pRect ) 5800 *pWinData->mpCursorRect = *pRect; 5801 else 5802 { 5803 delete pWinData->mpCursorRect; 5804 pWinData->mpCursorRect = NULL; 5805 } 5806 } 5807 else 5808 { 5809 if ( pRect ) 5810 pWinData->mpCursorRect = new Rectangle( *pRect ); 5811 } 5812 5813 pWinData->mnCursorExtWidth = nExtTextInputWidth; 5814 5815 } 5816 5817 // ----------------------------------------------------------------------- 5818 5819 const Rectangle* Window::GetCursorRect() const 5820 { 5821 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5822 5823 ImplWinData* pWinData = ImplGetWinData(); 5824 return pWinData->mpCursorRect; 5825 } 5826 5827 // ----------------------------------------------------------------------- 5828 5829 long Window::GetCursorExtTextInputWidth() const 5830 { 5831 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5832 5833 ImplWinData* pWinData = ImplGetWinData(); 5834 return pWinData->mnCursorExtWidth; 5835 } 5836 5837 // ----------------------------------------------------------------------- 5838 void Window::SetSettings( const AllSettings& rSettings ) 5839 { 5840 SetSettings( rSettings, sal_False ); 5841 } 5842 5843 void Window::SetSettings( const AllSettings& rSettings, sal_Bool bChild ) 5844 { 5845 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5846 5847 if ( mpWindowImpl->mpBorderWindow ) 5848 { 5849 mpWindowImpl->mpBorderWindow->SetSettings( rSettings, sal_False ); 5850 if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) && 5851 ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow ) 5852 ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->SetSettings( rSettings, sal_True ); 5853 } 5854 5855 AllSettings aOldSettings = maSettings; 5856 OutputDevice::SetSettings( rSettings ); 5857 sal_uLong nChangeFlags = aOldSettings.GetChangeFlags( rSettings ); 5858 5859 // AppFont-Aufloesung und DPI-Aufloesung neu berechnen 5860 ImplInitResolutionSettings(); 5861 5862 if ( nChangeFlags ) 5863 { 5864 DataChangedEvent aDCEvt( DATACHANGED_SETTINGS, &aOldSettings, nChangeFlags ); 5865 DataChanged( aDCEvt ); 5866 } 5867 5868 if ( bChild || mpWindowImpl->mbChildNotify ) 5869 { 5870 Window* pChild = mpWindowImpl->mpFirstChild; 5871 while ( pChild ) 5872 { 5873 pChild->SetSettings( rSettings, bChild ); 5874 pChild = pChild->mpWindowImpl->mpNext; 5875 } 5876 } 5877 } 5878 5879 // ----------------------------------------------------------------------- 5880 5881 void Window::UpdateSettings( const AllSettings& rSettings, sal_Bool bChild ) 5882 { 5883 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5884 5885 if ( mpWindowImpl->mpBorderWindow ) 5886 { 5887 mpWindowImpl->mpBorderWindow->UpdateSettings( rSettings, sal_False ); 5888 if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) && 5889 ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow ) 5890 ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->UpdateSettings( rSettings, sal_True ); 5891 } 5892 5893 AllSettings aOldSettings = maSettings; 5894 sal_uLong nChangeFlags = maSettings.Update( maSettings.GetWindowUpdate(), rSettings ); 5895 nChangeFlags |= SETTINGS_IN_UPDATE_SETTINGS; // Set this flag so the receiver of the data changed 5896 // event can distinguish between the changing of global 5897 // setting and a local change ( with SetSettings ) 5898 5899 // AppFont-Aufloesung und DPI-Aufloesung neu berechnen 5900 ImplInitResolutionSettings(); 5901 5902 /* #i73785# 5903 * do not overwrite a WheelBehavior with false 5904 * this looks kind of a hack, but WheelBehavior 5905 * is always a local change, not a system property, 5906 * so we can spare all our users the hassle of reacting on 5907 * this in their respective DataChanged. 5908 */ 5909 MouseSettings aSet( maSettings.GetMouseSettings() ); 5910 aSet.SetWheelBehavior( aOldSettings.GetMouseSettings().GetWheelBehavior() ); 5911 maSettings.SetMouseSettings( aSet ); 5912 5913 if( (nChangeFlags & SETTINGS_STYLE) && IsBackground() ) 5914 { 5915 Wallpaper aWallpaper = GetBackground(); 5916 if( !aWallpaper.IsBitmap() && !aWallpaper.IsGradient() ) 5917 { 5918 if ( mpWindowImpl->mnStyle & WB_3DLOOK ) 5919 SetBackground( Wallpaper( rSettings.GetStyleSettings().GetFaceColor() ) ); 5920 else 5921 SetBackground( Wallpaper( rSettings.GetStyleSettings().GetWindowColor() ) ); 5922 } 5923 } 5924 5925 if ( nChangeFlags ) 5926 { 5927 DataChangedEvent aDCEvt( DATACHANGED_SETTINGS, &aOldSettings, nChangeFlags ); 5928 DataChanged( aDCEvt ); 5929 // notify data change handler 5930 ImplCallEventListeners( VCLEVENT_WINDOW_DATACHANGED, &aDCEvt); 5931 } 5932 5933 if ( bChild || mpWindowImpl->mbChildNotify ) 5934 { 5935 Window* pChild = mpWindowImpl->mpFirstChild; 5936 while ( pChild ) 5937 { 5938 pChild->UpdateSettings( rSettings, bChild ); 5939 pChild = pChild->mpWindowImpl->mpNext; 5940 } 5941 } 5942 } 5943 5944 // ----------------------------------------------------------------------- 5945 5946 void Window::NotifyAllChilds( DataChangedEvent& rDCEvt ) 5947 { 5948 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5949 5950 DataChanged( rDCEvt ); 5951 5952 Window* pChild = mpWindowImpl->mpFirstChild; 5953 while ( pChild ) 5954 { 5955 pChild->NotifyAllChilds( rDCEvt ); 5956 pChild = pChild->mpWindowImpl->mpNext; 5957 } 5958 } 5959 5960 // ----------------------------------------------------------------------- 5961 5962 void Window::SetPointFont( const Font& rFont ) 5963 { 5964 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5965 5966 Font aFont = rFont; 5967 ImplPointToLogic( aFont ); 5968 SetFont( aFont ); 5969 } 5970 5971 // ----------------------------------------------------------------------- 5972 5973 Font Window::GetPointFont() const 5974 { 5975 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5976 5977 Font aFont = GetFont(); 5978 ImplLogicToPoint( aFont ); 5979 return aFont; 5980 } 5981 5982 // ----------------------------------------------------------------------- 5983 5984 // TODO: remove in next incompatible build 5985 void Window::GetFontResolution( sal_Int32& nDPIX, sal_Int32& nDPIY ) const 5986 { 5987 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5988 5989 nDPIX = mpWindowImpl->mpFrameData->mnDPIX; 5990 nDPIY = mpWindowImpl->mpFrameData->mnDPIY; 5991 } 5992 5993 // ----------------------------------------------------------------------- 5994 5995 void Window::SetParentClipMode( sal_uInt16 nMode ) 5996 { 5997 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 5998 5999 if ( mpWindowImpl->mpBorderWindow ) 6000 mpWindowImpl->mpBorderWindow->SetParentClipMode( nMode ); 6001 else 6002 { 6003 if ( !ImplIsOverlapWindow() ) 6004 { 6005 mpWindowImpl->mnParentClipMode = nMode; 6006 if ( nMode & PARENTCLIPMODE_CLIP ) 6007 mpWindowImpl->mpParent->mpWindowImpl->mbClipChildren = sal_True; 6008 } 6009 } 6010 } 6011 6012 // ----------------------------------------------------------------------- 6013 6014 sal_uInt16 Window::GetParentClipMode() const 6015 { 6016 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 6017 6018 if ( mpWindowImpl->mpBorderWindow ) 6019 return mpWindowImpl->mpBorderWindow->GetParentClipMode(); 6020 else 6021 return mpWindowImpl->mnParentClipMode; 6022 } 6023 6024 // ----------------------------------------------------------------------- 6025 6026 void Window::SetWindowRegionPixel() 6027 { 6028 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 6029 6030 if ( mpWindowImpl->mpBorderWindow ) 6031 mpWindowImpl->mpBorderWindow->SetWindowRegionPixel(); 6032 else if( mpWindowImpl->mbFrame ) 6033 { 6034 mpWindowImpl->maWinRegion = Region( REGION_NULL); 6035 mpWindowImpl->mbWinRegion = sal_False; 6036 mpWindowImpl->mpFrame->ResetClipRegion(); 6037 } 6038 else 6039 { 6040 if ( mpWindowImpl->mbWinRegion ) 6041 { 6042 mpWindowImpl->maWinRegion = Region( REGION_NULL ); 6043 mpWindowImpl->mbWinRegion = sal_False; 6044 ImplSetClipFlag(); 6045 6046 if ( IsReallyVisible() ) 6047 { 6048 // Hintergrund-Sicherung zuruecksetzen 6049 if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mpSaveBackDev ) 6050 ImplDeleteOverlapBackground(); 6051 if ( mpWindowImpl->mpFrameData->mpFirstBackWin ) 6052 ImplInvalidateAllOverlapBackgrounds(); 6053 Rectangle aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ); 6054 Region aRegion( aRect ); 6055 ImplInvalidateParentFrameRegion( aRegion ); 6056 } 6057 } 6058 } 6059 } 6060 6061 // ----------------------------------------------------------------------- 6062 6063 void Window::SetWindowRegionPixel( const Region& rRegion ) 6064 { 6065 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 6066 6067 if ( mpWindowImpl->mpBorderWindow ) 6068 mpWindowImpl->mpBorderWindow->SetWindowRegionPixel( rRegion ); 6069 else if( mpWindowImpl->mbFrame ) 6070 { 6071 if( rRegion.GetType() != REGION_NULL ) 6072 { 6073 mpWindowImpl->maWinRegion = rRegion; 6074 mpWindowImpl->mbWinRegion = ! rRegion.IsEmpty(); 6075 if( mpWindowImpl->mbWinRegion ) 6076 { 6077 // ClipRegion setzen/updaten 6078 long nX; 6079 long nY; 6080 long nWidth; 6081 long nHeight; 6082 sal_uLong nRectCount; 6083 ImplRegionInfo aInfo; 6084 sal_Bool bRegionRect; 6085 6086 nRectCount = mpWindowImpl->maWinRegion.GetRectCount(); 6087 mpWindowImpl->mpFrame->BeginSetClipRegion( nRectCount ); 6088 bRegionRect = mpWindowImpl->maWinRegion.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight ); 6089 while ( bRegionRect ) 6090 { 6091 mpWindowImpl->mpFrame->UnionClipRegion( nX, nY, nWidth, nHeight ); 6092 bRegionRect = mpWindowImpl->maWinRegion.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight ); 6093 } 6094 mpWindowImpl->mpFrame->EndSetClipRegion(); 6095 } 6096 else 6097 SetWindowRegionPixel(); 6098 } 6099 else 6100 SetWindowRegionPixel(); 6101 } 6102 else 6103 { 6104 sal_Bool bInvalidate = sal_False; 6105 6106 if ( rRegion.GetType() == REGION_NULL ) 6107 { 6108 if ( mpWindowImpl->mbWinRegion ) 6109 { 6110 mpWindowImpl->maWinRegion = Region( REGION_NULL ); 6111 mpWindowImpl->mbWinRegion = sal_False; 6112 ImplSetClipFlag(); 6113 bInvalidate = sal_True; 6114 } 6115 } 6116 else 6117 { 6118 mpWindowImpl->maWinRegion = rRegion; 6119 mpWindowImpl->mbWinRegion = sal_True; 6120 ImplSetClipFlag(); 6121 bInvalidate = sal_True; 6122 } 6123 6124 if ( IsReallyVisible() ) 6125 { 6126 // Hintergrund-Sicherung zuruecksetzen 6127 if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mpSaveBackDev ) 6128 ImplDeleteOverlapBackground(); 6129 if ( mpWindowImpl->mpFrameData->mpFirstBackWin ) 6130 ImplInvalidateAllOverlapBackgrounds(); 6131 Rectangle aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ); 6132 Region aRegion( aRect ); 6133 ImplInvalidateParentFrameRegion( aRegion ); 6134 } 6135 } 6136 } 6137 6138 // ----------------------------------------------------------------------- 6139 6140 const Region& Window::GetWindowRegionPixel() const 6141 { 6142 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 6143 6144 if ( mpWindowImpl->mpBorderWindow ) 6145 return mpWindowImpl->mpBorderWindow->GetWindowRegionPixel(); 6146 else 6147 return mpWindowImpl->maWinRegion; 6148 } 6149 6150 // ----------------------------------------------------------------------- 6151 6152 sal_Bool Window::IsWindowRegionPixel() const 6153 { 6154 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 6155 6156 if ( mpWindowImpl->mpBorderWindow ) 6157 return mpWindowImpl->mpBorderWindow->IsWindowRegionPixel(); 6158 else 6159 return mpWindowImpl->mbWinRegion; 6160 } 6161 6162 // ----------------------------------------------------------------------- 6163 6164 Region Window::GetWindowClipRegionPixel( sal_uInt16 nFlags ) const 6165 { 6166 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 6167 6168 Region aWinClipRegion; 6169 6170 if ( nFlags & WINDOW_GETCLIPREGION_NOCHILDREN ) 6171 { 6172 if ( mpWindowImpl->mbInitWinClipRegion ) 6173 ((Window*)this)->ImplInitWinClipRegion(); 6174 aWinClipRegion = mpWindowImpl->maWinClipRegion; 6175 } 6176 else 6177 { 6178 Region* pWinChildClipRegion = ((Window*)this)->ImplGetWinChildClipRegion(); 6179 aWinClipRegion = *pWinChildClipRegion; 6180 // --- RTL --- remirror clip region before passing it to somebody 6181 if( ImplIsAntiparallel() ) 6182 ImplReMirror( aWinClipRegion ); 6183 } 6184 6185 if ( nFlags & WINDOW_GETCLIPREGION_NULL ) 6186 { 6187 Rectangle aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ); 6188 Region aWinRegion( aWinRect ); 6189 6190 if ( aWinRegion == aWinClipRegion ) 6191 aWinClipRegion.SetNull(); 6192 } 6193 6194 aWinClipRegion.Move( -mnOutOffX, -mnOutOffY ); 6195 6196 return aWinClipRegion; 6197 } 6198 6199 // ----------------------------------------------------------------------- 6200 6201 Region Window::GetPaintRegion() const 6202 { 6203 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 6204 6205 if ( mpWindowImpl->mpPaintRegion ) 6206 { 6207 Region aRegion = *mpWindowImpl->mpPaintRegion; 6208 aRegion.Move( -mnOutOffX, -mnOutOffY ); 6209 return PixelToLogic( aRegion ); 6210 } 6211 else 6212 { 6213 Region aPaintRegion( REGION_NULL ); 6214 return aPaintRegion; 6215 } 6216 } 6217 6218 // ----------------------------------------------------------------------- 6219 6220 void Window::ExpandPaintClipRegion( const Region& rRegion ) 6221 { 6222 if( mpWindowImpl->mpPaintRegion ) 6223 { 6224 Region aPixRegion = LogicToPixel( rRegion ); 6225 Region aDevPixRegion = ImplPixelToDevicePixel( aPixRegion ); 6226 6227 Region aWinChildRegion = *ImplGetWinChildClipRegion(); 6228 // --- RTL -- only this region is in frame coordinates, so re-mirror it 6229 if( ImplIsAntiparallel() ) 6230 ImplReMirror( aWinChildRegion ); 6231 aDevPixRegion.Intersect( aWinChildRegion ); 6232 if( ! aDevPixRegion.IsEmpty() ) 6233 { 6234 mpWindowImpl->mpPaintRegion->Union( aDevPixRegion ); 6235 mbInitClipRegion = sal_True; 6236 } 6237 } 6238 } 6239 6240 // ----------------------------------------------------------------------- 6241 6242 static SystemWindow *ImplGetLastSystemWindow( Window *pWin ) 6243 { 6244 // get the most top-level system window, the one that contains the taskpanelist 6245 SystemWindow *pSysWin = NULL; 6246 if( !pWin ) 6247 return pSysWin; 6248 Window *pMyParent = pWin; 6249 while ( pMyParent ) 6250 { 6251 if ( pMyParent->IsSystemWindow() ) 6252 pSysWin = (SystemWindow*)pMyParent; 6253 pMyParent = pMyParent->GetParent(); 6254 } 6255 return pSysWin; 6256 } 6257 6258 void Window::SetParent( Window* pNewParent ) 6259 { 6260 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 6261 DBG_ASSERT( pNewParent, "Window::SetParent(): pParent == NULL" ); 6262 DBG_ASSERT( pNewParent != this, "someone tried to reparent a window to itself" ); 6263 6264 if( pNewParent == this ) 6265 return; 6266 6267 // check if the taskpanelist would change and move the window pointer accordingly 6268 SystemWindow *pSysWin = ImplGetLastSystemWindow(this); 6269 SystemWindow *pNewSysWin = NULL; 6270 sal_Bool bChangeTaskPaneList = sal_False; 6271 if( pSysWin && pSysWin->ImplIsInTaskPaneList( this ) ) 6272 { 6273 pNewSysWin = ImplGetLastSystemWindow( pNewParent ); 6274 if( pNewSysWin && pNewSysWin != pSysWin ) 6275 { 6276 bChangeTaskPaneList = sal_True; 6277 pSysWin->GetTaskPaneList()->RemoveWindow( this ); 6278 } 6279 } 6280 // remove ownerdraw decorated windows from list in the top-most frame window 6281 if( (GetStyle() & WB_OWNERDRAWDECORATION) && mpWindowImpl->mbFrame ) 6282 { 6283 ::std::vector< Window* >& rList = ImplGetOwnerDrawList(); 6284 ::std::vector< Window* >::iterator p; 6285 p = ::std::find( rList.begin(), rList.end(), this ); 6286 if( p != rList.end() ) 6287 rList.erase( p ); 6288 } 6289 6290 ImplSetFrameParent( pNewParent ); 6291 6292 if ( mpWindowImpl->mpBorderWindow ) 6293 { 6294 mpWindowImpl->mpRealParent = pNewParent; 6295 mpWindowImpl->mpBorderWindow->SetParent( pNewParent ); 6296 return; 6297 } 6298 6299 if ( mpWindowImpl->mpParent == pNewParent ) 6300 return; 6301 6302 if ( mpWindowImpl->mbFrame ) 6303 mpWindowImpl->mpFrame->SetParent( pNewParent->mpWindowImpl->mpFrame ); 6304 6305 sal_Bool bVisible = IsVisible(); 6306 Show( sal_False, SHOW_NOFOCUSCHANGE ); 6307 6308 // Testen, ob sich das Overlap-Window aendert 6309 Window* pOldOverlapWindow; 6310 Window* pNewOverlapWindow = NULL; 6311 if ( ImplIsOverlapWindow() ) 6312 pOldOverlapWindow = NULL; 6313 else 6314 { 6315 pNewOverlapWindow = pNewParent->ImplGetFirstOverlapWindow(); 6316 if ( mpWindowImpl->mpOverlapWindow != pNewOverlapWindow ) 6317 pOldOverlapWindow = mpWindowImpl->mpOverlapWindow; 6318 else 6319 pOldOverlapWindow = NULL; 6320 } 6321 6322 // Fenster in der Hirachie umsetzen 6323 sal_Bool bFocusOverlapWin = HasChildPathFocus( sal_True ); 6324 sal_Bool bFocusWin = HasChildPathFocus(); 6325 sal_Bool bNewFrame = pNewParent->mpWindowImpl->mpFrameWindow != mpWindowImpl->mpFrameWindow; 6326 if ( bNewFrame ) 6327 { 6328 if ( mpWindowImpl->mpFrameData->mpFocusWin ) 6329 { 6330 if ( IsWindowOrChild( mpWindowImpl->mpFrameData->mpFocusWin ) ) 6331 mpWindowImpl->mpFrameData->mpFocusWin = NULL; 6332 } 6333 if ( mpWindowImpl->mpFrameData->mpMouseMoveWin ) 6334 { 6335 if ( IsWindowOrChild( mpWindowImpl->mpFrameData->mpMouseMoveWin ) ) 6336 mpWindowImpl->mpFrameData->mpMouseMoveWin = NULL; 6337 } 6338 if ( mpWindowImpl->mpFrameData->mpMouseDownWin ) 6339 { 6340 if ( IsWindowOrChild( mpWindowImpl->mpFrameData->mpMouseDownWin ) ) 6341 mpWindowImpl->mpFrameData->mpMouseDownWin = NULL; 6342 } 6343 } 6344 ImplRemoveWindow( bNewFrame ); 6345 ImplInsertWindow( pNewParent ); 6346 if ( mpWindowImpl->mnParentClipMode & PARENTCLIPMODE_CLIP ) 6347 pNewParent->mpWindowImpl->mbClipChildren = sal_True; 6348 ImplUpdateWindowPtr(); 6349 if ( ImplUpdatePos() ) 6350 ImplUpdateSysObjPos(); 6351 6352 // Wenn sich das Overlap-Window geaendert hat, dann muss getestet werden, 6353 // ob auch OverlapWindow die das Child-Fenster als Parent gehabt haben 6354 // in der Window-Hirachie umgesetzt werden muessen 6355 if ( ImplIsOverlapWindow() ) 6356 { 6357 if ( bNewFrame ) 6358 { 6359 Window* pOverlapWindow = mpWindowImpl->mpFirstOverlap; 6360 while ( pOverlapWindow ) 6361 { 6362 Window* pNextOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext; 6363 pOverlapWindow->ImplUpdateOverlapWindowPtr( bNewFrame ); 6364 pOverlapWindow = pNextOverlapWindow; 6365 } 6366 } 6367 } 6368 else if ( pOldOverlapWindow ) 6369 { 6370 // Focus-Save zuruecksetzen 6371 if ( bFocusWin || 6372 (pOldOverlapWindow->mpWindowImpl->mpLastFocusWindow && 6373 IsWindowOrChild( pOldOverlapWindow->mpWindowImpl->mpLastFocusWindow )) ) 6374 pOldOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL; 6375 6376 Window* pOverlapWindow = pOldOverlapWindow->mpWindowImpl->mpFirstOverlap; 6377 while ( pOverlapWindow ) 6378 { 6379 Window* pNextOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext; 6380 if ( ImplIsRealParentPath( pOverlapWindow->ImplGetWindow() ) ) 6381 pOverlapWindow->ImplUpdateOverlapWindowPtr( bNewFrame ); 6382 pOverlapWindow = pNextOverlapWindow; 6383 } 6384 6385 // Activate-Status beim naechsten Overlap-Window updaten 6386 if ( HasChildPathFocus( sal_True ) ) 6387 ImplCallFocusChangeActivate( pNewOverlapWindow, pOldOverlapWindow ); 6388 } 6389 6390 // Activate-Status mit umsetzen 6391 if ( bNewFrame ) 6392 { 6393 if ( (GetType() == WINDOW_BORDERWINDOW) && 6394 (ImplGetWindow()->GetType() == WINDOW_FLOATINGWINDOW) ) 6395 ((ImplBorderWindow*)this)->SetDisplayActive( mpWindowImpl->mpFrameData->mbHasFocus ); 6396 } 6397 6398 // Focus evtl. auf den neuen Frame umsetzen, wenn FocusWindow mit 6399 // SetParent() umgesetzt wird 6400 if ( bFocusOverlapWin ) 6401 { 6402 mpWindowImpl->mpFrameData->mpFocusWin = Application::GetFocusWindow(); 6403 if ( !mpWindowImpl->mpFrameData->mbHasFocus ) 6404 { 6405 mpWindowImpl->mpFrame->ToTop( 0 ); 6406 } 6407 } 6408 6409 // Assure DragSource and DropTarget members are created 6410 if ( bNewFrame ) 6411 { 6412 GetDropTarget(); 6413 } 6414 6415 if( bChangeTaskPaneList ) 6416 pNewSysWin->GetTaskPaneList()->AddWindow( this ); 6417 6418 if( (GetStyle() & WB_OWNERDRAWDECORATION) && mpWindowImpl->mbFrame ) 6419 ImplGetOwnerDrawList().push_back( this ); 6420 6421 if ( bVisible ) 6422 Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE ); 6423 } 6424 6425 // ----------------------------------------------------------------------- 6426 6427 void Window::Show( sal_Bool bVisible, sal_uInt16 nFlags ) 6428 { 6429 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 6430 6431 if ( mpWindowImpl->mbVisible == bVisible ) 6432 return; 6433 6434 ImplDelData aDogTag( this ); 6435 6436 sal_Bool bRealVisibilityChanged = sal_False; 6437 mpWindowImpl->mbVisible = (bVisible != 0); 6438 6439 if ( !bVisible ) 6440 { 6441 ImplHideAllOverlaps(); 6442 if( aDogTag.IsDelete() ) 6443 return; 6444 6445 if ( mpWindowImpl->mpBorderWindow ) 6446 { 6447 sal_Bool bOldUpdate = mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate; 6448 if ( mpWindowImpl->mbNoParentUpdate ) 6449 mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate = sal_True; 6450 mpWindowImpl->mpBorderWindow->Show( sal_False, nFlags ); 6451 mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate = bOldUpdate; 6452 } 6453 else if ( mpWindowImpl->mbFrame ) 6454 { 6455 mpWindowImpl->mbSuppressAccessibilityEvents = sal_True; 6456 mpWindowImpl->mpFrame->Show( sal_False, sal_False ); 6457 } 6458 6459 StateChanged( STATE_CHANGE_VISIBLE ); 6460 6461 if ( mpWindowImpl->mbReallyVisible ) 6462 { 6463 Region aInvRegion( REGION_EMPTY ); 6464 sal_Bool bSaveBack = sal_False; 6465 6466 if ( ImplIsOverlapWindow() && !mpWindowImpl->mbFrame ) 6467 { 6468 if ( ImplRestoreOverlapBackground( aInvRegion ) ) 6469 bSaveBack = sal_True; 6470 } 6471 6472 if ( !bSaveBack ) 6473 { 6474 if ( mpWindowImpl->mbInitWinClipRegion ) 6475 ImplInitWinClipRegion(); 6476 aInvRegion = mpWindowImpl->maWinClipRegion; 6477 } 6478 6479 if( aDogTag.IsDelete() ) 6480 return; 6481 6482 bRealVisibilityChanged = mpWindowImpl->mbReallyVisible; 6483 ImplResetReallyVisible(); 6484 ImplSetClipFlag(); 6485 6486 if ( ImplIsOverlapWindow() && !mpWindowImpl->mbFrame ) 6487 { 6488 // Focus umsetzen 6489 if ( !(nFlags & SHOW_NOFOCUSCHANGE) && HasChildPathFocus() ) 6490 { 6491 if ( mpWindowImpl->mpOverlapWindow->IsEnabled() && 6492 mpWindowImpl->mpOverlapWindow->IsInputEnabled() && 6493 ! mpWindowImpl->mpOverlapWindow->IsInModalMode() 6494 ) 6495 mpWindowImpl->mpOverlapWindow->GrabFocus(); 6496 } 6497 } 6498 6499 if ( !mpWindowImpl->mbFrame ) 6500 { 6501 if( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mbEnableNativeWidget ) 6502 { 6503 /* 6504 * #i48371# native theming: some themes draw outside the control 6505 * area we tell them to (bad thing, but we cannot do much about it ). 6506 * On hiding these controls they get invalidated with their window rectangle 6507 * which leads to the parts outside the control area being left and not 6508 * invalidated. Workaround: invalidate an area on the parent, too 6509 */ 6510 const int workaround_border = 5; 6511 Rectangle aBounds( aInvRegion.GetBoundRect() ); 6512 aBounds.Left() -= workaround_border; 6513 aBounds.Top() -= workaround_border; 6514 aBounds.Right() += workaround_border; 6515 aBounds.Bottom() += workaround_border; 6516 aInvRegion = aBounds; 6517 } 6518 if ( !mpWindowImpl->mbNoParentUpdate && !(nFlags & SHOW_NOPARENTUPDATE) ) 6519 { 6520 if ( !aInvRegion.IsEmpty() ) 6521 ImplInvalidateParentFrameRegion( aInvRegion ); 6522 } 6523 ImplGenerateMouseMove(); 6524 } 6525 } 6526 } 6527 else 6528 { 6529 // inherit native widget flag for form controls 6530 // required here, because frames never show up in the child hierarchy - which should be fixed.... 6531 // eg, the drop down of a combobox which is a system floating window 6532 if( mpWindowImpl->mbFrame && GetParent() && GetParent()->IsCompoundControl() && 6533 GetParent()->IsNativeWidgetEnabled() != IsNativeWidgetEnabled() ) 6534 EnableNativeWidget( GetParent()->IsNativeWidgetEnabled() ); 6535 6536 if ( mpWindowImpl->mbCallMove ) 6537 { 6538 ImplCallMove(); 6539 } 6540 if ( mpWindowImpl->mbCallResize ) 6541 { 6542 ImplCallResize(); 6543 } 6544 6545 StateChanged( STATE_CHANGE_VISIBLE ); 6546 6547 Window* pTestParent; 6548 if ( ImplIsOverlapWindow() ) 6549 pTestParent = mpWindowImpl->mpOverlapWindow; 6550 else 6551 pTestParent = ImplGetParent(); 6552 if ( mpWindowImpl->mbFrame || pTestParent->mpWindowImpl->mbReallyVisible ) 6553 { 6554 // Wenn ein Window gerade sichtbar wird, schicken wir allen 6555 // Child-Fenstern ein StateChanged, damit diese sich 6556 // initialisieren koennen 6557 ImplCallInitShow(); 6558 6559 // Wenn es ein SystemWindow ist, dann kommt es auch automatisch 6560 // nach vorne, wenn es gewuenscht ist 6561 if ( ImplIsOverlapWindow() && !(nFlags & SHOW_NOACTIVATE) ) 6562 { 6563 ImplStartToTop(( nFlags & SHOW_FOREGROUNDTASK ) ? TOTOP_FOREGROUNDTASK : 0 ); 6564 ImplFocusToTop( 0, sal_False ); 6565 } 6566 6567 // Hintergrund sichern 6568 if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mbSaveBack ) 6569 ImplSaveOverlapBackground(); 6570 // adjust mpWindowImpl->mbReallyVisible 6571 bRealVisibilityChanged = !mpWindowImpl->mbReallyVisible; 6572 ImplSetReallyVisible(); 6573 6574 // Dafuer sorgen, das Clip-Rechtecke neu berechnet werden 6575 ImplSetClipFlag(); 6576 6577 if ( !mpWindowImpl->mbFrame ) 6578 { 6579 sal_uInt16 nInvalidateFlags = INVALIDATE_CHILDREN; 6580 if( ! IsPaintTransparent() ) 6581 nInvalidateFlags |= INVALIDATE_NOTRANSPARENT; 6582 ImplInvalidate( NULL, nInvalidateFlags ); 6583 ImplGenerateMouseMove(); 6584 } 6585 } 6586 6587 if ( mpWindowImpl->mpBorderWindow ) 6588 mpWindowImpl->mpBorderWindow->Show( sal_True, nFlags ); 6589 else if ( mpWindowImpl->mbFrame ) 6590 { 6591 ImplSVData* pSVData = ImplGetSVData(); 6592 // #106431#, hide SplashScreen 6593 if( pSVData->mpIntroWindow && !ImplIsWindowOrChild( pSVData->mpIntroWindow ) ) 6594 pSVData->mpIntroWindow->Hide(); 6595 6596 //DBG_ASSERT( !mpWindowImpl->mbSuppressAccessibilityEvents, "Window::Show() - Frame reactivated"); 6597 mpWindowImpl->mbSuppressAccessibilityEvents = sal_False; 6598 6599 mpWindowImpl->mbPaintFrame = sal_True; 6600 sal_Bool bNoActivate = (nFlags & (SHOW_NOACTIVATE|SHOW_NOFOCUSCHANGE)) ? sal_True : sal_False; 6601 mpWindowImpl->mpFrame->Show( sal_True, bNoActivate ); 6602 if( aDogTag.IsDelete() ) 6603 return; 6604 6605 // Query the correct size of the window, if we are waiting for 6606 // a system resize 6607 if ( mpWindowImpl->mbWaitSystemResize ) 6608 { 6609 long nOutWidth; 6610 long nOutHeight; 6611 mpWindowImpl->mpFrame->GetClientSize( nOutWidth, nOutHeight ); 6612 ImplHandleResize( this, nOutWidth, nOutHeight ); 6613 } 6614 } 6615 6616 if( aDogTag.IsDelete() ) 6617 return; 6618 6619 #ifdef DBG_UTIL 6620 if ( IsDialog() || (GetType() == WINDOW_TABPAGE) || (GetType() == WINDOW_DOCKINGWINDOW) ) 6621 { 6622 DBG_DIALOGTEST( this ); 6623 } 6624 #endif 6625 6626 ImplShowAllOverlaps(); 6627 } 6628 6629 if( aDogTag.IsDelete() ) 6630 return; 6631 // invalidate all saved backgrounds 6632 if ( mpWindowImpl->mpFrameData->mpFirstBackWin ) 6633 ImplInvalidateAllOverlapBackgrounds(); 6634 6635 // the SHOW/HIDE events also serve as indicators to send child creation/destroy events to the access bridge 6636 // However, the access bridge only uses this event if the data member is not NULL (it's kind of a hack that 6637 // we re-use the SHOW/HIDE events this way, with this particular semantics). 6638 // Since #104887#, the notifications for the access bridge are done in Impl(Set|Reset)ReallyVisible. Here, we 6639 // now only notify with a NULL data pointer, for all other clients except the access bridge. 6640 if ( !bRealVisibilityChanged ) 6641 ImplCallEventListeners( mpWindowImpl->mbVisible ? VCLEVENT_WINDOW_SHOW : VCLEVENT_WINDOW_HIDE, NULL ); 6642 if( aDogTag.IsDelete() ) 6643 return; 6644 6645 // #107575#, if a floating windows is shown that grabs the focus, we have to notify the toolkit about it 6646 // ImplGrabFocus() is not called in this case 6647 // Because this might lead to problems the task will be shifted to 6.y 6648 // Note: top-level context menues are registered at the access bridge after being shown, 6649 // so this will probably not help here.... 6650 /* 6651 if( mpWindowImpl->mbFloatWin && ((FloatingWindow*) this )->GrabsFocus() ) 6652 { 6653 ImplSVData* pSVData = ImplGetSVData(); 6654 if( !mpWindowImpl->mbVisible ) 6655 { 6656 ImplCallEventListeners( VCLEVENT_WINDOW_LOSEFOCUS ); 6657 if( pSVData->maWinData.mpFocusWin ) 6658 pSVData->maWinData.mpFocusWin->ImplCallEventListeners( VCLEVENT_WINDOW_GETFOCUS ); 6659 } 6660 else 6661 { 6662 if( pSVData->maWinData.mpFocusWin ) 6663 pSVData->maWinData.mpFocusWin->ImplCallEventListeners( VCLEVENT_WINDOW_LOSEFOCUS ); 6664 ImplCallEventListeners( VCLEVENT_WINDOW_GETFOCUS ); 6665 } 6666 } 6667 */ 6668 } 6669 6670 // ----------------------------------------------------------------------- 6671 6672 Size Window::GetSizePixel() const 6673 { 6674 // #i43257# trigger pending resize handler to assure correct window sizes 6675 if( mpWindowImpl->mpFrameData->maResizeTimer.IsActive() ) 6676 { 6677 ImplDelData aDogtag( this ); 6678 mpWindowImpl->mpFrameData->maResizeTimer.Stop(); 6679 mpWindowImpl->mpFrameData->maResizeTimer.GetTimeoutHdl().Call( NULL ); 6680 if( aDogtag.IsDelete() ) 6681 return Size(0,0); 6682 } 6683 6684 return Size( mnOutWidth+mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder, 6685 mnOutHeight+mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder ); 6686 } 6687 6688 void Window::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, 6689 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const 6690 { 6691 rLeftBorder = mpWindowImpl->mnLeftBorder; 6692 rTopBorder = mpWindowImpl->mnTopBorder; 6693 rRightBorder = mpWindowImpl->mnRightBorder; 6694 rBottomBorder = mpWindowImpl->mnBottomBorder; 6695 } 6696 6697 6698 // ----------------------------------------------------------------------- 6699 6700 void Window::Enable( bool bEnable, bool bChild ) 6701 { 6702 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 6703 6704 if ( !bEnable ) 6705 { 6706 // Wenn ein Fenster disablte wird, wird automatisch der Tracking-Modus 6707 // beendet oder der Capture geklaut 6708 if ( IsTracking() ) 6709 EndTracking( ENDTRACK_CANCEL ); 6710 if ( IsMouseCaptured() ) 6711 ReleaseMouse(); 6712 // Wenn Fenster den Focus hat und in der Dialog-Steuerung enthalten, 6713 // wird versucht, den Focus auf das naechste Control weiterzuschalten 6714 // mpWindowImpl->mbDisabled darf erst nach Aufruf von ImplDlgCtrlNextWindow() gesetzt 6715 // werden. Ansonsten muss ImplDlgCtrlNextWindow() umgestellt werden 6716 if ( HasFocus() ) 6717 ImplDlgCtrlNextWindow(); 6718 } 6719 6720 if ( mpWindowImpl->mpBorderWindow ) 6721 { 6722 mpWindowImpl->mpBorderWindow->Enable( bEnable, sal_False ); 6723 if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) && 6724 ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow ) 6725 ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->Enable( bEnable, sal_True ); 6726 } 6727 6728 // #i56102# restore app focus win in case the 6729 // window was disabled when the frame focus changed 6730 ImplSVData* pSVData = ImplGetSVData(); 6731 if( bEnable && 6732 pSVData->maWinData.mpFocusWin == NULL && 6733 mpWindowImpl->mpFrameData->mbHasFocus && 6734 mpWindowImpl->mpFrameData->mpFocusWin == this ) 6735 pSVData->maWinData.mpFocusWin = this; 6736 6737 if ( mpWindowImpl->mbDisabled != !bEnable ) 6738 { 6739 mpWindowImpl->mbDisabled = !bEnable; 6740 if ( mpWindowImpl->mpSysObj ) 6741 mpWindowImpl->mpSysObj->Enable( bEnable && !mpWindowImpl->mbInputDisabled ); 6742 // if ( mpWindowImpl->mbFrame ) 6743 // mpWindowImpl->mpFrame->Enable( bEnable && !mpWindowImpl->mbInputDisabled ); 6744 StateChanged( STATE_CHANGE_ENABLE ); 6745 6746 ImplCallEventListeners( bEnable ? VCLEVENT_WINDOW_ENABLED : VCLEVENT_WINDOW_DISABLED ); 6747 } 6748 6749 if ( bChild || mpWindowImpl->mbChildNotify ) 6750 { 6751 Window* pChild = mpWindowImpl->mpFirstChild; 6752 while ( pChild ) 6753 { 6754 pChild->Enable( bEnable, bChild ); 6755 pChild = pChild->mpWindowImpl->mpNext; 6756 } 6757 } 6758 6759 if ( IsReallyVisible() ) 6760 ImplGenerateMouseMove(); 6761 } 6762 6763 // ----------------------------------------------------------------------- 6764 6765 void Window::SetCallHandlersOnInputDisabled( bool bCall ) 6766 { 6767 mpWindowImpl->mbCallHandlersDuringInputDisabled = bCall ? sal_True : sal_False; 6768 6769 Window* pChild = mpWindowImpl->mpFirstChild; 6770 while ( pChild ) 6771 { 6772 pChild->SetCallHandlersOnInputDisabled( bCall ); 6773 pChild = pChild->mpWindowImpl->mpNext; 6774 } 6775 } 6776 6777 // ----------------------------------------------------------------------- 6778 6779 bool Window::IsCallHandlersOnInputDisabled() const 6780 { 6781 return mpWindowImpl->mbCallHandlersDuringInputDisabled ? true : false; 6782 } 6783 6784 // ----------------------------------------------------------------------- 6785 6786 void Window::EnableInput( sal_Bool bEnable, sal_Bool bChild ) 6787 { 6788 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 6789 6790 sal_Bool bNotify = (bEnable != mpWindowImpl->mbInputDisabled); 6791 if ( mpWindowImpl->mpBorderWindow ) 6792 { 6793 mpWindowImpl->mpBorderWindow->EnableInput( bEnable, sal_False ); 6794 if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) && 6795 ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow ) 6796 ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->EnableInput( bEnable, sal_True ); 6797 } 6798 6799 if ( (! bEnable && mpWindowImpl->meAlwaysInputMode != AlwaysInputEnabled) || 6800 ( bEnable && mpWindowImpl->meAlwaysInputMode != AlwaysInputDisabled) ) 6801 { 6802 // Wenn ein Fenster disablte wird, wird automatisch der 6803 // Tracking-Modus beendet oder der Capture geklaut 6804 if ( !bEnable ) 6805 { 6806 if ( IsTracking() ) 6807 EndTracking( ENDTRACK_CANCEL ); 6808 if ( IsMouseCaptured() ) 6809 ReleaseMouse(); 6810 } 6811 6812 if ( mpWindowImpl->mbInputDisabled != !bEnable ) 6813 { 6814 mpWindowImpl->mbInputDisabled = !bEnable; 6815 if ( mpWindowImpl->mpSysObj ) 6816 mpWindowImpl->mpSysObj->Enable( !mpWindowImpl->mbDisabled && bEnable ); 6817 // if ( mpWindowImpl->mbFrame ) 6818 // mpWindowImpl->mpFrame->Enable( !mpWindowImpl->mbDisabled && bEnable ); 6819 } 6820 } 6821 6822 // #i56102# restore app focus win in case the 6823 // window was disabled when the frame focus changed 6824 ImplSVData* pSVData = ImplGetSVData(); 6825 if( bEnable && 6826 pSVData->maWinData.mpFocusWin == NULL && 6827 mpWindowImpl->mpFrameData->mbHasFocus && 6828 mpWindowImpl->mpFrameData->mpFocusWin == this ) 6829 pSVData->maWinData.mpFocusWin = this; 6830 6831 if ( bChild || mpWindowImpl->mbChildNotify ) 6832 { 6833 Window* pChild = mpWindowImpl->mpFirstChild; 6834 while ( pChild ) 6835 { 6836 pChild->EnableInput( bEnable, bChild ); 6837 pChild = pChild->mpWindowImpl->mpNext; 6838 } 6839 } 6840 6841 if ( IsReallyVisible() ) 6842 ImplGenerateMouseMove(); 6843 6844 // #104827# notify parent 6845 if ( bNotify ) 6846 { 6847 NotifyEvent aNEvt( bEnable ? EVENT_INPUTENABLE : EVENT_INPUTDISABLE, this ); 6848 Notify( aNEvt ); 6849 } 6850 } 6851 6852 // ----------------------------------------------------------------------- 6853 6854 void Window::EnableInput( sal_Bool bEnable, sal_Bool bChild, sal_Bool bSysWin, 6855 const Window* pExcludeWindow ) 6856 { 6857 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 6858 6859 EnableInput( bEnable, bChild ); 6860 if ( bSysWin ) 6861 { 6862 // pExculeWindow is the first Overlap-Frame --> if this 6863 // shouldn't be the case, than this must be changed in dialog.cxx 6864 if( pExcludeWindow ) 6865 pExcludeWindow = pExcludeWindow->ImplGetFirstOverlapWindow(); 6866 Window* pSysWin = mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrameData->mpFirstOverlap; 6867 while ( pSysWin ) 6868 { 6869 // Is Window in the path from this window 6870 if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( pSysWin, sal_True ) ) 6871 { 6872 // Is Window not in the exclude window path or not the 6873 // exclude window, than change the status 6874 if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( pSysWin, sal_True ) ) 6875 pSysWin->EnableInput( bEnable, bChild ); 6876 } 6877 pSysWin = pSysWin->mpWindowImpl->mpNextOverlap; 6878 } 6879 6880 // enable/disable floating system windows as well 6881 Window* pFrameWin = ImplGetSVData()->maWinData.mpFirstFrame; 6882 while ( pFrameWin ) 6883 { 6884 if( pFrameWin->ImplIsFloatingWindow() ) 6885 { 6886 // Is Window in the path from this window 6887 if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( pFrameWin, sal_True ) ) 6888 { 6889 // Is Window not in the exclude window path or not the 6890 // exclude window, than change the status 6891 if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( pFrameWin, sal_True ) ) 6892 pFrameWin->EnableInput( bEnable, bChild ); 6893 } 6894 } 6895 pFrameWin = pFrameWin->mpWindowImpl->mpFrameData->mpNextFrame; 6896 } 6897 6898 // the same for ownerdraw floating windows 6899 if( mpWindowImpl->mbFrame ) 6900 { 6901 ::std::vector< Window* >& rList = mpWindowImpl->mpFrameData->maOwnerDrawList; 6902 ::std::vector< Window* >::iterator p = rList.begin(); 6903 while( p != rList.end() ) 6904 { 6905 // Is Window in the path from this window 6906 if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( (*p), sal_True ) ) 6907 { 6908 // Is Window not in the exclude window path or not the 6909 // exclude window, than change the status 6910 if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( (*p), sal_True ) ) 6911 (*p)->EnableInput( bEnable, bChild ); 6912 } 6913 p++; 6914 } 6915 } 6916 } 6917 } 6918 6919 // ----------------------------------------------------------------------- 6920 6921 void Window::AlwaysEnableInput( sal_Bool bAlways, sal_Bool bChild ) 6922 { 6923 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 6924 6925 if ( mpWindowImpl->mpBorderWindow ) 6926 mpWindowImpl->mpBorderWindow->AlwaysEnableInput( bAlways, sal_False ); 6927 6928 if( bAlways && mpWindowImpl->meAlwaysInputMode != AlwaysInputEnabled ) 6929 { 6930 mpWindowImpl->meAlwaysInputMode = AlwaysInputEnabled; 6931 6932 if ( bAlways ) 6933 EnableInput( sal_True, sal_False ); 6934 } 6935 else if( ! bAlways && mpWindowImpl->meAlwaysInputMode == AlwaysInputEnabled ) 6936 { 6937 mpWindowImpl->meAlwaysInputMode = AlwaysInputNone; 6938 } 6939 6940 if ( bChild || mpWindowImpl->mbChildNotify ) 6941 { 6942 Window* pChild = mpWindowImpl->mpFirstChild; 6943 while ( pChild ) 6944 { 6945 pChild->AlwaysEnableInput( bAlways, bChild ); 6946 pChild = pChild->mpWindowImpl->mpNext; 6947 } 6948 } 6949 } 6950 6951 // ----------------------------------------------------------------------- 6952 6953 void Window::AlwaysDisableInput( sal_Bool bAlways, sal_Bool bChild ) 6954 { 6955 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 6956 6957 if ( mpWindowImpl->mpBorderWindow ) 6958 mpWindowImpl->mpBorderWindow->AlwaysDisableInput( bAlways, sal_False ); 6959 6960 if( bAlways && mpWindowImpl->meAlwaysInputMode != AlwaysInputDisabled ) 6961 { 6962 mpWindowImpl->meAlwaysInputMode = AlwaysInputDisabled; 6963 6964 if ( bAlways ) 6965 EnableInput( sal_False, sal_False ); 6966 } 6967 else if( ! bAlways && mpWindowImpl->meAlwaysInputMode == AlwaysInputDisabled ) 6968 { 6969 mpWindowImpl->meAlwaysInputMode = AlwaysInputNone; 6970 } 6971 6972 if ( bChild || mpWindowImpl->mbChildNotify ) 6973 { 6974 Window* pChild = mpWindowImpl->mpFirstChild; 6975 while ( pChild ) 6976 { 6977 pChild->AlwaysDisableInput( bAlways, bChild ); 6978 pChild = pChild->mpWindowImpl->mpNext; 6979 } 6980 } 6981 } 6982 6983 // ----------------------------------------------------------------------- 6984 6985 void Window::SetActivateMode( sal_uInt16 nMode ) 6986 { 6987 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 6988 6989 if ( mpWindowImpl->mpBorderWindow ) 6990 mpWindowImpl->mpBorderWindow->SetActivateMode( nMode ); 6991 6992 if ( mpWindowImpl->mnActivateMode != nMode ) 6993 { 6994 mpWindowImpl->mnActivateMode = nMode; 6995 6996 // Evtl. ein Decativate/Activate ausloesen 6997 if ( mpWindowImpl->mnActivateMode ) 6998 { 6999 if ( (mpWindowImpl->mbActive || (GetType() == WINDOW_BORDERWINDOW)) && 7000 !HasChildPathFocus( sal_True ) ) 7001 { 7002 mpWindowImpl->mbActive = sal_False; 7003 Deactivate(); 7004 } 7005 } 7006 else 7007 { 7008 if ( !mpWindowImpl->mbActive || (GetType() == WINDOW_BORDERWINDOW) ) 7009 { 7010 mpWindowImpl->mbActive = sal_True; 7011 Activate(); 7012 } 7013 } 7014 } 7015 } 7016 7017 // ----------------------------------------------------------------------- 7018 7019 void Window::ToTop( sal_uInt16 nFlags ) 7020 { 7021 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7022 7023 ImplStartToTop( nFlags ); 7024 ImplFocusToTop( nFlags, IsReallyVisible() ); 7025 } 7026 7027 // ----------------------------------------------------------------------- 7028 7029 void Window::SetZOrder( Window* pRefWindow, sal_uInt16 nFlags ) 7030 { 7031 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7032 7033 if ( mpWindowImpl->mpBorderWindow ) 7034 { 7035 mpWindowImpl->mpBorderWindow->SetZOrder( pRefWindow, nFlags ); 7036 return; 7037 } 7038 7039 if ( nFlags & WINDOW_ZORDER_FIRST ) 7040 { 7041 if ( ImplIsOverlapWindow() ) 7042 pRefWindow = mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap; 7043 else 7044 pRefWindow = mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild; 7045 nFlags |= WINDOW_ZORDER_BEFOR; 7046 } 7047 else if ( nFlags & WINDOW_ZORDER_LAST ) 7048 { 7049 if ( ImplIsOverlapWindow() ) 7050 pRefWindow = mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap; 7051 else 7052 pRefWindow = mpWindowImpl->mpParent->mpWindowImpl->mpLastChild; 7053 nFlags |= WINDOW_ZORDER_BEHIND; 7054 } 7055 7056 while ( pRefWindow->mpWindowImpl->mpBorderWindow ) 7057 pRefWindow = pRefWindow->mpWindowImpl->mpBorderWindow; 7058 if ( (pRefWindow == this) || mpWindowImpl->mbFrame ) 7059 return; 7060 7061 DBG_ASSERT( pRefWindow->mpWindowImpl->mpParent == mpWindowImpl->mpParent, "Window::SetZOrder() - pRefWindow has other parent" ); 7062 if ( nFlags & WINDOW_ZORDER_BEFOR ) 7063 { 7064 if ( pRefWindow->mpWindowImpl->mpPrev == this ) 7065 return; 7066 7067 if ( ImplIsOverlapWindow() ) 7068 { 7069 if ( mpWindowImpl->mpPrev ) 7070 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext; 7071 else 7072 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap = mpWindowImpl->mpNext; 7073 if ( mpWindowImpl->mpNext ) 7074 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev; 7075 else 7076 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = mpWindowImpl->mpPrev; 7077 if ( !pRefWindow->mpWindowImpl->mpPrev ) 7078 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap = this; 7079 } 7080 else 7081 { 7082 if ( mpWindowImpl->mpPrev ) 7083 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext; 7084 else 7085 mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext; 7086 if ( mpWindowImpl->mpNext ) 7087 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev; 7088 else 7089 mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = mpWindowImpl->mpPrev; 7090 if ( !pRefWindow->mpWindowImpl->mpPrev ) 7091 mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = this; 7092 } 7093 7094 mpWindowImpl->mpPrev = pRefWindow->mpWindowImpl->mpPrev; 7095 mpWindowImpl->mpNext = pRefWindow; 7096 if ( mpWindowImpl->mpPrev ) 7097 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this; 7098 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = this; 7099 } 7100 else if ( nFlags & WINDOW_ZORDER_BEHIND ) 7101 { 7102 if ( pRefWindow->mpWindowImpl->mpNext == this ) 7103 return; 7104 7105 if ( ImplIsOverlapWindow() ) 7106 { 7107 if ( mpWindowImpl->mpPrev ) 7108 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext; 7109 else 7110 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap = mpWindowImpl->mpNext; 7111 if ( mpWindowImpl->mpNext ) 7112 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev; 7113 else 7114 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = mpWindowImpl->mpPrev; 7115 if ( !pRefWindow->mpWindowImpl->mpNext ) 7116 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = this; 7117 } 7118 else 7119 { 7120 if ( mpWindowImpl->mpPrev ) 7121 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext; 7122 else 7123 mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext; 7124 if ( mpWindowImpl->mpNext ) 7125 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev; 7126 else 7127 mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = mpWindowImpl->mpPrev; 7128 if ( !pRefWindow->mpWindowImpl->mpNext ) 7129 mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = this; 7130 } 7131 7132 mpWindowImpl->mpPrev = pRefWindow; 7133 mpWindowImpl->mpNext = pRefWindow->mpWindowImpl->mpNext; 7134 if ( mpWindowImpl->mpNext ) 7135 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = this; 7136 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this; 7137 } 7138 7139 if ( IsReallyVisible() ) 7140 { 7141 // Hintergrund-Sicherung zuruecksetzen 7142 if ( mpWindowImpl->mpFrameData->mpFirstBackWin ) 7143 ImplInvalidateAllOverlapBackgrounds(); 7144 7145 if ( mpWindowImpl->mbInitWinClipRegion || !mpWindowImpl->maWinClipRegion.IsEmpty() ) 7146 { 7147 sal_Bool bInitWinClipRegion = mpWindowImpl->mbInitWinClipRegion; 7148 ImplSetClipFlag(); 7149 7150 // Wenn ClipRegion noch nicht initalisiert wurde, dann 7151 // gehen wir davon aus, das das Fenster noch nicht 7152 // ausgegeben wurde und loesen somit auch keine 7153 // Invalidates aus. Dies ist eine Optimierung fuer 7154 // HTML-Dokumenten mit vielen Controls. Wenn es mal 7155 // Probleme mit dieser Abfrage gibt, sollte man ein 7156 // Flag einfuehren, ob das Fenster nach Show schon 7157 // einmal ausgegeben wurde. 7158 if ( !bInitWinClipRegion ) 7159 { 7160 // Alle nebeneinanderliegen Fenster invalidieren 7161 // Noch nicht komplett implementiert !!! 7162 Rectangle aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ); 7163 Window* pWindow = NULL; 7164 if ( ImplIsOverlapWindow() ) 7165 { 7166 if ( mpWindowImpl->mpOverlapWindow ) 7167 pWindow = mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap; 7168 } 7169 else 7170 pWindow = ImplGetParent()->mpWindowImpl->mpFirstChild; 7171 // Alle Fenster, die vor uns liegen und von uns verdeckt wurden, 7172 // invalidieren 7173 while ( pWindow ) 7174 { 7175 if ( pWindow == this ) 7176 break; 7177 Rectangle aCompRect( Point( pWindow->mnOutOffX, pWindow->mnOutOffY ), 7178 Size( pWindow->mnOutWidth, pWindow->mnOutHeight ) ); 7179 if ( aWinRect.IsOver( aCompRect ) ) 7180 pWindow->Invalidate( INVALIDATE_CHILDREN | INVALIDATE_NOTRANSPARENT ); 7181 pWindow = pWindow->mpWindowImpl->mpNext; 7182 } 7183 // Wenn uns ein Fenster welches im Hinterund liegt verdeckt hat, 7184 // dann muessen wir uns neu ausgeben 7185 while ( pWindow ) 7186 { 7187 if ( pWindow != this ) 7188 { 7189 Rectangle aCompRect( Point( pWindow->mnOutOffX, pWindow->mnOutOffY ), 7190 Size( pWindow->mnOutWidth, pWindow->mnOutHeight ) ); 7191 if ( aWinRect.IsOver( aCompRect ) ) 7192 { 7193 Invalidate( INVALIDATE_CHILDREN | INVALIDATE_NOTRANSPARENT ); 7194 break; 7195 } 7196 } 7197 pWindow = pWindow->mpWindowImpl->mpNext; 7198 } 7199 } 7200 } 7201 } 7202 } 7203 7204 // ----------------------------------------------------------------------- 7205 7206 void Window::EnableAlwaysOnTop( sal_Bool bEnable ) 7207 { 7208 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7209 7210 mpWindowImpl->mbAlwaysOnTop = bEnable; 7211 7212 if ( mpWindowImpl->mpBorderWindow ) 7213 mpWindowImpl->mpBorderWindow->EnableAlwaysOnTop( bEnable ); 7214 else if ( bEnable && IsReallyVisible() ) 7215 ToTop(); 7216 7217 if ( mpWindowImpl->mbFrame ) 7218 mpWindowImpl->mpFrame->SetAlwaysOnTop( bEnable ); 7219 } 7220 7221 // ----------------------------------------------------------------------- 7222 7223 void Window::SetPosSizePixel( long nX, long nY, 7224 long nWidth, long nHeight, sal_uInt16 nFlags ) 7225 { 7226 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7227 7228 sal_Bool bHasValidSize = !mpWindowImpl->mbDefSize; 7229 7230 if ( nFlags & WINDOW_POSSIZE_POS ) 7231 mpWindowImpl->mbDefPos = sal_False; 7232 if ( nFlags & WINDOW_POSSIZE_SIZE ) 7233 mpWindowImpl->mbDefSize = sal_False; 7234 7235 // Oberstes BorderWindow ist das Window, welches positioniert werden soll 7236 Window* pWindow = this; 7237 while ( pWindow->mpWindowImpl->mpBorderWindow ) 7238 pWindow = pWindow->mpWindowImpl->mpBorderWindow; 7239 7240 if ( pWindow->mpWindowImpl->mbFrame ) 7241 { 7242 // Note: if we're positioning a frame, the coordinates are interpreted 7243 // as being the top-left corner of the window's client area and NOT 7244 // as the position of the border ! (due to limitations of several UNIX window managers) 7245 long nOldWidth = pWindow->mnOutWidth; 7246 7247 if ( !(nFlags & WINDOW_POSSIZE_WIDTH) ) 7248 nWidth = pWindow->mnOutWidth; 7249 if ( !(nFlags & WINDOW_POSSIZE_HEIGHT) ) 7250 nHeight = pWindow->mnOutHeight; 7251 7252 7253 sal_uInt16 nSysFlags=0; 7254 if( nFlags & WINDOW_POSSIZE_WIDTH ) 7255 nSysFlags |= SAL_FRAME_POSSIZE_WIDTH; 7256 if( nFlags & WINDOW_POSSIZE_HEIGHT ) 7257 nSysFlags |= SAL_FRAME_POSSIZE_HEIGHT; 7258 if( nFlags & WINDOW_POSSIZE_X ) 7259 { 7260 nSysFlags |= SAL_FRAME_POSSIZE_X; 7261 if( pWindow->GetParent() && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) ) 7262 { 7263 Window* pParent = pWindow->GetParent(); 7264 nX += pParent->mnOutOffX; 7265 } 7266 if( GetParent() && GetParent()->ImplIsAntiparallel() ) 7267 { 7268 // --- RTL --- (re-mirror at parent window) 7269 Rectangle aRect( Point ( nX, nY ), Size( nWidth, nHeight ) ); 7270 GetParent()->ImplReMirror( aRect ); 7271 nX = aRect.nLeft; 7272 } 7273 } 7274 if( !(nFlags & WINDOW_POSSIZE_X) && bHasValidSize && pWindow->mpWindowImpl->mpFrame->maGeometry.nWidth ) 7275 { 7276 // --- RTL --- make sure the old right aligned position is not changed 7277 // system windows will always grow to the right 7278 if( pWindow->GetParent() && pWindow->GetParent()->ImplHasMirroredGraphics() ) 7279 { 7280 long myWidth = nOldWidth; 7281 if( !myWidth ) 7282 myWidth = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nWidth; 7283 if( !myWidth ) 7284 myWidth = nWidth; 7285 nFlags |= WINDOW_POSSIZE_X; 7286 nSysFlags |= SAL_FRAME_POSSIZE_X; 7287 nX = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX - pWindow->GetParent()->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX - 7288 mpWindowImpl->mpFrame->GetUnmirroredGeometry().nLeftDecoration; 7289 nX = pWindow->GetParent()->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX - mpWindowImpl->mpFrame->GetUnmirroredGeometry().nLeftDecoration + 7290 pWindow->GetParent()->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nWidth - myWidth - 1 - mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX; 7291 if(!(nFlags & WINDOW_POSSIZE_Y)) 7292 { 7293 nFlags |= WINDOW_POSSIZE_Y; 7294 nSysFlags |= SAL_FRAME_POSSIZE_Y; 7295 nY = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nY - pWindow->GetParent()->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nY - 7296 mpWindowImpl->mpFrame->GetUnmirroredGeometry().nTopDecoration; 7297 } 7298 } 7299 } 7300 if( nFlags & WINDOW_POSSIZE_Y ) 7301 { 7302 nSysFlags |= SAL_FRAME_POSSIZE_Y; 7303 if( pWindow->GetParent() && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) ) 7304 { 7305 Window* pParent = pWindow->GetParent(); 7306 nY += pParent->mnOutOffY; 7307 } 7308 } 7309 7310 if( nSysFlags & (SAL_FRAME_POSSIZE_WIDTH|SAL_FRAME_POSSIZE_HEIGHT) ) 7311 { 7312 // check for min/max client size and adjust size accordingly 7313 // otherwise it may happen that the resize event is ignored, i.e. the old size remains 7314 // unchanged but ImplHandleResize() is called with the wrong size 7315 SystemWindow *pSystemWindow = dynamic_cast< SystemWindow* >( pWindow ); 7316 if( pSystemWindow ) 7317 { 7318 Size aMinSize = pSystemWindow->GetMinOutputSizePixel(); 7319 Size aMaxSize = pSystemWindow->GetMaxOutputSizePixel(); 7320 if( nWidth < aMinSize.Width() ) 7321 nWidth = aMinSize.Width(); 7322 if( nHeight < aMinSize.Height() ) 7323 nHeight = aMinSize.Height(); 7324 7325 if( nWidth > aMaxSize.Width() ) 7326 nWidth = aMaxSize.Width(); 7327 if( nHeight > aMaxSize.Height() ) 7328 nHeight = aMaxSize.Height(); 7329 } 7330 } 7331 7332 pWindow->mpWindowImpl->mpFrame->SetPosSize( nX, nY, nWidth, nHeight, nSysFlags ); 7333 7334 // Resize should be called directly. If we havn't 7335 // set the correct size, we get a second resize from 7336 // the system with the correct size. This can be happend 7337 // if the size is to small or to large. 7338 ImplHandleResize( pWindow, nWidth, nHeight ); 7339 } 7340 else 7341 { 7342 pWindow->ImplPosSizeWindow( nX, nY, nWidth, nHeight, nFlags ); 7343 if ( IsReallyVisible() ) 7344 ImplGenerateMouseMove(); 7345 } 7346 } 7347 7348 // ----------------------------------------------------------------------- 7349 7350 Point Window::GetPosPixel() const 7351 { 7352 return mpWindowImpl->maPos; 7353 } 7354 7355 // ----------------------------------------------------------------------- 7356 7357 Rectangle Window::GetDesktopRectPixel() const 7358 { 7359 Rectangle rRect; 7360 mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrame->GetWorkArea( rRect ); 7361 return rRect; 7362 } 7363 7364 // ----------------------------------------------------------------------- 7365 7366 Point Window::OutputToScreenPixel( const Point& rPos ) const 7367 { 7368 // relative to top level parent 7369 return Point( rPos.X()+mnOutOffX, rPos.Y()+mnOutOffY ); 7370 } 7371 7372 // ----------------------------------------------------------------------- 7373 7374 Point Window::ScreenToOutputPixel( const Point& rPos ) const 7375 { 7376 // relative to top level parent 7377 return Point( rPos.X()-mnOutOffX, rPos.Y()-mnOutOffY ); 7378 } 7379 7380 // ----------------------------------------------------------------------- 7381 7382 long Window::ImplGetUnmirroredOutOffX() 7383 { 7384 // revert mnOutOffX changes that were potentially made in ImplPosSizeWindow 7385 long offx = mnOutOffX; 7386 if( ImplHasMirroredGraphics() ) 7387 { 7388 if( mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->ImplIsAntiparallel() ) 7389 { 7390 if ( !ImplIsOverlapWindow() ) 7391 offx -= mpWindowImpl->mpParent->mnOutOffX; 7392 7393 offx = mpWindowImpl->mpParent->mnOutWidth - mnOutWidth - offx; 7394 7395 if ( !ImplIsOverlapWindow() ) 7396 offx += mpWindowImpl->mpParent->mnOutOffX; 7397 7398 } 7399 } 7400 return offx; 7401 } 7402 7403 // normalized screen pixel are independent of mirroring 7404 Point Window::OutputToNormalizedScreenPixel( const Point& rPos ) const 7405 { 7406 // relative to top level parent 7407 long offx = ((Window*) this)->ImplGetUnmirroredOutOffX(); 7408 return Point( rPos.X()+offx, rPos.Y()+mnOutOffY ); 7409 } 7410 7411 Point Window::NormalizedScreenToOutputPixel( const Point& rPos ) const 7412 { 7413 // relative to top level parent 7414 long offx = ((Window*) this)->ImplGetUnmirroredOutOffX(); 7415 return Point( rPos.X()-offx, rPos.Y()-mnOutOffY ); 7416 } 7417 7418 // ----------------------------------------------------------------------- 7419 7420 Point Window::OutputToAbsoluteScreenPixel( const Point& rPos ) const 7421 { 7422 // relative to the screen 7423 Point p = OutputToScreenPixel( rPos ); 7424 SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry(); 7425 p.X() += g.nX; 7426 p.Y() += g.nY; 7427 return p; 7428 } 7429 7430 // ----------------------------------------------------------------------- 7431 7432 Point Window::AbsoluteScreenToOutputPixel( const Point& rPos ) const 7433 { 7434 // relative to the screen 7435 Point p = ScreenToOutputPixel( rPos ); 7436 SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry(); 7437 p.X() -= g.nX; 7438 p.Y() -= g.nY; 7439 return p; 7440 } 7441 7442 // ----------------------------------------------------------------------- 7443 7444 Rectangle Window::ImplOutputToUnmirroredAbsoluteScreenPixel( const Rectangle &rRect ) const 7445 { 7446 // this method creates unmirrored screen coordinates to be compared with the desktop 7447 // and is used for positioning of RTL popup windows correctly on the screen 7448 SalFrameGeometry g = mpWindowImpl->mpFrame->GetUnmirroredGeometry(); 7449 7450 Point p1 = OutputToScreenPixel( rRect.TopRight() ); 7451 p1.X() = g.nX+g.nWidth-p1.X(); 7452 p1.Y() += g.nY; 7453 7454 Point p2 = OutputToScreenPixel( rRect.BottomLeft() ); 7455 p2.X() = g.nX+g.nWidth-p2.X(); 7456 p2.Y() += g.nY; 7457 7458 return Rectangle( p1, p2 ); 7459 } 7460 7461 7462 // ----------------------------------------------------------------------- 7463 7464 Rectangle Window::GetWindowExtentsRelative( Window *pRelativeWindow ) const 7465 { 7466 // with decoration 7467 return ImplGetWindowExtentsRelative( pRelativeWindow, sal_False ); 7468 } 7469 7470 Rectangle Window::GetClientWindowExtentsRelative( Window *pRelativeWindow ) const 7471 { 7472 // without decoration 7473 return ImplGetWindowExtentsRelative( pRelativeWindow, sal_True ); 7474 } 7475 7476 // ----------------------------------------------------------------------- 7477 7478 Rectangle Window::ImplGetWindowExtentsRelative( Window *pRelativeWindow, sal_Bool bClientOnly ) const 7479 { 7480 SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry(); 7481 // make sure we use the extent of our border window, 7482 // otherwise we miss a few pixels 7483 const Window *pWin = (!bClientOnly && mpWindowImpl->mpBorderWindow) ? mpWindowImpl->mpBorderWindow : this; 7484 7485 Point aPos( pWin->OutputToScreenPixel( Point(0,0) ) ); 7486 aPos.X() += g.nX; 7487 aPos.Y() += g.nY; 7488 Size aSize ( pWin->GetSizePixel() ); 7489 // #104088# do not add decoration to the workwindow to be compatible to java accessibility api 7490 if( !bClientOnly && (mpWindowImpl->mbFrame || (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame && GetType() != WINDOW_WORKWINDOW)) ) 7491 { 7492 aPos.X() -= g.nLeftDecoration; 7493 aPos.Y() -= g.nTopDecoration; 7494 aSize.Width() += g.nLeftDecoration + g.nRightDecoration; 7495 aSize.Height() += g.nTopDecoration + g.nBottomDecoration; 7496 } 7497 if( pRelativeWindow ) 7498 { 7499 // #106399# express coordinates relative to borderwindow 7500 Window *pRelWin = (!bClientOnly && pRelativeWindow->mpWindowImpl->mpBorderWindow) ? pRelativeWindow->mpWindowImpl->mpBorderWindow : pRelativeWindow; 7501 aPos = pRelWin->AbsoluteScreenToOutputPixel( aPos ); 7502 } 7503 return Rectangle( aPos, aSize ); 7504 } 7505 7506 // ----------------------------------------------------------------------- 7507 7508 void Window::Scroll( long nHorzScroll, long nVertScroll, sal_uInt16 nFlags ) 7509 { 7510 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7511 7512 ImplScroll( Rectangle( Point( mnOutOffX, mnOutOffY ), 7513 Size( mnOutWidth, mnOutHeight ) ), 7514 nHorzScroll, nVertScroll, nFlags & ~SCROLL_CLIP ); 7515 } 7516 7517 // ----------------------------------------------------------------------- 7518 7519 void Window::Scroll( long nHorzScroll, long nVertScroll, 7520 const Rectangle& rRect, sal_uInt16 nFlags ) 7521 { 7522 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7523 7524 Rectangle aRect = ImplLogicToDevicePixel( rRect ); 7525 aRect.Intersection( Rectangle( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ) ); 7526 if ( !aRect.IsEmpty() ) 7527 ImplScroll( aRect, nHorzScroll, nVertScroll, nFlags ); 7528 } 7529 7530 // ----------------------------------------------------------------------- 7531 7532 void Window::Invalidate( sal_uInt16 nFlags ) 7533 { 7534 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7535 7536 if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight ) 7537 return; 7538 7539 ImplInvalidate( NULL, nFlags ); 7540 } 7541 7542 // ----------------------------------------------------------------------- 7543 7544 void Window::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags ) 7545 { 7546 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7547 7548 if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight ) 7549 return; 7550 7551 Rectangle aRect = ImplLogicToDevicePixel( rRect ); 7552 if ( !aRect.IsEmpty() ) 7553 { 7554 Region aRegion( aRect ); 7555 ImplInvalidate( &aRegion, nFlags ); 7556 } 7557 } 7558 7559 // ----------------------------------------------------------------------- 7560 7561 void Window::Invalidate( const Region& rRegion, sal_uInt16 nFlags ) 7562 { 7563 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7564 7565 if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight ) 7566 return; 7567 7568 if ( rRegion.IsNull() ) 7569 ImplInvalidate( NULL, nFlags ); 7570 else 7571 { 7572 Region aRegion = ImplPixelToDevicePixel( LogicToPixel( rRegion ) ); 7573 if ( !aRegion.IsEmpty() ) 7574 ImplInvalidate( &aRegion, nFlags ); 7575 } 7576 } 7577 7578 // ----------------------------------------------------------------------- 7579 7580 void Window::Validate( sal_uInt16 nFlags ) 7581 { 7582 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7583 7584 if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight ) 7585 return; 7586 7587 ImplValidate( NULL, nFlags ); 7588 } 7589 7590 // ----------------------------------------------------------------------- 7591 7592 void Window::Validate( const Rectangle& rRect, sal_uInt16 nFlags ) 7593 { 7594 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7595 7596 if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight ) 7597 return; 7598 7599 Rectangle aRect = ImplLogicToDevicePixel( rRect ); 7600 if ( !aRect.IsEmpty() ) 7601 { 7602 Region aRegion( aRect ); 7603 ImplValidate( &aRegion, nFlags ); 7604 } 7605 } 7606 7607 // ----------------------------------------------------------------------- 7608 7609 void Window::Validate( const Region& rRegion, sal_uInt16 nFlags ) 7610 { 7611 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7612 7613 if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight ) 7614 return; 7615 7616 if ( rRegion.IsNull() ) 7617 ImplValidate( NULL, nFlags ); 7618 else 7619 { 7620 Region aRegion = ImplPixelToDevicePixel( LogicToPixel( rRegion ) ); 7621 if ( !aRegion.IsEmpty() ) 7622 ImplValidate( &aRegion, nFlags ); 7623 } 7624 } 7625 7626 // ----------------------------------------------------------------------- 7627 7628 sal_Bool Window::HasPaintEvent() const 7629 { 7630 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7631 7632 if ( !mpWindowImpl->mbReallyVisible ) 7633 return sal_False; 7634 7635 if ( mpWindowImpl->mpFrameWindow->mpWindowImpl->mbPaintFrame ) 7636 return sal_True; 7637 7638 if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINT ) 7639 return sal_True; 7640 7641 if ( !ImplIsOverlapWindow() ) 7642 { 7643 const Window* pTempWindow = this; 7644 do 7645 { 7646 pTempWindow = pTempWindow->ImplGetParent(); 7647 if ( pTempWindow->mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINTCHILDS | IMPL_PAINT_PAINTALLCHILDS) ) 7648 return sal_True; 7649 } 7650 while ( !pTempWindow->ImplIsOverlapWindow() ); 7651 } 7652 7653 return sal_False; 7654 } 7655 7656 // ----------------------------------------------------------------------- 7657 7658 void Window::Update() 7659 { 7660 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7661 7662 if ( mpWindowImpl->mpBorderWindow ) 7663 { 7664 mpWindowImpl->mpBorderWindow->Update(); 7665 return; 7666 } 7667 7668 if ( !mpWindowImpl->mbReallyVisible ) 7669 return; 7670 7671 sal_Bool bFlush = sal_False; 7672 if ( mpWindowImpl->mpFrameWindow->mpWindowImpl->mbPaintFrame ) 7673 { 7674 Point aPoint( 0, 0 ); 7675 Region aRegion( Rectangle( aPoint, Size( mnOutWidth, mnOutHeight ) ) ); 7676 ImplInvalidateOverlapFrameRegion( aRegion ); 7677 if ( mpWindowImpl->mbFrame || (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame) ) 7678 bFlush = sal_True; 7679 } 7680 7681 // Zuerst muessen wir alle Fenster ueberspringen, die Paint-Transparent 7682 // sind 7683 Window* pUpdateWindow = this; 7684 Window* pWindow = pUpdateWindow; 7685 while ( !pWindow->ImplIsOverlapWindow() ) 7686 { 7687 if ( !pWindow->mpWindowImpl->mbPaintTransparent ) 7688 { 7689 pUpdateWindow = pWindow; 7690 break; 7691 } 7692 pWindow = pWindow->ImplGetParent(); 7693 } 7694 // Ein Update wirkt immer auf das Window, wo PAINTALLCHILDS gesetzt 7695 // ist, damit nicht zuviel gemalt wird 7696 pWindow = pUpdateWindow; 7697 do 7698 { 7699 if ( pWindow->mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALLCHILDS ) 7700 pUpdateWindow = pWindow; 7701 if ( pWindow->ImplIsOverlapWindow() ) 7702 break; 7703 pWindow = pWindow->ImplGetParent(); 7704 } 7705 while ( pWindow ); 7706 7707 // Wenn es etwas zu malen gibt, dann ein Paint ausloesen 7708 if ( pUpdateWindow->mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINT | IMPL_PAINT_PAINTCHILDS) ) 7709 { 7710 // und fuer alle ueber uns stehende System-Fenster auch ein Update 7711 // ausloesen, damit nicht die ganze Zeit luecken stehen bleiben 7712 Window* pUpdateOverlapWindow = ImplGetFirstOverlapWindow()->mpWindowImpl->mpFirstOverlap; 7713 while ( pUpdateOverlapWindow ) 7714 { 7715 pUpdateOverlapWindow->Update(); 7716 pUpdateOverlapWindow = pUpdateOverlapWindow->mpWindowImpl->mpNext; 7717 } 7718 7719 pUpdateWindow->ImplCallPaint( NULL, pUpdateWindow->mpWindowImpl->mnPaintFlags ); 7720 } 7721 7722 if ( bFlush ) 7723 Flush(); 7724 } 7725 7726 // ----------------------------------------------------------------------- 7727 7728 void Window::Flush() 7729 { 7730 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7731 7732 const Rectangle aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ); 7733 mpWindowImpl->mpFrame->Flush( aWinRect ); 7734 } 7735 7736 // ----------------------------------------------------------------------- 7737 7738 void Window::Sync() 7739 { 7740 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7741 7742 mpWindowImpl->mpFrame->Sync(); 7743 } 7744 7745 // ----------------------------------------------------------------------- 7746 7747 void Window::SetUpdateMode( sal_Bool bUpdate ) 7748 { 7749 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7750 7751 mpWindowImpl->mbNoUpdate = !bUpdate; 7752 StateChanged( STATE_CHANGE_UPDATEMODE ); 7753 } 7754 7755 // ----------------------------------------------------------------------- 7756 7757 void Window::GrabFocus() 7758 { 7759 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7760 7761 ImplGrabFocus( 0 ); 7762 } 7763 7764 // ----------------------------------------------------------------------- 7765 7766 sal_Bool Window::HasFocus() const 7767 { 7768 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7769 7770 // #107575# the first floating window always has the keyboard focus, see also winproc.cxx: ImplGetKeyInputWindow() 7771 // task was shifted to 6.y, so its commented out 7772 /* 7773 Window* pFocusWin = ImplGetSVData()->maWinData.mpFirstFloat; 7774 if( pFocusWin && pFocusWin->mpWindowImpl->mbFloatWin && ((FloatingWindow *)pFocusWin)->GrabsFocus() ) 7775 pFocusWin = pFocusWin->GetPreferredKeyInputWindow(); 7776 else 7777 pFocusWin = ImplGetSVData()->maWinData.mpFocusWin; 7778 7779 return (this == pFocusWin); 7780 */ 7781 7782 return (this == ImplGetSVData()->maWinData.mpFocusWin); 7783 } 7784 7785 // ----------------------------------------------------------------------- 7786 7787 void Window::GrabFocusToDocument() 7788 { 7789 Window *pWin = this; 7790 while( pWin ) 7791 { 7792 if( !pWin->GetParent() ) 7793 { 7794 pWin->ImplGetFrameWindow()->GetWindow( WINDOW_CLIENT )->GrabFocus(); 7795 return; 7796 } 7797 pWin = pWin->GetParent(); 7798 } 7799 } 7800 7801 void Window::SetFakeFocus( bool bFocus ) 7802 { 7803 ImplGetWindowImpl()->mbFakeFocusSet = bFocus; 7804 } 7805 7806 // ----------------------------------------------------------------------- 7807 7808 sal_Bool Window::HasChildPathFocus( sal_Bool bSystemWindow ) const 7809 { 7810 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7811 7812 // #107575#, the first floating window always has the keyboard focus, see also winproc.cxx: ImplGetKeyInputWindow() 7813 // task was shifted to 6.y, so its commented out 7814 /* 7815 Window* pFocusWin = ImplGetSVData()->maWinData.mpFirstFloat; 7816 if( pFocusWin && pFocusWin->mpWindowImpl->mbFloatWin && ((FloatingWindow *)pFocusWin)->GrabsFocus() ) 7817 pFocusWin = pFocusWin->GetPreferredKeyInputWindow(); 7818 else 7819 pFocusWin = ImplGetSVData()->maWinData.mpFocusWin; 7820 */ 7821 Window* pFocusWin = ImplGetSVData()->maWinData.mpFocusWin; 7822 if ( pFocusWin ) 7823 return ImplIsWindowOrChild( pFocusWin, bSystemWindow ); 7824 return sal_False; 7825 } 7826 7827 // ----------------------------------------------------------------------- 7828 7829 void Window::CaptureMouse() 7830 { 7831 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7832 7833 ImplSVData* pSVData = ImplGetSVData(); 7834 7835 // Tracking evt. beenden 7836 if ( pSVData->maWinData.mpTrackWin != this ) 7837 { 7838 if ( pSVData->maWinData.mpTrackWin ) 7839 pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL ); 7840 } 7841 7842 if ( pSVData->maWinData.mpCaptureWin != this ) 7843 { 7844 pSVData->maWinData.mpCaptureWin = this; 7845 mpWindowImpl->mpFrame->CaptureMouse( sal_True ); 7846 } 7847 } 7848 7849 // ----------------------------------------------------------------------- 7850 7851 void Window::ReleaseMouse() 7852 { 7853 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7854 7855 ImplSVData* pSVData = ImplGetSVData(); 7856 7857 DBG_ASSERTWARNING( pSVData->maWinData.mpCaptureWin == this, 7858 "Window::ReleaseMouse(): window doesn't have the mouse capture" ); 7859 7860 if ( pSVData->maWinData.mpCaptureWin == this ) 7861 { 7862 pSVData->maWinData.mpCaptureWin = NULL; 7863 mpWindowImpl->mpFrame->CaptureMouse( sal_False ); 7864 ImplGenerateMouseMove(); 7865 } 7866 } 7867 7868 // ----------------------------------------------------------------------- 7869 7870 sal_Bool Window::IsMouseCaptured() const 7871 { 7872 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7873 7874 return (this == ImplGetSVData()->maWinData.mpCaptureWin); 7875 } 7876 7877 // ----------------------------------------------------------------------- 7878 7879 void Window::SetPointer( const Pointer& rPointer ) 7880 { 7881 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7882 7883 if ( mpWindowImpl->maPointer == rPointer ) 7884 return; 7885 7886 mpWindowImpl->maPointer = rPointer; 7887 7888 // Pointer evt. direkt umsetzen 7889 if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() ) 7890 mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() ); 7891 } 7892 7893 // ----------------------------------------------------------------------- 7894 7895 void Window::EnableChildPointerOverwrite( sal_Bool bOverwrite ) 7896 { 7897 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7898 7899 if ( mpWindowImpl->mbChildPtrOverwrite == bOverwrite ) 7900 return; 7901 7902 mpWindowImpl->mbChildPtrOverwrite = bOverwrite; 7903 7904 // Pointer evt. direkt umsetzen 7905 if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() ) 7906 mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() ); 7907 } 7908 7909 // ----------------------------------------------------------------------- 7910 7911 void Window::SetPointerPosPixel( const Point& rPos ) 7912 { 7913 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7914 7915 Point aPos = ImplOutputToFrame( rPos ); 7916 if( ImplHasMirroredGraphics() ) 7917 { 7918 if( !IsRTLEnabled() ) 7919 { 7920 // --- RTL --- (re-mirror mouse pos at this window) 7921 ImplReMirror( aPos ); 7922 } 7923 // mirroring is required here, SetPointerPos bypasses SalGraphics 7924 mpGraphics->mirror( aPos.X(), this ); 7925 } 7926 else if( ImplIsAntiparallel() ) 7927 { 7928 ImplReMirror( aPos ); 7929 } 7930 mpWindowImpl->mpFrame->SetPointerPos( aPos.X(), aPos.Y() ); 7931 } 7932 7933 // ----------------------------------------------------------------------- 7934 7935 Point Window::GetPointerPosPixel() 7936 { 7937 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7938 7939 Point aPos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY ); 7940 if( ImplIsAntiparallel() ) 7941 { 7942 // --- RTL --- (re-mirror mouse pos at this window) 7943 ImplReMirror( aPos ); 7944 } 7945 return ImplFrameToOutput( aPos ); 7946 } 7947 7948 // ----------------------------------------------------------------------- 7949 7950 Point Window::GetLastPointerPosPixel() 7951 { 7952 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7953 7954 Point aPos( mpWindowImpl->mpFrameData->mnBeforeLastMouseX, mpWindowImpl->mpFrameData->mnBeforeLastMouseY ); 7955 if( ImplIsAntiparallel() ) 7956 { 7957 // --- RTL --- (re-mirror mouse pos at this window) 7958 ImplReMirror( aPos ); 7959 } 7960 return ImplFrameToOutput( aPos ); 7961 } 7962 7963 // ----------------------------------------------------------------------- 7964 7965 void Window::ShowPointer( sal_Bool bVisible ) 7966 { 7967 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 7968 7969 if ( mpWindowImpl->mbNoPtrVisible != !bVisible ) 7970 { 7971 mpWindowImpl->mbNoPtrVisible = !bVisible; 7972 7973 // Pointer evt. direkt umsetzen 7974 if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() ) 7975 mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() ); 7976 } 7977 } 7978 7979 // ----------------------------------------------------------------------- 7980 7981 Window::PointerState Window::GetPointerState() 7982 { 7983 PointerState aState; 7984 aState.mnState = 0; 7985 7986 if (mpWindowImpl->mpFrame) 7987 { 7988 SalFrame::SalPointerState aSalPointerState; 7989 7990 aSalPointerState = mpWindowImpl->mpFrame->GetPointerState(); 7991 if( ImplIsAntiparallel() ) 7992 { 7993 // --- RTL --- (re-mirror mouse pos at this window) 7994 ImplReMirror( aSalPointerState.maPos ); 7995 } 7996 aState.maPos = ImplFrameToOutput( aSalPointerState.maPos ); 7997 aState.mnState = aSalPointerState.mnState; 7998 } 7999 return aState; 8000 } 8001 8002 // ----------------------------------------------------------------------- 8003 8004 sal_Bool Window::IsMouseOver() 8005 { 8006 return ImplGetWinData()->mbMouseOver; 8007 } 8008 8009 // ----------------------------------------------------------------------- 8010 8011 void Window::EnterWait() 8012 { 8013 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8014 8015 mpWindowImpl->mnWaitCount++; 8016 8017 if ( mpWindowImpl->mnWaitCount == 1 ) 8018 { 8019 // Pointer evt. direkt umsetzen 8020 if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() ) 8021 mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() ); 8022 } 8023 } 8024 8025 // ----------------------------------------------------------------------- 8026 8027 void Window::LeaveWait() 8028 { 8029 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8030 8031 if ( mpWindowImpl->mnWaitCount ) 8032 { 8033 mpWindowImpl->mnWaitCount--; 8034 8035 if ( !mpWindowImpl->mnWaitCount ) 8036 { 8037 // Pointer evt. direkt umsetzen 8038 if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() ) 8039 mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() ); 8040 } 8041 } 8042 } 8043 8044 // ----------------------------------------------------------------------- 8045 8046 void Window::SetCursor( Cursor* pCursor ) 8047 { 8048 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8049 8050 if ( mpWindowImpl->mpCursor != pCursor ) 8051 { 8052 if ( mpWindowImpl->mpCursor ) 8053 mpWindowImpl->mpCursor->ImplHide( true ); 8054 mpWindowImpl->mpCursor = pCursor; 8055 if ( pCursor ) 8056 pCursor->ImplShow(); 8057 } 8058 } 8059 8060 // ----------------------------------------------------------------------- 8061 8062 void Window::SetText( const XubString& rStr ) 8063 { 8064 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8065 8066 String oldTitle( mpWindowImpl->maText ); 8067 mpWindowImpl->maText = rStr; 8068 8069 if ( mpWindowImpl->mpBorderWindow ) 8070 mpWindowImpl->mpBorderWindow->SetText( rStr ); 8071 else if ( mpWindowImpl->mbFrame ) 8072 mpWindowImpl->mpFrame->SetTitle( rStr ); 8073 8074 ImplCallEventListeners( VCLEVENT_WINDOW_FRAMETITLECHANGED, &oldTitle ); 8075 8076 // #107247# needed for accessibility 8077 // The VCLEVENT_WINDOW_FRAMETITLECHANGED is (mis)used to notify accessible name changes. 8078 // Therefore a window, which is labeled by this window, must also notify an accessible 8079 // name change. 8080 if ( IsReallyVisible() ) 8081 { 8082 Window* pWindow = GetAccessibleRelationLabelFor(); 8083 if ( pWindow && pWindow != this ) 8084 pWindow->ImplCallEventListeners( VCLEVENT_WINDOW_FRAMETITLECHANGED, &oldTitle ); 8085 } 8086 8087 StateChanged( STATE_CHANGE_TEXT ); 8088 } 8089 8090 // ----------------------------------------------------------------------- 8091 8092 String Window::GetText() const 8093 { 8094 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8095 8096 return mpWindowImpl->maText; 8097 } 8098 8099 // ----------------------------------------------------------------------- 8100 8101 String Window::GetDisplayText() const 8102 { 8103 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8104 8105 return GetText(); 8106 } 8107 8108 // ----------------------------------------------------------------------- 8109 8110 const Wallpaper& Window::GetDisplayBackground() const 8111 { 8112 // FIXME: fix issue 52349, need to fix this really in 8113 // all NWF enabled controls 8114 const ToolBox* pTB = dynamic_cast<const ToolBox*>(this); 8115 if( pTB ) 8116 { 8117 if( IsNativeWidgetEnabled() ) 8118 return pTB->ImplGetToolBoxPrivateData()->maDisplayBackground; 8119 } 8120 8121 if( !IsBackground() ) 8122 { 8123 if( mpWindowImpl->mpParent ) 8124 return mpWindowImpl->mpParent->GetDisplayBackground(); 8125 } 8126 8127 const Wallpaper& rBack = GetBackground(); 8128 if( ! rBack.IsBitmap() && 8129 ! rBack.IsGradient() && 8130 rBack.GetColor().GetColor() == COL_TRANSPARENT && 8131 mpWindowImpl->mpParent ) 8132 return mpWindowImpl->mpParent->GetDisplayBackground(); 8133 return rBack; 8134 } 8135 8136 // ----------------------------------------------------------------------- 8137 8138 const XubString& Window::GetHelpText() const 8139 { 8140 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8141 8142 String aStrHelpId( rtl::OStringToOUString( GetHelpId(), RTL_TEXTENCODING_UTF8 ) ); 8143 bool bStrHelpId = (aStrHelpId.Len() > 0); 8144 8145 if ( !mpWindowImpl->maHelpText.Len() && bStrHelpId ) 8146 { 8147 if ( !IsDialog() && (mpWindowImpl->mnType != WINDOW_TABPAGE) && (mpWindowImpl->mnType != WINDOW_FLOATINGWINDOW) ) 8148 { 8149 Help* pHelp = Application::GetHelp(); 8150 if ( pHelp ) 8151 { 8152 ((Window*)this)->mpWindowImpl->maHelpText = pHelp->GetHelpText( aStrHelpId, this ); 8153 mpWindowImpl->mbHelpTextDynamic = sal_False; 8154 } 8155 } 8156 } 8157 else if( mpWindowImpl->mbHelpTextDynamic && bStrHelpId ) 8158 { 8159 static const char* pEnv = getenv( "HELP_DEBUG" ); 8160 if( pEnv && *pEnv ) 8161 { 8162 rtl::OUStringBuffer aTxt( 64+mpWindowImpl->maHelpText.Len() ); 8163 aTxt.append( mpWindowImpl->maHelpText ); 8164 aTxt.appendAscii( "\n------------------\n" ); 8165 aTxt.append( rtl::OUString( aStrHelpId ) ); 8166 mpWindowImpl->maHelpText = aTxt.makeStringAndClear(); 8167 } 8168 mpWindowImpl->mbHelpTextDynamic = sal_False; 8169 } 8170 8171 return mpWindowImpl->maHelpText; 8172 } 8173 8174 // ----------------------------------------------------------------------- 8175 8176 Window* Window::FindWindow( const Point& rPos ) const 8177 { 8178 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8179 8180 Point aPos = OutputToScreenPixel( rPos ); 8181 return ((Window*)this)->ImplFindWindow( aPos ); 8182 } 8183 8184 // ----------------------------------------------------------------------- 8185 8186 sal_uInt16 Window::GetChildCount() const 8187 { 8188 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8189 8190 sal_uInt16 nChildCount = 0; 8191 Window* pChild = mpWindowImpl->mpFirstChild; 8192 while ( pChild ) 8193 { 8194 nChildCount++; 8195 pChild = pChild->mpWindowImpl->mpNext; 8196 } 8197 8198 return nChildCount; 8199 } 8200 8201 // ----------------------------------------------------------------------- 8202 8203 Window* Window::GetChild( sal_uInt16 nChild ) const 8204 { 8205 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8206 8207 sal_uInt16 nChildCount = 0; 8208 Window* pChild = mpWindowImpl->mpFirstChild; 8209 while ( pChild ) 8210 { 8211 if ( nChild == nChildCount ) 8212 return pChild; 8213 pChild = pChild->mpWindowImpl->mpNext; 8214 nChildCount++; 8215 } 8216 8217 return NULL; 8218 } 8219 8220 // ----------------------------------------------------------------------- 8221 8222 Window* Window::GetWindow( sal_uInt16 nType ) const 8223 { 8224 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8225 8226 switch ( nType ) 8227 { 8228 case WINDOW_PARENT: 8229 return mpWindowImpl->mpRealParent; 8230 8231 case WINDOW_FIRSTCHILD: 8232 return mpWindowImpl->mpFirstChild; 8233 8234 case WINDOW_LASTCHILD: 8235 return mpWindowImpl->mpLastChild; 8236 8237 case WINDOW_PREV: 8238 return mpWindowImpl->mpPrev; 8239 8240 case WINDOW_NEXT: 8241 return mpWindowImpl->mpNext; 8242 8243 case WINDOW_FIRSTOVERLAP: 8244 return mpWindowImpl->mpFirstOverlap; 8245 8246 case WINDOW_LASTOVERLAP: 8247 return mpWindowImpl->mpLastOverlap; 8248 8249 case WINDOW_OVERLAP: 8250 if ( ImplIsOverlapWindow() ) 8251 return (Window*)this; 8252 else 8253 return mpWindowImpl->mpOverlapWindow; 8254 8255 case WINDOW_PARENTOVERLAP: 8256 if ( ImplIsOverlapWindow() ) 8257 return mpWindowImpl->mpOverlapWindow; 8258 else 8259 return mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpOverlapWindow; 8260 8261 case WINDOW_CLIENT: 8262 return ((Window*)this)->ImplGetWindow(); 8263 8264 case WINDOW_REALPARENT: 8265 return ImplGetParent(); 8266 8267 case WINDOW_FRAME: 8268 return mpWindowImpl->mpFrameWindow; 8269 8270 case WINDOW_BORDER: 8271 if ( mpWindowImpl->mpBorderWindow ) 8272 return mpWindowImpl->mpBorderWindow->GetWindow( WINDOW_BORDER ); 8273 return (Window*)this; 8274 8275 case WINDOW_FIRSTTOPWINDOWCHILD: 8276 return ImplGetWinData()->maTopWindowChildren.empty() ? NULL : *ImplGetWinData()->maTopWindowChildren.begin(); 8277 8278 case WINDOW_LASTTOPWINDOWCHILD: 8279 return ImplGetWinData()->maTopWindowChildren.empty() ? NULL : *ImplGetWinData()->maTopWindowChildren.rbegin(); 8280 8281 case WINDOW_PREVTOPWINDOWSIBLING: 8282 { 8283 if ( !mpWindowImpl->mpRealParent ) 8284 return NULL; 8285 const ::std::list< Window* >& rTopWindows( mpWindowImpl->mpRealParent->ImplGetWinData()->maTopWindowChildren ); 8286 ::std::list< Window* >::const_iterator myPos = 8287 ::std::find( rTopWindows.begin(), rTopWindows.end(), this ); 8288 if ( myPos == rTopWindows.end() ) 8289 return NULL; 8290 if ( myPos == rTopWindows.begin() ) 8291 return NULL; 8292 return *--myPos; 8293 } 8294 8295 case WINDOW_NEXTTOPWINDOWSIBLING: 8296 { 8297 if ( !mpWindowImpl->mpRealParent ) 8298 return NULL; 8299 const ::std::list< Window* >& rTopWindows( mpWindowImpl->mpRealParent->ImplGetWinData()->maTopWindowChildren ); 8300 ::std::list< Window* >::const_iterator myPos = 8301 ::std::find( rTopWindows.begin(), rTopWindows.end(), this ); 8302 if ( ( myPos == rTopWindows.end() ) || ( ++myPos == rTopWindows.end() ) ) 8303 return NULL; 8304 return *myPos; 8305 } 8306 8307 } 8308 8309 return NULL; 8310 } 8311 8312 // ----------------------------------------------------------------------- 8313 8314 sal_Bool Window::IsChild( const Window* pWindow, sal_Bool bSystemWindow ) const 8315 { 8316 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8317 DBG_CHKOBJ( pWindow, Window, ImplDbgCheckWindow ); 8318 8319 do 8320 { 8321 if ( !bSystemWindow && pWindow->ImplIsOverlapWindow() ) 8322 break; 8323 8324 pWindow = pWindow->ImplGetParent(); 8325 8326 if ( pWindow == this ) 8327 return sal_True; 8328 } 8329 while ( pWindow ); 8330 8331 return sal_False; 8332 } 8333 8334 // ----------------------------------------------------------------------- 8335 8336 sal_Bool Window::IsWindowOrChild( const Window* pWindow, sal_Bool bSystemWindow ) const 8337 { 8338 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8339 DBG_CHKOBJ( pWindow, Window, ImplDbgCheckWindow ); 8340 8341 if ( this == pWindow ) 8342 return sal_True; 8343 return ImplIsChild( pWindow, bSystemWindow ); 8344 } 8345 8346 // ----------------------------------------------------------------------- 8347 8348 const SystemEnvData* Window::GetSystemData() const 8349 { 8350 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8351 8352 return mpWindowImpl->mpFrame ? mpWindowImpl->mpFrame->GetSystemData() : NULL; 8353 } 8354 8355 ::com::sun::star::uno::Any Window::GetSystemDataAny() const 8356 { 8357 ::com::sun::star::uno::Any aRet; 8358 const SystemEnvData* pSysData = GetSystemData(); 8359 if( pSysData ) 8360 { 8361 ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( (sal_Int8*)pSysData, pSysData->nSize ); 8362 aRet <<= aSeq; 8363 } 8364 return aRet; 8365 } 8366 8367 // ----------------------------------------------------------------------- 8368 8369 void Window::SetWindowPeer( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xPeer, VCLXWindow* pVCLXWindow ) 8370 { 8371 // be safe against re-entrance: first clear the old ref, then assign the new one 8372 // #133706# / 2006-03-30 / frank.schoenheit@sun.com 8373 mpWindowImpl->mxWindowPeer.clear(); 8374 mpWindowImpl->mxWindowPeer = xPeer; 8375 8376 mpWindowImpl->mpVCLXWindow = pVCLXWindow; 8377 } 8378 8379 // ----------------------------------------------------------------------- 8380 8381 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > Window::GetComponentInterface( sal_Bool bCreate ) 8382 { 8383 if ( !mpWindowImpl->mxWindowPeer.is() && bCreate ) 8384 { 8385 UnoWrapperBase* pWrapper = Application::GetUnoWrapper(); 8386 if ( pWrapper ) 8387 mpWindowImpl->mxWindowPeer = pWrapper->GetWindowInterface( this, sal_True ); 8388 } 8389 return mpWindowImpl->mxWindowPeer; 8390 } 8391 8392 // ----------------------------------------------------------------------- 8393 8394 void Window::SetComponentInterface( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xIFace ) 8395 { 8396 UnoWrapperBase* pWrapper = Application::GetUnoWrapper(); 8397 DBG_ASSERT( pWrapper, "SetComponentInterface: No Wrapper!" ); 8398 if ( pWrapper ) 8399 pWrapper->SetWindowInterface( this, xIFace ); 8400 } 8401 8402 // ----------------------------------------------------------------------- 8403 8404 void Window::ImplCallDeactivateListeners( Window *pNew ) 8405 { 8406 // no deactivation if the the newly activated window is my child 8407 if ( !pNew || !ImplIsChild( pNew ) ) 8408 { 8409 ImplDelData aDogtag( this ); 8410 ImplCallEventListeners( VCLEVENT_WINDOW_DEACTIVATE ); 8411 if( aDogtag.IsDelete() ) 8412 return; 8413 8414 // #100759#, avoid walking the wrong frame's hierarchy 8415 // eg, undocked docking windows (ImplDockFloatWin) 8416 if ( ImplGetParent() && mpWindowImpl->mpFrameWindow == ImplGetParent()->mpWindowImpl->mpFrameWindow ) 8417 ImplGetParent()->ImplCallDeactivateListeners( pNew ); 8418 } 8419 } 8420 8421 // ----------------------------------------------------------------------- 8422 8423 void Window::ImplCallActivateListeners( Window *pOld ) 8424 { 8425 // no activation if the the old active window is my child 8426 if ( !pOld || !ImplIsChild( pOld ) ) 8427 { 8428 ImplDelData aDogtag( this ); 8429 ImplCallEventListeners( VCLEVENT_WINDOW_ACTIVATE, pOld ); 8430 if( aDogtag.IsDelete() ) 8431 return; 8432 8433 // #106298# revoke the change for 105369, because this change 8434 // disabled the activate event for the parent, 8435 // if the parent is a compound control 8436 //if( !GetParent() || !GetParent()->IsCompoundControl() ) 8437 //{ 8438 // #100759#, avoid walking the wrong frame's hierarchy 8439 // eg, undocked docking windows (ImplDockFloatWin) 8440 // #104714#, revert the changes for 100759 because it has a side effect when pOld is a dialog 8441 // additionally the gallery is not dockable anymore, so 100759 canot occur 8442 if ( ImplGetParent() ) /* && mpWindowImpl->mpFrameWindow == ImplGetParent()->mpWindowImpl->mpFrameWindow ) */ 8443 ImplGetParent()->ImplCallActivateListeners( pOld ); 8444 else if( (mpWindowImpl->mnStyle & WB_INTROWIN) == 0 ) 8445 { 8446 // top level frame reached: store hint for DefModalDialogParent 8447 ImplGetSVData()->maWinData.mpActiveApplicationFrame = mpWindowImpl->mpFrameWindow; 8448 } 8449 //} 8450 } 8451 } 8452 8453 // ----------------------------------------------------------------------- 8454 8455 bool Window::ImplStopDnd() 8456 { 8457 bool bRet = false; 8458 if( mpWindowImpl->mpFrameData && mpWindowImpl->mpFrameData->mxDropTargetListener.is() ) 8459 { 8460 bRet = true; 8461 mpWindowImpl->mpFrameData->mxDropTarget.clear(); 8462 mpWindowImpl->mpFrameData->mxDragSource.clear(); 8463 mpWindowImpl->mpFrameData->mxDropTargetListener.clear(); 8464 } 8465 8466 return bRet; 8467 } 8468 8469 // ----------------------------------------------------------------------- 8470 8471 void Window::ImplStartDnd() 8472 { 8473 GetDropTarget(); 8474 } 8475 8476 // ----------------------------------------------------------------------- 8477 8478 uno::Reference< XDropTarget > Window::GetDropTarget() 8479 { 8480 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8481 8482 if( ! mpWindowImpl->mxDNDListenerContainer.is() ) 8483 { 8484 sal_Int8 nDefaultActions = 0; 8485 8486 if( mpWindowImpl->mpFrameData ) 8487 { 8488 if( ! mpWindowImpl->mpFrameData->mxDropTarget.is() ) 8489 { 8490 // initialization is done in GetDragSource 8491 uno::Reference< XDragSource > xDragSource = GetDragSource(); 8492 } 8493 8494 if( mpWindowImpl->mpFrameData->mxDropTarget.is() ) 8495 { 8496 nDefaultActions = mpWindowImpl->mpFrameData->mxDropTarget->getDefaultActions(); 8497 8498 if( ! mpWindowImpl->mpFrameData->mxDropTargetListener.is() ) 8499 { 8500 mpWindowImpl->mpFrameData->mxDropTargetListener = new DNDEventDispatcher( mpWindowImpl->mpFrameWindow ); 8501 8502 try 8503 { 8504 mpWindowImpl->mpFrameData->mxDropTarget->addDropTargetListener( mpWindowImpl->mpFrameData->mxDropTargetListener ); 8505 8506 // register also as drag gesture listener if directly supported by drag source 8507 uno::Reference< XDragGestureRecognizer > xDragGestureRecognizer = 8508 uno::Reference< XDragGestureRecognizer > (mpWindowImpl->mpFrameData->mxDragSource, UNO_QUERY); 8509 8510 if( xDragGestureRecognizer.is() ) 8511 { 8512 xDragGestureRecognizer->addDragGestureListener( 8513 uno::Reference< XDragGestureListener > (mpWindowImpl->mpFrameData->mxDropTargetListener, UNO_QUERY)); 8514 } 8515 else 8516 mpWindowImpl->mpFrameData->mbInternalDragGestureRecognizer = sal_True; 8517 8518 } 8519 8520 catch( RuntimeException&) 8521 { 8522 // release all instances 8523 mpWindowImpl->mpFrameData->mxDropTarget.clear(); 8524 mpWindowImpl->mpFrameData->mxDragSource.clear(); 8525 } 8526 } 8527 } 8528 8529 } 8530 8531 mpWindowImpl->mxDNDListenerContainer = static_cast < XDropTarget * > ( new DNDListenerContainer( nDefaultActions ) ); 8532 } 8533 8534 // this object is located in the same process, so there will be no runtime exception 8535 return uno::Reference< XDropTarget > ( mpWindowImpl->mxDNDListenerContainer, UNO_QUERY ); 8536 } 8537 8538 // ----------------------------------------------------------------------- 8539 8540 uno::Reference< XDragSource > Window::GetDragSource() 8541 { 8542 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8543 8544 if( mpWindowImpl->mpFrameData ) 8545 { 8546 if( ! mpWindowImpl->mpFrameData->mxDragSource.is() ) 8547 { 8548 try 8549 { 8550 uno::Reference< XMultiServiceFactory > xFactory = vcl::unohelper::GetMultiServiceFactory(); 8551 if ( xFactory.is() ) 8552 { 8553 const SystemEnvData * pEnvData = GetSystemData(); 8554 8555 if( pEnvData ) 8556 { 8557 Sequence< Any > aDragSourceAL( 2 ), aDropTargetAL( 2 ); 8558 OUString aDragSourceSN, aDropTargetSN; 8559 #if defined WNT 8560 aDragSourceSN = OUString::createFromAscii( "com.sun.star.datatransfer.dnd.OleDragSource" ); 8561 aDropTargetSN = OUString::createFromAscii( "com.sun.star.datatransfer.dnd.OleDropTarget" ); 8562 aDragSourceAL[ 1 ] = makeAny( (sal_uInt32) pEnvData->hWnd ); 8563 aDropTargetAL[ 0 ] = makeAny( (sal_uInt32) pEnvData->hWnd ); 8564 #elif defined QUARTZ 8565 /* FIXME: Mac OS X specific dnd interface does not exist! * 8566 * Using Windows based dnd as a temporary solution */ 8567 aDragSourceSN = OUString::createFromAscii( "com.sun.star.datatransfer.dnd.OleDragSource" ); 8568 aDropTargetSN = OUString::createFromAscii( "com.sun.star.datatransfer.dnd.OleDropTarget" ); 8569 aDragSourceAL[ 1 ] = makeAny( static_cast<sal_uInt64>( reinterpret_cast<sal_IntPtr>(pEnvData->pView) ) ); 8570 aDropTargetAL[ 0 ] = makeAny( static_cast<sal_uInt64>( reinterpret_cast<sal_IntPtr>(pEnvData->pView) ) ); 8571 #elif defined UNX 8572 aDropTargetAL.realloc( 3 ); 8573 aDragSourceAL.realloc( 3 ); 8574 aDragSourceSN = OUString::createFromAscii( "com.sun.star.datatransfer.dnd.X11DragSource" ); 8575 aDropTargetSN = OUString::createFromAscii( "com.sun.star.datatransfer.dnd.X11DropTarget" ); 8576 8577 aDragSourceAL[ 0 ] = makeAny( Application::GetDisplayConnection() ); 8578 aDragSourceAL[ 2 ] = makeAny( vcl::createBmpConverter() ); 8579 aDropTargetAL[ 0 ] = makeAny( Application::GetDisplayConnection() ); 8580 aDropTargetAL[ 1 ] = makeAny( (sal_Size)(pEnvData->aShellWindow) ); 8581 aDropTargetAL[ 2 ] = makeAny( vcl::createBmpConverter() ); 8582 #endif 8583 if( aDragSourceSN.getLength() ) 8584 mpWindowImpl->mpFrameData->mxDragSource = uno::Reference< XDragSource > ( xFactory->createInstanceWithArguments( aDragSourceSN, aDragSourceAL ), UNO_QUERY ); 8585 8586 if( aDropTargetSN.getLength() ) 8587 mpWindowImpl->mpFrameData->mxDropTarget = uno::Reference< XDropTarget > ( xFactory->createInstanceWithArguments( aDropTargetSN, aDropTargetAL ), UNO_QUERY ); 8588 } 8589 } 8590 } 8591 8592 // createInstance can throw any exception 8593 catch( Exception&) 8594 { 8595 // release all instances 8596 mpWindowImpl->mpFrameData->mxDropTarget.clear(); 8597 mpWindowImpl->mpFrameData->mxDragSource.clear(); 8598 } 8599 } 8600 8601 return mpWindowImpl->mpFrameData->mxDragSource; 8602 } 8603 8604 return uno::Reference< XDragSource > (); 8605 } 8606 8607 // ----------------------------------------------------------------------- 8608 8609 void Window::GetDragSourceDropTarget(uno::Reference< XDragSource >& xDragSource, uno::Reference< XDropTarget > &xDropTarget ) 8610 // only for RVP transmission 8611 { 8612 if( mpWindowImpl->mpFrameData ) 8613 { 8614 // initialization is done in GetDragSource 8615 xDragSource = GetDragSource(); 8616 xDropTarget = mpWindowImpl->mpFrameData->mxDropTarget; 8617 } 8618 else 8619 { 8620 xDragSource.clear(); 8621 xDropTarget.clear(); 8622 } 8623 } 8624 8625 // ----------------------------------------------------------------------- 8626 8627 uno::Reference< XDragGestureRecognizer > Window::GetDragGestureRecognizer() 8628 { 8629 return uno::Reference< XDragGestureRecognizer > ( GetDropTarget(), UNO_QUERY ); 8630 } 8631 8632 // ----------------------------------------------------------------------- 8633 8634 uno::Reference< XClipboard > Window::GetClipboard() 8635 { 8636 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8637 8638 if( mpWindowImpl->mpFrameData ) 8639 { 8640 if( ! mpWindowImpl->mpFrameData->mxClipboard.is() ) 8641 { 8642 try 8643 { 8644 uno::Reference< XMultiServiceFactory > xFactory( vcl::unohelper::GetMultiServiceFactory() ); 8645 8646 if( xFactory.is() ) 8647 { 8648 mpWindowImpl->mpFrameData->mxClipboard = uno::Reference< XClipboard >( xFactory->createInstance( OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.SystemClipboardExt" ) ), UNO_QUERY ); 8649 8650 if( !mpWindowImpl->mpFrameData->mxClipboard.is() ) 8651 mpWindowImpl->mpFrameData->mxClipboard = uno::Reference< XClipboard >( xFactory->createInstance( OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.SystemClipboard" ) ), UNO_QUERY ); 8652 8653 #if defined(UNX) && !defined(QUARTZ) // unix clipboard needs to be initialized 8654 if( mpWindowImpl->mpFrameData->mxClipboard.is() ) 8655 { 8656 uno::Reference< XInitialization > xInit = uno::Reference< XInitialization >( mpWindowImpl->mpFrameData->mxClipboard, UNO_QUERY ); 8657 8658 if( xInit.is() ) 8659 { 8660 Sequence< Any > aArgumentList( 3 ); 8661 aArgumentList[ 0 ] = makeAny( Application::GetDisplayConnection() ); 8662 aArgumentList[ 1 ] = makeAny( OUString::createFromAscii( "CLIPBOARD" ) ); 8663 aArgumentList[ 2 ] = makeAny( vcl::createBmpConverter() ); 8664 8665 xInit->initialize( aArgumentList ); 8666 } 8667 } 8668 #endif 8669 } 8670 } 8671 8672 // createInstance can throw any exception 8673 catch( Exception&) 8674 { 8675 // release all instances 8676 mpWindowImpl->mpFrameData->mxClipboard.clear(); 8677 } 8678 } 8679 8680 return mpWindowImpl->mpFrameData->mxClipboard; 8681 } 8682 8683 return static_cast < XClipboard * > (0); 8684 } 8685 8686 // ----------------------------------------------------------------------- 8687 8688 uno::Reference< XClipboard > Window::GetPrimarySelection() 8689 { 8690 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8691 8692 if( mpWindowImpl->mpFrameData ) 8693 { 8694 if( ! mpWindowImpl->mpFrameData->mxSelection.is() ) 8695 { 8696 try 8697 { 8698 uno::Reference< XMultiServiceFactory > xFactory( vcl::unohelper::GetMultiServiceFactory() ); 8699 8700 if( xFactory.is() ) 8701 { 8702 #if defined(UNX) && !defined(QUARTZ) 8703 Sequence< Any > aArgumentList( 3 ); 8704 aArgumentList[ 0 ] = makeAny( Application::GetDisplayConnection() ); 8705 aArgumentList[ 1 ] = makeAny( OUString::createFromAscii( "PRIMARY" ) ); 8706 aArgumentList[ 2 ] = makeAny( vcl::createBmpConverter() ); 8707 8708 mpWindowImpl->mpFrameData->mxSelection = uno::Reference< XClipboard >( xFactory->createInstanceWithArguments( 8709 OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.SystemClipboard" ), aArgumentList ), UNO_QUERY ); 8710 # else 8711 static uno::Reference< XClipboard > s_xSelection; 8712 8713 if ( !s_xSelection.is() ) 8714 s_xSelection = uno::Reference< XClipboard >( xFactory->createInstance( OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.GenericClipboardExt" ) ), UNO_QUERY ); 8715 8716 if ( !s_xSelection.is() ) 8717 s_xSelection = uno::Reference< XClipboard >( xFactory->createInstance( OUString::createFromAscii( "com.sun.star.datatransfer.clipboard.GenericClipboard" ) ), UNO_QUERY ); 8718 8719 mpWindowImpl->mpFrameData->mxSelection = s_xSelection; 8720 # endif 8721 } 8722 } 8723 8724 // createInstance can throw any exception 8725 catch( Exception&) 8726 { 8727 // release all instances 8728 mpWindowImpl->mpFrameData->mxSelection.clear(); 8729 } 8730 } 8731 8732 return mpWindowImpl->mpFrameData->mxSelection; 8733 } 8734 8735 return static_cast < XClipboard * > (0); 8736 } 8737 8738 // ----------------------------------------------------------------------- 8739 // Accessibility 8740 // ----------------------------------------------------------------------- 8741 8742 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > Window::GetAccessible( sal_Bool bCreate ) 8743 { 8744 // do not optimize hierarchy for the top level border win (ie, when there is no parent) 8745 /* // do not optimize accessible hierarchy at all to better reflect real VCL hierarchy 8746 if ( GetParent() && ( GetType() == WINDOW_BORDERWINDOW ) && ( GetChildCount() == 1 ) ) 8747 //if( !ImplIsAccessibleCandidate() ) 8748 { 8749 Window* pChild = GetAccessibleChildWindow( 0 ); 8750 if ( pChild ) 8751 return pChild->GetAccessible(); 8752 } 8753 */ 8754 if ( !mpWindowImpl->mxAccessible.is() && bCreate ) 8755 mpWindowImpl->mxAccessible = CreateAccessible(); 8756 8757 return mpWindowImpl->mxAccessible; 8758 } 8759 8760 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > Window::CreateAccessible() 8761 { 8762 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAcc( GetComponentInterface( sal_True ), ::com::sun::star::uno::UNO_QUERY ); 8763 return xAcc; 8764 } 8765 8766 void Window::SetAccessible( ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > x ) 8767 { 8768 mpWindowImpl->mxAccessible = x; 8769 } 8770 8771 // skip all border windows that are no top level frames 8772 sal_Bool Window::ImplIsAccessibleCandidate() const 8773 { 8774 if( !mpWindowImpl->mbBorderWin ) 8775 return sal_True; 8776 else 8777 // #101741 do not check for WB_CLOSEABLE because undecorated floaters (like menues!) are closeable 8778 if( mpWindowImpl->mbFrame && mpWindowImpl->mnStyle & (WB_MOVEABLE | WB_SIZEABLE) ) 8779 return sal_True; 8780 else 8781 return sal_False; 8782 } 8783 8784 sal_Bool Window::ImplIsAccessibleNativeFrame() const 8785 { 8786 if( mpWindowImpl->mbFrame ) 8787 // #101741 do not check for WB_CLOSEABLE because undecorated floaters (like menues!) are closeable 8788 if( (mpWindowImpl->mnStyle & (WB_MOVEABLE | WB_SIZEABLE)) ) 8789 return sal_True; 8790 else 8791 return sal_False; 8792 else 8793 return sal_False; 8794 } 8795 8796 sal_uInt16 Window::ImplGetAccessibleCandidateChildWindowCount( sal_uInt16 nFirstWindowType ) const 8797 { 8798 sal_uInt16 nChildren = 0; 8799 Window* pChild = GetWindow( nFirstWindowType ); 8800 while ( pChild ) 8801 { 8802 if( pChild->ImplIsAccessibleCandidate() ) 8803 nChildren++; 8804 else 8805 nChildren = sal::static_int_cast<sal_uInt16>(nChildren + pChild->ImplGetAccessibleCandidateChildWindowCount( WINDOW_FIRSTCHILD )); 8806 pChild = pChild->mpWindowImpl->mpNext; 8807 } 8808 return nChildren; 8809 } 8810 8811 Window* Window::ImplGetAccessibleCandidateChild( sal_uInt16 nChild, sal_uInt16& rChildCount, sal_uInt16 nFirstWindowType, sal_Bool bTopLevel ) const 8812 { 8813 DBG_CHKTHIS( Window, ImplDbgCheckWindow ); 8814 8815 if( bTopLevel ) 8816 rChildCount = 0; 8817 8818 Window* pChild = GetWindow( nFirstWindowType ); 8819 while ( pChild ) 8820 { 8821 Window *pTmpChild = pChild; 8822 8823 if( !pChild->ImplIsAccessibleCandidate() ) 8824 pTmpChild = pChild->ImplGetAccessibleCandidateChild( nChild, rChildCount, WINDOW_FIRSTCHILD, sal_False ); 8825 8826 if ( nChild == rChildCount ) 8827 return pTmpChild; 8828 pChild = pChild->mpWindowImpl->mpNext; 8829 rChildCount++; 8830 } 8831 8832 return NULL; 8833 } 8834 8835 /* 8836 Window* Window::GetAccessibleParentWindow() const 8837 { 8838 Window* pParent = GetParent(); 8839 while ( pParent ) 8840 if( pParent->ImplIsAccessibleCandidate() ) 8841 break; 8842 else 8843 pParent = pParent->GetParent(); 8844 return pParent; 8845 } 8846 */ 8847 8848 Window* Window::GetAccessibleParentWindow() const 8849 { 8850 if ( ImplIsAccessibleNativeFrame() ) 8851 return NULL; 8852 8853 Window* pParent = mpWindowImpl->mpParent; 8854 if( GetType() == WINDOW_MENUBARWINDOW ) 8855 { 8856 // report the menubar as a child of THE workwindow 8857 Window *pWorkWin = GetParent()->mpWindowImpl->mpFirstChild; 8858 while( pWorkWin && (pWorkWin == this) ) 8859 pWorkWin = pWorkWin->mpWindowImpl->mpNext; 8860 pParent = pWorkWin; 8861 } 8862 // If this a floating window which has a native boarder window, this one should be reported as 8863 // accessible parent 8864 else if( GetType() == WINDOW_FLOATINGWINDOW && 8865 mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame) 8866 { 8867 pParent = mpWindowImpl->mpBorderWindow; 8868 } 8869 else if( pParent && !pParent->ImplIsAccessibleCandidate() ) 8870 { 8871 pParent = pParent->mpWindowImpl->mpParent; 8872 } 8873 return pParent; 8874 } 8875 8876 /* 8877 sal_uInt16 Window::GetAccessibleChildWindowCount() 8878 { 8879 sal_uInt16 nChildren = ImplGetAccessibleCandidateChildWindowCount( WINDOW_FIRSTCHILD ); 8880 8881 // Search also for SystemWindows. 8882 Window* pOverlap = GetWindow( WINDOW_OVERLAP ); 8883 nChildren += pOverlap->ImplGetAccessibleCandidateChildWindowCount( WINDOW_FIRSTOVERLAP ); 8884 8885 return nChildren; 8886 } 8887 */ 8888 8889 sal_uInt16 Window::GetAccessibleChildWindowCount() 8890 { 8891 sal_uInt16 nChildren = 0; 8892 Window* pChild = mpWindowImpl->mpFirstChild; 8893 while( pChild ) 8894 { 8895 if( pChild->IsVisible() ) 8896 nChildren++; 8897 pChild = pChild->mpWindowImpl->mpNext; 8898 } 8899 8900 // #107176# ignore overlapwindows 8901 // this only affects non-system floating windows 8902 // which are either not accessible (like the HelpAgent) or should be changed to system windows anyway 8903 /* 8904 if( ImplIsOverlapWindow() ) 8905 { 8906 Window* pOverlap = GetWindow( WINDOW_FIRSTOVERLAP ); 8907 while ( pOverlap ) 8908 { 8909 if( pOverlap->IsVisible() ) 8910 nChildren++; 8911 pOverlap = pOverlap->GetWindow( WINDOW_NEXT ); 8912 } 8913 } 8914 */ 8915 8916 // report the menubarwindow as a child of THE workwindow 8917 if( GetType() == WINDOW_BORDERWINDOW ) 8918 { 8919 if( ((ImplBorderWindow *) this)->mpMenuBarWindow && 8920 ((ImplBorderWindow *) this)->mpMenuBarWindow->IsVisible() 8921 ) 8922 --nChildren; 8923 } 8924 else if( GetType() == WINDOW_WORKWINDOW ) 8925 { 8926 if( ((WorkWindow *) this)->GetMenuBar() && 8927 ((WorkWindow *) this)->GetMenuBar()->GetWindow() && 8928 ((WorkWindow *) this)->GetMenuBar()->GetWindow()->IsVisible() 8929 ) 8930 ++nChildren; 8931 } 8932 8933 return nChildren; 8934 } 8935 8936 /* 8937 Window* Window::GetAccessibleChildWindow( sal_uInt16 n ) 8938 { 8939 sal_uInt16 nChildCount; // will be set in ImplGetAccessibleCandidateChild(...) 8940 Window* pChild = ImplGetAccessibleCandidateChild( n, nChildCount, WINDOW_FIRSTCHILD, sal_True ); 8941 if ( !pChild && ( n >= nChildCount ) ) 8942 { 8943 Window* pOverlap = GetWindow( WINDOW_OVERLAP ); 8944 pChild = pOverlap->ImplGetAccessibleCandidateChild( n, nChildCount, WINDOW_FIRSTOVERLAP, sal_False ); 8945 } 8946 8947 return pChild; 8948 } 8949 */ 8950 8951 Window* Window::GetAccessibleChildWindow( sal_uInt16 n ) 8952 { 8953 // report the menubarwindow as a the first child of THE workwindow 8954 if( GetType() == WINDOW_WORKWINDOW && ((WorkWindow *) this)->GetMenuBar() ) 8955 { 8956 if( n == 0 ) 8957 { 8958 MenuBar *pMenuBar = ((WorkWindow *) this)->GetMenuBar(); 8959 if( pMenuBar->GetWindow() && pMenuBar->GetWindow()->IsVisible() ) 8960 return pMenuBar->GetWindow(); 8961 } 8962 else 8963 --n; 8964 } 8965 8966 // transform n to child number including invisible children 8967 sal_uInt16 nChildren = n; 8968 Window* pChild = mpWindowImpl->mpFirstChild; 8969 while( pChild ) 8970 { 8971 if( pChild->IsVisible() ) 8972 { 8973 if( ! nChildren ) 8974 break; 8975 nChildren--; 8976 } 8977 pChild = pChild->mpWindowImpl->mpNext; 8978 } 8979 8980 if( GetType() == WINDOW_BORDERWINDOW && pChild && pChild->GetType() == WINDOW_MENUBARWINDOW ) 8981 { 8982 do pChild = pChild->mpWindowImpl->mpNext; while( pChild && ! pChild->IsVisible() ); 8983 DBG_ASSERT( pChild, "GetAccessibleChildWindow(): wrong index in border window"); 8984 } 8985 if ( !pChild ) 8986 { 8987 // #107176# ignore overlapwindows 8988 /* 8989 if( ImplIsOverlapWindow() ) 8990 { 8991 Window* pOverlap = GetWindow( WINDOW_FIRSTOVERLAP ); 8992 while ( !pChild && pOverlap ) 8993 { 8994 if ( !nChildren && pOverlap->IsVisible() ) 8995 { 8996 pChild = pOverlap; 8997 break; 8998 } 8999 pOverlap = pOverlap->GetWindow( WINDOW_NEXT ); 9000 if( pOverlap && pOverlap->IsVisible() ) 9001 nChildren--; 9002 } 9003 } 9004 */ 9005 9006 } 9007 if ( pChild && ( pChild->GetType() == WINDOW_BORDERWINDOW ) && ( pChild->GetChildCount() == 1 ) ) 9008 { 9009 pChild = pChild->GetChild( 0 ); 9010 } 9011 return pChild; 9012 } 9013 9014 9015 void Window::SetAccessibleRole( sal_uInt16 nRole ) 9016 { 9017 if ( !mpWindowImpl->mpAccessibleInfos ) 9018 mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; 9019 9020 DBG_ASSERT( mpWindowImpl->mpAccessibleInfos->nAccessibleRole == 0xFFFF, "AccessibleRole already set!" ); 9021 mpWindowImpl->mpAccessibleInfos->nAccessibleRole = nRole; 9022 } 9023 9024 sal_uInt16 Window::GetAccessibleRole() const 9025 { 9026 using namespace ::com::sun::star; 9027 9028 sal_uInt16 nRole = mpWindowImpl->mpAccessibleInfos ? mpWindowImpl->mpAccessibleInfos->nAccessibleRole : 0xFFFF; 9029 if ( nRole == 0xFFFF ) 9030 { 9031 switch ( GetType() ) 9032 { 9033 case WINDOW_MESSBOX: // MT: Would be nice to have special roles! 9034 case WINDOW_INFOBOX: 9035 case WINDOW_WARNINGBOX: 9036 case WINDOW_ERRORBOX: 9037 case WINDOW_QUERYBOX: nRole = accessibility::AccessibleRole::ALERT; break; 9038 9039 case WINDOW_MODELESSDIALOG: 9040 case WINDOW_MODALDIALOG: 9041 case WINDOW_SYSTEMDIALOG: 9042 case WINDOW_PRINTERSETUPDIALOG: 9043 case WINDOW_PRINTDIALOG: 9044 case WINDOW_TABDIALOG: 9045 case WINDOW_BUTTONDIALOG: 9046 case WINDOW_DIALOG: nRole = accessibility::AccessibleRole::DIALOG; break; 9047 9048 case WINDOW_PUSHBUTTON: 9049 case WINDOW_OKBUTTON: 9050 case WINDOW_CANCELBUTTON: 9051 case WINDOW_HELPBUTTON: 9052 case WINDOW_IMAGEBUTTON: 9053 case WINDOW_MENUBUTTON: 9054 case WINDOW_MOREBUTTON: 9055 case WINDOW_SPINBUTTON: 9056 case WINDOW_BUTTON: nRole = accessibility::AccessibleRole::PUSH_BUTTON; break; 9057 9058 case WINDOW_PATHDIALOG: nRole = accessibility::AccessibleRole::DIRECTORY_PANE; break; 9059 case WINDOW_FILEDIALOG: nRole = accessibility::AccessibleRole::FILE_CHOOSER; break; 9060 case WINDOW_COLORDIALOG: nRole = accessibility::AccessibleRole::COLOR_CHOOSER; break; 9061 case WINDOW_FONTDIALOG: nRole = accessibility::AccessibleRole::FONT_CHOOSER; break; 9062 9063 case WINDOW_IMAGERADIOBUTTON: 9064 case WINDOW_RADIOBUTTON: nRole = accessibility::AccessibleRole::RADIO_BUTTON; break; 9065 case WINDOW_TRISTATEBOX: 9066 case WINDOW_CHECKBOX: nRole = accessibility::AccessibleRole::CHECK_BOX; break; 9067 9068 case WINDOW_MULTILINEEDIT: nRole = accessibility::AccessibleRole::SCROLL_PANE; break; 9069 9070 case WINDOW_PATTERNFIELD: 9071 case WINDOW_NUMERICFIELD: 9072 case WINDOW_METRICFIELD: 9073 case WINDOW_CURRENCYFIELD: 9074 case WINDOW_LONGCURRENCYFIELD: 9075 case WINDOW_EDIT: nRole = ( GetStyle() & WB_PASSWORD ) ? (accessibility::AccessibleRole::PASSWORD_TEXT) : (accessibility::AccessibleRole::TEXT); break; 9076 9077 case WINDOW_PATTERNBOX: 9078 case WINDOW_NUMERICBOX: 9079 case WINDOW_METRICBOX: 9080 case WINDOW_CURRENCYBOX: 9081 case WINDOW_LONGCURRENCYBOX: 9082 case WINDOW_COMBOBOX: nRole = accessibility::AccessibleRole::COMBO_BOX; break; 9083 9084 case WINDOW_LISTBOX: 9085 case WINDOW_MULTILISTBOX: nRole = accessibility::AccessibleRole::LIST; break; 9086 9087 case WINDOW_TREELISTBOX: nRole = accessibility::AccessibleRole::TREE; break; 9088 9089 case WINDOW_FIXEDTEXT: nRole = accessibility::AccessibleRole::LABEL; break; 9090 case WINDOW_FIXEDBORDER: 9091 case WINDOW_FIXEDLINE: nRole = accessibility::AccessibleRole::SEPARATOR; break; 9092 case WINDOW_FIXEDBITMAP: 9093 case WINDOW_FIXEDIMAGE: nRole = accessibility::AccessibleRole::ICON; break; 9094 case WINDOW_GROUPBOX: nRole = accessibility::AccessibleRole::GROUP_BOX; break; 9095 case WINDOW_SCROLLBAR: nRole = accessibility::AccessibleRole::SCROLL_BAR; break; 9096 9097 case WINDOW_SLIDER: 9098 case WINDOW_SPLITTER: 9099 case WINDOW_SPLITWINDOW: nRole = accessibility::AccessibleRole::SPLIT_PANE; break; 9100 9101 case WINDOW_DATEBOX: 9102 case WINDOW_TIMEBOX: 9103 case WINDOW_DATEFIELD: 9104 case WINDOW_TIMEFIELD: nRole = accessibility::AccessibleRole::DATE_EDITOR; break; 9105 9106 case WINDOW_SPINFIELD: nRole = accessibility::AccessibleRole::SPIN_BOX; break; 9107 9108 case WINDOW_TOOLBOX: nRole = accessibility::AccessibleRole::TOOL_BAR; break; 9109 case WINDOW_STATUSBAR: nRole = accessibility::AccessibleRole::STATUS_BAR; break; 9110 9111 case WINDOW_TABPAGE: nRole = accessibility::AccessibleRole::PANEL; break; 9112 case WINDOW_TABCONTROL: nRole = accessibility::AccessibleRole::PAGE_TAB_LIST; break; 9113 9114 case WINDOW_DOCKINGWINDOW: 9115 case WINDOW_SYSWINDOW: nRole = (mpWindowImpl->mbFrame) ? accessibility::AccessibleRole::FRAME : 9116 accessibility::AccessibleRole::PANEL; break; 9117 9118 case WINDOW_FLOATINGWINDOW: nRole = ( mpWindowImpl->mbFrame || 9119 (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame) || 9120 (GetStyle() & WB_OWNERDRAWDECORATION) ) ? accessibility::AccessibleRole::FRAME : 9121 accessibility::AccessibleRole::WINDOW; break; 9122 9123 case WINDOW_WORKWINDOW: nRole = accessibility::AccessibleRole::ROOT_PANE; break; 9124 9125 9126 case WINDOW_SCROLLBARBOX: nRole = accessibility::AccessibleRole::FILLER; break; 9127 9128 case WINDOW_HELPTEXTWINDOW: nRole = accessibility::AccessibleRole::TOOL_TIP; break; 9129 9130 case WINDOW_RULER: nRole = accessibility::AccessibleRole::RULER; break; 9131 case WINDOW_WINDOW: 9132 case WINDOW_CONTROL: 9133 case WINDOW_BORDERWINDOW: 9134 case WINDOW_SYSTEMCHILDWINDOW: 9135 default: 9136 if (ImplIsAccessibleNativeFrame() ) 9137 nRole = accessibility::AccessibleRole::FRAME; 9138 else if( IsScrollable() ) 9139 nRole = accessibility::AccessibleRole::SCROLL_PANE; 9140 else if( ((Window*)this)->ImplGetWindow()->IsMenuFloatingWindow() ) 9141 nRole = accessibility::AccessibleRole::WINDOW; // #106002#, contextmenues are windows (i.e. toplevel) 9142 else 9143 // #104051# WINDOW seems to be a bad default role, use LAYEREDPANE instead 9144 // a WINDOW is interpreted as a top-level window, which is typically not the case 9145 //nRole = accessibility::AccessibleRole::WINDOW; 9146 nRole = accessibility::AccessibleRole::PANEL; 9147 } 9148 } 9149 return nRole; 9150 } 9151 9152 void Window::SetAccessibleName( const String& rName ) 9153 { 9154 if ( !mpWindowImpl->mpAccessibleInfos ) 9155 mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; 9156 9157 delete mpWindowImpl->mpAccessibleInfos->pAccessibleName; 9158 mpWindowImpl->mpAccessibleInfos->pAccessibleName = new String( rName ); 9159 } 9160 9161 String Window::GetAccessibleName() const 9162 { 9163 String aAccessibleName; 9164 if ( mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pAccessibleName ) 9165 { 9166 aAccessibleName = *mpWindowImpl->mpAccessibleInfos->pAccessibleName; 9167 } 9168 else 9169 { 9170 switch ( GetType() ) 9171 { 9172 // case WINDOW_IMAGERADIOBUTTON: 9173 // case WINDOW_RADIOBUTTON: 9174 // case WINDOW_TRISTATEBOX: 9175 // case WINDOW_CHECKBOX: 9176 9177 case WINDOW_MULTILINEEDIT: 9178 case WINDOW_PATTERNFIELD: 9179 case WINDOW_NUMERICFIELD: 9180 case WINDOW_METRICFIELD: 9181 case WINDOW_CURRENCYFIELD: 9182 case WINDOW_LONGCURRENCYFIELD: 9183 case WINDOW_EDIT: 9184 9185 case WINDOW_DATEBOX: 9186 case WINDOW_TIMEBOX: 9187 case WINDOW_CURRENCYBOX: 9188 case WINDOW_LONGCURRENCYBOX: 9189 case WINDOW_DATEFIELD: 9190 case WINDOW_TIMEFIELD: 9191 case WINDOW_SPINFIELD: 9192 9193 case WINDOW_COMBOBOX: 9194 case WINDOW_LISTBOX: 9195 case WINDOW_MULTILISTBOX: 9196 case WINDOW_TREELISTBOX: 9197 case WINDOW_METRICBOX: 9198 { 9199 Window *pLabel = GetAccessibleRelationLabeledBy(); 9200 if ( pLabel && pLabel != this ) 9201 aAccessibleName = pLabel->GetText(); 9202 } 9203 break; 9204 9205 case WINDOW_IMAGEBUTTON: 9206 case WINDOW_PUSHBUTTON: 9207 aAccessibleName = GetText(); 9208 if ( !aAccessibleName.Len() ) 9209 { 9210 aAccessibleName = GetQuickHelpText(); 9211 if ( !aAccessibleName.Len() ) 9212 aAccessibleName = GetHelpText(); 9213 } 9214 break; 9215 9216 default: 9217 aAccessibleName = GetText(); 9218 break; 9219 } 9220 9221 aAccessibleName = GetNonMnemonicString( aAccessibleName ); 9222 } 9223 9224 return aAccessibleName; 9225 } 9226 9227 void Window::SetAccessibleDescription( const String& rDescription ) 9228 { 9229 if ( ! mpWindowImpl->mpAccessibleInfos ) 9230 mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; 9231 9232 DBG_ASSERT( !mpWindowImpl->mpAccessibleInfos->pAccessibleDescription, "AccessibleDescription already set!" ); 9233 delete mpWindowImpl->mpAccessibleInfos->pAccessibleDescription; 9234 mpWindowImpl->mpAccessibleInfos->pAccessibleDescription = new String( rDescription ); 9235 } 9236 9237 String Window::GetAccessibleDescription() const 9238 { 9239 String aAccessibleDescription; 9240 if ( mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pAccessibleDescription ) 9241 { 9242 aAccessibleDescription = *mpWindowImpl->mpAccessibleInfos->pAccessibleDescription; 9243 } 9244 else 9245 { 9246 // Special code for help text windows. ZT asks the border window for the 9247 // description so we have to forward this request to our inner window. 9248 const Window* pWin = ((Window *)this)->ImplGetWindow(); 9249 if ( pWin->GetType() == WINDOW_HELPTEXTWINDOW ) 9250 aAccessibleDescription = pWin->GetHelpText(); 9251 else 9252 aAccessibleDescription = GetHelpText(); 9253 } 9254 9255 return aAccessibleDescription; 9256 } 9257 9258 void Window::SetAccessibleRelationLabeledBy( Window* pLabeledBy ) 9259 { 9260 if ( !mpWindowImpl->mpAccessibleInfos ) 9261 mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; 9262 mpWindowImpl->mpAccessibleInfos->pLabeledByWindow = pLabeledBy; 9263 } 9264 9265 void Window::SetAccessibleRelationLabelFor( Window* pLabelFor ) 9266 { 9267 if ( !mpWindowImpl->mpAccessibleInfos ) 9268 mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; 9269 mpWindowImpl->mpAccessibleInfos->pLabelForWindow = pLabelFor; 9270 } 9271 9272 void Window::SetAccessibleRelationMemberOf( Window* pMemberOfWin ) 9273 { 9274 if ( !mpWindowImpl->mpAccessibleInfos ) 9275 mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; 9276 mpWindowImpl->mpAccessibleInfos->pMemberOfWindow = pMemberOfWin; 9277 } 9278 9279 sal_Bool Window::IsAccessibilityEventsSuppressed( sal_Bool bTraverseParentPath ) 9280 { 9281 if( !bTraverseParentPath ) 9282 return mpWindowImpl->mbSuppressAccessibilityEvents; 9283 else 9284 { 9285 Window *pParent = this; 9286 while ( pParent && pParent->mpWindowImpl) 9287 { 9288 if( pParent->mpWindowImpl->mbSuppressAccessibilityEvents ) 9289 return sal_True; 9290 else 9291 pParent = pParent->mpWindowImpl->mpParent; // do not use GetParent() to find borderwindows that are frames 9292 } 9293 return sal_False; 9294 } 9295 } 9296 9297 void Window::SetAccessibilityEventsSuppressed(sal_Bool bSuppressed) 9298 { 9299 mpWindowImpl->mbSuppressAccessibilityEvents = bSuppressed; 9300 } 9301 9302 void Window::RecordLayoutData( vcl::ControlLayoutData* pLayout, const Rectangle& rRect ) 9303 { 9304 if( ! mpOutDevData ) 9305 ImplInitOutDevData(); 9306 mpOutDevData->mpRecordLayout = pLayout; 9307 mpOutDevData->maRecordRect = rRect; 9308 Paint( rRect ); 9309 mpOutDevData->mpRecordLayout = NULL; 9310 } 9311 9312 // ----------------------------------------------------------------------- 9313 // ----------------------------------------------------------------------- 9314 9315 9316 // returns background color used in this control 9317 // false: could not determine color 9318 sal_Bool Window::ImplGetCurrentBackgroundColor( Color& rCol ) 9319 { 9320 sal_Bool bRet = sal_True; 9321 9322 switch ( GetType() ) 9323 { 9324 // peform special handling here 9325 case WINDOW_PUSHBUTTON: 9326 case WINDOW_OKBUTTON: 9327 case WINDOW_CANCELBUTTON: 9328 // etc. 9329 default: 9330 if( IsControlBackground() ) 9331 rCol = GetControlBackground(); 9332 else if( IsBackground() ) 9333 { 9334 Wallpaper aWall = GetBackground(); 9335 if( !aWall.IsGradient() && !aWall.IsBitmap() ) 9336 rCol = aWall.GetColor(); 9337 else 9338 bRet = sal_False; 9339 } 9340 else 9341 rCol = GetSettings().GetStyleSettings().GetFaceColor(); 9342 break; 9343 } 9344 return bRet; 9345 } 9346 9347 void Window::DrawSelectionBackground( const Rectangle& rRect, sal_uInt16 highlight, sal_Bool bChecked, sal_Bool bDrawBorder, sal_Bool bDrawExtBorderOnly ) 9348 { 9349 DrawSelectionBackground( rRect, highlight, bChecked, bDrawBorder, bDrawExtBorderOnly, 0, NULL, NULL ); 9350 } 9351 9352 void Window::DrawSelectionBackground( const Rectangle& rRect, sal_uInt16 highlight, sal_Bool bChecked, sal_Bool bDrawBorder, sal_Bool bDrawExtBorderOnly, Color* pSelectionTextColor ) 9353 { 9354 DrawSelectionBackground( rRect, highlight, bChecked, bDrawBorder, bDrawExtBorderOnly, 0, pSelectionTextColor, NULL ); 9355 } 9356 9357 void Window::DrawSelectionBackground( const Rectangle& rRect, 9358 sal_uInt16 highlight, 9359 sal_Bool bChecked, 9360 sal_Bool bDrawBorder, 9361 sal_Bool bDrawExtBorderOnly, 9362 long nCornerRadius, 9363 Color* pSelectionTextColor, 9364 Color* pPaintColor 9365 ) 9366 { 9367 if( rRect.IsEmpty() ) 9368 return; 9369 9370 bool bRoundEdges = nCornerRadius > 0; 9371 9372 const StyleSettings& rStyles = GetSettings().GetStyleSettings(); 9373 9374 9375 // colors used for item highlighting 9376 Color aSelectionBorderCol( pPaintColor ? *pPaintColor : rStyles.GetHighlightColor() ); 9377 Color aSelectionFillCol( aSelectionBorderCol ); 9378 9379 sal_Bool bDark = rStyles.GetFaceColor().IsDark(); 9380 sal_Bool bBright = ( rStyles.GetFaceColor() == Color( COL_WHITE ) ); 9381 9382 int c1 = aSelectionBorderCol.GetLuminance(); 9383 int c2 = GetDisplayBackground().GetColor().GetLuminance(); 9384 9385 if( !bDark && !bBright && abs( c2-c1 ) < (pPaintColor ? 40 : 75) ) 9386 { 9387 // constrast too low 9388 sal_uInt16 h,s,b; 9389 aSelectionFillCol.RGBtoHSB( h, s, b ); 9390 if( b > 50 ) b -= 40; 9391 else b += 40; 9392 aSelectionFillCol.SetColor( Color::HSBtoRGB( h, s, b ) ); 9393 aSelectionBorderCol = aSelectionFillCol; 9394 } 9395 9396 if( bRoundEdges ) 9397 { 9398 if( aSelectionBorderCol.IsDark() ) 9399 aSelectionBorderCol.IncreaseLuminance( 128 ); 9400 else 9401 aSelectionBorderCol.DecreaseLuminance( 128 ); 9402 } 9403 9404 Rectangle aRect( rRect ); 9405 if( bDrawExtBorderOnly ) 9406 { 9407 aRect.nLeft -= 1; 9408 aRect.nTop -= 1; 9409 aRect.nRight += 1; 9410 aRect.nBottom += 1; 9411 } 9412 Color oldFillCol = GetFillColor(); 9413 Color oldLineCol = GetLineColor(); 9414 9415 if( bDrawBorder ) 9416 SetLineColor( bDark ? Color(COL_WHITE) : ( bBright ? Color(COL_BLACK) : aSelectionBorderCol ) ); 9417 else 9418 SetLineColor(); 9419 9420 sal_uInt16 nPercent = 0; 9421 if( !highlight ) 9422 { 9423 if( bDark ) 9424 aSelectionFillCol = COL_BLACK; 9425 else 9426 nPercent = 80; // just checked (light) 9427 } 9428 else 9429 { 9430 if( bChecked && highlight == 2 ) 9431 { 9432 if( bDark ) 9433 aSelectionFillCol = COL_LIGHTGRAY; 9434 else if ( bBright ) 9435 { 9436 aSelectionFillCol = COL_BLACK; 9437 SetLineColor( COL_BLACK ); 9438 nPercent = 0; 9439 } 9440 else 9441 nPercent = bRoundEdges ? 40 : 20; // selected, pressed or checked ( very dark ) 9442 } 9443 else if( bChecked || highlight == 1 ) 9444 { 9445 if( bDark ) 9446 aSelectionFillCol = COL_GRAY; 9447 else if ( bBright ) 9448 { 9449 aSelectionFillCol = COL_BLACK; 9450 SetLineColor( COL_BLACK ); 9451 nPercent = 0; 9452 } 9453 else 9454 nPercent = bRoundEdges ? 60 : 35; // selected, pressed or checked ( very dark ) 9455 } 9456 else 9457 { 9458 if( bDark ) 9459 aSelectionFillCol = COL_LIGHTGRAY; 9460 else if ( bBright ) 9461 { 9462 aSelectionFillCol = COL_BLACK; 9463 SetLineColor( COL_BLACK ); 9464 if( highlight == 3 ) 9465 nPercent = 80; 9466 else 9467 nPercent = 0; 9468 } 9469 else 9470 nPercent = 70; // selected ( dark ) 9471 } 9472 } 9473 9474 if( bDark && bDrawExtBorderOnly ) 9475 { 9476 SetFillColor(); 9477 if( pSelectionTextColor ) 9478 *pSelectionTextColor = rStyles.GetHighlightTextColor(); 9479 } 9480 else 9481 { 9482 SetFillColor( aSelectionFillCol ); 9483 if( pSelectionTextColor ) 9484 { 9485 Color aTextColor = IsControlBackground() ? GetControlForeground() : rStyles.GetButtonTextColor(); 9486 Color aHLTextColor = rStyles.GetHighlightTextColor(); 9487 int nTextDiff = abs(aSelectionFillCol.GetLuminance() - aTextColor.GetLuminance()); 9488 int nHLDiff = abs(aSelectionFillCol.GetLuminance() - aHLTextColor.GetLuminance()); 9489 *pSelectionTextColor = (nHLDiff >= nTextDiff) ? aHLTextColor : aTextColor; 9490 } 9491 } 9492 9493 9494 if( bDark ) 9495 { 9496 DrawRect( aRect ); 9497 } 9498 else 9499 { 9500 if( bRoundEdges ) 9501 { 9502 Polygon aPoly( aRect, nCornerRadius, nCornerRadius ); 9503 PolyPolygon aPolyPoly( aPoly ); 9504 DrawTransparent( aPolyPoly, nPercent ); 9505 } 9506 else 9507 { 9508 Polygon aPoly( aRect ); 9509 PolyPolygon aPolyPoly( aPoly ); 9510 DrawTransparent( aPolyPoly, nPercent ); 9511 } 9512 } 9513 9514 SetFillColor( oldFillCol ); 9515 SetLineColor( oldLineCol ); 9516 } 9517 9518 /* 9519 void Window::DbgAssertNoEventListeners() 9520 { 9521 VclWindowEvent aEvent( this, 0, NULL ); 9522 DBG_ASSERT( mpWindowImpl->maEventListeners.empty(), "Eventlistener: Who is still listening???" ) 9523 if ( !mpWindowImpl->maEventListeners.empty() ) 9524 mpWindowImpl->maEventListeners.Call( &aEvent ); 9525 9526 DBG_ASSERT( mpWindowImpl->maChildEventListeners.empty(), "ChildEventlistener: Who is still listening???" ) 9527 if ( !mpWindowImpl->maChildEventListeners.empty() ) 9528 mpWindowImpl->maChildEventListeners.Call( &aEvent ); 9529 } 9530 */ 9531 9532 // controls should return the window that gets the 9533 // focus by default, so keyevents can be sent to that window directly 9534 Window* Window::GetPreferredKeyInputWindow() 9535 { 9536 return this; 9537 } 9538 9539 9540 sal_Bool Window::IsScrollable() const 9541 { 9542 // check for scrollbars 9543 Window *pChild = mpWindowImpl->mpFirstChild; 9544 while( pChild ) 9545 { 9546 if( pChild->GetType() == WINDOW_SCROLLBAR ) 9547 return true; 9548 else 9549 pChild = pChild->mpWindowImpl->mpNext; 9550 } 9551 return false; 9552 } 9553 9554 sal_Bool Window::IsTopWindow() const 9555 { 9556 if ( mpWindowImpl->mbInDtor ) 9557 return sal_False; 9558 9559 // topwindows must be frames or they must have a borderwindow which is a frame 9560 if( !mpWindowImpl->mbFrame && (!mpWindowImpl->mpBorderWindow || (mpWindowImpl->mpBorderWindow && !mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame) ) ) 9561 return sal_False; 9562 9563 ImplGetWinData(); 9564 if( mpWindowImpl->mpWinData->mnIsTopWindow == (sal_uInt16)~0) // still uninitialized 9565 { 9566 // #113722#, cache result of expensive queryInterface call 9567 Window *pThisWin = (Window*)this; 9568 uno::Reference< XTopWindow > xTopWindow( pThisWin->GetComponentInterface(), UNO_QUERY ); 9569 pThisWin->mpWindowImpl->mpWinData->mnIsTopWindow = xTopWindow.is() ? 1 : 0; 9570 } 9571 return mpWindowImpl->mpWinData->mnIsTopWindow == 1 ? sal_True : sal_False; 9572 } 9573 9574 void Window::ImplMirrorFramePos( Point &pt ) const 9575 { 9576 pt.X() = mpWindowImpl->mpFrame->maGeometry.nWidth-1-pt.X(); 9577 } 9578 9579 // frame based modal counter (dialogs are not modal to the whole application anymore) 9580 sal_Bool Window::IsInModalMode() const 9581 { 9582 return (mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrameData->mnModalMode != 0); 9583 } 9584 void Window::ImplIncModalCount() 9585 { 9586 Window* pFrameWindow = mpWindowImpl->mpFrameWindow; 9587 Window* pParent = pFrameWindow; 9588 while( pFrameWindow ) 9589 { 9590 pFrameWindow->mpWindowImpl->mpFrameData->mnModalMode++; 9591 while( pParent && pParent->mpWindowImpl->mpFrameWindow == pFrameWindow ) 9592 { 9593 pParent = pParent->GetParent(); 9594 } 9595 pFrameWindow = pParent ? pParent->mpWindowImpl->mpFrameWindow : NULL; 9596 } 9597 } 9598 void Window::ImplDecModalCount() 9599 { 9600 Window* pFrameWindow = mpWindowImpl->mpFrameWindow; 9601 Window* pParent = pFrameWindow; 9602 while( pFrameWindow ) 9603 { 9604 pFrameWindow->mpWindowImpl->mpFrameData->mnModalMode--; 9605 while( pParent && pParent->mpWindowImpl->mpFrameWindow == pFrameWindow ) 9606 { 9607 pParent = pParent->GetParent(); 9608 } 9609 pFrameWindow = pParent ? pParent->mpWindowImpl->mpFrameWindow : NULL; 9610 } 9611 } 9612 sal_Bool Window::ImplIsInTaskPaneList() 9613 { 9614 return mpWindowImpl->mbIsInTaskPaneList; 9615 } 9616 void Window::ImplIsInTaskPaneList( sal_Bool mbIsInTaskList ) 9617 { 9618 mpWindowImpl->mbIsInTaskPaneList = mbIsInTaskList; 9619 } 9620 9621 void Window::ImplNotifyIconifiedState( sal_Bool bIconified ) 9622 { 9623 mpWindowImpl->mpFrameWindow->ImplCallEventListeners( bIconified ? VCLEVENT_WINDOW_MINIMIZE : VCLEVENT_WINDOW_NORMALIZE ); 9624 // #109206# notify client window as well to have toolkit topwindow listeners notified 9625 if( mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow && mpWindowImpl->mpFrameWindow != mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow ) 9626 mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow->ImplCallEventListeners( bIconified ? VCLEVENT_WINDOW_MINIMIZE : VCLEVENT_WINDOW_NORMALIZE ); 9627 } 9628 9629 sal_Bool Window::HasActiveChildFrame() 9630 { 9631 sal_Bool bRet = sal_False; 9632 Window *pFrameWin = ImplGetSVData()->maWinData.mpFirstFrame; 9633 while( pFrameWin ) 9634 { 9635 if( pFrameWin != mpWindowImpl->mpFrameWindow ) 9636 { 9637 sal_Bool bDecorated = sal_False; 9638 Window *pChildFrame = pFrameWin->ImplGetWindow(); 9639 // #i15285# unfortunately WB_MOVEABLE is the same as WB_TABSTOP which can 9640 // be removed for ToolBoxes to influence the keyboard accessibility 9641 // thus WB_MOVEABLE is no indicator for decoration anymore 9642 // but FloatingWindows carry this information in their TitleType... 9643 // TODO: avoid duplicate WinBits !!! 9644 if( pChildFrame && pChildFrame->ImplIsFloatingWindow() ) 9645 bDecorated = ((FloatingWindow*) pChildFrame)->GetTitleType() != FLOATWIN_TITLE_NONE; 9646 if( bDecorated || (pFrameWin->mpWindowImpl->mnStyle & (WB_MOVEABLE | WB_SIZEABLE) ) ) 9647 if( pChildFrame && pChildFrame->IsVisible() && pChildFrame->IsActive() ) 9648 { 9649 if( ImplIsChild( pChildFrame, sal_True ) ) 9650 { 9651 bRet = sal_True; 9652 break; 9653 } 9654 } 9655 } 9656 pFrameWin = pFrameWin->mpWindowImpl->mpFrameData->mpNextFrame; 9657 } 9658 return bRet; 9659 } 9660 9661 LanguageType Window::GetInputLanguage() const 9662 { 9663 return mpWindowImpl->mpFrame->GetInputLanguage(); 9664 } 9665 9666 void Window::EnableNativeWidget( sal_Bool bEnable ) 9667 { 9668 static const char* pNoNWF = getenv( "SAL_NO_NWF" ); 9669 if( pNoNWF && *pNoNWF ) 9670 bEnable = sal_False; 9671 9672 if( bEnable != ImplGetWinData()->mbEnableNativeWidget ) 9673 { 9674 ImplGetWinData()->mbEnableNativeWidget = bEnable; 9675 9676 // send datachanged event to allow for internal changes required for NWF 9677 // like clipmode, transparency, etc. 9678 DataChangedEvent aDCEvt( DATACHANGED_SETTINGS, &maSettings, SETTINGS_STYLE ); 9679 DataChanged( aDCEvt ); 9680 9681 // sometimes the borderwindow is queried, so keep it in sync 9682 if( mpWindowImpl->mpBorderWindow ) 9683 mpWindowImpl->mpBorderWindow->ImplGetWinData()->mbEnableNativeWidget = bEnable; 9684 } 9685 9686 // push down, useful for compound controls 9687 Window *pChild = mpWindowImpl->mpFirstChild; 9688 while( pChild ) 9689 { 9690 pChild->EnableNativeWidget( bEnable ); 9691 pChild = pChild->mpWindowImpl->mpNext; 9692 } 9693 } 9694 9695 sal_Bool Window::IsNativeWidgetEnabled() const 9696 { 9697 return ImplGetWinData()->mbEnableNativeWidget; 9698 } 9699 9700 #ifdef WNT // see #140456# 9701 #include <win/salframe.h> 9702 #endif 9703 9704 uno::Reference< rendering::XCanvas > Window::ImplGetCanvas( const Size& rFullscreenSize, 9705 bool bFullscreen, 9706 bool bSpriteCanvas ) const 9707 { 9708 // try to retrieve hard reference from weak member 9709 uno::Reference< rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas ); 9710 9711 // canvas still valid? Then we're done. 9712 if( xCanvas.is() ) 9713 return xCanvas; 9714 9715 Sequence< Any > aArg(6); 9716 9717 // Feed any with operating system's window handle 9718 // ============================================== 9719 9720 // common: first any is VCL pointer to window (for VCL canvas) 9721 aArg[ 0 ] = makeAny( reinterpret_cast<sal_Int64>(this) ); 9722 9723 // TODO(Q1): Make GetSystemData method virtual 9724 9725 // check whether we're a SysChild: have to fetch system data 9726 // directly from SystemChildWindow, because the GetSystemData 9727 // method is unfortunately not virtual 9728 const SystemChildWindow* pSysChild = dynamic_cast< const SystemChildWindow* >( this ); 9729 if( pSysChild ) 9730 { 9731 aArg[ 1 ] = pSysChild->GetSystemDataAny(); 9732 aArg[ 5 ] = pSysChild->GetSystemGfxDataAny(); 9733 } 9734 else 9735 { 9736 aArg[ 1 ] = GetSystemDataAny(); 9737 aArg[ 5 ] = GetSystemGfxDataAny(); 9738 } 9739 9740 if( bFullscreen ) 9741 aArg[ 2 ] = makeAny( ::com::sun::star::awt::Rectangle( 0, 0, 9742 rFullscreenSize.Width(), 9743 rFullscreenSize.Height() ) ); 9744 else 9745 aArg[ 2 ] = makeAny( ::com::sun::star::awt::Rectangle( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight ) ); 9746 9747 aArg[ 3 ] = makeAny( mpWindowImpl->mbAlwaysOnTop ? sal_True : sal_False ); 9748 aArg[ 4 ] = makeAny( uno::Reference< awt::XWindow >( 9749 const_cast<Window*>(this)->GetComponentInterface(), 9750 uno::UNO_QUERY )); 9751 9752 uno::Reference< XMultiServiceFactory > xFactory = vcl::unohelper::GetMultiServiceFactory(); 9753 9754 // Create canvas instance with window handle 9755 // ========================================= 9756 if ( xFactory.is() ) 9757 { 9758 static ::vcl::DeleteUnoReferenceOnDeinit<lang::XMultiServiceFactory> xStaticCanvasFactory( 9759 uno::Reference<lang::XMultiServiceFactory>( 9760 xFactory->createInstance( 9761 OUString( RTL_CONSTASCII_USTRINGPARAM( 9762 "com.sun.star.rendering.CanvasFactory") ) ), 9763 UNO_QUERY )); 9764 uno::Reference<lang::XMultiServiceFactory> xCanvasFactory(xStaticCanvasFactory.get()); 9765 9766 if(xCanvasFactory.is()) 9767 { 9768 #ifdef WNT 9769 // see #140456# - if we're running on a multiscreen setup, 9770 // request special, multi-screen safe sprite canvas 9771 // implementation (not DX5 canvas, as it cannot cope with 9772 // surfaces spanning multiple displays). Note: canvas 9773 // (without sprite) stays the same) 9774 const sal_uInt32 nDisplay = static_cast< WinSalFrame* >( mpWindowImpl->mpFrame )->mnDisplay; 9775 if( (nDisplay >= Application::GetScreenCount()) ) 9776 { 9777 xCanvas.set( xCanvasFactory->createInstanceWithArguments( 9778 bSpriteCanvas ? 9779 OUString( RTL_CONSTASCII_USTRINGPARAM( 9780 "com.sun.star.rendering.SpriteCanvas.MultiScreen" )) : 9781 OUString( RTL_CONSTASCII_USTRINGPARAM( 9782 "com.sun.star.rendering.Canvas.MultiScreen" )), 9783 aArg ), 9784 UNO_QUERY ); 9785 9786 } 9787 else 9788 { 9789 #endif 9790 xCanvas.set( xCanvasFactory->createInstanceWithArguments( 9791 bSpriteCanvas ? 9792 OUString( RTL_CONSTASCII_USTRINGPARAM( 9793 "com.sun.star.rendering.SpriteCanvas" )) : 9794 OUString( RTL_CONSTASCII_USTRINGPARAM( 9795 "com.sun.star.rendering.Canvas" )), 9796 aArg ), 9797 UNO_QUERY ); 9798 9799 #ifdef WNT 9800 } 9801 #endif 9802 9803 mpWindowImpl->mxCanvas = xCanvas; 9804 } 9805 } 9806 9807 // no factory??? Empty reference, then. 9808 return xCanvas; 9809 } 9810 9811 uno::Reference< rendering::XCanvas > Window::GetCanvas() const 9812 { 9813 return ImplGetCanvas( Size(), false, false ); 9814 } 9815 9816 uno::Reference< rendering::XSpriteCanvas > Window::GetSpriteCanvas() const 9817 { 9818 uno::Reference< rendering::XSpriteCanvas > xSpriteCanvas( 9819 ImplGetCanvas( Size(), false, true ), uno::UNO_QUERY ); 9820 return xSpriteCanvas; 9821 } 9822 9823 uno::Reference< ::com::sun::star::rendering::XSpriteCanvas > Window::GetFullscreenSpriteCanvas( const Size& rFullscreenSize ) const 9824 { 9825 uno::Reference< rendering::XSpriteCanvas > xSpriteCanvas( 9826 ImplGetCanvas( rFullscreenSize, true, true ), uno::UNO_QUERY ); 9827 return xSpriteCanvas; 9828 } 9829 9830 void Window::ImplPaintToDevice( OutputDevice* i_pTargetOutDev, const Point& i_rPos ) 9831 { 9832 sal_Bool bRVisible = mpWindowImpl->mbReallyVisible; 9833 mpWindowImpl->mbReallyVisible = mpWindowImpl->mbVisible; 9834 sal_Bool bDevOutput = mbDevOutput; 9835 mbDevOutput = sal_True; 9836 9837 long nOldDPIX = ImplGetDPIX(); 9838 long nOldDPIY = ImplGetDPIY(); 9839 mnDPIX = i_pTargetOutDev->ImplGetDPIX(); 9840 mnDPIY = i_pTargetOutDev->ImplGetDPIY(); 9841 sal_Bool bOutput = IsOutputEnabled(); 9842 EnableOutput(); 9843 9844 DBG_ASSERT( GetMapMode().GetMapUnit() == MAP_PIXEL, "MapMode must be PIXEL based" ); 9845 if ( GetMapMode().GetMapUnit() != MAP_PIXEL ) 9846 return; 9847 9848 // preserve graphicsstate 9849 Push(); 9850 Region aClipRegion( GetClipRegion() ); 9851 SetClipRegion(); 9852 9853 GDIMetaFile* pOldMtf = GetConnectMetaFile(); 9854 GDIMetaFile aMtf; 9855 SetConnectMetaFile( &aMtf ); 9856 9857 // put a push action to metafile 9858 Push(); 9859 // copy graphics state to metafile 9860 Font aCopyFont = GetFont(); 9861 if( nOldDPIX != mnDPIX || nOldDPIY != mnDPIY ) 9862 { 9863 aCopyFont.SetHeight( aCopyFont.GetHeight() * mnDPIY / nOldDPIY ); 9864 aCopyFont.SetWidth( aCopyFont.GetWidth() * mnDPIX / nOldDPIX ); 9865 } 9866 SetFont( aCopyFont ); 9867 SetTextColor( GetTextColor() ); 9868 if( IsLineColor() ) 9869 SetLineColor( GetLineColor() ); 9870 else 9871 SetLineColor(); 9872 if( IsFillColor() ) 9873 SetFillColor( GetFillColor() ); 9874 else 9875 SetFillColor(); 9876 if( IsTextLineColor() ) 9877 SetTextLineColor( GetTextLineColor() ); 9878 else 9879 SetTextLineColor(); 9880 if( IsOverlineColor() ) 9881 SetOverlineColor( GetOverlineColor() ); 9882 else 9883 SetOverlineColor(); 9884 if( IsTextFillColor() ) 9885 SetTextFillColor( GetTextFillColor() ); 9886 else 9887 SetTextFillColor(); 9888 SetTextAlign( GetTextAlign() ); 9889 SetRasterOp( GetRasterOp() ); 9890 if( IsRefPoint() ) 9891 SetRefPoint( GetRefPoint() ); 9892 else 9893 SetRefPoint(); 9894 SetLayoutMode( GetLayoutMode() ); 9895 SetDigitLanguage( GetDigitLanguage() ); 9896 Rectangle aPaintRect( Point( 0, 0 ), GetOutputSizePixel() ); 9897 aClipRegion.Intersect( aPaintRect ); 9898 SetClipRegion( aClipRegion ); 9899 9900 // do the actual paint 9901 9902 // background 9903 if( ! IsPaintTransparent() && IsBackground() && ! (GetParentClipMode() & PARENTCLIPMODE_NOCLIP ) ) 9904 Erase(); 9905 // foreground 9906 Paint( aPaintRect ); 9907 // put a pop action to metafile 9908 Pop(); 9909 9910 SetConnectMetaFile( pOldMtf ); 9911 EnableOutput( bOutput ); 9912 mpWindowImpl->mbReallyVisible = bRVisible; 9913 9914 // paint metafile to VDev 9915 VirtualDevice* pMaskedDevice = new VirtualDevice( *i_pTargetOutDev, 0, 0 ); 9916 pMaskedDevice->SetOutputSizePixel( GetOutputSizePixel() ); 9917 pMaskedDevice->EnableRTL( IsRTLEnabled() ); 9918 aMtf.WindStart(); 9919 aMtf.Play( pMaskedDevice ); 9920 BitmapEx aBmpEx( pMaskedDevice->GetBitmapEx( Point( 0, 0 ), pMaskedDevice->GetOutputSizePixel() ) ); 9921 i_pTargetOutDev->DrawBitmapEx( i_rPos, aBmpEx ); 9922 // get rid of virtual device now so they don't pile up during recursive calls 9923 delete pMaskedDevice, pMaskedDevice = NULL; 9924 9925 9926 for( Window* pChild = mpWindowImpl->mpFirstChild; pChild; pChild = pChild->mpWindowImpl->mpNext ) 9927 { 9928 if( pChild->mpWindowImpl->mpFrame == mpWindowImpl->mpFrame && pChild->IsVisible() ) 9929 { 9930 long nDeltaX = pChild->mnOutOffX - mnOutOffX; 9931 if( ImplHasMirroredGraphics() ) 9932 nDeltaX = mnOutWidth - nDeltaX - pChild->mnOutWidth; 9933 long nDeltaY = pChild->GetOutOffYPixel() - GetOutOffYPixel(); 9934 Point aPos( i_rPos ); 9935 Point aDelta( nDeltaX, nDeltaY ); 9936 aPos += aDelta; 9937 pChild->ImplPaintToDevice( i_pTargetOutDev, aPos ); 9938 } 9939 } 9940 9941 // restore graphics state 9942 Pop(); 9943 9944 EnableOutput( bOutput ); 9945 mpWindowImpl->mbReallyVisible = bRVisible; 9946 mbDevOutput = bDevOutput; 9947 mnDPIX = nOldDPIX; 9948 mnDPIY = nOldDPIY; 9949 } 9950 9951 void Window::PaintToDevice( OutputDevice* pDev, const Point& rPos, const Size& /*rSize*/ ) 9952 { 9953 // FIXME: scaling: currently this is for pixel copying only 9954 9955 DBG_ASSERT( ! pDev->ImplHasMirroredGraphics(), "PaintToDevice to mirroring graphics" ); 9956 DBG_ASSERT( ! pDev->IsRTLEnabled(), "PaintToDevice to mirroring device" ); 9957 9958 9959 Point aPos = pDev->LogicToPixel( rPos ); 9960 9961 Window* pRealParent = NULL; 9962 if( ! mpWindowImpl->mbVisible ) 9963 { 9964 Window* pTempParent = ImplGetDefaultWindow(); 9965 if( pTempParent ) 9966 pTempParent->EnableChildTransparentMode(); 9967 pRealParent = GetParent(); 9968 SetParent( pTempParent ); 9969 // trigger correct visibility flags for children 9970 Show(); 9971 Hide(); 9972 } 9973 9974 sal_Bool bVisible = mpWindowImpl->mbVisible; 9975 mpWindowImpl->mbVisible = sal_True; 9976 9977 if( mpWindowImpl->mpBorderWindow ) 9978 mpWindowImpl->mpBorderWindow->ImplPaintToDevice( pDev, rPos ); 9979 else 9980 ImplPaintToDevice( pDev, rPos ); 9981 9982 mpWindowImpl->mbVisible = bVisible; 9983 9984 if( pRealParent ) 9985 SetParent( pRealParent ); 9986 } 9987 9988 XubString Window::GetSurroundingText() const 9989 { 9990 return XubString::EmptyString(); 9991 } 9992 9993 Selection Window::GetSurroundingTextSelection() const 9994 { 9995 return Selection( 0, 0 ); 9996 } 9997 9998