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