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 <config_features.h>
21 : #include <rtl/strbuf.hxx>
22 : #include <tools/rc.h>
23 :
24 : #include <sal/types.h>
25 :
26 : #include <vcl/salgtype.hxx>
27 : #include <vcl/event.hxx>
28 : #include <vcl/help.hxx>
29 : #include <vcl/cursor.hxx>
30 : #include <vcl/svapp.hxx>
31 : #include <vcl/window.hxx>
32 : #include <vcl/syswin.hxx>
33 : #include <vcl/syschild.hxx>
34 : #include <vcl/dockwin.hxx>
35 : #include <vcl/wall.hxx>
36 : #include <vcl/gradient.hxx>
37 : #include <vcl/button.hxx>
38 : #include <vcl/taskpanelist.hxx>
39 : #include <vcl/dialog.hxx>
40 : #include <vcl/unowrap.hxx>
41 : #include <vcl/gdimtf.hxx>
42 : #include <vcl/lazydelete.hxx>
43 : #include <vcl/virdev.hxx>
44 : #include <vcl/settings.hxx>
45 : #include <vcl/sysdata.hxx>
46 :
47 : #include <salframe.hxx>
48 : #include <salobj.hxx>
49 : #include <salinst.hxx>
50 : #include <salgdi.hxx>
51 : #include <svdata.hxx>
52 : #include <dbggui.hxx>
53 : #include <window.h>
54 : #include <toolbox.h>
55 : #include <outdev.h>
56 : #include <brdwin.hxx>
57 : #include <helpwin.hxx>
58 : #include <dndlcon.hxx>
59 :
60 : #include <com/sun/star/awt/XTopWindow.hpp>
61 : #include <com/sun/star/awt/XDisplayConnection.hpp>
62 : #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
63 : #include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp>
64 : #include <com/sun/star/rendering/CanvasFactory.hpp>
65 : #include <com/sun/star/rendering/XSpriteCanvas.hpp>
66 : #include <comphelper/processfactory.hxx>
67 :
68 : #include <cassert>
69 : #include <set>
70 : #include <typeinfo>
71 :
72 : #ifdef WNT // see #140456#
73 : #include <win/salframe.h>
74 : #endif
75 :
76 :
77 : using namespace ::com::sun::star::uno;
78 : using namespace ::com::sun::star::lang;
79 : using namespace ::com::sun::star::datatransfer::clipboard;
80 : using namespace ::com::sun::star::datatransfer::dnd;
81 :
82 : using ::com::sun::star::awt::XTopWindow;
83 :
84 : namespace vcl {
85 :
86 358032 : Window::Window( WindowType nType )
87 : {
88 358032 : ImplInitWindowData( nType );
89 358032 : }
90 :
91 84998 : Window::Window( vcl::Window* pParent, WinBits nStyle )
92 : {
93 :
94 84998 : ImplInitWindowData( WINDOW_WINDOW );
95 84998 : ImplInit( pParent, nStyle, NULL );
96 84998 : }
97 :
98 122 : Window::Window( vcl::Window* pParent, const ResId& rResId )
99 122 : : mpWindowImpl(NULL)
100 : {
101 122 : rResId.SetRT( RSC_WINDOW );
102 122 : WinBits nStyle = ImplInitRes( rResId );
103 122 : ImplInitWindowData( WINDOW_WINDOW );
104 122 : ImplInit( pParent, nStyle, NULL );
105 122 : ImplLoadRes( rResId );
106 :
107 122 : if ( !(nStyle & WB_HIDE) )
108 2 : Show();
109 122 : }
110 :
111 : #if OSL_DEBUG_LEVEL > 0
112 : namespace
113 : {
114 : OString lcl_createWindowInfo(const vcl::Window& i_rWindow)
115 : {
116 : // skip border windows, they don't carry information which helps diagnosing the problem
117 : const vcl::Window* pWindow( &i_rWindow );
118 : while ( pWindow && ( pWindow->GetType() == WINDOW_BORDERWINDOW ) )
119 : pWindow = pWindow->GetWindow( WINDOW_FIRSTCHILD );
120 : if ( !pWindow )
121 : pWindow = &i_rWindow;
122 :
123 : OStringBuffer aErrorString;
124 : aErrorString.append(' ');
125 : aErrorString.append(typeid( *pWindow ).name());
126 : aErrorString.append(" (");
127 : aErrorString.append(OUStringToOString(pWindow->GetText(), RTL_TEXTENCODING_UTF8));
128 : aErrorString.append(")");
129 : return aErrorString.makeStringAndClear();
130 : }
131 : }
132 : #endif
133 :
134 895056 : Window::~Window()
135 : {
136 442826 : vcl::LazyDeletor<vcl::Window>::Undelete( this );
137 :
138 : DBG_ASSERT( !mpWindowImpl->mbInDtor, "~Window - already in DTOR!" );
139 :
140 442826 : dispose();
141 :
142 : // remove Key and Mouse events issued by Application::PostKey/MouseEvent
143 442826 : Application::RemoveMouseAndKeyEvents( this );
144 :
145 : // Dispose of the canvas implementation (which, currently, has an
146 : // own wrapper window as a child to this one.
147 442826 : Reference< css::rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
148 442826 : if( xCanvas.is() )
149 : {
150 0 : Reference < XComponent > xCanvasComponent( xCanvas, UNO_QUERY );
151 0 : if( xCanvasComponent.is() )
152 0 : xCanvasComponent->dispose();
153 : }
154 :
155 442826 : mpWindowImpl->mbInDtor = true;
156 :
157 442826 : ImplCallEventListeners( VCLEVENT_OBJECT_DYING );
158 :
159 : // do not send child events for frames that were registered as native frames
160 442826 : if( !ImplIsAccessibleNativeFrame() && mpWindowImpl->mbReallyVisible )
161 74135 : if ( ImplIsAccessibleCandidate() && GetAccessibleParentWindow() )
162 74131 : GetAccessibleParentWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_CHILDDESTROYED, this );
163 :
164 : // remove associated data structures from dockingmanager
165 442826 : ImplGetDockingManager()->RemoveWindow( this );
166 :
167 : // remove ownerdraw decorated windows from list in the top-most frame window
168 442826 : if( (GetStyle() & WB_OWNERDRAWDECORATION) && mpWindowImpl->mbFrame )
169 : {
170 0 : ::std::vector< vcl::Window* >& rList = ImplGetOwnerDrawList();
171 0 : ::std::vector< vcl::Window* >::iterator p;
172 0 : p = ::std::find( rList.begin(), rList.end(), this );
173 0 : if( p != rList.end() )
174 0 : rList.erase( p );
175 : }
176 :
177 : // shutdown drag and drop
178 885652 : Reference < XComponent > xDnDComponent( mpWindowImpl->mxDNDListenerContainer, UNO_QUERY );
179 :
180 442826 : if( xDnDComponent.is() )
181 42254 : xDnDComponent->dispose();
182 :
183 442826 : if( mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData )
184 : {
185 : try
186 : {
187 : // deregister drop target listener
188 12418 : if( mpWindowImpl->mpFrameData->mxDropTargetListener.is() )
189 : {
190 : Reference< XDragGestureRecognizer > xDragGestureRecognizer =
191 2390 : Reference< XDragGestureRecognizer > (mpWindowImpl->mpFrameData->mxDragSource, UNO_QUERY);
192 2390 : if( xDragGestureRecognizer.is() )
193 : {
194 0 : xDragGestureRecognizer->removeDragGestureListener(
195 0 : Reference< XDragGestureListener > (mpWindowImpl->mpFrameData->mxDropTargetListener, UNO_QUERY));
196 : }
197 :
198 2390 : mpWindowImpl->mpFrameData->mxDropTarget->removeDropTargetListener( mpWindowImpl->mpFrameData->mxDropTargetListener );
199 2390 : mpWindowImpl->mpFrameData->mxDropTargetListener.clear();
200 : }
201 :
202 : // shutdown drag and drop for this frame window
203 12418 : Reference< XComponent > xComponent( mpWindowImpl->mpFrameData->mxDropTarget, UNO_QUERY );
204 :
205 : // DNDEventDispatcher does not hold a reference of the DropTarget,
206 : // so it's ok if it does not support XComponent
207 12418 : if( xComponent.is() )
208 2390 : xComponent->dispose();
209 : }
210 0 : catch (const Exception&)
211 : {
212 : // can be safely ignored here.
213 : }
214 : }
215 :
216 442826 : UnoWrapperBase* pWrapper = Application::GetUnoWrapper( false );
217 442826 : if ( pWrapper )
218 442562 : pWrapper->WindowDestroyed( this );
219 :
220 : // MT: Must be called after WindowDestroyed!
221 : // Otherwise, if the accessible is a VCLXWindow, it will try to destroy this window again!
222 : // But accessibility implementations from applications need this dispose.
223 442826 : if ( mpWindowImpl->mxAccessible.is() )
224 : {
225 738 : Reference< XComponent> xC( mpWindowImpl->mxAccessible, UNO_QUERY );
226 738 : if ( xC.is() )
227 704 : xC->dispose();
228 : }
229 :
230 442826 : ImplSVData* pSVData = ImplGetSVData();
231 :
232 442826 : if ( pSVData->maHelpData.mpHelpWin && (pSVData->maHelpData.mpHelpWin->GetParent() == this) )
233 0 : ImplDestroyHelpWindow( true );
234 :
235 : DBG_ASSERT( pSVData->maWinData.mpTrackWin != this,
236 : "Window::~Window(): Window is in TrackingMode" );
237 : DBG_ASSERT( pSVData->maWinData.mpCaptureWin != this,
238 : "Window::~Window(): Window has the mouse captured" );
239 :
240 : // due to old compatibility
241 442826 : if ( pSVData->maWinData.mpTrackWin == this )
242 0 : EndTracking();
243 442826 : if ( pSVData->maWinData.mpCaptureWin == this )
244 0 : ReleaseMouse();
245 442826 : if ( pSVData->maWinData.mpDefDialogParent == this )
246 0 : pSVData->maWinData.mpDefDialogParent = NULL;
247 :
248 : #if OSL_DEBUG_LEVEL > 0
249 : if ( true ) // always perform these tests in debug builds
250 : {
251 : OStringBuffer aErrorStr;
252 : bool bError = false;
253 : vcl::Window* pTempWin;
254 : if (mpWindowImpl->mpFrameData != 0)
255 : {
256 : pTempWin = mpWindowImpl->mpFrameData->mpFirstOverlap;
257 : while ( pTempWin )
258 : {
259 : if ( ImplIsRealParentPath( pTempWin ) )
260 : {
261 : bError = true;
262 : aErrorStr.append(lcl_createWindowInfo(*pTempWin));
263 : }
264 : pTempWin = pTempWin->mpWindowImpl->mpNextOverlap;
265 : }
266 : if ( bError )
267 : {
268 : OStringBuffer aTempStr;
269 : aTempStr.append("Window (");
270 : aTempStr.append(OUStringToOString(GetText(),
271 : RTL_TEXTENCODING_UTF8));
272 : aTempStr.append(") with live SystemWindows destroyed: ");
273 : aTempStr.append(aErrorStr.toString());
274 : OSL_FAIL(aTempStr.getStr());
275 : // abort in debug builds, must be fixed!
276 : Application::Abort(OStringToOUString(
277 : aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8));
278 : }
279 : }
280 :
281 : bError = false;
282 : pTempWin = pSVData->maWinData.mpFirstFrame;
283 : while ( pTempWin )
284 : {
285 : if ( ImplIsRealParentPath( pTempWin ) )
286 : {
287 : bError = true;
288 : aErrorStr.append(lcl_createWindowInfo(*pTempWin));
289 : }
290 : pTempWin = pTempWin->mpWindowImpl->mpFrameData->mpNextFrame;
291 : }
292 : if ( bError )
293 : {
294 : OStringBuffer aTempStr( "Window (" );
295 : aTempStr.append(OUStringToOString(GetText(), RTL_TEXTENCODING_UTF8));
296 : aTempStr.append(") with live SystemWindows destroyed: ");
297 : aTempStr.append(aErrorStr.toString());
298 : OSL_FAIL( aTempStr.getStr() );
299 : Application::Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); // abort in debug builds, this must be fixed!
300 : }
301 :
302 : if ( mpWindowImpl->mpFirstChild )
303 : {
304 : OStringBuffer aTempStr("Window (");
305 : aTempStr.append(OUStringToOString(GetText(), RTL_TEXTENCODING_UTF8));
306 : aTempStr.append(") with live children destroyed: ");
307 : pTempWin = mpWindowImpl->mpFirstChild;
308 : while ( pTempWin )
309 : {
310 : aTempStr.append(lcl_createWindowInfo(*pTempWin));
311 : pTempWin = pTempWin->mpWindowImpl->mpNext;
312 : }
313 : OSL_FAIL( aTempStr.getStr() );
314 : Application::Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); // abort in debug builds, this must be fixed!
315 : }
316 :
317 : if ( mpWindowImpl->mpFirstOverlap )
318 : {
319 : OStringBuffer aTempStr("Window (");
320 : aTempStr.append(OUStringToOString(GetText(), RTL_TEXTENCODING_UTF8));
321 : aTempStr.append(") with live SystemWindows destroyed: ");
322 : pTempWin = mpWindowImpl->mpFirstOverlap;
323 : while ( pTempWin )
324 : {
325 : aTempStr.append(lcl_createWindowInfo(*pTempWin));
326 : pTempWin = pTempWin->mpWindowImpl->mpNext;
327 : }
328 : OSL_FAIL( aTempStr.getStr() );
329 : Application::Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); // abort in debug builds, this must be fixed!
330 : }
331 :
332 : vcl::Window* pMyParent = GetParent();
333 : SystemWindow* pMySysWin = NULL;
334 :
335 : while ( pMyParent )
336 : {
337 : if ( pMyParent->IsSystemWindow() )
338 : {
339 : pMySysWin = dynamic_cast<SystemWindow *>(pMyParent);
340 : }
341 : pMyParent = pMyParent->GetParent();
342 : }
343 : if ( pMySysWin && pMySysWin->ImplIsInTaskPaneList( this ) )
344 : {
345 : OStringBuffer aTempStr("Window (");
346 : aTempStr.append(OUStringToOString(GetText(), RTL_TEXTENCODING_UTF8));
347 : aTempStr.append(") still in TaskPanelList!");
348 : OSL_FAIL( aTempStr.getStr() );
349 : Application::Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); // abort in debug builds, this must be fixed!
350 : }
351 : }
352 : #endif
353 :
354 442826 : if( mpWindowImpl->mbIsInTaskPaneList )
355 : {
356 0 : vcl::Window* pMyParent = GetParent();
357 0 : SystemWindow* pMySysWin = NULL;
358 :
359 0 : while ( pMyParent )
360 : {
361 0 : if ( pMyParent->IsSystemWindow() )
362 : {
363 0 : pMySysWin = dynamic_cast<SystemWindow *>(pMyParent);
364 : }
365 0 : pMyParent = pMyParent->GetParent();
366 : }
367 0 : if ( pMySysWin && pMySysWin->ImplIsInTaskPaneList( this ) )
368 : {
369 0 : pMySysWin->GetTaskPaneList()->RemoveWindow( this );
370 : }
371 : else
372 : {
373 0 : OStringBuffer aTempStr("Window (");
374 0 : aTempStr.append(OUStringToOString(GetText(), RTL_TEXTENCODING_UTF8));
375 0 : aTempStr.append(") not found in TaskPanelList!");
376 0 : OSL_FAIL( aTempStr.getStr() );
377 : }
378 : }
379 :
380 : // remove from size-group if necessary
381 442826 : remove_from_all_size_groups();
382 :
383 : // clear mnemonic labels
384 885652 : std::vector<FixedText*> aMnemonicLabels(list_mnemonic_labels());
385 1332906 : for (std::vector<FixedText*>::iterator aI = aMnemonicLabels.begin();
386 888604 : aI != aMnemonicLabels.end(); ++aI)
387 : {
388 1476 : remove_mnemonic_label(*aI);
389 : }
390 :
391 : // hide window in order to trigger the Paint-Handling
392 442826 : Hide();
393 :
394 : // announce the window is to be destroyed
395 : {
396 442826 : NotifyEvent aNEvt( EVENT_DESTROY, this );
397 442826 : Notify( aNEvt );
398 : }
399 :
400 : // EndExtTextInputMode
401 442826 : if ( pSVData->maWinData.mpExtTextInputWin == this )
402 : {
403 0 : EndExtTextInput( EXTTEXTINPUT_END_COMPLETE );
404 0 : if ( pSVData->maWinData.mpExtTextInputWin == this )
405 0 : pSVData->maWinData.mpExtTextInputWin = NULL;
406 : }
407 :
408 : // check if the focus window is our child
409 442826 : bool bHasFocussedChild = false;
410 442826 : if( pSVData->maWinData.mpFocusWin && ImplIsRealParentPath( pSVData->maWinData.mpFocusWin ) )
411 : {
412 : // #122232#, this must not happen and is an application bug ! but we try some cleanup to hopefully avoid crashes, see below
413 0 : bHasFocussedChild = true;
414 : #if OSL_DEBUG_LEVEL > 0
415 : OStringBuffer aTempStr("Window (");
416 : aTempStr.append(OUStringToOString(GetText(),
417 : RTL_TEXTENCODING_UTF8)).
418 : append(") with focussed child window destroyed ! THIS WILL LEAD TO CRASHES AND MUST BE FIXED !");
419 : OSL_FAIL( aTempStr.getStr() );
420 : Application::Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8 )); // abort in debug build version, this must be fixed!
421 : #endif
422 : }
423 :
424 : // if we get focus pass focus to another window
425 442826 : vcl::Window* pOverlapWindow = ImplGetFirstOverlapWindow();
426 442826 : if ( pSVData->maWinData.mpFocusWin == this
427 427533 : || bHasFocussedChild ) // #122232#, see above, try some cleanup
428 : {
429 15293 : if ( mpWindowImpl->mbFrame )
430 : {
431 6 : pSVData->maWinData.mpFocusWin = NULL;
432 6 : pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
433 6 : GetpApp()->FocusChanged();
434 : }
435 : else
436 : {
437 15287 : vcl::Window* pParent = GetParent();
438 15287 : vcl::Window* pBorderWindow = mpWindowImpl->mpBorderWindow;
439 : // when windows overlap, give focus to the parent
440 : // of the next FrameWindow
441 15287 : if ( pBorderWindow )
442 : {
443 10022 : if ( pBorderWindow->ImplIsOverlapWindow() )
444 4962 : pParent = pBorderWindow->mpWindowImpl->mpOverlapWindow;
445 : }
446 5265 : else if ( ImplIsOverlapWindow() )
447 0 : pParent = mpWindowImpl->mpOverlapWindow;
448 :
449 15287 : if ( pParent && pParent->IsEnabled() && pParent->IsInputEnabled() && ! pParent->IsInModalMode() )
450 15285 : pParent->GrabFocus();
451 : else
452 2 : mpWindowImpl->mpFrameWindow->GrabFocus();
453 :
454 : // If the focus was set back to 'this' set it to nothing
455 15287 : if ( pSVData->maWinData.mpFocusWin == this )
456 : {
457 4985 : pSVData->maWinData.mpFocusWin = NULL;
458 4985 : pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
459 4985 : GetpApp()->FocusChanged();
460 : }
461 : }
462 : }
463 :
464 885652 : if ( pOverlapWindow != 0 &&
465 442826 : pOverlapWindow->mpWindowImpl->mpLastFocusWindow == this )
466 519 : pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
467 :
468 : // reset hint for DefModalDialogParent
469 442826 : if( pSVData->maWinData.mpActiveApplicationFrame == this )
470 4992 : pSVData->maWinData.mpActiveApplicationFrame = NULL;
471 :
472 : // reset marked windows
473 442826 : if ( mpWindowImpl->mpFrameData != 0 )
474 : {
475 442826 : if ( mpWindowImpl->mpFrameData->mpFocusWin == this )
476 5510 : mpWindowImpl->mpFrameData->mpFocusWin = NULL;
477 442826 : if ( mpWindowImpl->mpFrameData->mpMouseMoveWin == this )
478 0 : mpWindowImpl->mpFrameData->mpMouseMoveWin = NULL;
479 442826 : if ( mpWindowImpl->mpFrameData->mpMouseDownWin == this )
480 0 : mpWindowImpl->mpFrameData->mpMouseDownWin = NULL;
481 : }
482 :
483 : // reset Deactivate-Window
484 442826 : if ( pSVData->maWinData.mpLastDeacWin == this )
485 0 : pSVData->maWinData.mpLastDeacWin = NULL;
486 :
487 442826 : if ( mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData )
488 : {
489 12418 : if ( mpWindowImpl->mpFrameData->mnFocusId )
490 8 : Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnFocusId );
491 12418 : if ( mpWindowImpl->mpFrameData->mnMouseMoveId )
492 5465 : Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnMouseMoveId );
493 : }
494 :
495 : // release SalGraphics
496 442826 : OutputDevice *pOutDev = GetOutDev();
497 442826 : pOutDev->ReleaseGraphics();
498 :
499 : // notify ImplDelData subscribers of this window about the window deletion
500 442826 : ImplDelData* pDelData = mpWindowImpl->mpFirstDel;
501 885656 : while ( pDelData )
502 : {
503 4 : pDelData->mbDel = true;
504 4 : pDelData->mpWindow = NULL; // #112873# pDel is not associated with a Window anymore
505 4 : pDelData = pDelData->mpNext;
506 : }
507 :
508 : // remove window from the lists
509 442826 : ImplRemoveWindow( true );
510 :
511 : // de-register as "top window child" at our parent, if necessary
512 442826 : if ( mpWindowImpl->mbFrame )
513 : {
514 12418 : bool bIsTopWindow = mpWindowImpl->mpWinData && ( mpWindowImpl->mpWinData->mnIsTopWindow == 1 );
515 12418 : if ( mpWindowImpl->mpRealParent && bIsTopWindow )
516 : {
517 38 : ImplWinData* pParentWinData = mpWindowImpl->mpRealParent->ImplGetWinData();
518 :
519 : ::std::list< vcl::Window* >::iterator myPos = ::std::find( pParentWinData->maTopWindowChildren.begin(),
520 38 : pParentWinData->maTopWindowChildren.end(), this );
521 : DBG_ASSERT( myPos != pParentWinData->maTopWindowChildren.end(), "Window::~Window: inconsistency in top window chain!" );
522 38 : if ( myPos != pParentWinData->maTopWindowChildren.end() )
523 34 : pParentWinData->maTopWindowChildren.erase( myPos );
524 : }
525 : }
526 :
527 : // cleanup Extra Window Data, TODO: add and use ImplWinData destructor
528 442826 : if ( mpWindowImpl->mpWinData )
529 : {
530 442562 : if ( mpWindowImpl->mpWinData->mpExtOldText )
531 0 : delete mpWindowImpl->mpWinData->mpExtOldText;
532 442562 : if ( mpWindowImpl->mpWinData->mpExtOldAttrAry )
533 0 : delete mpWindowImpl->mpWinData->mpExtOldAttrAry;
534 442562 : if ( mpWindowImpl->mpWinData->mpCursorRect )
535 0 : delete mpWindowImpl->mpWinData->mpCursorRect;
536 442562 : if ( mpWindowImpl->mpWinData->mpCompositionCharRects)
537 0 : delete[] mpWindowImpl->mpWinData->mpCompositionCharRects;
538 442562 : if ( mpWindowImpl->mpWinData->mpFocusRect )
539 129 : delete mpWindowImpl->mpWinData->mpFocusRect;
540 442562 : if ( mpWindowImpl->mpWinData->mpTrackRect )
541 0 : delete mpWindowImpl->mpWinData->mpTrackRect;
542 :
543 442562 : delete mpWindowImpl->mpWinData;
544 : }
545 :
546 : // cleanup overlap related window data
547 442826 : if ( mpWindowImpl->mpOverlapData )
548 12418 : delete mpWindowImpl->mpOverlapData;
549 :
550 : // remove BorderWindow or Frame window data
551 442826 : if ( mpWindowImpl->mpBorderWindow )
552 34707 : delete mpWindowImpl->mpBorderWindow;
553 408119 : else if ( mpWindowImpl->mbFrame )
554 : {
555 12418 : if ( pSVData->maWinData.mpFirstFrame == this )
556 8277 : pSVData->maWinData.mpFirstFrame = mpWindowImpl->mpFrameData->mpNextFrame;
557 : else
558 : {
559 4141 : vcl::Window* pSysWin = pSVData->maWinData.mpFirstFrame;
560 14927 : while ( pSysWin->mpWindowImpl->mpFrameData->mpNextFrame != this )
561 6645 : pSysWin = pSysWin->mpWindowImpl->mpFrameData->mpNextFrame;
562 4141 : pSysWin->mpWindowImpl->mpFrameData->mpNextFrame = mpWindowImpl->mpFrameData->mpNextFrame;
563 : }
564 12418 : mpWindowImpl->mpFrame->SetCallback( NULL, NULL );
565 12418 : pSVData->mpDefInst->DestroyFrame( mpWindowImpl->mpFrame );
566 12418 : delete mpWindowImpl->mpFrameData;
567 : }
568 :
569 : // should be the last statements
570 885652 : delete mpWindowImpl; mpWindowImpl = NULL;
571 452230 : }
572 :
573 : } /* namespace vcl */
574 :
575 443152 : WindowImpl::WindowImpl( WindowType nType )
576 : {
577 443152 : maZoom = Fraction( 1, 1 );
578 443152 : maWinRegion = vcl::Region(true);
579 443152 : maWinClipRegion = vcl::Region(true);
580 443152 : mpWinData = NULL; // Extra Window Data, that we dont need for all windows
581 443152 : mpOverlapData = NULL; // Overlap Data
582 443152 : mpFrameData = NULL; // Frame Data
583 443152 : mpFrame = NULL; // Pointer to frame window
584 443152 : mpSysObj = NULL;
585 443152 : mpFrameWindow = NULL; // window to top level parent (same as frame window)
586 443152 : mpOverlapWindow = NULL; // first overlap parent
587 443152 : mpBorderWindow = NULL; // Border-Window
588 443152 : mpClientWindow = NULL; // Client-Window of a FrameWindow
589 443152 : mpParent = NULL; // parent (inkl. BorderWindow)
590 443152 : mpRealParent = NULL; // real parent (exkl. BorderWindow)
591 443152 : mpFirstChild = NULL; // first child window
592 443152 : mpLastChild = NULL; // last child window
593 443152 : mpFirstOverlap = NULL; // first overlap window (only set in overlap windows)
594 443152 : mpLastOverlap = NULL; // last overlap window (only set in overlap windows)
595 443152 : mpPrev = NULL; // prev window
596 443152 : mpNext = NULL; // next window
597 443152 : mpNextOverlap = NULL; // next overlap window of frame
598 443152 : mpLastFocusWindow = NULL; // window for focus restore
599 443152 : mpDlgCtrlDownWindow = NULL; // window for dialog control
600 443152 : mpFirstDel = NULL; // Dtor notification list
601 443152 : mpUserData = NULL; // user data
602 443152 : mpCursor = NULL; // cursor
603 443152 : mpControlFont = NULL; // font properties
604 443152 : mpVCLXWindow = NULL;
605 443152 : mpAccessibleInfos = NULL;
606 443152 : maControlForeground = Color( COL_TRANSPARENT ); // no foreground set
607 443152 : maControlBackground = Color( COL_TRANSPARENT ); // no background set
608 443152 : mnLeftBorder = 0; // left border
609 443152 : mnTopBorder = 0; // top border
610 443152 : mnRightBorder = 0; // right border
611 443152 : mnBottomBorder = 0; // bottom border
612 443152 : mnWidthRequest = -1; // width request
613 443152 : mnHeightRequest = -1; // height request
614 443152 : mnOptimalWidthCache = -1; // optimal width cache
615 443152 : mnOptimalHeightCache = -1; // optimal height cache
616 443152 : mnX = 0; // X-Position to Parent
617 443152 : mnY = 0; // Y-Position to Parent
618 443152 : mnAbsScreenX = 0; // absolute X-position on screen, used for RTL window positioning
619 443152 : mpChildClipRegion = NULL; // Child-Clip-Region when ClipChildren
620 443152 : mpPaintRegion = NULL; // Paint-ClipRegion
621 443152 : mnStyle = 0; // style (init in ImplInitWindow)
622 443152 : mnPrevStyle = 0; // prevstyle (set in SetStyle)
623 443152 : mnExtendedStyle = 0; // extended style (init in ImplInitWindow)
624 443152 : mnPrevExtendedStyle = 0; // prevstyle (set in SetExtendedStyle)
625 443152 : mnType = nType; // type
626 443152 : mnGetFocusFlags = 0; // Flags fuer GetFocus()-Aufruf
627 443152 : mnWaitCount = 0; // Wait-Count (>1 == Warte-MousePointer)
628 443152 : mnPaintFlags = 0; // Flags for ImplCallPaint
629 443152 : mnParentClipMode = 0; // Flags for Parent-ClipChildren-Mode
630 443152 : mnActivateMode = 0; // Will be converted in System/Overlap-Windows
631 443152 : mnDlgCtrlFlags = 0; // DialogControl-Flags
632 443152 : mnLockCount = 0; // LockCount
633 443152 : meAlwaysInputMode = AlwaysInputNone; // neither AlwaysEnableInput nor AlwaysDisableInput called
634 443152 : meHalign = VCL_ALIGN_FILL;
635 443152 : meValign = VCL_ALIGN_FILL;
636 443152 : mePackType = VCL_PACK_START;
637 443152 : mnPadding = 0;
638 443152 : mnGridHeight = 1;
639 443152 : mnGridLeftAttach = -1;
640 443152 : mnGridTopAttach = -1;
641 443152 : mnGridWidth = 1;
642 443152 : mnBorderWidth = 0;
643 443152 : mnMarginLeft = 0;
644 443152 : mnMarginRight = 0;
645 443152 : mnMarginTop = 0;
646 443152 : mnMarginBottom = 0;
647 443152 : mbFrame = false; // true: Window is a frame window
648 443152 : mbBorderWin = false; // true: Window is a border window
649 443152 : mbOverlapWin = false; // true: Window is a overlap window
650 443152 : mbSysWin = false; // true: SystemWindow is the base class
651 443152 : mbDialog = false; // true: Dialog is the base class
652 443152 : mbDockWin = false; // true: DockingWindow is the base class
653 443152 : mbFloatWin = false; // true: FloatingWindow is the base class
654 443152 : mbPushButton = false; // true: PushButton is the base class
655 443152 : mbToolBox = false; // true: ToolBox is the base class
656 443152 : mbMenuFloatingWindow = false; // true: MenuFloatingWindow is the base class
657 443152 : mbToolbarFloatingWindow = false; // true: ImplPopupFloatWin is the base class, used for subtoolbars
658 443152 : mbSplitter = false; // true: Splitter is the base class
659 443152 : mbVisible = false; // true: Show( true ) called
660 443152 : mbOverlapVisible = false; // true: Hide called for visible window from ImplHideAllOverlapWindow()
661 443152 : mbDisabled = false; // true: Enable( false ) called
662 443152 : mbInputDisabled = false; // true: EnableInput( false ) called
663 443152 : mbDropDisabled = false; // true: Drop is enabled
664 443152 : mbNoUpdate = false; // true: SetUpdateMode( false ) called
665 443152 : mbNoParentUpdate = false; // true: SetParentUpdateMode( false ) called
666 443152 : mbActive = false; // true: Window Active
667 443152 : mbParentActive = false; // true: OverlapActive from Parent
668 443152 : mbReallyVisible = false; // true: this and all parents to an overlapped window are visible
669 443152 : mbReallyShown = false; // true: this and all parents to an overlapped window are shown
670 443152 : mbInInitShow = false; // true: we are in InitShow
671 443152 : mbChildNotify = false; // true: ChildNotify
672 443152 : mbChildPtrOverwrite = false; // true: PointerStyle overwrites Child-Pointer
673 443152 : mbNoPtrVisible = false; // true: ShowPointer( false ) called
674 443152 : mbMouseMove = false; // true: BaseMouseMove called
675 443152 : mbPaintFrame = false; // true: Paint is visible, but not painted
676 443152 : mbInPaint = false; // true: Inside PaintHdl
677 443152 : mbMouseButtonDown = false; // true: BaseMouseButtonDown called
678 443152 : mbMouseButtonUp = false; // true: BaseMouseButtonUp called
679 443152 : mbKeyInput = false; // true: BaseKeyInput called
680 443152 : mbKeyUp = false; // true: BaseKeyUp called
681 443152 : mbCommand = false; // true: BaseCommand called
682 443152 : mbDefPos = true; // true: Position is not Set
683 443152 : mbDefSize = true; // true: Size is not Set
684 443152 : mbCallMove = true; // true: Move must be called by Show
685 443152 : mbCallResize = true; // true: Resize must be called by Show
686 443152 : mbWaitSystemResize = true; // true: Wait for System-Resize
687 443152 : mbInitWinClipRegion = true; // true: Calc Window Clip Region
688 443152 : mbInitChildRegion = false; // true: InitChildClipRegion
689 443152 : mbWinRegion = false; // true: Window Region
690 443152 : mbClipChildren = false; // true: Child-window should be clipped
691 443152 : mbClipSiblings = false; // true: Adjacent Child-window should be clipped
692 443152 : mbChildTransparent = false; // true: Child-windows are allowed to switch to transparent (incl. Parent-CLIPCHILDREN)
693 443152 : mbPaintTransparent = false; // true: Paints should be executed on the Parent
694 443152 : mbMouseTransparent = false; // true: Window is transparent for Mouse
695 443152 : mbDlgCtrlStart = false; // true: From here on own Dialog-Control
696 443152 : mbFocusVisible = false; // true: Focus Visible
697 443152 : mbUseNativeFocus = false;
698 443152 : mbNativeFocusVisible = false; // true: native Focus Visible
699 443152 : mbInShowFocus = false; // prevent recursion
700 443152 : mbInHideFocus = false; // prevent recursion
701 443152 : mbTrackVisible = false; // true: Tracking Visible
702 443152 : mbControlForeground = false; // true: Foreground-Property set
703 443152 : mbControlBackground = false; // true: Background-Property set
704 443152 : mbAlwaysOnTop = false; // true: always visible for all others windows
705 443152 : mbCompoundControl = false; // true: Composite Control => Listener...
706 443152 : mbCompoundControlHasFocus = false; // true: Composite Control has focus somewhere
707 443152 : mbPaintDisabled = false; // true: Paint should not be executed
708 443152 : mbAllResize = false; // true: Also sent ResizeEvents with 0,0
709 443152 : mbInDtor = false; // true: We're still in Window-Dtor
710 443152 : mbExtTextInput = false; // true: ExtTextInput-Mode is active
711 443152 : mbInFocusHdl = false; // true: Within GetFocus-Handler
712 443152 : mbCreatedWithToolkit = false;
713 443152 : mbSuppressAccessibilityEvents = false; // true: do not send any accessibility events
714 443152 : mbDrawSelectionBackground = false; // true: draws transparent window background to indicate (toolbox) selection
715 443152 : mbIsInTaskPaneList = false; // true: window was added to the taskpanelist in the topmost system window
716 443152 : mnNativeBackground = 0; // initialize later, depends on type
717 443152 : mbCallHandlersDuringInputDisabled = false; // true: call event handlers even if input is disabled
718 443152 : mbHelpTextDynamic = false; // true: append help id in HELP_DEBUG case
719 443152 : mbFakeFocusSet = false; // true: pretend as if the window has focus.
720 443152 : mbHexpand = false;
721 443152 : mbVexpand = false;
722 443152 : mbExpand = false;
723 443152 : mbFill = true;
724 443152 : mbSecondary = false;
725 443152 : mbNonHomogeneous = false;
726 443152 : }
727 :
728 885652 : WindowImpl::~WindowImpl()
729 : {
730 442826 : delete mpChildClipRegion;
731 442826 : delete mpAccessibleInfos;
732 442826 : delete mpControlFont;
733 442826 : }
734 :
735 : namespace vcl {
736 :
737 3375955 : bool Window::AcquireGraphics() const
738 : {
739 : DBG_TESTSOLARMUTEX();
740 :
741 3375955 : if ( mpGraphics )
742 2953206 : return true;
743 :
744 422749 : mbInitLineColor = true;
745 422749 : mbInitFillColor = true;
746 422749 : mbInitFont = true;
747 422749 : mbInitTextColor = true;
748 422749 : mbInitClipRegion = true;
749 :
750 422749 : ImplSVData* pSVData = ImplGetSVData();
751 :
752 422749 : mpGraphics = mpWindowImpl->mpFrame->AcquireGraphics();
753 : // try harder if no wingraphics was available directly
754 422749 : if ( !mpGraphics )
755 : {
756 : // find another output device in the same frame
757 0 : OutputDevice* pReleaseOutDev = pSVData->maGDIData.mpLastWinGraphics;
758 0 : while ( pReleaseOutDev )
759 : {
760 0 : if ( static_cast<vcl::Window*>(pReleaseOutDev)->mpWindowImpl->mpFrame == mpWindowImpl->mpFrame )
761 0 : break;
762 0 : pReleaseOutDev = pReleaseOutDev->mpPrevGraphics;
763 : }
764 :
765 0 : if ( pReleaseOutDev )
766 : {
767 : // steal the wingraphics from the other outdev
768 0 : mpGraphics = pReleaseOutDev->mpGraphics;
769 0 : pReleaseOutDev->ReleaseGraphics( false );
770 : }
771 : else
772 : {
773 : // if needed retry after releasing least recently used wingraphics
774 0 : while ( !mpGraphics )
775 : {
776 0 : if ( !pSVData->maGDIData.mpLastWinGraphics )
777 0 : break;
778 0 : pSVData->maGDIData.mpLastWinGraphics->ReleaseGraphics();
779 0 : mpGraphics = mpWindowImpl->mpFrame->AcquireGraphics();
780 : }
781 : }
782 : }
783 :
784 : // update global LRU list of wingraphics
785 422749 : if ( mpGraphics )
786 : {
787 422749 : mpNextGraphics = pSVData->maGDIData.mpFirstWinGraphics;
788 422749 : pSVData->maGDIData.mpFirstWinGraphics = const_cast<vcl::Window*>(this);
789 422749 : if ( mpNextGraphics )
790 422433 : mpNextGraphics->mpPrevGraphics = const_cast<vcl::Window*>(this);
791 422749 : if ( !pSVData->maGDIData.mpLastWinGraphics )
792 316 : pSVData->maGDIData.mpLastWinGraphics = const_cast<vcl::Window*>(this);
793 : }
794 :
795 422749 : if ( mpGraphics )
796 : {
797 422749 : mpGraphics->SetXORMode( (ROP_INVERT == meRasterOp) || (ROP_XOR == meRasterOp), ROP_INVERT == meRasterOp );
798 422749 : mpGraphics->setAntiAliasB2DDraw(mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW);
799 : }
800 :
801 422749 : return mpGraphics ? true : false;
802 : }
803 :
804 901340 : void Window::ReleaseGraphics( bool bRelease )
805 : {
806 : DBG_TESTSOLARMUTEX();
807 :
808 901340 : if ( !mpGraphics )
809 1380229 : return;
810 :
811 : // release the fonts of the physically released graphics device
812 422451 : if( bRelease )
813 422451 : ImplReleaseFonts();
814 :
815 422451 : ImplSVData* pSVData = ImplGetSVData();
816 :
817 422451 : vcl::Window* pWindow = (vcl::Window*)this;
818 :
819 422451 : if ( bRelease )
820 422451 : pWindow->mpWindowImpl->mpFrame->ReleaseGraphics( mpGraphics );
821 : // remove from global LRU list of window graphics
822 422451 : if ( mpPrevGraphics )
823 380028 : mpPrevGraphics->mpNextGraphics = mpNextGraphics;
824 : else
825 42423 : pSVData->maGDIData.mpFirstWinGraphics = mpNextGraphics;
826 422451 : if ( mpNextGraphics )
827 422081 : mpNextGraphics->mpPrevGraphics = mpPrevGraphics;
828 : else
829 370 : pSVData->maGDIData.mpLastWinGraphics = mpPrevGraphics;
830 :
831 422451 : mpGraphics = NULL;
832 422451 : mpPrevGraphics = NULL;
833 422451 : mpNextGraphics = NULL;
834 : }
835 :
836 443862 : static sal_Int32 CountDPIScaleFactor(sal_Int32 nDPI)
837 : {
838 443862 : sal_Int32 nResult = 1;
839 :
840 : #ifndef MACOSX
841 : // Setting of HiDPI is unfortunately all only a heuristic; and to add
842 : // insult to an injury, the system is constantly lying to us about
843 : // the DPI and whatnot
844 : // eg. fdo#77059 - set the value from which we do consider the
845 : // screen hi-dpi to greater than 168
846 443862 : if (nDPI > 168)
847 0 : nResult = std::max(sal_Int32(1), (nDPI + 48) / 96);
848 : #else
849 : (void)nDPI;
850 : #endif
851 :
852 443862 : return nResult;
853 : }
854 :
855 443152 : void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData )
856 : {
857 : DBG_ASSERT( mpWindowImpl->mbFrame || pParent, "Window::Window(): pParent == NULL" );
858 :
859 443152 : ImplSVData* pSVData = ImplGetSVData();
860 443152 : vcl::Window* pRealParent = pParent;
861 :
862 : // inherit 3D look
863 443152 : if ( !mpWindowImpl->mbOverlapWin && pParent && (pParent->GetStyle() & WB_3DLOOK) )
864 272543 : nStyle |= WB_3DLOOK;
865 :
866 : // create border window if necessary
867 443152 : if ( !mpWindowImpl->mbFrame && !mpWindowImpl->mbBorderWin && !mpWindowImpl->mpBorderWindow
868 408359 : && (nStyle & (WB_BORDER | WB_SYSTEMCHILDWINDOW) ) )
869 : {
870 22365 : sal_uInt16 nBorderTypeStyle = 0;
871 22365 : if( (nStyle & WB_SYSTEMCHILDWINDOW) )
872 : {
873 : // handle WB_SYSTEMCHILDWINDOW
874 : // these should be analogous to a top level frame; meaning they
875 : // should have a border window with style BORDERWINDOW_STYLE_FRAME
876 : // which controls their size
877 0 : nBorderTypeStyle |= BORDERWINDOW_STYLE_FRAME;
878 0 : nStyle |= WB_BORDER;
879 : }
880 22365 : ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, nStyle & (WB_BORDER | WB_DIALOGCONTROL | WB_NODIALOGCONTROL | WB_NEEDSFOCUS), nBorderTypeStyle );
881 22365 : ((vcl::Window*)pBorderWin)->mpWindowImpl->mpClientWindow = this;
882 22365 : pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
883 22365 : mpWindowImpl->mpBorderWindow = pBorderWin;
884 22365 : pParent = mpWindowImpl->mpBorderWindow;
885 : }
886 420787 : else if( !mpWindowImpl->mbFrame && ! pParent )
887 : {
888 8 : mpWindowImpl->mbOverlapWin = true;
889 8 : mpWindowImpl->mbFrame = true;
890 : }
891 :
892 : // insert window in list
893 443152 : ImplInsertWindow( pParent );
894 443152 : mpWindowImpl->mnStyle = nStyle;
895 :
896 : // Overlap-Window-Data
897 443152 : if ( mpWindowImpl->mbOverlapWin )
898 : {
899 12436 : mpWindowImpl->mpOverlapData = new ImplOverlapData;
900 12436 : mpWindowImpl->mpOverlapData->mpSaveBackDev = NULL;
901 12436 : mpWindowImpl->mpOverlapData->mpSaveBackRgn = NULL;
902 12436 : mpWindowImpl->mpOverlapData->mpNextBackWin = NULL;
903 12436 : mpWindowImpl->mpOverlapData->mnSaveBackSize = 0;
904 12436 : mpWindowImpl->mpOverlapData->mbSaveBack = false;
905 12436 : mpWindowImpl->mpOverlapData->mnTopLevel = 1;
906 : }
907 :
908 443152 : if( pParent && ! mpWindowImpl->mbFrame )
909 430716 : mbEnableRTL = Application::GetSettings().GetLayoutRTL();
910 :
911 : // test for frame creation
912 443152 : if ( mpWindowImpl->mbFrame )
913 : {
914 : // create frame
915 12436 : sal_uLong nFrameStyle = 0;
916 :
917 12436 : if ( nStyle & WB_MOVEABLE )
918 5832 : nFrameStyle |= SAL_FRAME_STYLE_MOVEABLE;
919 12436 : if ( nStyle & WB_SIZEABLE )
920 5790 : nFrameStyle |= SAL_FRAME_STYLE_SIZEABLE;
921 12436 : if ( nStyle & WB_CLOSEABLE )
922 12106 : nFrameStyle |= SAL_FRAME_STYLE_CLOSEABLE;
923 12436 : if ( nStyle & WB_APP )
924 0 : nFrameStyle |= SAL_FRAME_STYLE_DEFAULT;
925 : // check for undecorated floating window
926 12436 : if( // 1. floating windows that are not moveable/sizeable (only closeable allowed)
927 19040 : ( !(nFrameStyle & ~SAL_FRAME_STYLE_CLOSEABLE) &&
928 31476 : ( mpWindowImpl->mbFloatWin || ((GetType() == WINDOW_BORDERWINDOW) && static_cast<ImplBorderWindow*>(this)->mbFloatWindow) || (nStyle & WB_SYSTEMFLOATWIN) ) ) ||
929 : // 2. borderwindows of floaters with ownerdraw decoration
930 12268 : ( ((GetType() == WINDOW_BORDERWINDOW) && static_cast<ImplBorderWindow*>(this)->mbFloatWindow && (nStyle & WB_OWNERDRAWDECORATION) ) ) )
931 : {
932 6274 : nFrameStyle = SAL_FRAME_STYLE_FLOAT;
933 6274 : if( nStyle & WB_OWNERDRAWDECORATION )
934 0 : nFrameStyle |= (SAL_FRAME_STYLE_OWNERDRAWDECORATION | SAL_FRAME_STYLE_NOSHADOW);
935 6274 : if( nStyle & WB_NEEDSFOCUS )
936 0 : nFrameStyle |= SAL_FRAME_STYLE_FLOAT_FOCUSABLE;
937 : }
938 6162 : else if( mpWindowImpl->mbFloatWin )
939 34 : nFrameStyle |= SAL_FRAME_STYLE_TOOLWINDOW;
940 :
941 12436 : if( nStyle & WB_INTROWIN )
942 0 : nFrameStyle |= SAL_FRAME_STYLE_INTRO;
943 12436 : if( nStyle & WB_TOOLTIPWIN )
944 0 : nFrameStyle |= SAL_FRAME_STYLE_TOOLTIP;
945 :
946 12436 : if( nStyle & WB_NOSHADOW )
947 6258 : nFrameStyle |= SAL_FRAME_STYLE_NOSHADOW;
948 :
949 12436 : if( nStyle & WB_SYSTEMCHILDWINDOW )
950 0 : nFrameStyle |= SAL_FRAME_STYLE_SYSTEMCHILD;
951 :
952 12436 : switch (mpWindowImpl->mnType)
953 : {
954 : case WINDOW_DIALOG:
955 : case WINDOW_TABDIALOG:
956 : case WINDOW_MODALDIALOG:
957 : case WINDOW_MODELESSDIALOG:
958 : case WINDOW_MESSBOX:
959 : case WINDOW_INFOBOX:
960 : case WINDOW_WARNINGBOX:
961 : case WINDOW_ERRORBOX:
962 : case WINDOW_QUERYBOX:
963 14 : nFrameStyle |= SAL_FRAME_STYLE_DIALOG;
964 : default:
965 12436 : break;
966 : }
967 :
968 12436 : SalFrame* pParentFrame = NULL;
969 12436 : if ( pParent )
970 6314 : pParentFrame = pParent->mpWindowImpl->mpFrame;
971 : SalFrame* pFrame;
972 12436 : if ( pSystemParentData )
973 0 : pFrame = pSVData->mpDefInst->CreateChildFrame( pSystemParentData, nFrameStyle | SAL_FRAME_STYLE_PLUG );
974 : else
975 12436 : pFrame = pSVData->mpDefInst->CreateFrame( pParentFrame, nFrameStyle );
976 12436 : if ( !pFrame )
977 : {
978 : // do not abort but throw an exception, may be the current thread terminates anyway (plugin-scenario)
979 : throw RuntimeException(
980 : "Could not create system window!",
981 0 : Reference< XInterface >() );
982 : }
983 :
984 12436 : pFrame->SetCallback( this, ImplWindowFrameProc );
985 :
986 : // set window frame data
987 12436 : mpWindowImpl->mpFrameData = new ImplFrameData;
988 12436 : mpWindowImpl->mpFrame = pFrame;
989 12436 : mpWindowImpl->mpFrameWindow = this;
990 12436 : mpWindowImpl->mpOverlapWindow = this;
991 :
992 : // set frame data
993 12436 : mpWindowImpl->mpFrameData->mpNextFrame = pSVData->maWinData.mpFirstFrame;
994 12436 : pSVData->maWinData.mpFirstFrame = this;
995 12436 : mpWindowImpl->mpFrameData->mpFirstOverlap = NULL;
996 12436 : mpWindowImpl->mpFrameData->mpFocusWin = NULL;
997 12436 : mpWindowImpl->mpFrameData->mpMouseMoveWin = NULL;
998 12436 : mpWindowImpl->mpFrameData->mpMouseDownWin = NULL;
999 12436 : mpWindowImpl->mpFrameData->mpFirstBackWin = NULL;
1000 12436 : mpWindowImpl->mpFrameData->mpFontCollection = pSVData->maGDIData.mpScreenFontList;
1001 12436 : mpWindowImpl->mpFrameData->mpFontCache = pSVData->maGDIData.mpScreenFontCache;
1002 12436 : mpWindowImpl->mpFrameData->mnAllSaveBackSize = 0;
1003 12436 : mpWindowImpl->mpFrameData->mnFocusId = 0;
1004 12436 : mpWindowImpl->mpFrameData->mnMouseMoveId = 0;
1005 12436 : mpWindowImpl->mpFrameData->mnLastMouseX = -1;
1006 12436 : mpWindowImpl->mpFrameData->mnLastMouseY = -1;
1007 12436 : mpWindowImpl->mpFrameData->mnBeforeLastMouseX = -1;
1008 12436 : mpWindowImpl->mpFrameData->mnBeforeLastMouseY = -1;
1009 12436 : mpWindowImpl->mpFrameData->mnFirstMouseX = -1;
1010 12436 : mpWindowImpl->mpFrameData->mnFirstMouseY = -1;
1011 12436 : mpWindowImpl->mpFrameData->mnLastMouseWinX = -1;
1012 12436 : mpWindowImpl->mpFrameData->mnLastMouseWinY = -1;
1013 12436 : mpWindowImpl->mpFrameData->mnModalMode = 0;
1014 12436 : mpWindowImpl->mpFrameData->mnMouseDownTime = 0;
1015 12436 : mpWindowImpl->mpFrameData->mnClickCount = 0;
1016 12436 : mpWindowImpl->mpFrameData->mnFirstMouseCode = 0;
1017 12436 : mpWindowImpl->mpFrameData->mnMouseCode = 0;
1018 12436 : mpWindowImpl->mpFrameData->mnMouseMode = 0;
1019 12436 : mpWindowImpl->mpFrameData->meMapUnit = MAP_PIXEL;
1020 12436 : mpWindowImpl->mpFrameData->mbHasFocus = false;
1021 12436 : mpWindowImpl->mpFrameData->mbInMouseMove = false;
1022 12436 : mpWindowImpl->mpFrameData->mbMouseIn = false;
1023 12436 : mpWindowImpl->mpFrameData->mbStartDragCalled = false;
1024 12436 : mpWindowImpl->mpFrameData->mbNeedSysWindow = false;
1025 12436 : mpWindowImpl->mpFrameData->mbMinimized = false;
1026 12436 : mpWindowImpl->mpFrameData->mbStartFocusState = false;
1027 12436 : mpWindowImpl->mpFrameData->mbInSysObjFocusHdl = false;
1028 12436 : mpWindowImpl->mpFrameData->mbInSysObjToTopHdl = false;
1029 12436 : mpWindowImpl->mpFrameData->mbSysObjFocus = false;
1030 12436 : if (!ImplDoTiledRendering())
1031 : {
1032 12436 : mpWindowImpl->mpFrameData->maPaintTimer.SetTimeout( 30 );
1033 12436 : mpWindowImpl->mpFrameData->maPaintTimer.SetTimeoutHdl( LINK( this, Window, ImplHandlePaintHdl ) );
1034 : }
1035 12436 : mpWindowImpl->mpFrameData->maResizeTimer.SetTimeout( 50 );
1036 12436 : mpWindowImpl->mpFrameData->maResizeTimer.SetTimeoutHdl( LINK( this, Window, ImplHandleResizeTimerHdl ) );
1037 12436 : mpWindowImpl->mpFrameData->mbInternalDragGestureRecognizer = false;
1038 :
1039 12436 : if ( pRealParent && IsTopWindow() )
1040 : {
1041 38 : ImplWinData* pParentWinData = pRealParent->ImplGetWinData();
1042 38 : pParentWinData->maTopWindowChildren.push_back( this );
1043 : }
1044 : }
1045 :
1046 : // init data
1047 443152 : mpWindowImpl->mpRealParent = pRealParent;
1048 :
1049 : // #99318: make sure fontcache and list is available before call to SetSettings
1050 443152 : mpFontCollection = mpWindowImpl->mpFrameData->mpFontCollection;
1051 443152 : mpFontCache = mpWindowImpl->mpFrameData->mpFontCache;
1052 :
1053 443152 : if ( mpWindowImpl->mbFrame )
1054 : {
1055 12436 : if ( pParent )
1056 : {
1057 6314 : mpWindowImpl->mpFrameData->mnDPIX = pParent->mpWindowImpl->mpFrameData->mnDPIX;
1058 6314 : mpWindowImpl->mpFrameData->mnDPIY = pParent->mpWindowImpl->mpFrameData->mnDPIY;
1059 : }
1060 : else
1061 : {
1062 6122 : OutputDevice *pOutDev = GetOutDev();
1063 6122 : if ( pOutDev->AcquireGraphics() )
1064 : {
1065 6122 : mpGraphics->GetResolution( mpWindowImpl->mpFrameData->mnDPIX, mpWindowImpl->mpFrameData->mnDPIY );
1066 : }
1067 : }
1068 :
1069 : // add ownerdraw decorated frame windows to list in the top-most frame window
1070 : // so they can be hidden on lose focus
1071 12436 : if( nStyle & WB_OWNERDRAWDECORATION )
1072 0 : ImplGetOwnerDrawList().push_back( this );
1073 :
1074 : // delay settings initialization until first "real" frame
1075 : // this relies on the IntroWindow not needing any system settings
1076 12786 : if ( !pSVData->maAppData.mbSettingsInit &&
1077 350 : ! (nStyle & (WB_INTROWIN|WB_DEFAULTWIN))
1078 : )
1079 : {
1080 : // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings
1081 108 : ImplUpdateGlobalSettings( *pSVData->maAppData.mpSettings );
1082 108 : OutputDevice::SetSettings( *pSVData->maAppData.mpSettings );
1083 108 : pSVData->maAppData.mbSettingsInit = true;
1084 : }
1085 :
1086 : // If we create a Window with default size, query this
1087 : // size directly, because we want resize all Controls to
1088 : // the correct size before we display the window
1089 12436 : if ( nStyle & (WB_MOVEABLE | WB_SIZEABLE | WB_APP) )
1090 5832 : mpWindowImpl->mpFrame->GetClientSize( mnOutWidth, mnOutHeight );
1091 : }
1092 : else
1093 : {
1094 430716 : if ( pParent )
1095 : {
1096 430716 : if ( !ImplIsOverlapWindow() )
1097 : {
1098 430716 : mpWindowImpl->mbDisabled = pParent->mpWindowImpl->mbDisabled;
1099 430716 : mpWindowImpl->mbInputDisabled = pParent->mpWindowImpl->mbInputDisabled;
1100 430716 : mpWindowImpl->meAlwaysInputMode = pParent->mpWindowImpl->meAlwaysInputMode;
1101 : }
1102 :
1103 430716 : OutputDevice::SetSettings( pParent->GetSettings() );
1104 : }
1105 :
1106 : }
1107 :
1108 : // setup the scale factor for Hi-DPI displays
1109 443152 : mnDPIScaleFactor = CountDPIScaleFactor(mpWindowImpl->mpFrameData->mnDPIY);
1110 :
1111 443152 : const StyleSettings& rStyleSettings = mxSettings->GetStyleSettings();
1112 443152 : sal_uInt16 nScreenZoom = rStyleSettings.GetScreenZoom();
1113 443152 : mnDPIX = (mpWindowImpl->mpFrameData->mnDPIX*nScreenZoom)/100;
1114 443152 : mnDPIY = (mpWindowImpl->mpFrameData->mnDPIY*nScreenZoom)/100;
1115 443152 : maFont = rStyleSettings.GetAppFont();
1116 443152 : ImplPointToLogic( maFont );
1117 :
1118 443152 : if ( nStyle & WB_3DLOOK )
1119 : {
1120 351281 : SetTextColor( rStyleSettings.GetButtonTextColor() );
1121 351281 : SetBackground( Wallpaper( rStyleSettings.GetFaceColor() ) );
1122 : }
1123 : else
1124 : {
1125 91871 : SetTextColor( rStyleSettings.GetWindowTextColor() );
1126 91871 : SetBackground( Wallpaper( rStyleSettings.GetWindowColor() ) );
1127 : }
1128 :
1129 443152 : (void)ImplUpdatePos();
1130 :
1131 : // calculate app font res (except for the Intro Window or the default window)
1132 443152 : if ( mpWindowImpl->mbFrame && !pSVData->maGDIData.mnAppFontX && ! (nStyle & (WB_INTROWIN|WB_DEFAULTWIN)) )
1133 108 : ImplInitAppFontData( this );
1134 :
1135 443152 : if ( GetAccessibleParentWindow() && GetParent() != Application::GetDefDialogParent() )
1136 396897 : GetAccessibleParentWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_CHILDCREATED, this );
1137 443152 : }
1138 :
1139 708 : void Window::ImplInitAppFontData( vcl::Window* pWindow )
1140 : {
1141 708 : ImplSVData* pSVData = ImplGetSVData();
1142 708 : long nTextHeight = pWindow->GetTextHeight();
1143 708 : long nTextWidth = pWindow->approximate_char_width() * 8;
1144 708 : long nSymHeight = nTextHeight*4;
1145 : // Make the basis wider if the font is too narrow
1146 : // such that the dialog looks symmetrical and does not become too narrow.
1147 : // Add some extra space when the dialog has the same width,
1148 : // as a little more space is better.
1149 708 : if ( nSymHeight > nTextWidth )
1150 0 : nTextWidth = nSymHeight;
1151 708 : else if ( nSymHeight+5 > nTextWidth )
1152 0 : nTextWidth = nSymHeight+5;
1153 708 : pSVData->maGDIData.mnAppFontX = nTextWidth * 10 / 8;
1154 708 : pSVData->maGDIData.mnAppFontY = nTextHeight * 10;
1155 :
1156 : // FIXME: this is currently only on OS X, check with other
1157 : // platforms
1158 708 : if( pSVData->maNWFData.mbNoFocusRects )
1159 : {
1160 : // try to find out whether there is a large correction
1161 : // of control sizes, if yes, make app font scalings larger
1162 : // so dialog positioning is not completely off
1163 0 : ImplControlValue aControlValue;
1164 0 : Rectangle aCtrlRegion( Point(), Size( nTextWidth < 10 ? 10 : nTextWidth, nTextHeight < 10 ? 10 : nTextHeight ) );
1165 0 : Rectangle aBoundingRgn( aCtrlRegion );
1166 0 : Rectangle aContentRgn( aCtrlRegion );
1167 0 : if( pWindow->GetNativeControlRegion( CTRL_EDITBOX, PART_ENTIRE_CONTROL, aCtrlRegion,
1168 : CTRL_STATE_ENABLED, aControlValue, OUString(),
1169 0 : aBoundingRgn, aContentRgn ) )
1170 : {
1171 : // comment: the magical +6 is for the extra border in bordered
1172 : // (which is the standard) edit fields
1173 0 : if( aContentRgn.GetHeight() - nTextHeight > (nTextHeight+4)/4 )
1174 0 : pSVData->maGDIData.mnAppFontY = (aContentRgn.GetHeight()-4) * 10;
1175 0 : }
1176 : }
1177 :
1178 708 : pSVData->maGDIData.mnRealAppFontX = pSVData->maGDIData.mnAppFontX;
1179 708 : if ( pSVData->maAppData.mnDialogScaleX )
1180 674 : pSVData->maGDIData.mnAppFontX += (pSVData->maGDIData.mnAppFontX*pSVData->maAppData.mnDialogScaleX)/100;
1181 708 : }
1182 :
1183 443152 : void Window::ImplInitWindowData( WindowType nType )
1184 : {
1185 : // We will eventually being removing the inheritance of OutputDevice from Window.
1186 : // It will be replaced with a composition relationship. A Window will use an OutputDevice,
1187 : // it will not *be* an OutputDevice
1188 443152 : mpOutputDevice = (OutputDevice*)this;
1189 :
1190 443152 : mnRefCnt = 0;
1191 :
1192 443152 : mpWindowImpl = new WindowImpl( nType );
1193 :
1194 443152 : meOutDevType = OUTDEV_WINDOW;
1195 :
1196 443152 : mbEnableRTL = Application::GetSettings().GetLayoutRTL(); // true: this outdev will be mirrored if RTL window layout (UI mirroring) is globally active
1197 443152 : }
1198 :
1199 3330944 : ImplWinData* Window::ImplGetWinData() const
1200 : {
1201 3330944 : if ( !mpWindowImpl->mpWinData )
1202 : {
1203 442692 : static const char* pNoNWF = getenv( "SAL_NO_NWF" );
1204 :
1205 442692 : ((vcl::Window*)this)->mpWindowImpl->mpWinData = new ImplWinData;
1206 442692 : mpWindowImpl->mpWinData->mpExtOldText = NULL;
1207 442692 : mpWindowImpl->mpWinData->mpExtOldAttrAry = NULL;
1208 442692 : mpWindowImpl->mpWinData->mpCursorRect = NULL;
1209 442692 : mpWindowImpl->mpWinData->mnCursorExtWidth = 0;
1210 442692 : mpWindowImpl->mpWinData->mpCompositionCharRects = NULL;
1211 442692 : mpWindowImpl->mpWinData->mnCompositionCharRects = 0;
1212 442692 : mpWindowImpl->mpWinData->mpFocusRect = NULL;
1213 442692 : mpWindowImpl->mpWinData->mpTrackRect = NULL;
1214 442692 : mpWindowImpl->mpWinData->mnTrackFlags = 0;
1215 442692 : mpWindowImpl->mpWinData->mnIsTopWindow = (sal_uInt16) ~0; // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow())
1216 442692 : mpWindowImpl->mpWinData->mbMouseOver = false;
1217 442692 : mpWindowImpl->mpWinData->mbEnableNativeWidget = (pNoNWF && *pNoNWF) ? false : true; // true: try to draw this control with native theme API
1218 : }
1219 :
1220 3330944 : return mpWindowImpl->mpWinData;
1221 : }
1222 :
1223 :
1224 0 : void Window::CopyDeviceArea( SalTwoRect& aPosAry, sal_uInt32 nFlags )
1225 : {
1226 0 : if (aPosAry.mnSrcWidth == 0 || aPosAry.mnSrcHeight == 0 || aPosAry.mnDestWidth == 0 || aPosAry.mnDestHeight == 0)
1227 0 : return;
1228 :
1229 0 : if (nFlags & COPYAREA_WINDOWINVALIDATE)
1230 : {
1231 : const Rectangle aSrcRect(Point(aPosAry.mnSrcX, aPosAry.mnSrcY),
1232 0 : Size(aPosAry.mnSrcWidth, aPosAry.mnSrcHeight));
1233 :
1234 : ImplMoveAllInvalidateRegions(aSrcRect,
1235 : aPosAry.mnDestX-aPosAry.mnSrcX,
1236 : aPosAry.mnDestY-aPosAry.mnSrcY,
1237 0 : false);
1238 :
1239 : mpGraphics->CopyArea(aPosAry.mnDestX, aPosAry.mnDestY,
1240 : aPosAry.mnSrcX, aPosAry.mnSrcY,
1241 : aPosAry.mnSrcWidth, aPosAry.mnSrcHeight,
1242 0 : SAL_COPYAREA_WINDOWINVALIDATE, this);
1243 :
1244 0 : return;
1245 : }
1246 :
1247 0 : OutputDevice::CopyDeviceArea(aPosAry, nFlags);
1248 : }
1249 :
1250 1140 : bool Window::ImplCheckUIFont( const vcl::Font& rFont )
1251 : {
1252 1140 : if( ImplGetSVData()->maGDIData.mbNativeFontConfig )
1253 904 : return true;
1254 :
1255 : // create a text string using the localized text of important buttons
1256 236 : OUString aTestText;
1257 : static const StandardButtonType aTestButtons[] =
1258 : {
1259 : BUTTON_OK, BUTTON_CANCEL, BUTTON_CLOSE, BUTTON_ABORT,
1260 : BUTTON_YES, BUTTON_NO, BUTTON_MORE, BUTTON_IGNORE,
1261 : BUTTON_RETRY, BUTTON_HELP
1262 : };
1263 :
1264 236 : const int nTestButtonCount = SAL_N_ELEMENTS(aTestButtons);
1265 2596 : for( int n = 0; n < nTestButtonCount; ++n )
1266 : {
1267 2360 : OUString aButtonStr = Button::GetStandardText( aTestButtons[n] );
1268 : // #i115432# ignore mnemonic+accelerator part of each string
1269 : // TODO: use a string filtering method when it becomes available
1270 2360 : const sal_Int32 nLen = aButtonStr.getLength();
1271 2360 : bool bInside = false;
1272 14632 : for( int i = 0; i < nLen; ++i ) {
1273 12272 : const sal_Unicode c = aButtonStr[ i ];
1274 12272 : if( (c == '('))
1275 0 : bInside = true;
1276 12272 : if( (c == ')'))
1277 0 : bInside = false;
1278 12272 : if( (c == '~')
1279 9912 : || (c == '(') || (c == ')')
1280 9912 : || ((c >= 'A') && (c <= 'Z') && bInside) )
1281 2360 : aButtonStr = aButtonStr.replaceAt( i, 1, " " );
1282 : }
1283 : // append sanitized button text to test string
1284 2360 : aTestText += aButtonStr;
1285 2360 : }
1286 :
1287 236 : const bool bUIFontOk = ( HasGlyphs( rFont, aTestText ) == -1 );
1288 236 : return bUIFontOk;
1289 : }
1290 :
1291 1597 : SalGraphics* Window::ImplGetFrameGraphics() const
1292 : {
1293 1597 : if ( mpWindowImpl->mpFrameWindow->mpGraphics )
1294 : {
1295 1597 : mpWindowImpl->mpFrameWindow->mbInitClipRegion = true;
1296 : }
1297 : else
1298 : {
1299 0 : OutputDevice* pFrameWinOutDev = mpWindowImpl->mpFrameWindow;
1300 0 : if ( ! pFrameWinOutDev->AcquireGraphics() )
1301 : {
1302 0 : return NULL;
1303 : }
1304 : }
1305 1597 : mpWindowImpl->mpFrameWindow->mpGraphics->ResetClipRegion();
1306 1597 : return mpWindowImpl->mpFrameWindow->mpGraphics;
1307 : }
1308 :
1309 292383 : void Window::ImplSetReallyVisible()
1310 : {
1311 : // #i43594# it is possible that INITSHOW was never send, because the visibility state changed between
1312 : // ImplCallInitShow() and ImplSetReallyVisible() when called from Show()
1313 : // mbReallyShown is a useful indicator
1314 292383 : if( !mpWindowImpl->mbReallyShown )
1315 3711 : ImplCallInitShow();
1316 :
1317 292383 : bool bBecameReallyVisible = !mpWindowImpl->mbReallyVisible;
1318 :
1319 292383 : mbDevOutput = true;
1320 292383 : mpWindowImpl->mbReallyVisible = true;
1321 292383 : mpWindowImpl->mbReallyShown = true;
1322 :
1323 : // the SHOW/HIDE events serve as indicators to send child creation/destroy events to the access bridge.
1324 : // For this, the data member of the event must not be NULL.
1325 : // Previously, we did this in Window::Show, but there some events got lost in certain situations. Now
1326 : // we're doing it when the visibility really changes
1327 292383 : if( bBecameReallyVisible && ImplIsAccessibleCandidate() )
1328 253292 : ImplCallEventListeners( VCLEVENT_WINDOW_SHOW, this );
1329 : // TODO. It's kind of a hack that we're re-using the VCLEVENT_WINDOW_SHOW. Normally, we should
1330 : // introduce another event which explicitly triggers the Accessibility implementations.
1331 :
1332 292383 : vcl::Window* pWindow = mpWindowImpl->mpFirstOverlap;
1333 584766 : while ( pWindow )
1334 : {
1335 0 : if ( pWindow->mpWindowImpl->mbVisible )
1336 0 : pWindow->ImplSetReallyVisible();
1337 0 : pWindow = pWindow->mpWindowImpl->mpNext;
1338 : }
1339 :
1340 292383 : pWindow = mpWindowImpl->mpFirstChild;
1341 871846 : while ( pWindow )
1342 : {
1343 287080 : if ( pWindow->mpWindowImpl->mbVisible )
1344 207687 : pWindow->ImplSetReallyVisible();
1345 287080 : pWindow = pWindow->mpWindowImpl->mpNext;
1346 : }
1347 292383 : }
1348 :
1349 51144344 : void Window::ImplAddDel( ImplDelData* pDel ) // TODO: make "const" when incompatiblity ok
1350 : {
1351 : DBG_ASSERT( !pDel->mpWindow, "Window::ImplAddDel(): cannot add ImplDelData twice !" );
1352 51144344 : if( !pDel->mpWindow )
1353 : {
1354 51144344 : pDel->mpWindow = this; // #112873# store ref to this window, so pDel can remove itself
1355 51144344 : pDel->mpNext = mpWindowImpl->mpFirstDel;
1356 51144344 : mpWindowImpl->mpFirstDel = pDel;
1357 : }
1358 51144344 : }
1359 :
1360 51144340 : void Window::ImplRemoveDel( ImplDelData* pDel ) // TODO: make "const" when incompatiblity ok
1361 : {
1362 51144340 : pDel->mpWindow = NULL; // #112873# pDel is not associated with a Window anymore
1363 51144340 : if ( mpWindowImpl->mpFirstDel == pDel )
1364 51144340 : mpWindowImpl->mpFirstDel = pDel->mpNext;
1365 : else
1366 : {
1367 0 : ImplDelData* pData = mpWindowImpl->mpFirstDel;
1368 0 : while ( pData->mpNext != pDel )
1369 0 : pData = pData->mpNext;
1370 0 : pData->mpNext = pDel->mpNext;
1371 : }
1372 51144340 : }
1373 :
1374 87774 : void Window::ImplInitResolutionSettings()
1375 : {
1376 : // recalculate AppFont-resolution and DPI-resolution
1377 87774 : if ( mpWindowImpl->mbFrame )
1378 : {
1379 710 : const StyleSettings& rStyleSettings = mxSettings->GetStyleSettings();
1380 710 : sal_uInt16 nScreenZoom = rStyleSettings.GetScreenZoom();
1381 710 : mnDPIX = (mpWindowImpl->mpFrameData->mnDPIX*nScreenZoom)/100;
1382 710 : mnDPIY = (mpWindowImpl->mpFrameData->mnDPIY*nScreenZoom)/100;
1383 :
1384 : // setup the scale factor for Hi-DPI displays
1385 710 : mnDPIScaleFactor = CountDPIScaleFactor(mpWindowImpl->mpFrameData->mnDPIY);
1386 710 : SetPointFont( rStyleSettings.GetAppFont() );
1387 : }
1388 87064 : else if ( mpWindowImpl->mpParent )
1389 : {
1390 87064 : mnDPIX = mpWindowImpl->mpParent->mnDPIX;
1391 87064 : mnDPIY = mpWindowImpl->mpParent->mnDPIY;
1392 87064 : mnDPIScaleFactor = mpWindowImpl->mpParent->mnDPIScaleFactor;
1393 : }
1394 :
1395 : // update the recalculated values for logical units
1396 : // and also tools belonging to the values
1397 87774 : if ( IsMapMode() )
1398 : {
1399 76406 : MapMode aMapMode = GetMapMode();
1400 76406 : SetMapMode();
1401 76406 : SetMapMode( aMapMode );
1402 : }
1403 87774 : }
1404 :
1405 613622 : void Window::ImplPointToLogic( vcl::Font& rFont ) const
1406 : {
1407 613622 : Size aSize = rFont.GetSize();
1408 613622 : sal_uInt16 nScreenFontZoom = mxSettings->GetStyleSettings().GetScreenFontZoom();
1409 :
1410 613622 : if ( aSize.Width() )
1411 : {
1412 6656 : aSize.Width() *= mpWindowImpl->mpFrameData->mnDPIX;
1413 6656 : aSize.Width() += 72/2;
1414 6656 : aSize.Width() /= 72;
1415 6656 : aSize.Width() *= nScreenFontZoom;
1416 6656 : aSize.Width() /= 100;
1417 : }
1418 613622 : aSize.Height() *= mpWindowImpl->mpFrameData->mnDPIY;
1419 613622 : aSize.Height() += 72/2;
1420 613622 : aSize.Height() /= 72;
1421 613622 : aSize.Height() *= nScreenFontZoom;
1422 613622 : aSize.Height() /= 100;
1423 :
1424 613622 : if ( IsMapModeEnabled() )
1425 0 : aSize = PixelToLogic( aSize );
1426 :
1427 613622 : rFont.SetSize( aSize );
1428 613622 : }
1429 :
1430 16 : void Window::ImplLogicToPoint( vcl::Font& rFont ) const
1431 : {
1432 16 : Size aSize = rFont.GetSize();
1433 16 : sal_uInt16 nScreenFontZoom = mxSettings->GetStyleSettings().GetScreenFontZoom();
1434 :
1435 16 : if ( IsMapModeEnabled() )
1436 0 : aSize = LogicToPixel( aSize );
1437 :
1438 16 : if ( aSize.Width() )
1439 : {
1440 0 : aSize.Width() *= 100;
1441 0 : aSize.Width() /= nScreenFontZoom;
1442 0 : aSize.Width() *= 72;
1443 0 : aSize.Width() += mpWindowImpl->mpFrameData->mnDPIX/2;
1444 0 : aSize.Width() /= mpWindowImpl->mpFrameData->mnDPIX;
1445 : }
1446 16 : aSize.Height() *= 100;
1447 16 : aSize.Height() /= nScreenFontZoom;
1448 16 : aSize.Height() *= 72;
1449 16 : aSize.Height() += mpWindowImpl->mpFrameData->mnDPIY/2;
1450 16 : aSize.Height() /= mpWindowImpl->mpFrameData->mnDPIY;
1451 :
1452 16 : rFont.SetSize( aSize );
1453 16 : }
1454 :
1455 4056595 : bool Window::ImplUpdatePos()
1456 : {
1457 4056595 : bool bSysChild = false;
1458 :
1459 4056595 : if ( ImplIsOverlapWindow() )
1460 : {
1461 12456 : mnOutOffX = mpWindowImpl->mnX;
1462 12456 : mnOutOffY = mpWindowImpl->mnY;
1463 : }
1464 : else
1465 : {
1466 4044139 : vcl::Window* pParent = ImplGetParent();
1467 :
1468 4044139 : mnOutOffX = mpWindowImpl->mnX + pParent->mnOutOffX;
1469 4044139 : mnOutOffY = mpWindowImpl->mnY + pParent->mnOutOffY;
1470 : }
1471 :
1472 4056595 : vcl::Window* pChild = mpWindowImpl->mpFirstChild;
1473 11033333 : while ( pChild )
1474 : {
1475 2920143 : if ( pChild->ImplUpdatePos() )
1476 196 : bSysChild = true;
1477 2920143 : pChild = pChild->mpWindowImpl->mpNext;
1478 : }
1479 :
1480 4056595 : if ( mpWindowImpl->mpSysObj )
1481 92 : bSysChild = true;
1482 :
1483 4056595 : return bSysChild;
1484 : }
1485 :
1486 1838 : void Window::ImplUpdateSysObjPos()
1487 : {
1488 1838 : if ( mpWindowImpl->mpSysObj )
1489 58 : mpWindowImpl->mpSysObj->SetPosSize( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight );
1490 :
1491 1838 : vcl::Window* pChild = mpWindowImpl->mpFirstChild;
1492 5456 : while ( pChild )
1493 : {
1494 1780 : pChild->ImplUpdateSysObjPos();
1495 1780 : pChild = pChild->mpWindowImpl->mpNext;
1496 : }
1497 1838 : }
1498 :
1499 1350782 : void Window::ImplPosSizeWindow( long nX, long nY,
1500 : long nWidth, long nHeight, sal_uInt16 nFlags )
1501 : {
1502 1350782 : bool bNewPos = false;
1503 1350782 : bool bNewSize = false;
1504 1350782 : bool bCopyBits = false;
1505 1350782 : long nOldOutOffX = mnOutOffX;
1506 1350782 : long nOldOutOffY = mnOutOffY;
1507 1350782 : long nOldOutWidth = mnOutWidth;
1508 1350782 : long nOldOutHeight = mnOutHeight;
1509 1350782 : vcl::Region* pOverlapRegion = NULL;
1510 1350782 : vcl::Region* pOldRegion = NULL;
1511 :
1512 1350782 : if ( IsReallyVisible() )
1513 : {
1514 493276 : if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
1515 0 : ImplInvalidateAllOverlapBackgrounds();
1516 :
1517 : Rectangle aOldWinRect( Point( nOldOutOffX, nOldOutOffY ),
1518 493276 : Size( nOldOutWidth, nOldOutHeight ) );
1519 493276 : pOldRegion = new vcl::Region( aOldWinRect );
1520 493276 : if ( mpWindowImpl->mbWinRegion )
1521 0 : pOldRegion->Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
1522 :
1523 1262042 : if ( mnOutWidth && mnOutHeight && !mpWindowImpl->mbPaintTransparent &&
1524 980989 : !mpWindowImpl->mbInitWinClipRegion && !mpWindowImpl->maWinClipRegion.IsEmpty() &&
1525 68269 : !HasPaintEvent() )
1526 1722 : bCopyBits = true;
1527 : }
1528 :
1529 1350782 : bool bnXRecycled = false; // avoid duplicate mirroring in RTL case
1530 1350782 : if ( nFlags & WINDOW_POSSIZE_WIDTH )
1531 : {
1532 1271064 : if(!( nFlags & WINDOW_POSSIZE_X ))
1533 : {
1534 244880 : nX = mpWindowImpl->mnX;
1535 244880 : nFlags |= WINDOW_POSSIZE_X;
1536 244880 : bnXRecycled = true; // we're using a mnX which was already mirrored in RTL case
1537 : }
1538 :
1539 1271064 : if ( nWidth < 0 )
1540 47608 : nWidth = 0;
1541 1271064 : if ( nWidth != mnOutWidth )
1542 : {
1543 458059 : mnOutWidth = nWidth;
1544 458059 : bNewSize = true;
1545 458059 : bCopyBits = false;
1546 : }
1547 : }
1548 1350782 : if ( nFlags & WINDOW_POSSIZE_HEIGHT )
1549 : {
1550 1276288 : if ( nHeight < 0 )
1551 29585 : nHeight = 0;
1552 1276288 : if ( nHeight != mnOutHeight )
1553 : {
1554 542665 : mnOutHeight = nHeight;
1555 542665 : bNewSize = true;
1556 542665 : bCopyBits = false;
1557 : }
1558 : }
1559 :
1560 1350782 : if ( nFlags & WINDOW_POSSIZE_X )
1561 : {
1562 1345054 : long nOrgX = nX;
1563 : // --- RTL --- (compare the screen coordinates)
1564 1345054 : Point aPtDev( Point( nX+mnOutOffX, 0 ) );
1565 1345054 : OutputDevice *pOutDev = GetOutDev();
1566 1345054 : if( pOutDev->HasMirroredGraphics() )
1567 : {
1568 0 : mpGraphics->mirror( aPtDev.X(), this );
1569 :
1570 : // #106948# always mirror our pos if our parent is not mirroring, even
1571 : // if we are also not mirroring
1572 : // --- RTL --- check if parent is in different coordinates
1573 0 : if( !bnXRecycled && mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->ImplIsAntiparallel() )
1574 : {
1575 : // --- RTL --- (re-mirror at parent window)
1576 0 : nX = mpWindowImpl->mpParent->mnOutWidth - mnOutWidth - nX;
1577 : }
1578 : /* #i99166# An LTR window in RTL UI that gets sized only would be
1579 : expected to not moved its upper left point
1580 : */
1581 0 : if( bnXRecycled )
1582 : {
1583 0 : if( ImplIsAntiparallel() )
1584 : {
1585 0 : aPtDev.X() = mpWindowImpl->mnAbsScreenX;
1586 0 : nOrgX = mpWindowImpl->maPos.X();
1587 : }
1588 : }
1589 : }
1590 1345054 : else if( !bnXRecycled && mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->ImplIsAntiparallel() )
1591 : {
1592 : // mirrored window in LTR UI
1593 : {
1594 : // --- RTL --- (re-mirror at parent window)
1595 900 : nX = mpWindowImpl->mpParent->mnOutWidth - mnOutWidth - nX;
1596 : }
1597 : }
1598 :
1599 : // check maPos as well, as it could have been changed for client windows (ImplCallMove())
1600 1345054 : if ( mpWindowImpl->mnAbsScreenX != aPtDev.X() || nX != mpWindowImpl->mnX || nOrgX != mpWindowImpl->maPos.X() )
1601 : {
1602 567614 : if ( bCopyBits && !pOverlapRegion )
1603 : {
1604 223 : pOverlapRegion = new vcl::Region();
1605 : ImplCalcOverlapRegion( Rectangle( Point( mnOutOffX, mnOutOffY ),
1606 : Size( mnOutWidth, mnOutHeight ) ),
1607 223 : *pOverlapRegion, false, true, true );
1608 : }
1609 567614 : mpWindowImpl->mnX = nX;
1610 567614 : mpWindowImpl->maPos.X() = nOrgX;
1611 567614 : mpWindowImpl->mnAbsScreenX = aPtDev.X(); // --- RTL --- (store real screen pos)
1612 567614 : bNewPos = true;
1613 : }
1614 : }
1615 1350782 : if ( nFlags & WINDOW_POSSIZE_Y )
1616 : {
1617 : // check maPos as well, as it could have been changed for client windows (ImplCallMove())
1618 1100418 : if ( nY != mpWindowImpl->mnY || nY != mpWindowImpl->maPos.Y() )
1619 : {
1620 326754 : if ( bCopyBits && !pOverlapRegion )
1621 : {
1622 0 : pOverlapRegion = new vcl::Region();
1623 : ImplCalcOverlapRegion( Rectangle( Point( mnOutOffX, mnOutOffY ),
1624 : Size( mnOutWidth, mnOutHeight ) ),
1625 0 : *pOverlapRegion, false, true, true );
1626 : }
1627 326754 : mpWindowImpl->mnY = nY;
1628 326754 : mpWindowImpl->maPos.Y() = nY;
1629 326754 : bNewPos = true;
1630 : }
1631 : }
1632 :
1633 1350782 : if ( bNewPos || bNewSize )
1634 : {
1635 967592 : bool bUpdateSysObjPos = false;
1636 967592 : if ( bNewPos )
1637 666172 : bUpdateSysObjPos = ImplUpdatePos();
1638 :
1639 : // the borderwindow always specifies the position for its client window
1640 967592 : if ( mpWindowImpl->mpBorderWindow )
1641 151917 : mpWindowImpl->maPos = mpWindowImpl->mpBorderWindow->mpWindowImpl->maPos;
1642 :
1643 967592 : if ( mpWindowImpl->mpClientWindow )
1644 : {
1645 : mpWindowImpl->mpClientWindow->ImplPosSizeWindow( mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder,
1646 : mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder,
1647 57346 : mnOutWidth-mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnRightBorder,
1648 57346 : mnOutHeight-mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnBottomBorder,
1649 : WINDOW_POSSIZE_X | WINDOW_POSSIZE_Y |
1650 114692 : WINDOW_POSSIZE_WIDTH | WINDOW_POSSIZE_HEIGHT );
1651 : // If we have a client window, then this is the position
1652 : // of the Application's floating windows
1653 57346 : mpWindowImpl->mpClientWindow->mpWindowImpl->maPos = mpWindowImpl->maPos;
1654 57346 : if ( bNewPos )
1655 : {
1656 30402 : if ( mpWindowImpl->mpClientWindow->IsVisible() )
1657 : {
1658 19234 : mpWindowImpl->mpClientWindow->ImplCallMove();
1659 : }
1660 : else
1661 : {
1662 11168 : mpWindowImpl->mpClientWindow->mpWindowImpl->mbCallMove = true;
1663 : }
1664 : }
1665 : }
1666 :
1667 : // Move()/Resize() will be called only for Show(), such that
1668 : // at least one is called before Show()
1669 967592 : if ( IsVisible() )
1670 : {
1671 617117 : if ( bNewPos )
1672 : {
1673 429473 : ImplCallMove();
1674 : }
1675 617117 : if ( bNewSize )
1676 : {
1677 423628 : ImplCallResize();
1678 : }
1679 : }
1680 : else
1681 : {
1682 350475 : if ( bNewPos )
1683 236699 : mpWindowImpl->mbCallMove = true;
1684 350475 : if ( bNewSize )
1685 283181 : mpWindowImpl->mbCallResize = true;
1686 : }
1687 :
1688 967592 : bool bUpdateSysObjClip = false;
1689 967592 : if ( IsReallyVisible() )
1690 : {
1691 317244 : if ( bNewPos || bNewSize )
1692 : {
1693 : // reset background storage
1694 317244 : if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mpSaveBackDev )
1695 0 : ImplDeleteOverlapBackground();
1696 317244 : if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
1697 0 : ImplInvalidateAllOverlapBackgrounds();
1698 : // set Clip-Flag
1699 317244 : bUpdateSysObjClip = !ImplSetClipFlag( true );
1700 : }
1701 :
1702 : // invalidate window content ?
1703 317244 : if ( bNewPos || (mnOutWidth > nOldOutWidth) || (mnOutHeight > nOldOutHeight) )
1704 : {
1705 191987 : if ( bNewPos )
1706 : {
1707 168381 : bool bInvalidate = false;
1708 168381 : bool bParentPaint = true;
1709 168381 : if ( !ImplIsOverlapWindow() )
1710 168381 : bParentPaint = mpWindowImpl->mpParent->IsPaintEnabled();
1711 168381 : if ( bCopyBits && bParentPaint && !HasPaintEvent() )
1712 : {
1713 223 : Point aPoint( mnOutOffX, mnOutOffY );
1714 : vcl::Region aRegion( Rectangle( aPoint,
1715 223 : Size( mnOutWidth, mnOutHeight ) ) );
1716 223 : if ( mpWindowImpl->mbWinRegion )
1717 0 : aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
1718 223 : ImplClipBoundaries( aRegion, false, true );
1719 223 : if ( !pOverlapRegion->IsEmpty() )
1720 : {
1721 0 : pOverlapRegion->Move( mnOutOffX-nOldOutOffX, mnOutOffY-nOldOutOffY );
1722 0 : aRegion.Exclude( *pOverlapRegion );
1723 : }
1724 223 : if ( !aRegion.IsEmpty() )
1725 : {
1726 : // adapt Paint areas
1727 : ImplMoveAllInvalidateRegions( Rectangle( Point( nOldOutOffX, nOldOutOffY ),
1728 : Size( nOldOutWidth, nOldOutHeight ) ),
1729 : mnOutOffX-nOldOutOffX, mnOutOffY-nOldOutOffY,
1730 223 : true );
1731 223 : SalGraphics* pGraphics = ImplGetFrameGraphics();
1732 223 : if ( pGraphics )
1733 : {
1734 :
1735 223 : OutputDevice *pOutDev = GetOutDev();
1736 223 : const bool bSelectClipRegion = pOutDev->SelectClipRegion( aRegion, pGraphics );
1737 223 : if ( bSelectClipRegion )
1738 : {
1739 : pGraphics->CopyArea( mnOutOffX, mnOutOffY,
1740 : nOldOutOffX, nOldOutOffY,
1741 : nOldOutWidth, nOldOutHeight,
1742 223 : SAL_COPYAREA_WINDOWINVALIDATE, this );
1743 : }
1744 : else
1745 0 : bInvalidate = true;
1746 : }
1747 : else
1748 0 : bInvalidate = true;
1749 223 : if ( !bInvalidate )
1750 : {
1751 223 : if ( !pOverlapRegion->IsEmpty() )
1752 0 : ImplInvalidateFrameRegion( pOverlapRegion, INVALIDATE_CHILDREN );
1753 : }
1754 : }
1755 : else
1756 0 : bInvalidate = true;
1757 : }
1758 : else
1759 168158 : bInvalidate = true;
1760 168381 : if ( bInvalidate )
1761 168158 : ImplInvalidateFrameRegion( NULL, INVALIDATE_CHILDREN );
1762 : }
1763 : else
1764 : {
1765 23606 : Point aPoint( mnOutOffX, mnOutOffY );
1766 : vcl::Region aRegion( Rectangle( aPoint,
1767 23606 : Size( mnOutWidth, mnOutHeight ) ) );
1768 23606 : aRegion.Exclude( *pOldRegion );
1769 23606 : if ( mpWindowImpl->mbWinRegion )
1770 0 : aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
1771 23606 : ImplClipBoundaries( aRegion, false, true );
1772 23606 : if ( !aRegion.IsEmpty() )
1773 22837 : ImplInvalidateFrameRegion( &aRegion, INVALIDATE_CHILDREN );
1774 : }
1775 : }
1776 :
1777 : // invalidate Parent or Overlaps
1778 466107 : if ( bNewPos ||
1779 259702 : (mnOutWidth < nOldOutWidth) || (mnOutHeight < nOldOutHeight) )
1780 : {
1781 293696 : vcl::Region aRegion( *pOldRegion );
1782 293696 : if ( !mpWindowImpl->mbPaintTransparent )
1783 283673 : ImplExcludeWindowRegion( aRegion );
1784 293696 : ImplClipBoundaries( aRegion, false, true );
1785 293696 : if ( !aRegion.IsEmpty() && !mpWindowImpl->mpBorderWindow )
1786 99357 : ImplInvalidateParentFrameRegion( aRegion );
1787 : }
1788 : }
1789 :
1790 : // adapt system objects
1791 967592 : if ( bUpdateSysObjClip )
1792 0 : ImplUpdateSysObjClip();
1793 967592 : if ( bUpdateSysObjPos )
1794 58 : ImplUpdateSysObjPos();
1795 967592 : if ( bNewSize && mpWindowImpl->mpSysObj )
1796 0 : mpWindowImpl->mpSysObj->SetPosSize( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight );
1797 : }
1798 :
1799 1350782 : delete pOverlapRegion;
1800 1350782 : delete pOldRegion;
1801 1350782 : }
1802 :
1803 31479 : void Window::ImplNewInputContext()
1804 : {
1805 31479 : ImplSVData* pSVData = ImplGetSVData();
1806 31479 : vcl::Window* pFocusWin = pSVData->maWinData.mpFocusWin;
1807 31479 : if ( !pFocusWin )
1808 22056 : return;
1809 :
1810 : // Is InputContext changed?
1811 31479 : const InputContext& rInputContext = pFocusWin->GetInputContext();
1812 31479 : if ( rInputContext == pFocusWin->mpWindowImpl->mpFrameData->maOldInputContext )
1813 22056 : return;
1814 :
1815 9423 : pFocusWin->mpWindowImpl->mpFrameData->maOldInputContext = rInputContext;
1816 :
1817 : SalInputContext aNewContext;
1818 9423 : const vcl::Font& rFont = rInputContext.GetFont();
1819 9423 : const OUString& rFontName = rFont.GetName();
1820 9423 : ImplFontEntry* pFontEntry = NULL;
1821 9423 : aNewContext.mpFont = NULL;
1822 9423 : if (!rFontName.isEmpty())
1823 : {
1824 687 : OutputDevice *pFocusWinOutDev = pFocusWin->GetOutDev();
1825 687 : Size aSize = pFocusWinOutDev->ImplLogicToDevicePixel( rFont.GetSize() );
1826 687 : if ( !aSize.Height() )
1827 : {
1828 : // only set default sizes if the font height in logical
1829 : // coordinates equals 0
1830 643 : if ( rFont.GetSize().Height() )
1831 0 : aSize.Height() = 1;
1832 : else
1833 643 : aSize.Height() = (12*pFocusWin->mnDPIY)/72;
1834 : }
1835 : pFontEntry = pFocusWin->mpFontCache->GetFontEntry( pFocusWin->mpFontCollection,
1836 687 : rFont, aSize, static_cast<float>(aSize.Height()) );
1837 687 : if ( pFontEntry )
1838 687 : aNewContext.mpFont = &pFontEntry->maFontSelData;
1839 : }
1840 9423 : aNewContext.meLanguage = rFont.GetLanguage();
1841 9423 : aNewContext.mnOptions = rInputContext.GetOptions();
1842 9423 : pFocusWin->ImplGetFrame()->SetInputContext( &aNewContext );
1843 :
1844 9423 : if ( pFontEntry )
1845 687 : pFocusWin->mpFontCache->Release( pFontEntry );
1846 : }
1847 :
1848 16282 : void Window::doLazyDelete()
1849 : {
1850 16282 : SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(this);
1851 16282 : DockingWindow* pDockWin = dynamic_cast<DockingWindow*>(this);
1852 16282 : if( pSysWin || ( pDockWin && pDockWin->IsFloatingMode() ) )
1853 : {
1854 20 : Show( false );
1855 20 : SetParent( ImplGetDefaultWindow() );
1856 : }
1857 16282 : vcl::LazyDeletor<vcl::Window>::Delete( this );
1858 16282 : }
1859 :
1860 0 : sal_uInt16 Window::GetIndicatorState() const
1861 : {
1862 0 : return mpWindowImpl->mpFrame->GetIndicatorState().mnState;
1863 : }
1864 :
1865 0 : void Window::SimulateKeyPress( sal_uInt16 nKeyCode ) const
1866 : {
1867 0 : mpWindowImpl->mpFrame->SimulateKeyPress(nKeyCode);
1868 0 : }
1869 :
1870 0 : void Window::KeyInput( const KeyEvent& rKEvt )
1871 : {
1872 0 : NotifyEvent aNEvt( EVENT_KEYINPUT, this, &rKEvt );
1873 0 : if ( !Notify( aNEvt ) )
1874 0 : mpWindowImpl->mbKeyInput = true;
1875 0 : }
1876 :
1877 0 : void Window::KeyUp( const KeyEvent& rKEvt )
1878 : {
1879 0 : NotifyEvent aNEvt( EVENT_KEYUP, this, &rKEvt );
1880 0 : if ( !Notify( aNEvt ) )
1881 0 : mpWindowImpl->mbKeyUp = true;
1882 0 : }
1883 :
1884 0 : void Window::Draw( OutputDevice*, const Point&, const Size&, sal_uLong )
1885 : {
1886 0 : }
1887 :
1888 745858 : void Window::Move() {}
1889 :
1890 475515 : void Window::Resize() {}
1891 :
1892 16388 : void Window::Activate() {}
1893 :
1894 6210 : void Window::Deactivate() {}
1895 :
1896 20406 : void Window::GetFocus()
1897 : {
1898 20406 : if ( HasFocus() && mpWindowImpl->mpLastFocusWindow && !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) )
1899 : {
1900 6 : ImplDelData aDogtag( this );
1901 6 : mpWindowImpl->mpLastFocusWindow->GrabFocus();
1902 6 : if( aDogtag.IsDead() )
1903 20406 : return;
1904 : }
1905 :
1906 20406 : NotifyEvent aNEvt( EVENT_GETFOCUS, this );
1907 20406 : Notify( aNEvt );
1908 : }
1909 :
1910 25408 : void Window::LoseFocus()
1911 : {
1912 25408 : NotifyEvent aNEvt( EVENT_LOSEFOCUS, this );
1913 25408 : Notify( aNEvt );
1914 25408 : }
1915 :
1916 0 : void Window::RequestHelp( const HelpEvent& rHEvt )
1917 : {
1918 : // if Balloon-Help is requested, show the balloon
1919 : // with help text set
1920 0 : if ( rHEvt.GetMode() & HELPMODE_BALLOON )
1921 : {
1922 0 : OUString rStr = GetHelpText();
1923 0 : if ( rStr.isEmpty() )
1924 0 : rStr = GetQuickHelpText();
1925 0 : if ( rStr.isEmpty() && ImplGetParent() && !ImplIsOverlapWindow() )
1926 0 : ImplGetParent()->RequestHelp( rHEvt );
1927 : else
1928 0 : Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), rStr );
1929 : }
1930 0 : else if ( rHEvt.GetMode() & HELPMODE_QUICK )
1931 : {
1932 0 : const OUString& rStr = GetQuickHelpText();
1933 0 : if ( rStr.isEmpty() && ImplGetParent() && !ImplIsOverlapWindow() )
1934 0 : ImplGetParent()->RequestHelp( rHEvt );
1935 : else
1936 : {
1937 0 : Point aPos = GetPosPixel();
1938 0 : if ( ImplGetParent() && !ImplIsOverlapWindow() )
1939 0 : aPos = ImplGetParent()->OutputToScreenPixel( aPos );
1940 0 : Rectangle aRect( aPos, GetSizePixel() );
1941 0 : OUString aHelpText;
1942 0 : if ( !rStr.isEmpty() )
1943 0 : aHelpText = GetHelpText();
1944 0 : Help::ShowQuickHelp( this, aRect, rStr, aHelpText, QUICKHELP_CTRLTEXT );
1945 : }
1946 : }
1947 : else
1948 : {
1949 0 : OUString aStrHelpId( OStringToOUString( GetHelpId(), RTL_TEXTENCODING_UTF8 ) );
1950 0 : if ( aStrHelpId.isEmpty() && ImplGetParent() )
1951 0 : ImplGetParent()->RequestHelp( rHEvt );
1952 : else
1953 : {
1954 0 : Help* pHelp = Application::GetHelp();
1955 0 : if ( pHelp )
1956 : {
1957 0 : if( !aStrHelpId.isEmpty() )
1958 0 : pHelp->Start( aStrHelpId, this );
1959 : else
1960 0 : pHelp->Start( OUString( OOO_HELP_INDEX ), this );
1961 : }
1962 0 : }
1963 : }
1964 0 : }
1965 :
1966 0 : void Window::Command( const CommandEvent& rCEvt )
1967 : {
1968 0 : ImplCallEventListeners( VCLEVENT_WINDOW_COMMAND, (void*)&rCEvt );
1969 :
1970 0 : NotifyEvent aNEvt( EVENT_COMMAND, this, &rCEvt );
1971 0 : if ( !Notify( aNEvt ) )
1972 0 : mpWindowImpl->mbCommand = true;
1973 0 : }
1974 :
1975 0 : void Window::Tracking( const TrackingEvent& rTEvt )
1976 : {
1977 :
1978 0 : ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
1979 0 : if( pWrapper )
1980 0 : pWrapper->Tracking( rTEvt );
1981 0 : }
1982 :
1983 2011493 : void Window::StateChanged(StateChangedType eType)
1984 : {
1985 2011493 : switch (eType)
1986 : {
1987 : //stuff that doesn't invalidate the layout
1988 : case StateChangedType::CONTROLFOREGROUND:
1989 : case StateChangedType::CONTROLBACKGROUND:
1990 : case StateChangedType::TRANSPARENT:
1991 : case StateChangedType::UPDATEMODE:
1992 : case StateChangedType::READONLY:
1993 : case StateChangedType::ENABLE:
1994 : case StateChangedType::STATE:
1995 : case StateChangedType::DATA:
1996 : case StateChangedType::INITSHOW:
1997 : case StateChangedType::CONTROL_FOCUS:
1998 1209653 : break;
1999 : //stuff that does invalidate the layout
2000 : default:
2001 801840 : queue_resize(eType);
2002 801840 : break;
2003 : }
2004 2011493 : }
2005 :
2006 0 : bool Window::IsLocked( bool bChildren ) const
2007 : {
2008 0 : if ( mpWindowImpl->mnLockCount != 0 )
2009 0 : return true;
2010 :
2011 0 : if ( bChildren || mpWindowImpl->mbChildNotify )
2012 : {
2013 0 : vcl::Window* pChild = mpWindowImpl->mpFirstChild;
2014 0 : while ( pChild )
2015 : {
2016 0 : if ( pChild->IsLocked( true ) )
2017 0 : return true;
2018 0 : pChild = pChild->mpWindowImpl->mpNext;
2019 : }
2020 : }
2021 :
2022 0 : return false;
2023 : }
2024 :
2025 93684 : void Window::SetStyle( WinBits nStyle )
2026 : {
2027 :
2028 93684 : if ( mpWindowImpl->mnStyle != nStyle )
2029 : {
2030 43810 : mpWindowImpl->mnPrevStyle = mpWindowImpl->mnStyle;
2031 43810 : mpWindowImpl->mnStyle = nStyle;
2032 43810 : StateChanged( StateChangedType::STYLE );
2033 : }
2034 93684 : }
2035 :
2036 165559 : void Window::SetExtendedStyle( WinBits nExtendedStyle )
2037 : {
2038 :
2039 165559 : if ( mpWindowImpl->mnExtendedStyle != nExtendedStyle )
2040 : {
2041 8444 : vcl::Window* pWindow = ImplGetBorderWindow();
2042 8444 : if( ! pWindow )
2043 0 : pWindow = this;
2044 8444 : if( pWindow->mpWindowImpl->mbFrame )
2045 : {
2046 8444 : SalExtStyle nExt = 0;
2047 8444 : if( (nExtendedStyle & WB_EXT_DOCUMENT) )
2048 5556 : nExt |= SAL_FRAME_EXT_STYLE_DOCUMENT;
2049 8444 : if( (nExtendedStyle & WB_EXT_DOCMODIFIED) )
2050 1510 : nExt |= SAL_FRAME_EXT_STYLE_DOCMODIFIED;
2051 :
2052 8444 : pWindow->ImplGetFrame()->SetExtendedFrameStyle( nExt );
2053 : }
2054 8444 : mpWindowImpl->mnPrevExtendedStyle = mpWindowImpl->mnExtendedStyle;
2055 8444 : mpWindowImpl->mnExtendedStyle = nExtendedStyle;
2056 8444 : StateChanged( StateChangedType::EXTENDEDSTYLE );
2057 : }
2058 165559 : }
2059 :
2060 6313 : void Window::SetBorderStyle( WindowBorderStyle nBorderStyle )
2061 : {
2062 :
2063 6313 : if ( mpWindowImpl->mpBorderWindow )
2064 : {
2065 6207 : if( nBorderStyle == WindowBorderStyle::REMOVEBORDER &&
2066 0 : ! mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame &&
2067 : mpWindowImpl->mpBorderWindow->mpWindowImpl->mpParent
2068 : )
2069 : {
2070 : // this is a little awkward: some controls (e.g. svtools ProgressBar)
2071 : // cannot avoid getting constructed with WB_BORDER but want to disable
2072 : // borders in case of NWF drawing. So they need a method to remove their border window
2073 0 : vcl::Window* pBorderWin = mpWindowImpl->mpBorderWindow;
2074 : // remove us as border window's client
2075 0 : pBorderWin->mpWindowImpl->mpClientWindow = NULL;
2076 0 : mpWindowImpl->mpBorderWindow = NULL;
2077 0 : mpWindowImpl->mpRealParent = pBorderWin->mpWindowImpl->mpParent;
2078 : // reparent us above the border window
2079 0 : SetParent( pBorderWin->mpWindowImpl->mpParent );
2080 : // set us to the position and size of our previous border
2081 0 : Point aBorderPos( pBorderWin->GetPosPixel() );
2082 0 : Size aBorderSize( pBorderWin->GetSizePixel() );
2083 0 : setPosSizePixel( aBorderPos.X(), aBorderPos.Y(), aBorderSize.Width(), aBorderSize.Height() );
2084 : // release border window
2085 0 : delete pBorderWin;
2086 :
2087 : // set new style bits
2088 0 : SetStyle( GetStyle() & (~WB_BORDER) );
2089 : }
2090 : else
2091 : {
2092 6207 : if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
2093 6207 : static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetBorderStyle( nBorderStyle );
2094 : else
2095 0 : mpWindowImpl->mpBorderWindow->SetBorderStyle( nBorderStyle );
2096 : }
2097 : }
2098 6313 : }
2099 :
2100 16 : WindowBorderStyle Window::GetBorderStyle() const
2101 : {
2102 :
2103 16 : if ( mpWindowImpl->mpBorderWindow )
2104 : {
2105 16 : if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
2106 16 : return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->GetBorderStyle();
2107 : else
2108 0 : return mpWindowImpl->mpBorderWindow->GetBorderStyle();
2109 : }
2110 :
2111 0 : return WindowBorderStyle::NONE;
2112 : }
2113 :
2114 0 : long Window::CalcTitleWidth() const
2115 : {
2116 :
2117 0 : if ( mpWindowImpl->mpBorderWindow )
2118 : {
2119 0 : if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
2120 0 : return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->CalcTitleWidth();
2121 : else
2122 0 : return mpWindowImpl->mpBorderWindow->CalcTitleWidth();
2123 : }
2124 0 : else if ( mpWindowImpl->mbFrame && (mpWindowImpl->mnStyle & WB_MOVEABLE) )
2125 : {
2126 : // we guess the width for frame windows as we do not know the
2127 : // border of external dialogs
2128 0 : const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
2129 0 : vcl::Font aFont = GetFont();
2130 0 : ((vcl::Window*)this)->SetPointFont( rStyleSettings.GetTitleFont() );
2131 0 : long nTitleWidth = GetTextWidth( GetText() );
2132 0 : ((vcl::Window*)this)->SetFont( aFont );
2133 0 : nTitleWidth += rStyleSettings.GetTitleHeight() * 3;
2134 0 : nTitleWidth += rStyleSettings.GetBorderSize() * 2;
2135 0 : nTitleWidth += 10;
2136 0 : return nTitleWidth;
2137 : }
2138 :
2139 0 : return 0;
2140 : }
2141 :
2142 17315 : void Window::SetInputContext( const InputContext& rInputContext )
2143 : {
2144 :
2145 17315 : mpWindowImpl->maInputContext = rInputContext;
2146 17315 : if ( !mpWindowImpl->mbInFocusHdl && HasFocus() )
2147 1039 : ImplNewInputContext();
2148 17315 : }
2149 :
2150 0 : void Window::EndExtTextInput( sal_uInt16 nFlags )
2151 : {
2152 :
2153 0 : if ( mpWindowImpl->mbExtTextInput )
2154 0 : ImplGetFrame()->EndExtTextInput( nFlags );
2155 0 : }
2156 :
2157 0 : void Window::SetCursorRect( const Rectangle* pRect, long nExtTextInputWidth )
2158 : {
2159 :
2160 0 : ImplWinData* pWinData = ImplGetWinData();
2161 0 : if ( pWinData->mpCursorRect )
2162 : {
2163 0 : if ( pRect )
2164 0 : *pWinData->mpCursorRect = *pRect;
2165 : else
2166 : {
2167 0 : delete pWinData->mpCursorRect;
2168 0 : pWinData->mpCursorRect = NULL;
2169 : }
2170 : }
2171 : else
2172 : {
2173 0 : if ( pRect )
2174 0 : pWinData->mpCursorRect = new Rectangle( *pRect );
2175 : }
2176 :
2177 0 : pWinData->mnCursorExtWidth = nExtTextInputWidth;
2178 :
2179 0 : }
2180 :
2181 0 : const Rectangle* Window::GetCursorRect() const
2182 : {
2183 :
2184 0 : ImplWinData* pWinData = ImplGetWinData();
2185 0 : return pWinData->mpCursorRect;
2186 : }
2187 :
2188 0 : long Window::GetCursorExtTextInputWidth() const
2189 : {
2190 :
2191 0 : ImplWinData* pWinData = ImplGetWinData();
2192 0 : return pWinData->mnCursorExtWidth;
2193 : }
2194 :
2195 0 : void Window::SetCompositionCharRect( const Rectangle* pRect, long nCompositionLength, bool bVertical ) {
2196 :
2197 0 : ImplWinData* pWinData = ImplGetWinData();
2198 0 : delete[] pWinData->mpCompositionCharRects;
2199 0 : pWinData->mbVertical = bVertical;
2200 0 : pWinData->mpCompositionCharRects = NULL;
2201 0 : pWinData->mnCompositionCharRects = nCompositionLength;
2202 0 : if ( pRect && (nCompositionLength > 0) )
2203 : {
2204 0 : pWinData->mpCompositionCharRects = new Rectangle[nCompositionLength];
2205 0 : for (long i = 0; i < nCompositionLength; ++i)
2206 0 : pWinData->mpCompositionCharRects[i] = pRect[i];
2207 : }
2208 0 : }
2209 :
2210 0 : void Window::CollectChildren(::std::vector<vcl::Window *>& rAllChildren )
2211 : {
2212 0 : rAllChildren.push_back( this );
2213 :
2214 0 : vcl::Window* pChild = mpWindowImpl->mpFirstChild;
2215 0 : while ( pChild )
2216 : {
2217 0 : pChild->CollectChildren( rAllChildren );
2218 0 : pChild = pChild->mpWindowImpl->mpNext;
2219 : }
2220 0 : }
2221 :
2222 170470 : void Window::SetPointFont( const vcl::Font& rFont )
2223 : {
2224 :
2225 170470 : vcl::Font aFont = rFont;
2226 170470 : ImplPointToLogic( aFont );
2227 170470 : SetFont( aFont );
2228 170470 : }
2229 :
2230 16 : vcl::Font Window::GetPointFont() const
2231 : {
2232 :
2233 16 : vcl::Font aFont = GetFont();
2234 16 : ImplLogicToPoint( aFont );
2235 16 : return aFont;
2236 : }
2237 :
2238 1503486 : void Window::Show( bool bVisible, sal_uInt16 nFlags )
2239 : {
2240 :
2241 1503486 : if ( mpWindowImpl->mbVisible == bVisible )
2242 1760712 : return;
2243 :
2244 623130 : ImplDelData aDogTag( this );
2245 :
2246 623130 : bool bRealVisibilityChanged = false;
2247 623130 : mpWindowImpl->mbVisible = bVisible;
2248 :
2249 623130 : if ( !bVisible )
2250 : {
2251 311485 : ImplHideAllOverlaps();
2252 311485 : if( aDogTag.IsDead() )
2253 0 : return;
2254 :
2255 311485 : if ( mpWindowImpl->mpBorderWindow )
2256 : {
2257 23805 : bool bOldUpdate = mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate;
2258 23805 : if ( mpWindowImpl->mbNoParentUpdate )
2259 0 : mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate = true;
2260 23805 : mpWindowImpl->mpBorderWindow->Show( false, nFlags );
2261 23805 : mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate = bOldUpdate;
2262 : }
2263 287680 : else if ( mpWindowImpl->mbFrame )
2264 : {
2265 5598 : mpWindowImpl->mbSuppressAccessibilityEvents = true;
2266 5598 : mpWindowImpl->mpFrame->Show( false, false );
2267 : }
2268 :
2269 311485 : StateChanged( StateChangedType::VISIBLE );
2270 :
2271 311485 : if ( mpWindowImpl->mbReallyVisible )
2272 : {
2273 127335 : vcl::Region aInvRegion;
2274 127335 : bool bSaveBack = false;
2275 :
2276 127335 : if ( ImplIsOverlapWindow() && !mpWindowImpl->mbFrame )
2277 : {
2278 0 : if ( ImplRestoreOverlapBackground( aInvRegion ) )
2279 0 : bSaveBack = true;
2280 : }
2281 :
2282 127335 : if ( !bSaveBack )
2283 : {
2284 127335 : if ( mpWindowImpl->mbInitWinClipRegion )
2285 53650 : ImplInitWinClipRegion();
2286 127335 : aInvRegion = mpWindowImpl->maWinClipRegion;
2287 : }
2288 :
2289 127335 : if( aDogTag.IsDead() )
2290 0 : return;
2291 :
2292 127335 : bRealVisibilityChanged = mpWindowImpl->mbReallyVisible;
2293 127335 : ImplResetReallyVisible();
2294 127335 : ImplSetClipFlag();
2295 :
2296 127335 : if ( ImplIsOverlapWindow() && !mpWindowImpl->mbFrame )
2297 : {
2298 : // convert focus
2299 0 : if ( !(nFlags & SHOW_NOFOCUSCHANGE) && HasChildPathFocus() )
2300 : {
2301 0 : if ( mpWindowImpl->mpOverlapWindow->IsEnabled() &&
2302 0 : mpWindowImpl->mpOverlapWindow->IsInputEnabled() &&
2303 0 : ! mpWindowImpl->mpOverlapWindow->IsInModalMode()
2304 : )
2305 0 : mpWindowImpl->mpOverlapWindow->GrabFocus();
2306 : }
2307 : }
2308 :
2309 127335 : if ( !mpWindowImpl->mbFrame )
2310 : {
2311 121737 : if( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mbEnableNativeWidget )
2312 : {
2313 : /*
2314 : * #i48371# native theming: some themes draw outside the control
2315 : * area we tell them to (bad thing, but we cannot do much about it ).
2316 : * On hiding these controls they get invalidated with their window rectangle
2317 : * which leads to the parts outside the control area being left and not
2318 : * invalidated. Workaround: invalidate an area on the parent, too
2319 : */
2320 96114 : const int workaround_border = 5;
2321 96114 : Rectangle aBounds( aInvRegion.GetBoundRect() );
2322 96114 : aBounds.Left() -= workaround_border;
2323 96114 : aBounds.Top() -= workaround_border;
2324 96114 : aBounds.Right() += workaround_border;
2325 96114 : aBounds.Bottom() += workaround_border;
2326 96114 : aInvRegion = aBounds;
2327 : }
2328 121737 : if ( !mpWindowImpl->mbNoParentUpdate && !(nFlags & SHOW_NOPARENTUPDATE) )
2329 : {
2330 121705 : if ( !aInvRegion.IsEmpty() )
2331 115907 : ImplInvalidateParentFrameRegion( aInvRegion );
2332 : }
2333 121737 : ImplGenerateMouseMove();
2334 127335 : }
2335 : }
2336 : }
2337 : else
2338 : {
2339 : // inherit native widget flag for form controls
2340 : // required here, because frames never show up in the child hierarchy - which should be fixed....
2341 : // eg, the drop down of a combobox which is a system floating window
2342 311653 : if( mpWindowImpl->mbFrame && GetParent() && GetParent()->IsCompoundControl() &&
2343 8 : GetParent()->IsNativeWidgetEnabled() != IsNativeWidgetEnabled() )
2344 : {
2345 0 : EnableNativeWidget( GetParent()->IsNativeWidgetEnabled() );
2346 : }
2347 :
2348 311645 : if ( mpWindowImpl->mbCallMove )
2349 : {
2350 306872 : ImplCallMove();
2351 : }
2352 311645 : if ( mpWindowImpl->mbCallResize )
2353 : {
2354 306040 : ImplCallResize();
2355 : }
2356 :
2357 311645 : StateChanged( StateChangedType::VISIBLE );
2358 :
2359 : vcl::Window* pTestParent;
2360 311645 : if ( ImplIsOverlapWindow() )
2361 5602 : pTestParent = mpWindowImpl->mpOverlapWindow;
2362 : else
2363 306043 : pTestParent = ImplGetParent();
2364 311645 : if ( mpWindowImpl->mbFrame || pTestParent->mpWindowImpl->mbReallyVisible )
2365 : {
2366 : // if a window becomes visible, send all child windows a StateChange,
2367 : // such that these can initialise themselves
2368 84696 : ImplCallInitShow();
2369 :
2370 : // If it is a SystemWindow it automatically pops up on top of
2371 : // all other windows if needed.
2372 84696 : if ( ImplIsOverlapWindow() && !(nFlags & SHOW_NOACTIVATE) )
2373 : {
2374 5510 : ImplStartToTop(( nFlags & SHOW_FOREGROUNDTASK ) ? TOTOP_FOREGROUNDTASK : 0 );
2375 5510 : ImplFocusToTop( 0, false );
2376 : }
2377 :
2378 : // save background
2379 84696 : if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mbSaveBack )
2380 0 : ImplSaveOverlapBackground();
2381 : // adjust mpWindowImpl->mbReallyVisible
2382 84696 : bRealVisibilityChanged = !mpWindowImpl->mbReallyVisible;
2383 84696 : ImplSetReallyVisible();
2384 :
2385 : // assure clip rectangles will be recalculated
2386 84696 : ImplSetClipFlag();
2387 :
2388 84696 : if ( !mpWindowImpl->mbFrame )
2389 : {
2390 79094 : sal_uInt16 nInvalidateFlags = INVALIDATE_CHILDREN;
2391 79094 : if( ! IsPaintTransparent() )
2392 67644 : nInvalidateFlags |= INVALIDATE_NOTRANSPARENT;
2393 79094 : ImplInvalidate( NULL, nInvalidateFlags );
2394 79094 : ImplGenerateMouseMove();
2395 : }
2396 : }
2397 :
2398 311645 : if ( mpWindowImpl->mpBorderWindow )
2399 23823 : mpWindowImpl->mpBorderWindow->Show( true, nFlags );
2400 287822 : else if ( mpWindowImpl->mbFrame )
2401 : {
2402 : // #106431#, hide SplashScreen
2403 5602 : ImplSVData* pSVData = ImplGetSVData();
2404 5602 : if ( !pSVData->mpIntroWindow )
2405 : {
2406 : // The right way would be just to call this (not even in the 'if')
2407 5602 : GetpApp()->InitFinished();
2408 : }
2409 0 : else if ( !ImplIsWindowOrChild( pSVData->mpIntroWindow ) )
2410 : {
2411 : // ... but the VCL splash is broken, and it needs this
2412 : // (for ./soffice slot:5500)
2413 0 : pSVData->mpIntroWindow->Hide();
2414 : }
2415 :
2416 : //DBG_ASSERT( !mpWindowImpl->mbSuppressAccessibilityEvents, "Window::Show() - Frame reactivated");
2417 5602 : mpWindowImpl->mbSuppressAccessibilityEvents = false;
2418 :
2419 5602 : mpWindowImpl->mbPaintFrame = true;
2420 5602 : if (!Application::GetSettings().GetMiscSettings().GetPseudoHeadless())
2421 : {
2422 5602 : bool bNoActivate = (nFlags & (SHOW_NOACTIVATE|SHOW_NOFOCUSCHANGE)) ? true : false;
2423 5602 : mpWindowImpl->mpFrame->Show( true, bNoActivate );
2424 : }
2425 5602 : if( aDogTag.IsDead() )
2426 0 : return;
2427 :
2428 : // Query the correct size of the window, if we are waiting for
2429 : // a system resize
2430 5602 : if ( mpWindowImpl->mbWaitSystemResize )
2431 : {
2432 : long nOutWidth;
2433 : long nOutHeight;
2434 114 : mpWindowImpl->mpFrame->GetClientSize( nOutWidth, nOutHeight );
2435 114 : ImplHandleResize( this, nOutWidth, nOutHeight );
2436 : }
2437 : }
2438 :
2439 311645 : if( aDogTag.IsDead() )
2440 0 : return;
2441 :
2442 : #if OSL_DEBUG_LEVEL > 0
2443 : if ( IsDialog() || (GetType() == WINDOW_TABPAGE) || (GetType() == WINDOW_DOCKINGWINDOW) )
2444 : {
2445 : DBG_DIALOGTEST( this );
2446 : }
2447 : #endif
2448 :
2449 311645 : ImplShowAllOverlaps();
2450 : }
2451 :
2452 623130 : if( aDogTag.IsDead() )
2453 0 : return;
2454 : // invalidate all saved backgrounds
2455 623130 : if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
2456 0 : ImplInvalidateAllOverlapBackgrounds();
2457 :
2458 : // the SHOW/HIDE events also serve as indicators to send child creation/destroy events to the access bridge
2459 : // However, the access bridge only uses this event if the data member is not NULL (it's kind of a hack that
2460 : // we re-use the SHOW/HIDE events this way, with this particular semantics).
2461 : // Since #104887#, the notifications for the access bridge are done in Impl(Set|Reset)ReallyVisible. Here, we
2462 : // now only notify with a NULL data pointer, for all other clients except the access bridge.
2463 623130 : if ( !bRealVisibilityChanged )
2464 411099 : ImplCallEventListeners( mpWindowImpl->mbVisible ? VCLEVENT_WINDOW_SHOW : VCLEVENT_WINDOW_HIDE, NULL );
2465 623130 : if( aDogTag.IsDead() )
2466 0 : return;
2467 :
2468 : }
2469 :
2470 1460785 : Size Window::GetSizePixel() const
2471 : {
2472 1460785 : if (!mpWindowImpl)
2473 : {
2474 : SAL_WARN("vcl.layout", "WTF no windowimpl");
2475 0 : return Size(0,0);
2476 : }
2477 :
2478 : // #i43257# trigger pending resize handler to assure correct window sizes
2479 1460785 : if( mpWindowImpl->mpFrameData->maResizeTimer.IsActive() )
2480 : {
2481 5419 : ImplDelData aDogtag( this );
2482 5419 : mpWindowImpl->mpFrameData->maResizeTimer.Stop();
2483 5419 : mpWindowImpl->mpFrameData->maResizeTimer.GetTimeoutHdl().Call( NULL );
2484 5419 : if( aDogtag.IsDead() )
2485 0 : return Size(0,0);
2486 : }
2487 :
2488 1460785 : return Size( mnOutWidth+mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder,
2489 2921570 : mnOutHeight+mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder );
2490 : }
2491 :
2492 194550 : void Window::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
2493 : sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
2494 : {
2495 194550 : rLeftBorder = mpWindowImpl->mnLeftBorder;
2496 194550 : rTopBorder = mpWindowImpl->mnTopBorder;
2497 194550 : rRightBorder = mpWindowImpl->mnRightBorder;
2498 194550 : rBottomBorder = mpWindowImpl->mnBottomBorder;
2499 194550 : }
2500 :
2501 191224 : void Window::Enable( bool bEnable, bool bChild )
2502 : {
2503 :
2504 191224 : if ( !bEnable )
2505 : {
2506 : // the tracking mode will be stopped or the capture will be stolen
2507 : // when a window is disabled,
2508 75924 : if ( IsTracking() )
2509 0 : EndTracking( ENDTRACK_CANCEL );
2510 75924 : if ( IsMouseCaptured() )
2511 0 : ReleaseMouse();
2512 : // try to pass focus to the next control
2513 : // if the window has focus and is contained in the dialog control
2514 : // mpWindowImpl->mbDisabled should only be set after a call of ImplDlgCtrlNextWindow().
2515 : // Otherwise ImplDlgCtrlNextWindow() should be used
2516 75924 : if ( HasFocus() )
2517 1028 : ImplDlgCtrlNextWindow();
2518 : }
2519 :
2520 191224 : if ( mpWindowImpl->mpBorderWindow )
2521 : {
2522 19909 : mpWindowImpl->mpBorderWindow->Enable( bEnable, false );
2523 19909 : if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
2524 : static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
2525 2248 : static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->Enable( bEnable, true );
2526 : }
2527 :
2528 : // #i56102# restore app focus win in case the
2529 : // window was disabled when the frame focus changed
2530 191224 : ImplSVData* pSVData = ImplGetSVData();
2531 306524 : if( bEnable &&
2532 143099 : pSVData->maWinData.mpFocusWin == NULL &&
2533 2716 : mpWindowImpl->mpFrameData->mbHasFocus &&
2534 2716 : mpWindowImpl->mpFrameData->mpFocusWin == this )
2535 4 : pSVData->maWinData.mpFocusWin = this;
2536 :
2537 191224 : if ( mpWindowImpl->mbDisabled != !bEnable )
2538 : {
2539 129909 : mpWindowImpl->mbDisabled = !bEnable;
2540 129909 : if ( mpWindowImpl->mpSysObj )
2541 0 : mpWindowImpl->mpSysObj->Enable( bEnable && !mpWindowImpl->mbInputDisabled );
2542 129909 : StateChanged( StateChangedType::ENABLE );
2543 :
2544 129909 : ImplCallEventListeners( bEnable ? VCLEVENT_WINDOW_ENABLED : VCLEVENT_WINDOW_DISABLED );
2545 : }
2546 :
2547 191224 : if ( bChild || mpWindowImpl->mbChildNotify )
2548 : {
2549 170227 : vcl::Window* pChild = mpWindowImpl->mpFirstChild;
2550 472239 : while ( pChild )
2551 : {
2552 131785 : pChild->Enable( bEnable, bChild );
2553 131785 : pChild = pChild->mpWindowImpl->mpNext;
2554 : }
2555 : }
2556 :
2557 191224 : if ( IsReallyVisible() )
2558 109468 : ImplGenerateMouseMove();
2559 191224 : }
2560 :
2561 260 : void Window::SetCallHandlersOnInputDisabled( bool bCall )
2562 : {
2563 260 : mpWindowImpl->mbCallHandlersDuringInputDisabled = bCall ? true : false;
2564 :
2565 260 : vcl::Window* pChild = mpWindowImpl->mpFirstChild;
2566 520 : while ( pChild )
2567 : {
2568 0 : pChild->SetCallHandlersOnInputDisabled( bCall );
2569 0 : pChild = pChild->mpWindowImpl->mpNext;
2570 : }
2571 260 : }
2572 :
2573 0 : bool Window::IsCallHandlersOnInputDisabled() const
2574 : {
2575 0 : return mpWindowImpl->mbCallHandlersDuringInputDisabled;
2576 : }
2577 :
2578 81817 : void Window::EnableInput( bool bEnable, bool bChild )
2579 : {
2580 :
2581 81817 : bool bNotify = (bEnable != mpWindowImpl->mbInputDisabled);
2582 81817 : if ( mpWindowImpl->mpBorderWindow )
2583 : {
2584 3461 : mpWindowImpl->mpBorderWindow->EnableInput( bEnable, false );
2585 3461 : if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
2586 : static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
2587 52 : static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->EnableInput( bEnable, true );
2588 : }
2589 :
2590 81817 : if ( (! bEnable && mpWindowImpl->meAlwaysInputMode != AlwaysInputEnabled) ||
2591 42868 : ( bEnable && mpWindowImpl->meAlwaysInputMode != AlwaysInputDisabled) )
2592 : {
2593 : // automatically stop the tracking mode or steal capture
2594 : // if the window is disabled
2595 81741 : if ( !bEnable )
2596 : {
2597 38949 : if ( IsTracking() )
2598 0 : EndTracking( ENDTRACK_CANCEL );
2599 38949 : if ( IsMouseCaptured() )
2600 0 : ReleaseMouse();
2601 : }
2602 :
2603 81741 : if ( mpWindowImpl->mbInputDisabled != !bEnable )
2604 : {
2605 76312 : mpWindowImpl->mbInputDisabled = !bEnable;
2606 76312 : if ( mpWindowImpl->mpSysObj )
2607 0 : mpWindowImpl->mpSysObj->Enable( !mpWindowImpl->mbDisabled && bEnable );
2608 : }
2609 : }
2610 :
2611 : // #i56102# restore app focus win in case the
2612 : // window was disabled when the frame focus changed
2613 81817 : ImplSVData* pSVData = ImplGetSVData();
2614 124685 : if( bEnable &&
2615 45150 : pSVData->maWinData.mpFocusWin == NULL &&
2616 182 : mpWindowImpl->mpFrameData->mbHasFocus &&
2617 182 : mpWindowImpl->mpFrameData->mpFocusWin == this )
2618 0 : pSVData->maWinData.mpFocusWin = this;
2619 :
2620 81817 : if ( bChild || mpWindowImpl->mbChildNotify )
2621 : {
2622 78096 : vcl::Window* pChild = mpWindowImpl->mpFirstChild;
2623 230943 : while ( pChild )
2624 : {
2625 74751 : pChild->EnableInput( bEnable, bChild );
2626 74751 : pChild = pChild->mpWindowImpl->mpNext;
2627 : }
2628 : }
2629 :
2630 81817 : if ( IsReallyVisible() )
2631 51468 : ImplGenerateMouseMove();
2632 :
2633 : // #104827# notify parent
2634 81817 : if ( bNotify )
2635 : {
2636 5429 : NotifyEvent aNEvt( bEnable ? EVENT_INPUTENABLE : EVENT_INPUTDISABLE, this );
2637 5429 : Notify( aNEvt );
2638 : }
2639 81817 : }
2640 :
2641 0 : void Window::EnableInput( bool bEnable, bool bChild, bool bSysWin,
2642 : const vcl::Window* pExcludeWindow )
2643 : {
2644 :
2645 0 : EnableInput( bEnable, bChild );
2646 0 : if ( bSysWin )
2647 : {
2648 : // pExcuteWindow is the first Overlap-Frame --> if this
2649 : // shouldn't be the case, than this must be changed in dialog.cxx
2650 0 : if( pExcludeWindow )
2651 0 : pExcludeWindow = pExcludeWindow->ImplGetFirstOverlapWindow();
2652 0 : vcl::Window* pSysWin = mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrameData->mpFirstOverlap;
2653 0 : while ( pSysWin )
2654 : {
2655 : // Is Window in the path from this window
2656 0 : if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( pSysWin, true ) )
2657 : {
2658 : // Is Window not in the exclude window path or not the
2659 : // exclude window, than change the status
2660 0 : if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( pSysWin, true ) )
2661 0 : pSysWin->EnableInput( bEnable, bChild );
2662 : }
2663 0 : pSysWin = pSysWin->mpWindowImpl->mpNextOverlap;
2664 : }
2665 :
2666 : // enable/disable floating system windows as well
2667 0 : vcl::Window* pFrameWin = ImplGetSVData()->maWinData.mpFirstFrame;
2668 0 : while ( pFrameWin )
2669 : {
2670 0 : if( pFrameWin->ImplIsFloatingWindow() )
2671 : {
2672 : // Is Window in the path from this window
2673 0 : if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( pFrameWin, true ) )
2674 : {
2675 : // Is Window not in the exclude window path or not the
2676 : // exclude window, than change the status
2677 0 : if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( pFrameWin, true ) )
2678 0 : pFrameWin->EnableInput( bEnable, bChild );
2679 : }
2680 : }
2681 0 : pFrameWin = pFrameWin->mpWindowImpl->mpFrameData->mpNextFrame;
2682 : }
2683 :
2684 : // the same for ownerdraw floating windows
2685 0 : if( mpWindowImpl->mbFrame )
2686 : {
2687 0 : ::std::vector< vcl::Window* >& rList = mpWindowImpl->mpFrameData->maOwnerDrawList;
2688 0 : ::std::vector< vcl::Window* >::iterator p = rList.begin();
2689 0 : while( p != rList.end() )
2690 : {
2691 : // Is Window in the path from this window
2692 0 : if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( (*p), true ) )
2693 : {
2694 : // Is Window not in the exclude window path or not the
2695 : // exclude window, than change the status
2696 0 : if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( (*p), true ) )
2697 0 : (*p)->EnableInput( bEnable, bChild );
2698 : }
2699 0 : ++p;
2700 : }
2701 : }
2702 : }
2703 0 : }
2704 :
2705 0 : void Window::AlwaysEnableInput( bool bAlways, bool bChild )
2706 : {
2707 :
2708 0 : if ( mpWindowImpl->mpBorderWindow )
2709 0 : mpWindowImpl->mpBorderWindow->AlwaysEnableInput( bAlways, false );
2710 :
2711 0 : if( bAlways && mpWindowImpl->meAlwaysInputMode != AlwaysInputEnabled )
2712 : {
2713 0 : mpWindowImpl->meAlwaysInputMode = AlwaysInputEnabled;
2714 :
2715 0 : if ( bAlways )
2716 0 : EnableInput( true, false );
2717 : }
2718 0 : else if( ! bAlways && mpWindowImpl->meAlwaysInputMode == AlwaysInputEnabled )
2719 : {
2720 0 : mpWindowImpl->meAlwaysInputMode = AlwaysInputNone;
2721 : }
2722 :
2723 0 : if ( bChild || mpWindowImpl->mbChildNotify )
2724 : {
2725 0 : vcl::Window* pChild = mpWindowImpl->mpFirstChild;
2726 0 : while ( pChild )
2727 : {
2728 0 : pChild->AlwaysEnableInput( bAlways, bChild );
2729 0 : pChild = pChild->mpWindowImpl->mpNext;
2730 : }
2731 : }
2732 0 : }
2733 :
2734 260 : void Window::AlwaysDisableInput( bool bAlways, bool bChild )
2735 : {
2736 :
2737 260 : if ( mpWindowImpl->mpBorderWindow )
2738 0 : mpWindowImpl->mpBorderWindow->AlwaysDisableInput( bAlways, false );
2739 :
2740 260 : if( bAlways && mpWindowImpl->meAlwaysInputMode != AlwaysInputDisabled )
2741 : {
2742 260 : mpWindowImpl->meAlwaysInputMode = AlwaysInputDisabled;
2743 :
2744 520 : if ( bAlways )
2745 260 : EnableInput( false, false );
2746 : }
2747 0 : else if( ! bAlways && mpWindowImpl->meAlwaysInputMode == AlwaysInputDisabled )
2748 : {
2749 0 : mpWindowImpl->meAlwaysInputMode = AlwaysInputNone;
2750 : }
2751 :
2752 260 : if ( bChild || mpWindowImpl->mbChildNotify )
2753 : {
2754 260 : vcl::Window* pChild = mpWindowImpl->mpFirstChild;
2755 520 : while ( pChild )
2756 : {
2757 0 : pChild->AlwaysDisableInput( bAlways, bChild );
2758 0 : pChild = pChild->mpWindowImpl->mpNext;
2759 : }
2760 : }
2761 260 : }
2762 :
2763 24808 : void Window::SetActivateMode( sal_uInt16 nMode )
2764 : {
2765 :
2766 24808 : if ( mpWindowImpl->mpBorderWindow )
2767 12380 : mpWindowImpl->mpBorderWindow->SetActivateMode( nMode );
2768 :
2769 24808 : if ( mpWindowImpl->mnActivateMode != nMode )
2770 : {
2771 12414 : mpWindowImpl->mnActivateMode = nMode;
2772 :
2773 : // possibly trigger Decativate/Activate
2774 12414 : if ( mpWindowImpl->mnActivateMode )
2775 : {
2776 12212 : if ( (mpWindowImpl->mbActive || (GetType() == WINDOW_BORDERWINDOW)) &&
2777 6106 : !HasChildPathFocus( true ) )
2778 : {
2779 6106 : mpWindowImpl->mbActive = false;
2780 6106 : Deactivate();
2781 : }
2782 : }
2783 : else
2784 : {
2785 6308 : if ( !mpWindowImpl->mbActive || (GetType() == WINDOW_BORDERWINDOW) )
2786 : {
2787 6308 : mpWindowImpl->mbActive = true;
2788 6308 : Activate();
2789 : }
2790 : }
2791 : }
2792 24808 : }
2793 :
2794 1209990 : void Window::setPosSizePixel( long nX, long nY,
2795 : long nWidth, long nHeight, sal_uInt16 nFlags )
2796 : {
2797 :
2798 1209990 : bool bHasValidSize = !mpWindowImpl->mbDefSize;
2799 :
2800 1209990 : if ( nFlags & WINDOW_POSSIZE_POS )
2801 948457 : mpWindowImpl->mbDefPos = false;
2802 1209990 : if ( nFlags & WINDOW_POSSIZE_SIZE )
2803 1135712 : mpWindowImpl->mbDefSize = false;
2804 :
2805 : // The top BorderWindow is the window which is to be positioned
2806 1209990 : vcl::Window* pWindow = this;
2807 2501467 : while ( pWindow->mpWindowImpl->mpBorderWindow )
2808 81487 : pWindow = pWindow->mpWindowImpl->mpBorderWindow;
2809 :
2810 1209990 : if ( pWindow->mpWindowImpl->mbFrame )
2811 : {
2812 : // Note: if we're positioning a frame, the coordinates are interpreted
2813 : // as being the top-left corner of the window's client area and NOT
2814 : // as the position of the border ! (due to limitations of several UNIX window managers)
2815 11231 : long nOldWidth = pWindow->mnOutWidth;
2816 :
2817 11231 : if ( !(nFlags & WINDOW_POSSIZE_WIDTH) )
2818 40 : nWidth = pWindow->mnOutWidth;
2819 11231 : if ( !(nFlags & WINDOW_POSSIZE_HEIGHT) )
2820 40 : nHeight = pWindow->mnOutHeight;
2821 :
2822 11231 : sal_uInt16 nSysFlags=0;
2823 11231 : vcl::Window *pParent = GetParent();
2824 :
2825 11231 : if( nFlags & WINDOW_POSSIZE_WIDTH )
2826 11191 : nSysFlags |= SAL_FRAME_POSSIZE_WIDTH;
2827 11231 : if( nFlags & WINDOW_POSSIZE_HEIGHT )
2828 11191 : nSysFlags |= SAL_FRAME_POSSIZE_HEIGHT;
2829 11231 : if( nFlags & WINDOW_POSSIZE_X )
2830 : {
2831 62 : nSysFlags |= SAL_FRAME_POSSIZE_X;
2832 62 : if( pParent && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) )
2833 : {
2834 0 : nX += pParent->mnOutOffX;
2835 : }
2836 62 : if( pParent && pParent->ImplIsAntiparallel() )
2837 : {
2838 : // --- RTL --- (re-mirror at parent window)
2839 0 : Rectangle aRect( Point ( nX, nY ), Size( nWidth, nHeight ) );
2840 0 : const OutputDevice *pParentOutDev = pParent->GetOutDev();
2841 0 : pParentOutDev->ReMirror( aRect );
2842 0 : nX = aRect.Left();
2843 : }
2844 : }
2845 11231 : if( !(nFlags & WINDOW_POSSIZE_X) && bHasValidSize && pWindow->mpWindowImpl->mpFrame->maGeometry.nWidth )
2846 : {
2847 : // --- RTL --- make sure the old right aligned position is not changed
2848 : // system windows will always grow to the right
2849 5221 : if ( pParent )
2850 : {
2851 5219 : OutputDevice *pParentOutDev = pParent->GetOutDev();
2852 5219 : if( pParentOutDev->HasMirroredGraphics() )
2853 : {
2854 0 : long myWidth = nOldWidth;
2855 0 : if( !myWidth )
2856 0 : myWidth = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nWidth;
2857 0 : if( !myWidth )
2858 0 : myWidth = nWidth;
2859 0 : nFlags |= WINDOW_POSSIZE_X;
2860 0 : nSysFlags |= SAL_FRAME_POSSIZE_X;
2861 0 : nX = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX - pParent->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX -
2862 0 : mpWindowImpl->mpFrame->GetUnmirroredGeometry().nLeftDecoration;
2863 0 : nX = pParent->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX - mpWindowImpl->mpFrame->GetUnmirroredGeometry().nLeftDecoration +
2864 0 : pParent->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nWidth - myWidth - 1 - mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX;
2865 0 : if(!(nFlags & WINDOW_POSSIZE_Y))
2866 : {
2867 0 : nFlags |= WINDOW_POSSIZE_Y;
2868 0 : nSysFlags |= SAL_FRAME_POSSIZE_Y;
2869 0 : nY = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nY - pWindow->GetParent()->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nY -
2870 0 : mpWindowImpl->mpFrame->GetUnmirroredGeometry().nTopDecoration;
2871 : }
2872 : }
2873 : }
2874 : }
2875 11231 : if( nFlags & WINDOW_POSSIZE_Y )
2876 : {
2877 62 : nSysFlags |= SAL_FRAME_POSSIZE_Y;
2878 62 : if( pParent && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) )
2879 : {
2880 0 : nY += pParent->mnOutOffY;
2881 : }
2882 : }
2883 :
2884 11231 : if( nSysFlags & (SAL_FRAME_POSSIZE_WIDTH|SAL_FRAME_POSSIZE_HEIGHT) )
2885 : {
2886 : // check for min/max client size and adjust size accordingly
2887 : // otherwise it may happen that the resize event is ignored, i.e. the old size remains
2888 : // unchanged but ImplHandleResize() is called with the wrong size
2889 11191 : SystemWindow *pSystemWindow = dynamic_cast< SystemWindow* >( pWindow );
2890 11191 : if( pSystemWindow )
2891 : {
2892 160 : Size aMinSize = pSystemWindow->GetMinOutputSizePixel();
2893 160 : Size aMaxSize = pSystemWindow->GetMaxOutputSizePixel();
2894 160 : if( nWidth < aMinSize.Width() )
2895 34 : nWidth = aMinSize.Width();
2896 160 : if( nHeight < aMinSize.Height() )
2897 34 : nHeight = aMinSize.Height();
2898 :
2899 160 : if( nWidth > aMaxSize.Width() )
2900 0 : nWidth = aMaxSize.Width();
2901 160 : if( nHeight > aMaxSize.Height() )
2902 0 : nHeight = aMaxSize.Height();
2903 : }
2904 : }
2905 :
2906 11231 : pWindow->mpWindowImpl->mpFrame->SetPosSize( nX, nY, nWidth, nHeight, nSysFlags );
2907 :
2908 : // Resize should be called directly. If we havn't
2909 : // set the correct size, we get a second resize from
2910 : // the system with the correct size. This can be happened
2911 : // if the size is to small or to large.
2912 11231 : ImplHandleResize( pWindow, nWidth, nHeight );
2913 : }
2914 : else
2915 : {
2916 1198759 : pWindow->ImplPosSizeWindow( nX, nY, nWidth, nHeight, nFlags );
2917 1198759 : if ( IsReallyVisible() )
2918 451384 : ImplGenerateMouseMove();
2919 : }
2920 1209990 : }
2921 :
2922 641840 : Point Window::GetPosPixel() const
2923 : {
2924 641840 : return mpWindowImpl->maPos;
2925 : }
2926 :
2927 32500 : Rectangle Window::GetDesktopRectPixel() const
2928 : {
2929 32500 : Rectangle rRect;
2930 32500 : mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrame->GetWorkArea( rRect );
2931 32500 : return rRect;
2932 : }
2933 :
2934 47996 : Point Window::OutputToScreenPixel( const Point& rPos ) const
2935 : {
2936 : // relative to top level parent
2937 47996 : return Point( rPos.X()+mnOutOffX, rPos.Y()+mnOutOffY );
2938 : }
2939 :
2940 7412 : Point Window::ScreenToOutputPixel( const Point& rPos ) const
2941 : {
2942 : // relative to top level parent
2943 7412 : return Point( rPos.X()-mnOutOffX, rPos.Y()-mnOutOffY );
2944 : }
2945 :
2946 0 : long Window::ImplGetUnmirroredOutOffX()
2947 : {
2948 : // revert mnOutOffX changes that were potentially made in ImplPosSizeWindow
2949 0 : long offx = mnOutOffX;
2950 0 : OutputDevice *pOutDev = GetOutDev();
2951 0 : if( pOutDev->HasMirroredGraphics() )
2952 : {
2953 0 : if( mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->ImplIsAntiparallel() )
2954 : {
2955 0 : if ( !ImplIsOverlapWindow() )
2956 0 : offx -= mpWindowImpl->mpParent->mnOutOffX;
2957 :
2958 0 : offx = mpWindowImpl->mpParent->mnOutWidth - mnOutWidth - offx;
2959 :
2960 0 : if ( !ImplIsOverlapWindow() )
2961 0 : offx += mpWindowImpl->mpParent->mnOutOffX;
2962 :
2963 : }
2964 : }
2965 0 : return offx;
2966 : }
2967 :
2968 : // normalized screen pixel are independent of mirroring
2969 0 : Point Window::OutputToNormalizedScreenPixel( const Point& rPos ) const
2970 : {
2971 : // relative to top level parent
2972 0 : long offx = ((vcl::Window*) this)->ImplGetUnmirroredOutOffX();
2973 0 : return Point( rPos.X()+offx, rPos.Y()+mnOutOffY );
2974 : }
2975 :
2976 0 : Point Window::NormalizedScreenToOutputPixel( const Point& rPos ) const
2977 : {
2978 : // relative to top level parent
2979 0 : long offx = ((vcl::Window*) this)->ImplGetUnmirroredOutOffX();
2980 0 : return Point( rPos.X()-offx, rPos.Y()-mnOutOffY );
2981 : }
2982 :
2983 120 : Point Window::OutputToAbsoluteScreenPixel( const Point& rPos ) const
2984 : {
2985 : // relative to the screen
2986 120 : Point p = OutputToScreenPixel( rPos );
2987 120 : SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
2988 120 : p.X() += g.nX;
2989 120 : p.Y() += g.nY;
2990 120 : return p;
2991 : }
2992 :
2993 2318 : Point Window::AbsoluteScreenToOutputPixel( const Point& rPos ) const
2994 : {
2995 : // relative to the screen
2996 2318 : Point p = ScreenToOutputPixel( rPos );
2997 2318 : SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
2998 2318 : p.X() -= g.nX;
2999 2318 : p.Y() -= g.nY;
3000 2318 : return p;
3001 : }
3002 :
3003 0 : Rectangle Window::ImplOutputToUnmirroredAbsoluteScreenPixel( const Rectangle &rRect ) const
3004 : {
3005 : // this method creates unmirrored screen coordinates to be compared with the desktop
3006 : // and is used for positioning of RTL popup windows correctly on the screen
3007 0 : SalFrameGeometry g = mpWindowImpl->mpFrame->GetUnmirroredGeometry();
3008 :
3009 0 : Point p1 = OutputToScreenPixel( rRect.TopRight() );
3010 0 : p1.X() = g.nX+g.nWidth-p1.X();
3011 0 : p1.Y() += g.nY;
3012 :
3013 0 : Point p2 = OutputToScreenPixel( rRect.BottomLeft() );
3014 0 : p2.X() = g.nX+g.nWidth-p2.X();
3015 0 : p2.Y() += g.nY;
3016 :
3017 0 : return Rectangle( p1, p2 );
3018 : }
3019 :
3020 36548 : Rectangle Window::GetWindowExtentsRelative( vcl::Window *pRelativeWindow ) const
3021 : {
3022 : // with decoration
3023 36548 : return ImplGetWindowExtentsRelative( pRelativeWindow, false );
3024 : }
3025 :
3026 0 : Rectangle Window::GetClientWindowExtentsRelative( vcl::Window *pRelativeWindow ) const
3027 : {
3028 : // without decoration
3029 0 : return ImplGetWindowExtentsRelative( pRelativeWindow, true );
3030 : }
3031 :
3032 36548 : Rectangle Window::ImplGetWindowExtentsRelative( vcl::Window *pRelativeWindow, bool bClientOnly ) const
3033 : {
3034 36548 : SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
3035 : // make sure we use the extent of our border window,
3036 : // otherwise we miss a few pixels
3037 36548 : const vcl::Window *pWin = (!bClientOnly && mpWindowImpl->mpBorderWindow) ? mpWindowImpl->mpBorderWindow : this;
3038 :
3039 36548 : Point aPos( pWin->OutputToScreenPixel( Point(0,0) ) );
3040 36548 : aPos.X() += g.nX;
3041 36548 : aPos.Y() += g.nY;
3042 36548 : Size aSize ( pWin->GetSizePixel() );
3043 : // #104088# do not add decoration to the workwindow to be compatible to java accessibility api
3044 36548 : if( !bClientOnly && (mpWindowImpl->mbFrame || (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame && GetType() != WINDOW_WORKWINDOW)) )
3045 : {
3046 1924 : aPos.X() -= g.nLeftDecoration;
3047 1924 : aPos.Y() -= g.nTopDecoration;
3048 1924 : aSize.Width() += g.nLeftDecoration + g.nRightDecoration;
3049 1924 : aSize.Height() += g.nTopDecoration + g.nBottomDecoration;
3050 : }
3051 36548 : if( pRelativeWindow )
3052 : {
3053 : // #106399# express coordinates relative to borderwindow
3054 2290 : vcl::Window *pRelWin = (!bClientOnly && pRelativeWindow->mpWindowImpl->mpBorderWindow) ? pRelativeWindow->mpWindowImpl->mpBorderWindow : pRelativeWindow;
3055 2290 : aPos = pRelWin->AbsoluteScreenToOutputPixel( aPos );
3056 : }
3057 36548 : return Rectangle( aPos, aSize );
3058 : }
3059 :
3060 8395 : void Window::Scroll( long nHorzScroll, long nVertScroll, sal_uInt16 nFlags )
3061 : {
3062 :
3063 : ImplScroll( Rectangle( Point( mnOutOffX, mnOutOffY ),
3064 : Size( mnOutWidth, mnOutHeight ) ),
3065 8395 : nHorzScroll, nVertScroll, nFlags & ~SCROLL_CLIP );
3066 8395 : }
3067 :
3068 953 : void Window::Scroll( long nHorzScroll, long nVertScroll,
3069 : const Rectangle& rRect, sal_uInt16 nFlags )
3070 : {
3071 :
3072 953 : OutputDevice *pOutDev = GetOutDev();
3073 953 : Rectangle aRect = pOutDev->ImplLogicToDevicePixel( rRect );
3074 953 : aRect.Intersection( Rectangle( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ) );
3075 953 : if ( !aRect.IsEmpty() )
3076 903 : ImplScroll( aRect, nHorzScroll, nVertScroll, nFlags );
3077 953 : }
3078 :
3079 121588 : void Window::Flush()
3080 : {
3081 :
3082 121588 : const Rectangle aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
3083 121588 : mpWindowImpl->mpFrame->Flush( aWinRect );
3084 121588 : }
3085 :
3086 0 : void Window::Sync()
3087 : {
3088 :
3089 0 : mpWindowImpl->mpFrame->Sync();
3090 0 : }
3091 :
3092 424478 : void Window::SetUpdateMode( bool bUpdate )
3093 : {
3094 :
3095 424478 : mpWindowImpl->mbNoUpdate = !bUpdate;
3096 424478 : StateChanged( StateChangedType::UPDATEMODE );
3097 424478 : }
3098 :
3099 51363 : void Window::GrabFocus()
3100 : {
3101 :
3102 51363 : ImplGrabFocus( 0 );
3103 51363 : }
3104 :
3105 187767 : bool Window::HasFocus() const
3106 : {
3107 187767 : return (this == ImplGetSVData()->maWinData.mpFocusWin);
3108 : }
3109 :
3110 4 : void Window::GrabFocusToDocument()
3111 : {
3112 4 : ImplGrabFocusToDocument(0);
3113 4 : }
3114 :
3115 0 : void Window::SetFakeFocus( bool bFocus )
3116 : {
3117 0 : ImplGetWindowImpl()->mbFakeFocusSet = bFocus;
3118 0 : }
3119 :
3120 126542 : bool Window::HasChildPathFocus( bool bSystemWindow ) const
3121 : {
3122 :
3123 126542 : vcl::Window* pFocusWin = ImplGetSVData()->maWinData.mpFocusWin;
3124 126542 : if ( pFocusWin )
3125 97157 : return ImplIsWindowOrChild( pFocusWin, bSystemWindow );
3126 29385 : return false;
3127 : }
3128 :
3129 61276 : void Window::SetCursor( vcl::Cursor* pCursor )
3130 : {
3131 :
3132 61276 : if ( mpWindowImpl->mpCursor != pCursor )
3133 : {
3134 61276 : if ( mpWindowImpl->mpCursor )
3135 30567 : mpWindowImpl->mpCursor->ImplHide( true );
3136 61276 : mpWindowImpl->mpCursor = pCursor;
3137 61276 : if ( pCursor )
3138 30709 : pCursor->ImplShow();
3139 : }
3140 61276 : }
3141 :
3142 56728 : void Window::SetText( const OUString& rStr )
3143 : {
3144 56728 : if (rStr == mpWindowImpl->maText)
3145 63306 : return;
3146 :
3147 50150 : OUString oldTitle( mpWindowImpl->maText );
3148 50150 : mpWindowImpl->maText = rStr;
3149 :
3150 50150 : if ( mpWindowImpl->mpBorderWindow )
3151 11514 : mpWindowImpl->mpBorderWindow->SetText( rStr );
3152 38636 : else if ( mpWindowImpl->mbFrame )
3153 11514 : mpWindowImpl->mpFrame->SetTitle( rStr );
3154 :
3155 50150 : ImplCallEventListeners( VCLEVENT_WINDOW_FRAMETITLECHANGED, &oldTitle );
3156 :
3157 : // #107247# needed for accessibility
3158 : // The VCLEVENT_WINDOW_FRAMETITLECHANGED is (mis)used to notify accessible name changes.
3159 : // Therefore a window, which is labeled by this window, must also notify an accessible
3160 : // name change.
3161 50150 : if ( IsReallyVisible() )
3162 : {
3163 18630 : vcl::Window* pWindow = GetAccessibleRelationLabelFor();
3164 18630 : if ( pWindow && pWindow != this )
3165 0 : pWindow->ImplCallEventListeners( VCLEVENT_WINDOW_FRAMETITLECHANGED, &oldTitle );
3166 : }
3167 :
3168 50150 : StateChanged( StateChangedType::TEXT );
3169 : }
3170 :
3171 84361 : OUString Window::GetText() const
3172 : {
3173 :
3174 84361 : return mpWindowImpl->maText;
3175 : }
3176 :
3177 0 : OUString Window::GetDisplayText() const
3178 : {
3179 :
3180 0 : return GetText();
3181 : }
3182 :
3183 7506 : const Wallpaper& Window::GetDisplayBackground() const
3184 : {
3185 : // FIXME: fix issue 52349, need to fix this really in
3186 : // all NWF enabled controls
3187 7506 : const ToolBox* pTB = dynamic_cast<const ToolBox*>(this);
3188 7506 : if( pTB )
3189 : {
3190 6292 : if( IsNativeWidgetEnabled() )
3191 6292 : return pTB->ImplGetToolBoxPrivateData()->maDisplayBackground;
3192 : }
3193 :
3194 1214 : if( !IsBackground() )
3195 : {
3196 0 : if( mpWindowImpl->mpParent )
3197 0 : return mpWindowImpl->mpParent->GetDisplayBackground();
3198 : }
3199 :
3200 1214 : const Wallpaper& rBack = GetBackground();
3201 3642 : if( ! rBack.IsBitmap() &&
3202 2428 : ! rBack.IsGradient() &&
3203 2428 : rBack.GetColor().GetColor() == COL_TRANSPARENT &&
3204 : mpWindowImpl->mpParent )
3205 0 : return mpWindowImpl->mpParent->GetDisplayBackground();
3206 1214 : return rBack;
3207 : }
3208 :
3209 5268 : const OUString& Window::GetHelpText() const
3210 : {
3211 :
3212 5268 : OUString aStrHelpId( OStringToOUString( GetHelpId(), RTL_TEXTENCODING_UTF8 ) );
3213 5268 : bool bStrHelpId = !aStrHelpId.isEmpty();
3214 :
3215 5268 : if ( !mpWindowImpl->maHelpText.getLength() && bStrHelpId )
3216 : {
3217 126 : if ( !IsDialog() && (mpWindowImpl->mnType != WINDOW_TABPAGE) && (mpWindowImpl->mnType != WINDOW_FLOATINGWINDOW) )
3218 : {
3219 126 : Help* pHelp = Application::GetHelp();
3220 126 : if ( pHelp )
3221 : {
3222 126 : ((vcl::Window*)this)->mpWindowImpl->maHelpText = pHelp->GetHelpText( aStrHelpId, this );
3223 126 : mpWindowImpl->mbHelpTextDynamic = false;
3224 : }
3225 : }
3226 : }
3227 5142 : else if( mpWindowImpl->mbHelpTextDynamic && bStrHelpId )
3228 : {
3229 0 : static const char* pEnv = getenv( "HELP_DEBUG" );
3230 0 : if( pEnv && *pEnv )
3231 : {
3232 0 : OUStringBuffer aTxt( 64+mpWindowImpl->maHelpText.getLength() );
3233 0 : aTxt.append( mpWindowImpl->maHelpText );
3234 0 : aTxt.appendAscii( "\n------------------\n" );
3235 0 : aTxt.append( OUString( aStrHelpId ) );
3236 0 : mpWindowImpl->maHelpText = aTxt.makeStringAndClear();
3237 : }
3238 0 : mpWindowImpl->mbHelpTextDynamic = false;
3239 : }
3240 :
3241 5268 : return mpWindowImpl->maHelpText;
3242 : }
3243 :
3244 265654 : void Window::SetWindowPeer( Reference< css::awt::XWindowPeer > xPeer, VCLXWindow* pVCLXWindow )
3245 : {
3246 : // be safe against re-entrance: first clear the old ref, then assign the new one
3247 265654 : mpWindowImpl->mxWindowPeer.clear();
3248 265654 : mpWindowImpl->mxWindowPeer = xPeer;
3249 :
3250 265654 : mpWindowImpl->mpVCLXWindow = pVCLXWindow;
3251 265654 : }
3252 :
3253 865706 : Reference< css::awt::XWindowPeer > Window::GetComponentInterface( bool bCreate )
3254 : {
3255 865706 : if ( !mpWindowImpl->mxWindowPeer.is() && bCreate )
3256 : {
3257 126577 : UnoWrapperBase* pWrapper = Application::GetUnoWrapper();
3258 126577 : if ( pWrapper )
3259 126577 : mpWindowImpl->mxWindowPeer = pWrapper->GetWindowInterface( this, true );
3260 : }
3261 865706 : return mpWindowImpl->mxWindowPeer;
3262 : }
3263 :
3264 6312 : void Window::SetComponentInterface( Reference< css::awt::XWindowPeer > xIFace )
3265 : {
3266 6312 : UnoWrapperBase* pWrapper = Application::GetUnoWrapper();
3267 : DBG_ASSERT( pWrapper, "SetComponentInterface: No Wrapper!" );
3268 6312 : if ( pWrapper )
3269 6312 : pWrapper->SetWindowInterface( this, xIFace );
3270 6312 : }
3271 :
3272 61777 : void Window::ImplCallDeactivateListeners( vcl::Window *pNew )
3273 : {
3274 : // no deactivation if the newly activated window is my child
3275 61777 : if ( !pNew || !ImplIsChild( pNew ) )
3276 : {
3277 36380 : ImplDelData aDogtag( this );
3278 36380 : ImplCallEventListeners( VCLEVENT_WINDOW_DEACTIVATE );
3279 36380 : if( aDogtag.IsDead() )
3280 61777 : return;
3281 :
3282 : // #100759#, avoid walking the wrong frame's hierarchy
3283 : // eg, undocked docking windows (ImplDockFloatWin)
3284 36380 : if ( ImplGetParent() && mpWindowImpl->mpFrameWindow == ImplGetParent()->mpWindowImpl->mpFrameWindow )
3285 36328 : ImplGetParent()->ImplCallDeactivateListeners( pNew );
3286 : }
3287 : }
3288 :
3289 66814 : void Window::ImplCallActivateListeners( vcl::Window *pOld )
3290 : {
3291 : // no activation if the old active window is my child
3292 66814 : if ( !pOld || !ImplIsChild( pOld ) )
3293 : {
3294 41417 : ImplDelData aDogtag( this );
3295 41417 : ImplCallEventListeners( VCLEVENT_WINDOW_ACTIVATE, pOld );
3296 41417 : if( aDogtag.IsDead() )
3297 66814 : return;
3298 :
3299 41417 : if ( ImplGetParent() )
3300 36374 : ImplGetParent()->ImplCallActivateListeners( pOld );
3301 5043 : else if( (mpWindowImpl->mnStyle & WB_INTROWIN) == 0 )
3302 : {
3303 : // top level frame reached: store hint for DefModalDialogParent
3304 5043 : ImplGetSVData()->maWinData.mpActiveApplicationFrame = mpWindowImpl->mpFrameWindow;
3305 41417 : }
3306 : }
3307 : }
3308 :
3309 9971 : Reference< XClipboard > Window::GetClipboard()
3310 : {
3311 :
3312 9971 : if( mpWindowImpl->mpFrameData )
3313 : {
3314 9971 : if( ! mpWindowImpl->mpFrameData->mxClipboard.is() )
3315 : {
3316 : try
3317 : {
3318 : mpWindowImpl->mpFrameData->mxClipboard
3319 7182 : = css::datatransfer::clipboard::SystemClipboard::create(
3320 1598 : comphelper::getProcessComponentContext());
3321 : }
3322 3986 : catch (DeploymentException & e)
3323 : {
3324 : SAL_WARN(
3325 : "vcl.window",
3326 : "ignoring DeploymentException \"" << e.Message << "\"");
3327 : }
3328 : }
3329 :
3330 9971 : return mpWindowImpl->mpFrameData->mxClipboard;
3331 : }
3332 :
3333 0 : return static_cast < XClipboard * > (0);
3334 : }
3335 :
3336 490 : Reference< XClipboard > Window::GetPrimarySelection()
3337 : {
3338 :
3339 490 : if( mpWindowImpl->mpFrameData )
3340 : {
3341 490 : if( ! mpWindowImpl->mpFrameData->mxSelection.is() )
3342 : {
3343 : try
3344 : {
3345 354 : Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
3346 :
3347 : #if HAVE_FEATURE_X11
3348 : // A hack, making the primary selection available as an instance
3349 : // of the SystemClipboard service on X11:
3350 708 : Sequence< Any > args(1);
3351 354 : args[0] <<= OUString("PRIMARY");
3352 : mpWindowImpl->mpFrameData->mxSelection.set(
3353 708 : (xContext->getServiceManager()->
3354 : createInstanceWithArgumentsAndContext(
3355 : "com.sun.star.datatransfer.clipboard.SystemClipboard",
3356 354 : args, xContext)),
3357 1028 : UNO_QUERY_THROW);
3358 : #else
3359 : static Reference< XClipboard > s_xSelection(
3360 : xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.datatransfer.clipboard.GenericClipboard", xContext ), UNO_QUERY );
3361 :
3362 : mpWindowImpl->mpFrameData->mxSelection = s_xSelection;
3363 : #endif
3364 : }
3365 320 : catch (RuntimeException & e)
3366 : {
3367 : SAL_WARN(
3368 : "vcl.window",
3369 : "ignoring RuntimeException \"" << e.Message << "\"");
3370 : }
3371 : }
3372 :
3373 490 : return mpWindowImpl->mpFrameData->mxSelection;
3374 : }
3375 :
3376 0 : return static_cast < XClipboard * > (0);
3377 : }
3378 :
3379 410 : void Window::RecordLayoutData( vcl::ControlLayoutData* pLayout, const Rectangle& rRect )
3380 : {
3381 : assert(mpOutDevData);
3382 410 : mpOutDevData->mpRecordLayout = pLayout;
3383 410 : mpOutDevData->maRecordRect = rRect;
3384 410 : Paint( rRect );
3385 410 : mpOutDevData->mpRecordLayout = NULL;
3386 410 : }
3387 :
3388 12 : void Window::DrawSelectionBackground( const Rectangle& rRect, sal_uInt16 highlight, bool bChecked, bool bDrawBorder, bool bDrawExtBorderOnly )
3389 : {
3390 12 : DrawSelectionBackground( rRect, highlight, bChecked, bDrawBorder, bDrawExtBorderOnly, 0, NULL, NULL );
3391 12 : }
3392 :
3393 0 : void Window::DrawSelectionBackground( const Rectangle& rRect, sal_uInt16 highlight, bool bChecked, bool bDrawBorder, bool bDrawExtBorderOnly, Color* pSelectionTextColor )
3394 : {
3395 0 : DrawSelectionBackground( rRect, highlight, bChecked, bDrawBorder, bDrawExtBorderOnly, 0, pSelectionTextColor, NULL );
3396 0 : }
3397 :
3398 6336 : void Window::DrawSelectionBackground( const Rectangle& rRect,
3399 : sal_uInt16 highlight,
3400 : bool bChecked,
3401 : bool bDrawBorder,
3402 : bool bDrawExtBorderOnly,
3403 : long nCornerRadius,
3404 : Color* pSelectionTextColor,
3405 : Color* pPaintColor
3406 : )
3407 : {
3408 6336 : if( rRect.IsEmpty() )
3409 6336 : return;
3410 :
3411 6336 : bool bRoundEdges = nCornerRadius > 0;
3412 :
3413 6336 : const StyleSettings& rStyles = GetSettings().GetStyleSettings();
3414 :
3415 : // colors used for item highlighting
3416 6336 : Color aSelectionBorderCol( pPaintColor ? *pPaintColor : rStyles.GetHighlightColor() );
3417 6336 : Color aSelectionFillCol( aSelectionBorderCol );
3418 :
3419 6336 : bool bDark = rStyles.GetFaceColor().IsDark();
3420 6336 : bool bBright = ( rStyles.GetFaceColor() == Color( COL_WHITE ) );
3421 :
3422 6336 : int c1 = aSelectionBorderCol.GetLuminance();
3423 6336 : int c2 = GetDisplayBackground().GetColor().GetLuminance();
3424 :
3425 6336 : if( !bDark && !bBright && abs( c2-c1 ) < (pPaintColor ? 40 : 75) )
3426 : {
3427 : // constrast too low
3428 : sal_uInt16 h,s,b;
3429 0 : aSelectionFillCol.RGBtoHSB( h, s, b );
3430 0 : if( b > 50 ) b -= 40;
3431 0 : else b += 40;
3432 0 : aSelectionFillCol.SetColor( Color::HSBtoRGB( h, s, b ) );
3433 0 : aSelectionBorderCol = aSelectionFillCol;
3434 : }
3435 :
3436 6336 : if( bRoundEdges )
3437 : {
3438 6324 : if( aSelectionBorderCol.IsDark() )
3439 6324 : aSelectionBorderCol.IncreaseLuminance( 128 );
3440 : else
3441 0 : aSelectionBorderCol.DecreaseLuminance( 128 );
3442 : }
3443 :
3444 6336 : Rectangle aRect( rRect );
3445 6336 : if( bDrawExtBorderOnly )
3446 : {
3447 0 : --aRect.Left();
3448 0 : --aRect.Top();
3449 0 : ++aRect.Right();
3450 0 : ++aRect.Bottom();
3451 : }
3452 6336 : Color oldFillCol = GetFillColor();
3453 6336 : Color oldLineCol = GetLineColor();
3454 :
3455 6336 : if( bDrawBorder )
3456 6336 : SetLineColor( bDark ? Color(COL_WHITE) : ( bBright ? Color(COL_BLACK) : aSelectionBorderCol ) );
3457 : else
3458 0 : SetLineColor();
3459 :
3460 6336 : sal_uInt16 nPercent = 0;
3461 6336 : if( !highlight )
3462 : {
3463 6322 : if( bDark )
3464 0 : aSelectionFillCol = COL_BLACK;
3465 : else
3466 6322 : nPercent = 80; // just checked (light)
3467 : }
3468 : else
3469 : {
3470 14 : if( bChecked && highlight == 2 )
3471 : {
3472 0 : if( bDark )
3473 0 : aSelectionFillCol = COL_LIGHTGRAY;
3474 0 : else if ( bBright )
3475 : {
3476 0 : aSelectionFillCol = COL_BLACK;
3477 0 : SetLineColor( COL_BLACK );
3478 0 : nPercent = 0;
3479 : }
3480 : else
3481 0 : nPercent = bRoundEdges ? 40 : 20; // selected, pressed or checked ( very dark )
3482 : }
3483 14 : else if( bChecked || highlight == 1 )
3484 : {
3485 24 : if( bDark )
3486 0 : aSelectionFillCol = COL_GRAY;
3487 12 : else if ( bBright )
3488 : {
3489 0 : aSelectionFillCol = COL_BLACK;
3490 0 : SetLineColor( COL_BLACK );
3491 0 : nPercent = 0;
3492 : }
3493 : else
3494 12 : nPercent = bRoundEdges ? 60 : 35; // selected, pressed or checked ( very dark )
3495 : }
3496 : else
3497 : {
3498 2 : if( bDark )
3499 0 : aSelectionFillCol = COL_LIGHTGRAY;
3500 2 : else if ( bBright )
3501 : {
3502 0 : aSelectionFillCol = COL_BLACK;
3503 0 : SetLineColor( COL_BLACK );
3504 0 : if( highlight == 3 )
3505 0 : nPercent = 80;
3506 : else
3507 0 : nPercent = 0;
3508 : }
3509 : else
3510 2 : nPercent = 70; // selected ( dark )
3511 : }
3512 : }
3513 :
3514 6336 : if( bDark && bDrawExtBorderOnly )
3515 : {
3516 0 : SetFillColor();
3517 0 : if( pSelectionTextColor )
3518 0 : *pSelectionTextColor = rStyles.GetHighlightTextColor();
3519 : }
3520 : else
3521 : {
3522 6336 : SetFillColor( aSelectionFillCol );
3523 6336 : if( pSelectionTextColor )
3524 : {
3525 0 : Color aTextColor = IsControlBackground() ? GetControlForeground() : rStyles.GetButtonTextColor();
3526 0 : Color aHLTextColor = rStyles.GetHighlightTextColor();
3527 0 : int nTextDiff = abs(aSelectionFillCol.GetLuminance() - aTextColor.GetLuminance());
3528 0 : int nHLDiff = abs(aSelectionFillCol.GetLuminance() - aHLTextColor.GetLuminance());
3529 0 : *pSelectionTextColor = (nHLDiff >= nTextDiff) ? aHLTextColor : aTextColor;
3530 : }
3531 : }
3532 :
3533 6336 : if( bDark )
3534 : {
3535 0 : DrawRect( aRect );
3536 : }
3537 : else
3538 : {
3539 6336 : if( bRoundEdges )
3540 : {
3541 6324 : Polygon aPoly( aRect, nCornerRadius, nCornerRadius );
3542 12648 : tools::PolyPolygon aPolyPoly( aPoly );
3543 12648 : DrawTransparent( aPolyPoly, nPercent );
3544 : }
3545 : else
3546 : {
3547 12 : Polygon aPoly( aRect );
3548 24 : tools::PolyPolygon aPolyPoly( aPoly );
3549 24 : DrawTransparent( aPolyPoly, nPercent );
3550 : }
3551 : }
3552 :
3553 6336 : SetFillColor( oldFillCol );
3554 6336 : SetLineColor( oldLineCol );
3555 : }
3556 :
3557 : // controls should return the window that gets the
3558 : // focus by default, so keyevents can be sent to that window directly
3559 0 : vcl::Window* Window::GetPreferredKeyInputWindow()
3560 : {
3561 0 : return this;
3562 : }
3563 :
3564 2702 : bool Window::IsScrollable() const
3565 : {
3566 : // check for scrollbars
3567 2702 : vcl::Window *pChild = mpWindowImpl->mpFirstChild;
3568 15350 : while( pChild )
3569 : {
3570 11372 : if( pChild->GetType() == WINDOW_SCROLLBAR )
3571 1426 : return true;
3572 : else
3573 9946 : pChild = pChild->mpWindowImpl->mpNext;
3574 : }
3575 1276 : return false;
3576 : }
3577 :
3578 0 : void Window::ImplMirrorFramePos( Point &pt ) const
3579 : {
3580 0 : pt.X() = mpWindowImpl->mpFrame->maGeometry.nWidth-1-pt.X();
3581 0 : }
3582 :
3583 : // frame based modal counter (dialogs are not modal to the whole application anymore)
3584 72462 : bool Window::IsInModalMode() const
3585 : {
3586 72462 : return (mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrameData->mnModalMode != 0);
3587 : }
3588 :
3589 36109 : bool Window::IsInModalNonRefMode() const
3590 : {
3591 36109 : if(mpWindowImpl->mnStyle & WB_REFMODE)
3592 0 : return false;
3593 :
3594 36109 : return IsInModalMode();
3595 : }
3596 :
3597 0 : void Window::ImplIncModalCount()
3598 : {
3599 0 : vcl::Window* pFrameWindow = mpWindowImpl->mpFrameWindow;
3600 0 : vcl::Window* pParent = pFrameWindow;
3601 0 : while( pFrameWindow )
3602 : {
3603 0 : pFrameWindow->mpWindowImpl->mpFrameData->mnModalMode++;
3604 0 : while( pParent && pParent->mpWindowImpl->mpFrameWindow == pFrameWindow )
3605 : {
3606 0 : pParent = pParent->GetParent();
3607 : }
3608 0 : pFrameWindow = pParent ? pParent->mpWindowImpl->mpFrameWindow : NULL;
3609 : }
3610 0 : }
3611 0 : void Window::ImplDecModalCount()
3612 : {
3613 0 : vcl::Window* pFrameWindow = mpWindowImpl->mpFrameWindow;
3614 0 : vcl::Window* pParent = pFrameWindow;
3615 0 : while( pFrameWindow )
3616 : {
3617 0 : pFrameWindow->mpWindowImpl->mpFrameData->mnModalMode--;
3618 0 : while( pParent && pParent->mpWindowImpl->mpFrameWindow == pFrameWindow )
3619 : {
3620 0 : pParent = pParent->GetParent();
3621 : }
3622 0 : pFrameWindow = pParent ? pParent->mpWindowImpl->mpFrameWindow : NULL;
3623 : }
3624 0 : }
3625 :
3626 67718 : void Window::ImplIsInTaskPaneList( bool mbIsInTaskList )
3627 : {
3628 67718 : mpWindowImpl->mbIsInTaskPaneList = mbIsInTaskList;
3629 67718 : }
3630 :
3631 47 : void Window::ImplNotifyIconifiedState( bool bIconified )
3632 : {
3633 47 : mpWindowImpl->mpFrameWindow->ImplCallEventListeners( bIconified ? VCLEVENT_WINDOW_MINIMIZE : VCLEVENT_WINDOW_NORMALIZE );
3634 : // #109206# notify client window as well to have toolkit topwindow listeners notified
3635 47 : if( mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow && mpWindowImpl->mpFrameWindow != mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow )
3636 15 : mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow->ImplCallEventListeners( bIconified ? VCLEVENT_WINDOW_MINIMIZE : VCLEVENT_WINDOW_NORMALIZE );
3637 47 : }
3638 :
3639 64 : bool Window::HasActiveChildFrame()
3640 : {
3641 64 : bool bRet = false;
3642 64 : vcl::Window *pFrameWin = ImplGetSVData()->maWinData.mpFirstFrame;
3643 538 : while( pFrameWin )
3644 : {
3645 410 : if( pFrameWin != mpWindowImpl->mpFrameWindow )
3646 : {
3647 346 : bool bDecorated = false;
3648 346 : vcl::Window *pChildFrame = pFrameWin->ImplGetWindow();
3649 : // #i15285# unfortunately WB_MOVEABLE is the same as WB_TABSTOP which can
3650 : // be removed for ToolBoxes to influence the keyboard accessibility
3651 : // thus WB_MOVEABLE is no indicator for decoration anymore
3652 : // but FloatingWindows carry this information in their TitleType...
3653 : // TODO: avoid duplicate WinBits !!!
3654 346 : if( pChildFrame && pChildFrame->ImplIsFloatingWindow() )
3655 282 : bDecorated = static_cast<FloatingWindow*>(pChildFrame)->GetTitleType() != FLOATWIN_TITLE_NONE;
3656 346 : if( bDecorated || (pFrameWin->mpWindowImpl->mnStyle & (WB_MOVEABLE | WB_SIZEABLE) ) )
3657 2 : if( pChildFrame && pChildFrame->IsVisible() && pChildFrame->IsActive() )
3658 : {
3659 2 : if( ImplIsChild( pChildFrame, true ) )
3660 : {
3661 0 : bRet = true;
3662 0 : break;
3663 : }
3664 : }
3665 : }
3666 410 : pFrameWin = pFrameWin->mpWindowImpl->mpFrameData->mpNextFrame;
3667 : }
3668 64 : return bRet;
3669 : }
3670 :
3671 4741 : LanguageType Window::GetInputLanguage() const
3672 : {
3673 4741 : return mpWindowImpl->mpFrame->GetInputLanguage();
3674 : }
3675 :
3676 61575 : void Window::EnableNativeWidget( bool bEnable )
3677 : {
3678 61575 : static const char* pNoNWF = getenv( "SAL_NO_NWF" );
3679 61575 : if( pNoNWF && *pNoNWF )
3680 0 : bEnable = false;
3681 :
3682 61575 : if( bEnable != ImplGetWinData()->mbEnableNativeWidget )
3683 : {
3684 6629 : ImplGetWinData()->mbEnableNativeWidget = bEnable;
3685 :
3686 : // send datachanged event to allow for internal changes required for NWF
3687 : // like clipmode, transparency, etc.
3688 6629 : DataChangedEvent aDCEvt( DATACHANGED_SETTINGS, mxSettings.get(), SETTINGS_STYLE );
3689 6629 : DataChanged( aDCEvt );
3690 :
3691 : // sometimes the borderwindow is queried, so keep it in sync
3692 6629 : if( mpWindowImpl->mpBorderWindow )
3693 2192 : mpWindowImpl->mpBorderWindow->ImplGetWinData()->mbEnableNativeWidget = bEnable;
3694 : }
3695 :
3696 : // push down, useful for compound controls
3697 61575 : vcl::Window *pChild = mpWindowImpl->mpFirstChild;
3698 169852 : while( pChild )
3699 : {
3700 46702 : pChild->EnableNativeWidget( bEnable );
3701 46702 : pChild = pChild->mpWindowImpl->mpNext;
3702 : }
3703 61575 : }
3704 :
3705 1854419 : bool Window::IsNativeWidgetEnabled() const
3706 : {
3707 1854419 : return ImplGetWinData()->mbEnableNativeWidget;
3708 : }
3709 :
3710 162 : Reference< css::rendering::XCanvas > Window::ImplGetCanvas( const Size& rFullscreenSize,
3711 : bool bFullscreen,
3712 : bool bSpriteCanvas ) const
3713 : {
3714 : // try to retrieve hard reference from weak member
3715 162 : Reference< css::rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
3716 :
3717 : // canvas still valid? Then we're done.
3718 162 : if( xCanvas.is() )
3719 0 : return xCanvas;
3720 :
3721 324 : Sequence< Any > aArg(6);
3722 :
3723 : // Feed any with operating system's window handle
3724 :
3725 : // common: first any is VCL pointer to window (for VCL canvas)
3726 162 : aArg[ 0 ] = makeAny( reinterpret_cast<sal_Int64>(this) );
3727 :
3728 : // TODO(Q1): Make GetSystemData method virtual
3729 :
3730 : // check whether we're a SysChild: have to fetch system data
3731 : // directly from SystemChildWindow, because the GetSystemData
3732 : // method is unfortunately not virtual
3733 162 : const SystemChildWindow* pSysChild = dynamic_cast< const SystemChildWindow* >( this );
3734 162 : if( pSysChild )
3735 : {
3736 0 : aArg[ 1 ] = pSysChild->GetSystemDataAny();
3737 0 : aArg[ 5 ] = pSysChild->GetSystemGfxDataAny();
3738 : }
3739 : else
3740 : {
3741 162 : aArg[ 1 ] = GetSystemDataAny();
3742 162 : aArg[ 5 ] = GetSystemGfxDataAny();
3743 : }
3744 :
3745 162 : if( bFullscreen )
3746 0 : aArg[ 2 ] = makeAny( css::awt::Rectangle( 0, 0,
3747 0 : rFullscreenSize.Width(),
3748 0 : rFullscreenSize.Height() ) );
3749 : else
3750 162 : aArg[ 2 ] = makeAny( css::awt::Rectangle( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight ) );
3751 :
3752 162 : aArg[ 3 ] = makeAny( mpWindowImpl->mbAlwaysOnTop ? true : false );
3753 324 : aArg[ 4 ] = makeAny( Reference< css::awt::XWindow >(
3754 162 : const_cast<vcl::Window*>(this)->GetComponentInterface(),
3755 162 : UNO_QUERY ));
3756 :
3757 324 : Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
3758 :
3759 : // Create canvas instance with window handle
3760 :
3761 : static ::vcl::DeleteUnoReferenceOnDeinit<XMultiComponentFactory> xStaticCanvasFactory(
3762 162 : css::rendering::CanvasFactory::create( xContext ) );
3763 324 : Reference<XMultiComponentFactory> xCanvasFactory(xStaticCanvasFactory.get());
3764 :
3765 162 : if(xCanvasFactory.is())
3766 : {
3767 : #ifdef WNT
3768 : // see #140456# - if we're running on a multiscreen setup,
3769 : // request special, multi-screen safe sprite canvas
3770 : // implementation (not DX5 canvas, as it cannot cope with
3771 : // surfaces spanning multiple displays). Note: canvas
3772 : // (without sprite) stays the same)
3773 : const sal_uInt32 nDisplay = static_cast< WinSalFrame* >( mpWindowImpl->mpFrame )->mnDisplay;
3774 : if( (nDisplay >= Application::GetScreenCount()) )
3775 : {
3776 : xCanvas.set( xCanvasFactory->createInstanceWithArgumentsAndContext(
3777 : bSpriteCanvas ?
3778 : OUString( "com.sun.star.rendering.SpriteCanvas.MultiScreen" ) :
3779 : OUString( "com.sun.star.rendering.Canvas.MultiScreen" ),
3780 : aArg,
3781 : xContext ),
3782 : UNO_QUERY );
3783 :
3784 : }
3785 : else
3786 : {
3787 : #endif
3788 162 : xCanvas.set( xCanvasFactory->createInstanceWithArgumentsAndContext(
3789 : bSpriteCanvas ?
3790 : OUString( "com.sun.star.rendering.SpriteCanvas" ) :
3791 : OUString( "com.sun.star.rendering.Canvas" ),
3792 : aArg,
3793 162 : xContext ),
3794 162 : UNO_QUERY );
3795 :
3796 : #ifdef WNT
3797 : }
3798 : #endif
3799 162 : mpWindowImpl->mxCanvas = xCanvas;
3800 : }
3801 :
3802 : // no factory??? Empty reference, then.
3803 162 : return xCanvas;
3804 : }
3805 :
3806 162 : Reference< css::rendering::XCanvas > Window::GetCanvas() const
3807 : {
3808 162 : return ImplGetCanvas( Size(), false, false );
3809 : }
3810 :
3811 0 : Reference< css::rendering::XSpriteCanvas > Window::GetSpriteCanvas() const
3812 : {
3813 : Reference< css::rendering::XSpriteCanvas > xSpriteCanvas(
3814 0 : ImplGetCanvas( Size(), false, true ), UNO_QUERY );
3815 0 : return xSpriteCanvas;
3816 : }
3817 :
3818 0 : OUString Window::GetSurroundingText() const
3819 : {
3820 0 : return OUString();
3821 : }
3822 :
3823 0 : Selection Window::GetSurroundingTextSelection() const
3824 : {
3825 0 : return Selection( 0, 0 );
3826 : }
3827 :
3828 0 : bool Window::UsePolyPolygonForComplexGradient()
3829 : {
3830 0 : if ( meRasterOp != ROP_OVERPAINT )
3831 0 : return true;
3832 :
3833 0 : return false;
3834 : }
3835 :
3836 17391 : void Window::DrawGradientWallpaper( long nX, long nY,
3837 : long nWidth, long nHeight,
3838 : const Wallpaper& rWallpaper )
3839 : {
3840 17391 : Rectangle aBound;
3841 17391 : GDIMetaFile* pOldMetaFile = mpMetaFile;
3842 17391 : const bool bOldMap = mbMap;
3843 17391 : bool bNeedGradient = true;
3844 :
3845 17391 : aBound = Rectangle( Point( nX, nY ), Size( nWidth, nHeight ) );
3846 :
3847 17391 : mpMetaFile = NULL;
3848 17391 : EnableMapMode( false );
3849 17391 : Push( PushFlags::CLIPREGION );
3850 17391 : IntersectClipRegion( Rectangle( Point( nX, nY ), Size( nWidth, nHeight ) ) );
3851 :
3852 17391 : if( rWallpaper.GetStyle() == WALLPAPER_APPLICATIONGRADIENT )
3853 : {
3854 : // limit gradient to useful size, so that it still can be noticed
3855 : // in maximized windows
3856 13685 : long gradientWidth = GetDesktopRectPixel().GetSize().Width();
3857 13685 : if( gradientWidth > 1024 )
3858 0 : gradientWidth = 1024;
3859 13685 : if( mnOutOffX+nWidth > gradientWidth )
3860 0 : DrawColorWallpaper( nX, nY, nWidth, nHeight, rWallpaper.GetGradient().GetEndColor() );
3861 13685 : if( mnOutOffX > gradientWidth )
3862 0 : bNeedGradient = false;
3863 : else
3864 13685 : aBound = Rectangle( Point( -mnOutOffX, nY ), Size( gradientWidth, nHeight ) );
3865 : }
3866 :
3867 17391 : if( bNeedGradient )
3868 17391 : DrawGradient( aBound, rWallpaper.GetGradient() );
3869 :
3870 17391 : Pop();
3871 17391 : EnableMapMode( bOldMap );
3872 17391 : mpMetaFile = pOldMetaFile;
3873 17391 : }
3874 :
3875 15538 : const SystemEnvData* Window::GetSystemData() const
3876 : {
3877 :
3878 15538 : return mpWindowImpl->mpFrame ? mpWindowImpl->mpFrame->GetSystemData() : NULL;
3879 : }
3880 :
3881 162 : Any Window::GetSystemDataAny() const
3882 : {
3883 162 : Any aRet;
3884 162 : const SystemEnvData* pSysData = GetSystemData();
3885 162 : if( pSysData )
3886 : {
3887 162 : Sequence< sal_Int8 > aSeq( (sal_Int8*)pSysData, pSysData->nSize );
3888 162 : aRet <<= aSeq;
3889 : }
3890 162 : return aRet;
3891 : }
3892 :
3893 : } /* namespace vcl */
3894 :
3895 828054 : bool ImplDoTiledRendering()
3896 : {
3897 : #if !HAVE_FEATURE_DESKTOP
3898 : // We do tiled rendering only for iOS at the moment, actually, but
3899 : // let's see what happens if we assume it for Android, too.
3900 : return true;
3901 : #else
3902 : // We need some way to know globally if this process will use
3903 : // tiled rendering or not. Or should this be a per-window setting?
3904 : // Or what?
3905 828054 : return false;
3906 : #endif
3907 1233 : }
3908 :
3909 :
3910 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|