LibreOffice Module vcl (master) 1
window.cxx
Go to the documentation of this file.
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 <sal/config.h>
21
22#include <rtl/strbuf.hxx>
23#include <sal/log.hxx>
24
25#include <sal/types.h>
27#include <vcl/salgtype.hxx>
28#include <vcl/event.hxx>
29#include <vcl/help.hxx>
30#include <vcl/cursor.hxx>
31#include <vcl/svapp.hxx>
32#include <vcl/transfer.hxx>
33#include <vcl/vclevent.hxx>
34#include <vcl/window.hxx>
35#include <vcl/syswin.hxx>
36#include <vcl/dockwin.hxx>
37#include <vcl/wall.hxx>
38#include <vcl/toolkit/fixed.hxx>
39#include <vcl/taskpanelist.hxx>
41#include <vcl/lazydelete.hxx>
42#include <vcl/virdev.hxx>
43#include <vcl/settings.hxx>
44#include <vcl/sysdata.hxx>
45#include <vcl/ptrstyle.hxx>
47
49
50#include <ImplOutDevData.hxx>
51#include <impfontcache.hxx>
52#include <salframe.hxx>
53#include <salobj.hxx>
54#include <salinst.hxx>
55#include <salgdi.hxx>
56#include <svdata.hxx>
57#include <window.h>
58#include <toolbox.h>
59#include <brdwin.hxx>
60#include <helpwin.hxx>
61
62#include <com/sun/star/accessibility/AccessibleRelation.hpp>
63#include <com/sun/star/accessibility/XAccessible.hpp>
64#include <com/sun/star/accessibility/XAccessibleEditableText.hpp>
65#include <com/sun/star/awt/XWindowPeer.hpp>
66#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
67#include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp>
68#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
69#include <com/sun/star/rendering/CanvasFactory.hpp>
70#include <com/sun/star/rendering/XSpriteCanvas.hpp>
71#include <comphelper/lok.hxx>
74#include <osl/diagnose.h>
75#include <tools/debug.hxx>
76#include <tools/json_writer.hxx>
77#include <boost/property_tree/ptree.hpp>
78
79#include <cassert>
80#include <typeinfo>
81
82#ifdef _WIN32 // see #140456#
83#include <win/salframe.h>
84#endif
85
87
88using namespace ::com::sun::star::uno;
89using namespace ::com::sun::star::lang;
91using namespace ::com::sun::star::datatransfer::dnd;
92
93namespace vcl {
94
96 : mpWindowImpl(new WindowImpl( *this, nType ))
97{
98 // true: this outdev will be mirrored if RTL window layout (UI mirroring) is globally active
99 mpWindowImpl->mxOutDev->mbEnableRTL = AllSettings::GetLayoutRTL();
100}
101
103 : mpWindowImpl(new WindowImpl( *this, WindowType::WINDOW ))
104{
105 // true: this outdev will be mirrored if RTL window layout (UI mirroring) is globally active
106 mpWindowImpl->mxOutDev->mbEnableRTL = AllSettings::GetLayoutRTL();
107
108 ImplInit( pParent, nStyle, nullptr );
109}
110
111#if OSL_DEBUG_LEVEL > 0
112namespace
113{
114 OString lcl_createWindowInfo(const vcl::Window* pWindow)
115 {
116 // skip border windows, they do not carry information that
117 // would help with diagnosing the problem
118 const vcl::Window* pTempWin( pWindow );
119 while ( pTempWin && pTempWin->GetType() == WindowType::BORDERWINDOW ) {
120 pTempWin = pTempWin->GetWindow( GetWindowType::FirstChild );
121 }
122 // check if pTempWin is not null, otherwise use the
123 // original address
124 if ( pTempWin ) {
125 pWindow = pTempWin;
126 }
127
128 return OString::Concat(" ") +
129 typeid( *pWindow ).name() +
130 "(" +
132 pWindow->GetText(),
133 RTL_TEXTENCODING_UTF8
134 ) +
135 ")";
136 }
137}
138#endif
139
141{
142 assert( mpWindowImpl );
143 assert( !mpWindowImpl->mbInDispose ); // should only be called from disposeOnce()
144 assert( (!mpWindowImpl->mpParent ||
145 mpWindowImpl->mpParent->mpWindowImpl) &&
146 "vcl::Window child should have its parent disposed first" );
147
148 // remove Key and Mouse events issued by Application::PostKey/MouseEvent
150
151 // Dispose of the canvas implementation (which, currently, has an
152 // own wrapper window as a child to this one.
154
155 mpWindowImpl->mbInDispose = true;
156
158
159 // do not send child events for frames that were registered as native frames
160 if( !ImplIsAccessibleNativeFrame() && mpWindowImpl->mbReallyVisible )
163
164 // remove associated data structures from dockingmanager
166
167 // remove ownerdraw decorated windows from list in the top-most frame window
168 if( (GetStyle() & WB_OWNERDRAWDECORATION) && mpWindowImpl->mbFrame )
169 {
170 ::std::vector< VclPtr<vcl::Window> >& rList = ImplGetOwnerDrawList();
171 auto p = ::std::find( rList.begin(), rList.end(), VclPtr<vcl::Window>(this) );
172 if( p != rList.end() )
173 rList.erase( p );
174 }
175
176 // shutdown drag and drop
177 Reference < XComponent > xDnDComponent( mpWindowImpl->mxDNDListenerContainer, UNO_QUERY );
178
179 if( xDnDComponent.is() )
180 xDnDComponent->dispose();
181
182 if( mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData )
183 {
184 try
185 {
186 // deregister drop target listener
187 if( mpWindowImpl->mpFrameData->mxDropTargetListener.is() )
188 {
189 Reference< XDragGestureRecognizer > xDragGestureRecognizer(mpWindowImpl->mpFrameData->mxDragSource, UNO_QUERY);
190 if( xDragGestureRecognizer.is() )
191 {
192 xDragGestureRecognizer->removeDragGestureListener(
193 Reference< XDragGestureListener > (mpWindowImpl->mpFrameData->mxDropTargetListener, UNO_QUERY));
194 }
195
196 mpWindowImpl->mpFrameData->mxDropTarget->removeDropTargetListener( mpWindowImpl->mpFrameData->mxDropTargetListener );
197 mpWindowImpl->mpFrameData->mxDropTargetListener.clear();
198 }
199
200 // shutdown drag and drop for this frame window
201 Reference< XComponent > xComponent( mpWindowImpl->mpFrameData->mxDropTarget, UNO_QUERY );
202
203 // DNDEventDispatcher does not hold a reference of the DropTarget,
204 // so it's ok if it does not support XComponent
205 if( xComponent.is() )
206 xComponent->dispose();
207 }
208 catch (const Exception&)
209 {
210 // can be safely ignored here.
211 }
212 }
213
215 if ( pWrapper )
216 pWrapper->WindowDestroyed( this );
217
218 // MT: Must be called after WindowDestroyed!
219 // Otherwise, if the accessible is a VCLXWindow, it will try to destroy this window again!
220 // But accessibility implementations from applications need this dispose.
221 if ( mpWindowImpl->mxAccessible.is() )
222 {
223 Reference< XComponent> xC( mpWindowImpl->mxAccessible, UNO_QUERY );
224 if ( xC.is() )
225 xC->dispose();
226 }
227
228 ImplSVData* pSVData = ImplGetSVData();
229
230 if ( ImplGetSVHelpData().mpHelpWin && (ImplGetSVHelpData().mpHelpWin->GetParent() == this) )
231 ImplDestroyHelpWindow( true );
232
233 SAL_WARN_IF(pSVData->mpWinData->mpTrackWin.get() == this, "vcl.window",
234 "Window::~Window(): Window is in TrackingMode");
235 SAL_WARN_IF(IsMouseCaptured(), "vcl.window",
236 "Window::~Window(): Window has the mouse captured");
237
238 // due to old compatibility
239 if (pSVData->mpWinData->mpTrackWin == this)
240 EndTracking();
241 if (IsMouseCaptured())
242 ReleaseMouse();
243
244#if OSL_DEBUG_LEVEL > 0
245 // always perform these tests in debug builds
246 {
247 OStringBuffer aErrorStr;
248 bool bError = false;
249 vcl::Window* pTempWin;
250
251 if ( mpWindowImpl->mpFirstChild )
252 {
253 OStringBuffer aTempStr = "Window (" +
254 lcl_createWindowInfo(this) +
255 ") with live children destroyed: ";
256 pTempWin = mpWindowImpl->mpFirstChild;
257 while ( pTempWin )
258 {
259 aTempStr.append(lcl_createWindowInfo(pTempWin));
260 pTempWin = pTempWin->mpWindowImpl->mpNext;
261 }
262 OSL_FAIL( aTempStr.getStr() );
263 Application::Abort(OStringToOUString(aTempStr, RTL_TEXTENCODING_UTF8));
264 }
265
266 if (mpWindowImpl->mpFrameData != nullptr)
267 {
268 pTempWin = mpWindowImpl->mpFrameData->mpFirstOverlap;
269 while ( pTempWin )
270 {
271 if ( ImplIsRealParentPath( pTempWin ) )
272 {
273 bError = true;
274 aErrorStr.append(lcl_createWindowInfo(pTempWin));
275 }
276 pTempWin = pTempWin->mpWindowImpl->mpNextOverlap;
277 }
278 if ( bError )
279 {
280 OString aTempStr =
281 "Window (" +
282 lcl_createWindowInfo(this) +
283 ") with live SystemWindows destroyed: " +
284 aErrorStr;
285 OSL_FAIL(aTempStr.getStr());
286 Application::Abort(OStringToOUString(aTempStr, RTL_TEXTENCODING_UTF8));
287 }
288 }
289
290 bError = false;
291 pTempWin = pSVData->maFrameData.mpFirstFrame;
292 while ( pTempWin )
293 {
294 if ( ImplIsRealParentPath( pTempWin ) )
295 {
296 bError = true;
297 aErrorStr.append(lcl_createWindowInfo(pTempWin));
298 }
299 pTempWin = pTempWin->mpWindowImpl->mpFrameData->mpNextFrame;
300 }
301 if ( bError )
302 {
303 OString aTempStr = "Window (" +
304 lcl_createWindowInfo(this) +
305 ") with live SystemWindows destroyed: " +
306 aErrorStr;
307 OSL_FAIL( aTempStr.getStr() );
308 Application::Abort(OStringToOUString(aTempStr, RTL_TEXTENCODING_UTF8));
309 }
310
311 if ( mpWindowImpl->mpFirstOverlap )
312 {
313 OStringBuffer aTempStr = "Window (" +
314 lcl_createWindowInfo(this) +
315 ") with live SystemWindows destroyed: ";
316 pTempWin = mpWindowImpl->mpFirstOverlap;
317 while ( pTempWin )
318 {
319 aTempStr.append(lcl_createWindowInfo(pTempWin));
320 pTempWin = pTempWin->mpWindowImpl->mpNext;
321 }
322 OSL_FAIL( aTempStr.getStr() );
323 Application::Abort(OStringToOUString(aTempStr, RTL_TEXTENCODING_UTF8));
324 }
325
326 vcl::Window* pMyParent = GetParent();
327 SystemWindow* pMySysWin = nullptr;
328
329 while ( pMyParent )
330 {
331 if ( pMyParent->IsSystemWindow() )
332 {
333 pMySysWin = dynamic_cast<SystemWindow *>(pMyParent);
334 }
335 pMyParent = pMyParent->GetParent();
336 }
337 if ( pMySysWin && pMySysWin->ImplIsInTaskPaneList( this ) )
338 {
339 OString aTempStr = "Window (" +
340 lcl_createWindowInfo(this) +
341 ") still in TaskPanelList!";
342 OSL_FAIL( aTempStr.getStr() );
343 Application::Abort(OStringToOUString(aTempStr, RTL_TEXTENCODING_UTF8));
344 }
345 }
346#endif
347
348 if( mpWindowImpl->mbIsInTaskPaneList )
349 {
350 vcl::Window* pMyParent = GetParent();
351 SystemWindow* pMySysWin = nullptr;
352
353 while ( pMyParent )
354 {
355 if ( pMyParent->IsSystemWindow() )
356 {
357 pMySysWin = dynamic_cast<SystemWindow *>(pMyParent);
358 }
359 pMyParent = pMyParent->GetParent();
360 }
361 if ( pMySysWin && pMySysWin->ImplIsInTaskPaneList( this ) )
362 {
363 pMySysWin->GetTaskPaneList()->RemoveWindow( this );
364 }
365 else
366 {
367 SAL_WARN( "vcl", "Window (" << GetText() << ") not found in TaskPanelList");
368 }
369 }
370
371 // remove from size-group if necessary
373
374 // clear mnemonic labels
375 std::vector<VclPtr<FixedText> > aMnemonicLabels(list_mnemonic_labels());
376 for (auto const& mnemonicLabel : aMnemonicLabels)
377 {
378 remove_mnemonic_label(mnemonicLabel);
379 }
380
381 // hide window in order to trigger the Paint-Handling
382 Hide();
383
384 // EndExtTextInputMode
385 if (pSVData->mpWinData->mpExtTextInputWin == this)
386 {
388 if (pSVData->mpWinData->mpExtTextInputWin == this)
389 pSVData->mpWinData->mpExtTextInputWin = nullptr;
390 }
391
392 // check if the focus window is our child
393 bool bHasFocusedChild = false;
395 {
396 // #122232#, this must not happen and is an application bug ! but we try some cleanup to hopefully avoid crashes, see below
397 bHasFocusedChild = true;
398#if OSL_DEBUG_LEVEL > 0
399 OUString aTempStr = "Window (" + GetText() +
400 ") with focused child window destroyed ! THIS WILL LEAD TO CRASHES AND MUST BE FIXED !";
401 SAL_WARN( "vcl", aTempStr );
402 Application::Abort(aTempStr);
403#endif
404 }
405
406 // if we get focus pass focus to another window
407 vcl::Window* pOverlapWindow = ImplGetFirstOverlapWindow();
408 if (pSVData->mpWinData->mpFocusWin == this
409 || bHasFocusedChild) // #122232#, see above, try some cleanup
410 {
411 if ( mpWindowImpl->mbFrame )
412 {
413 pSVData->mpWinData->mpFocusWin = nullptr;
414 pOverlapWindow->mpWindowImpl->mpLastFocusWindow = nullptr;
415 }
416 else
417 {
418 vcl::Window* pParent = GetParent();
419 vcl::Window* pBorderWindow = mpWindowImpl->mpBorderWindow;
420 // when windows overlap, give focus to the parent
421 // of the next FrameWindow
422 if ( pBorderWindow )
423 {
424 if ( pBorderWindow->ImplIsOverlapWindow() )
425 pParent = pBorderWindow->mpWindowImpl->mpOverlapWindow;
426 }
427 else if ( ImplIsOverlapWindow() )
428 pParent = mpWindowImpl->mpOverlapWindow;
429
430 if ( pParent && pParent->IsEnabled() && pParent->IsInputEnabled() && ! pParent->IsInModalMode() )
431 pParent->GrabFocus();
432 else
433 mpWindowImpl->mpFrameWindow->GrabFocus();
434
435 // If the focus was set back to 'this' set it to nothing
436 if (pSVData->mpWinData->mpFocusWin == this)
437 {
438 pSVData->mpWinData->mpFocusWin = nullptr;
439 pOverlapWindow->mpWindowImpl->mpLastFocusWindow = nullptr;
440 }
441 }
442 }
443
444 if ( pOverlapWindow != nullptr &&
445 pOverlapWindow->mpWindowImpl->mpLastFocusWindow == this )
446 pOverlapWindow->mpWindowImpl->mpLastFocusWindow = nullptr;
447
448 // reset hint for DefModalDialogParent
449 if( pSVData->maFrameData.mpActiveApplicationFrame == this )
450 pSVData->maFrameData.mpActiveApplicationFrame = nullptr;
451
452 // reset hint of what was the last wheeled window
453 if (pSVData->mpWinData->mpLastWheelWindow == this)
454 pSVData->mpWinData->mpLastWheelWindow = nullptr;
455
456 // reset marked windows
457 if ( mpWindowImpl->mpFrameData != nullptr )
458 {
459 if ( mpWindowImpl->mpFrameData->mpFocusWin == this )
460 mpWindowImpl->mpFrameData->mpFocusWin = nullptr;
461 if ( mpWindowImpl->mpFrameData->mpMouseMoveWin == this )
462 mpWindowImpl->mpFrameData->mpMouseMoveWin = nullptr;
463 if ( mpWindowImpl->mpFrameData->mpMouseDownWin == this )
464 mpWindowImpl->mpFrameData->mpMouseDownWin = nullptr;
465 }
466
467 // reset Deactivate-Window
468 if (pSVData->mpWinData->mpLastDeacWin == this)
469 pSVData->mpWinData->mpLastDeacWin = nullptr;
470
471 if ( mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData )
472 {
473 if ( mpWindowImpl->mpFrameData->mnFocusId )
474 Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnFocusId );
475 mpWindowImpl->mpFrameData->mnFocusId = nullptr;
476 if ( mpWindowImpl->mpFrameData->mnMouseMoveId )
477 Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnMouseMoveId );
478 mpWindowImpl->mpFrameData->mnMouseMoveId = nullptr;
479 }
480
481 // release SalGraphics
483 pOutDev->ReleaseGraphics();
484
485 // remove window from the lists
486 ImplRemoveWindow( true );
487
488 // de-register as "top window child" at our parent, if necessary
489 if ( mpWindowImpl->mbFrame )
490 {
491 bool bIsTopWindow
492 = mpWindowImpl->mpWinData && (mpWindowImpl->mpWinData->mnIsTopWindow == 1);
493 if ( mpWindowImpl->mpRealParent && bIsTopWindow )
494 {
495 ImplWinData* pParentWinData = mpWindowImpl->mpRealParent->ImplGetWinData();
496
497 auto myPos = ::std::find( pParentWinData->maTopWindowChildren.begin(),
498 pParentWinData->maTopWindowChildren.end(), VclPtr<vcl::Window>(this) );
499 SAL_WARN_IF( myPos == pParentWinData->maTopWindowChildren.end(), "vcl.window", "Window::~Window: inconsistency in top window chain!" );
500 if ( myPos != pParentWinData->maTopWindowChildren.end() )
501 pParentWinData->maTopWindowChildren.erase( myPos );
502 }
503 }
504
505 mpWindowImpl->mpWinData.reset();
506
507 // remove BorderWindow or Frame window data
508 mpWindowImpl->mpBorderWindow.disposeAndClear();
509 if ( mpWindowImpl->mbFrame )
510 {
511 if ( pSVData->maFrameData.mpFirstFrame == this )
512 pSVData->maFrameData.mpFirstFrame = mpWindowImpl->mpFrameData->mpNextFrame;
513 else
514 {
515 sal_Int32 nWindows = 0;
516 vcl::Window* pSysWin = pSVData->maFrameData.mpFirstFrame;
517 while ( pSysWin && pSysWin->mpWindowImpl->mpFrameData->mpNextFrame.get() != this )
518 {
519 pSysWin = pSysWin->mpWindowImpl->mpFrameData->mpNextFrame;
520 nWindows++;
521 }
522
523 if ( pSysWin )
524 {
525 assert (mpWindowImpl->mpFrameData->mpNextFrame.get() != pSysWin);
526 pSysWin->mpWindowImpl->mpFrameData->mpNextFrame = mpWindowImpl->mpFrameData->mpNextFrame;
527 }
528 else // if it is not in the list, we can't remove it.
529 SAL_WARN("vcl.window", "Window " << this << " marked as frame window, "
530 "is missing from list of " << nWindows << " frames");
531 }
532 if (mpWindowImpl->mpFrame) // otherwise exception during init
533 {
534 mpWindowImpl->mpFrame->SetCallback( nullptr, nullptr );
535 pSVData->mpDefInst->DestroyFrame( mpWindowImpl->mpFrame );
536 }
537 assert (mpWindowImpl->mpFrameData->mnFocusId == nullptr);
538 assert (mpWindowImpl->mpFrameData->mnMouseMoveId == nullptr);
539
540 mpWindowImpl->mpFrameData->mpBuffer.disposeAndClear();
541 delete mpWindowImpl->mpFrameData;
542 mpWindowImpl->mpFrameData = nullptr;
543 }
544
545 if (mpWindowImpl->mxWindowPeer)
546 mpWindowImpl->mxWindowPeer->dispose();
547
548 // should be the last statements
549 mpWindowImpl.reset();
550
551 pOutDev.disposeAndClear();
552 // just to make loplugin:vclwidgets happy
554}
555
557{
558 disposeOnce();
559}
560
561// We will eventually being removing the inheritance of OutputDevice
562// from Window. It will be replaced with a transient relationship such
563// that the OutputDevice is only live for the scope of the Paint method.
564// In the meantime this can help move us towards a Window use an
565// OutputDevice, not being one.
566
568{
569 return mpWindowImpl->mxOutDev.get();
570}
571
573{
574 return mpWindowImpl->mxOutDev.get();
575}
576
578{
580}
581
583{
585}
586
587} /* namespace vcl */
588
590{
592 maZoom = Fraction( 1, 1 );
593 mfPartialScrollX = 0.0;
594 mfPartialScrollY = 0.0;
595 maWinRegion = vcl::Region(true);
597 mpWinData = nullptr; // Extra Window Data, that we don't need for all windows
598 mpFrameData = nullptr; // Frame Data
599 mpFrame = nullptr; // Pointer to frame window
600 mpSysObj = nullptr;
601 mpFrameWindow = nullptr; // window to top level parent (same as frame window)
602 mpOverlapWindow = nullptr; // first overlap parent
603 mpBorderWindow = nullptr; // Border-Window
604 mpClientWindow = nullptr; // Client-Window of a FrameWindow
605 mpParent = nullptr; // parent (incl. BorderWindow)
606 mpRealParent = nullptr; // real parent (excl. BorderWindow)
607 mpFirstChild = nullptr; // first child window
608 mpLastChild = nullptr; // last child window
609 mpFirstOverlap = nullptr; // first overlap window (only set in overlap windows)
610 mpLastOverlap = nullptr; // last overlap window (only set in overlap windows)
611 mpPrev = nullptr; // prev window
612 mpNext = nullptr; // next window
613 mpNextOverlap = nullptr; // next overlap window of frame
614 mpLastFocusWindow = nullptr; // window for focus restore
615 mpDlgCtrlDownWindow = nullptr; // window for dialog control
618 mpCursor = nullptr; // cursor
620 mpVCLXWindow = nullptr;
621 mpAccessibleInfos = nullptr;
622 maControlForeground = COL_TRANSPARENT; // no foreground set
623 maControlBackground = COL_TRANSPARENT; // no background set
624 mnLeftBorder = 0; // left border
625 mnTopBorder = 0; // top border
626 mnRightBorder = 0; // right border
627 mnBottomBorder = 0; // bottom border
628 mnWidthRequest = -1; // width request
629 mnHeightRequest = -1; // height request
630 mnOptimalWidthCache = -1; // optimal width cache
631 mnOptimalHeightCache = -1; // optimal height cache
632 mnX = 0; // X-Position to Parent
633 mnY = 0; // Y-Position to Parent
634 mnAbsScreenX = 0; // absolute X-position on screen, used for RTL window positioning
635 mpChildClipRegion = nullptr; // Child-Clip-Region when ClipChildren
636 mpPaintRegion = nullptr; // Paint-ClipRegion
637 mnStyle = 0; // style (init in ImplInitWindow)
638 mnPrevStyle = 0; // prevstyle (set in SetStyle)
639 mnExtendedStyle = WindowExtendedStyle::NONE; // extended style (init in ImplInitWindow)
640 mnType = nType; // type
641 mnGetFocusFlags = GetFocusFlags::NONE; // Flags for GetFocus()-Call
642 mnWaitCount = 0; // Wait-Count (>1 == "wait" mouse pointer)
643 mnPaintFlags = ImplPaintFlags::NONE; // Flags for ImplCallPaint
644 mnParentClipMode = ParentClipMode::NONE; // Flags for Parent-ClipChildren-Mode
645 mnActivateMode = ActivateModeFlags::NONE; // Will be converted in System/Overlap-Windows
646 mnDlgCtrlFlags = DialogControlFlags::NONE; // DialogControl-Flags
647 meAlwaysInputMode = AlwaysInputNone; // AlwaysEnableInput not called
651 mnPadding = 0;
652 mnGridHeight = 1;
653 mnGridLeftAttach = -1;
654 mnGridTopAttach = -1;
655 mnGridWidth = 1;
656 mnBorderWidth = 0;
657 mnMarginLeft = 0;
658 mnMarginRight = 0;
659 mnMarginTop = 0;
660 mnMarginBottom = 0;
661 mbFrame = false; // true: Window is a frame window
662 mbBorderWin = false; // true: Window is a border window
663 mbOverlapWin = false; // true: Window is an overlap window
664 mbSysWin = false; // true: SystemWindow is the base class
665 mbDialog = false; // true: Dialog is the base class
666 mbDockWin = false; // true: DockingWindow is the base class
667 mbFloatWin = false; // true: FloatingWindow is the base class
668 mbPushButton = false; // true: PushButton is the base class
669 mbToolBox = false; // true: ToolBox is the base class
670 mbMenuFloatingWindow = false; // true: MenuFloatingWindow is the base class
671 mbToolbarFloatingWindow = false; // true: ImplPopupFloatWin is the base class, used for subtoolbars
672 mbSplitter = false; // true: Splitter is the base class
673 mbVisible = false; // true: Show( true ) called
674 mbOverlapVisible = false; // true: Hide called for visible window from ImplHideAllOverlapWindow()
675 mbDisabled = false; // true: Enable( false ) called
676 mbInputDisabled = false; // true: EnableInput( false ) called
677 mbNoUpdate = false; // true: SetUpdateMode( false ) called
678 mbNoParentUpdate = false; // true: SetParentUpdateMode( false ) called
679 mbActive = false; // true: Window Active
680 mbReallyVisible = false; // true: this and all parents to an overlapped window are visible
681 mbReallyShown = false; // true: this and all parents to an overlapped window are shown
682 mbInInitShow = false; // true: we are in InitShow
683 mbChildPtrOverwrite = false; // true: PointerStyle overwrites Child-Pointer
684 mbNoPtrVisible = false; // true: ShowPointer( false ) called
685 mbPaintFrame = false; // true: Paint is visible, but not painted
686 mbInPaint = false; // true: Inside PaintHdl
687 mbMouseButtonDown = false; // true: BaseMouseButtonDown called
688 mbMouseButtonUp = false; // true: BaseMouseButtonUp called
689 mbKeyInput = false; // true: BaseKeyInput called
690 mbKeyUp = false; // true: BaseKeyUp called
691 mbCommand = false; // true: BaseCommand called
692 mbDefPos = true; // true: Position is not Set
693 mbDefSize = true; // true: Size is not Set
694 mbCallMove = true; // true: Move must be called by Show
695 mbCallResize = true; // true: Resize must be called by Show
696 mbWaitSystemResize = true; // true: Wait for System-Resize
697 mbInitWinClipRegion = true; // true: Calc Window Clip Region
698 mbInitChildRegion = false; // true: InitChildClipRegion
699 mbWinRegion = false; // true: Window Region
700 mbClipChildren = false; // true: Child-window should be clipped
701 mbClipSiblings = false; // true: Adjacent Child-window should be clipped
702 mbChildTransparent = false; // true: Child-windows are allowed to switch to transparent (incl. Parent-CLIPCHILDREN)
703 mbPaintTransparent = false; // true: Paints should be executed on the Parent
704 mbMouseTransparent = false; // true: Window is transparent for Mouse
705 mbDlgCtrlStart = false; // true: From here on own Dialog-Control
706 mbFocusVisible = false; // true: Focus Visible
707 mbUseNativeFocus = false;
708 mbNativeFocusVisible = false; // true: native Focus Visible
709 mbInShowFocus = false; // prevent recursion
710 mbInHideFocus = false; // prevent recursion
711 mbTrackVisible = false; // true: Tracking Visible
712 mbControlForeground = false; // true: Foreground-Property set
713 mbControlBackground = false; // true: Background-Property set
714 mbAlwaysOnTop = false; // true: always visible for all others windows
715 mbCompoundControl = false; // true: Composite Control => Listener...
716 mbCompoundControlHasFocus = false; // true: Composite Control has focus somewhere
717 mbPaintDisabled = false; // true: Paint should not be executed
718 mbAllResize = false; // true: Also sent ResizeEvents with 0,0
719 mbInDispose = false; // true: We're still in Window::dispose()
720 mbExtTextInput = false; // true: ExtTextInput-Mode is active
721 mbInFocusHdl = false; // true: Within GetFocus-Handler
722 mbCreatedWithToolkit = false;
723 mbSuppressAccessibilityEvents = false; // true: do not send any accessibility events
724 mbDrawSelectionBackground = false; // true: draws transparent window background to indicate (toolbox) selection
725 mbIsInTaskPaneList = false; // true: window was added to the taskpanelist in the topmost system window
726 mnNativeBackground = ControlPart::NONE; // initialize later, depends on type
727 mbHelpTextDynamic = false; // true: append help id in HELP_DEBUG case
728 mbFakeFocusSet = false; // true: pretend as if the window has focus.
729 mbHexpand = false;
730 mbVexpand = false;
731 mbExpand = false;
732 mbFill = true;
733 mbSecondary = false;
734 mbNonHomogeneous = false;
735 static bool bDoubleBuffer = getenv("VCL_DOUBLEBUFFERING_FORCE_ENABLE");
736 mbDoubleBufferingRequested = bDoubleBuffer; // when we are not sure, assume it cannot do double-buffering via RenderContext
737 mpLOKNotifier = nullptr;
738 mnLOKWindowId = 0;
739 mbLOKParentNotifier = false;
740 mbUseFrameData = false;
741}
742
744{
745 mpChildClipRegion.reset();
746 mpAccessibleInfos.reset();
747}
748
750 mnCursorExtWidth(0),
751 mbVertical(false),
752 mnCompositionCharRects(0),
753 mnTrackFlags(ShowTrackFlags::NONE),
754 mnIsTopWindow(sal_uInt16(~0)), // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow())
755 mbMouseOver(false),
756 mbEnableNativeWidget(false)
757{
758}
759
761{
763}
764
766 : maPaintIdle( "vcl::Window maPaintIdle" ),
767 maResizeIdle( "vcl::Window maResizeIdle" )
768{
769 ImplSVData* pSVData = ImplGetSVData();
770 assert (pSVData->maFrameData.mpFirstFrame.get() != pWindow);
772 pSVData->maFrameData.mpFirstFrame = pWindow;
773 mpFirstOverlap = nullptr;
774 mpFocusWin = nullptr;
775 mpMouseMoveWin = nullptr;
776 mpMouseDownWin = nullptr;
777 mpTrackWin = nullptr;
780 mnFocusId = nullptr;
781 mnMouseMoveId = nullptr;
782 mnLastMouseX = -1;
783 mnLastMouseY = -1;
786 mnFirstMouseX = -1;
787 mnFirstMouseY = -1;
788 mnLastMouseWinX = -1;
789 mnLastMouseWinY = -1;
790 mnModalMode = 0;
791 mnMouseDownTime = 0;
792 mnClickCount = 0;
794 mnMouseCode = 0;
796 mbHasFocus = false;
797 mbInMouseMove = false;
798 mbMouseIn = false;
799 mbStartDragCalled = false;
800 mbNeedSysWindow = false;
801 mbMinimized = false;
802 mbStartFocusState = false;
803 mbInSysObjFocusHdl = false;
804 mbInSysObjToTopHdl = false;
805 mbSysObjFocus = false;
807 maPaintIdle.SetInvokeHandler( LINK( pWindow, vcl::Window, ImplHandlePaintHdl ) );
809 maResizeIdle.SetInvokeHandler( LINK( pWindow, vcl::Window, ImplHandleResizeTimerHdl ) );
811 mbDragging = false;
812 mbInBufferedPaint = false;
813 mnDPIX = 96;
814 mnDPIY = 96;
816}
817
818namespace vcl {
819
821{
823
824 if (isDisposed())
825 return false;
826
827 if (mpGraphics)
828 return true;
829
830 mbInitLineColor = true;
831 mbInitFillColor = true;
832 mbInitFont = true;
833 mbInitTextColor = true;
834 mbInitClipRegion = true;
835
836 ImplSVData* pSVData = ImplGetSVData();
837
838 mpGraphics = mxOwnerWindow->mpWindowImpl->mpFrame->AcquireGraphics();
839 // try harder if no wingraphics was available directly
840 if ( !mpGraphics )
841 {
842 // find another output device in the same frame
843 vcl::WindowOutputDevice* pReleaseOutDev = pSVData->maGDIData.mpLastWinGraphics.get();
844 while ( pReleaseOutDev )
845 {
846 if ( pReleaseOutDev->mxOwnerWindow && pReleaseOutDev->mxOwnerWindow->mpWindowImpl->mpFrame == mxOwnerWindow->mpWindowImpl->mpFrame )
847 break;
848 pReleaseOutDev = static_cast<vcl::WindowOutputDevice*>(pReleaseOutDev->mpPrevGraphics.get());
849 }
850
851 if ( pReleaseOutDev )
852 {
853 // steal the wingraphics from the other outdev
854 mpGraphics = pReleaseOutDev->mpGraphics;
855 pReleaseOutDev->ReleaseGraphics( false );
856 }
857 else
858 {
859 // if needed retry after releasing least recently used wingraphics
860 while ( !mpGraphics )
861 {
862 if ( !pSVData->maGDIData.mpLastWinGraphics )
863 break;
865 mpGraphics = mxOwnerWindow->mpWindowImpl->mpFrame->AcquireGraphics();
866 }
867 }
868 }
869
870 if ( mpGraphics )
871 {
872 // update global LRU list of wingraphics
874 pSVData->maGDIData.mpFirstWinGraphics = const_cast<vcl::WindowOutputDevice*>(this);
875 if ( mpNextGraphics )
877 if ( !pSVData->maGDIData.mpLastWinGraphics )
878 pSVData->maGDIData.mpLastWinGraphics = const_cast<vcl::WindowOutputDevice*>(this);
879
882 }
883
884 return mpGraphics != nullptr;
885}
886
888{
890
891 if ( !mpGraphics )
892 return;
893
894 // release the fonts of the physically released graphics device
895 if( bRelease )
897
898 ImplSVData* pSVData = ImplGetSVData();
899
900 vcl::Window* pWindow = mxOwnerWindow.get();
901 if (!pWindow)
902 return;
903
904 if ( bRelease )
905 pWindow->mpWindowImpl->mpFrame->ReleaseGraphics( mpGraphics );
906 // remove from global LRU list of window graphics
907 if ( mpPrevGraphics )
909 else
911 if ( mpNextGraphics )
913 else
915
916 mpGraphics = nullptr;
917 mpPrevGraphics = nullptr;
918 mpNextGraphics = nullptr;
919}
920
921static sal_Int32 CountDPIScaleFactor(sal_Int32 nDPI)
922{
923#ifndef MACOSX
924 // Setting of HiDPI is unfortunately all only a heuristic; and to add
925 // insult to an injury, the system is constantly lying to us about
926 // the DPI and whatnot
927 // eg. fdo#77059 - set the value from which we do consider the
928 // screen HiDPI to greater than 168
929 if (nDPI > 216) // 96 * 2 + 96 / 4
930 return 250;
931 else if (nDPI > 168) // 96 * 2 - 96 / 4
932 return 200;
933 else if (nDPI > 120) // 96 * 1.5 - 96 / 4
934 return 150;
935#else
936 (void)nDPI;
937#endif
938
939 return 100;
940}
941
942void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData )
943{
944 SAL_WARN_IF( !mpWindowImpl->mbFrame && !pParent && GetType() != WindowType::FIXEDIMAGE, "vcl.window",
945 "Window::Window(): pParent == NULL" );
946
947 ImplSVData* pSVData = ImplGetSVData();
948 vcl::Window* pRealParent = pParent;
949
950 // inherit 3D look
951 if ( !mpWindowImpl->mbOverlapWin && pParent && (pParent->GetStyle() & WB_3DLOOK) )
952 nStyle |= WB_3DLOOK;
953
954 // create border window if necessary
955 if ( !mpWindowImpl->mbFrame && !mpWindowImpl->mbBorderWin && !mpWindowImpl->mpBorderWindow
956 && (nStyle & (WB_BORDER | WB_SYSTEMCHILDWINDOW) ) )
957 {
959 if( nStyle & WB_SYSTEMCHILDWINDOW )
960 {
961 // handle WB_SYSTEMCHILDWINDOW
962 // these should be analogous to a top level frame; meaning they
963 // should have a border window with style BorderWindowStyle::Frame
964 // which controls their size
965 nBorderTypeStyle |= BorderWindowStyle::Frame;
966 nStyle |= WB_BORDER;
967 }
968 VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, nStyle & (WB_BORDER | WB_DIALOGCONTROL | WB_NODIALOGCONTROL), nBorderTypeStyle );
969 static_cast<vcl::Window*>(pBorderWin)->mpWindowImpl->mpClientWindow = this;
970 pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
971 mpWindowImpl->mpBorderWindow = pBorderWin;
972 pParent = mpWindowImpl->mpBorderWindow;
973 }
974 else if( !mpWindowImpl->mbFrame && ! pParent )
975 {
976 mpWindowImpl->mbOverlapWin = true;
977 mpWindowImpl->mbFrame = true;
978 }
979
980 // insert window in list
981 ImplInsertWindow( pParent );
982 mpWindowImpl->mnStyle = nStyle;
983
984 if( pParent && ! mpWindowImpl->mbFrame )
985 mpWindowImpl->mxOutDev->mbEnableRTL = AllSettings::GetLayoutRTL();
986
987 // test for frame creation
988 if ( mpWindowImpl->mbFrame )
989 {
990 // create frame
992
993 if ( nStyle & WB_MOVEABLE )
994 nFrameStyle |= SalFrameStyleFlags::MOVEABLE;
995 if ( nStyle & WB_SIZEABLE )
996 nFrameStyle |= SalFrameStyleFlags::SIZEABLE;
997 if ( nStyle & WB_CLOSEABLE )
998 nFrameStyle |= SalFrameStyleFlags::CLOSEABLE;
999 if ( nStyle & WB_APP )
1000 nFrameStyle |= SalFrameStyleFlags::DEFAULT;
1001 // check for undecorated floating window
1002 if( // 1. floating windows that are not moveable/sizeable (only closeable allowed)
1003 ( !(nFrameStyle & ~SalFrameStyleFlags::CLOSEABLE) &&
1004 ( mpWindowImpl->mbFloatWin || ((GetType() == WindowType::BORDERWINDOW) && static_cast<ImplBorderWindow*>(this)->mbFloatWindow) || (nStyle & WB_SYSTEMFLOATWIN) ) ) ||
1005 // 2. borderwindows of floaters with ownerdraw decoration
1006 ((GetType() == WindowType::BORDERWINDOW) && static_cast<ImplBorderWindow*>(this)->mbFloatWindow && (nStyle & WB_OWNERDRAWDECORATION) ) )
1007 {
1008 nFrameStyle = SalFrameStyleFlags::FLOAT;
1009 if( nStyle & WB_OWNERDRAWDECORATION )
1011 }
1012 else if( mpWindowImpl->mbFloatWin )
1013 nFrameStyle |= SalFrameStyleFlags::TOOLWINDOW;
1014
1015 if( nStyle & WB_INTROWIN )
1016 nFrameStyle |= SalFrameStyleFlags::INTRO;
1017 if( nStyle & WB_TOOLTIPWIN )
1018 nFrameStyle |= SalFrameStyleFlags::TOOLTIP;
1019
1020 if( nStyle & WB_NOSHADOW )
1021 nFrameStyle |= SalFrameStyleFlags::NOSHADOW;
1022
1023 if( nStyle & WB_SYSTEMCHILDWINDOW )
1024 nFrameStyle |= SalFrameStyleFlags::SYSTEMCHILD;
1025
1026 switch (mpWindowImpl->mnType)
1027 {
1028 case WindowType::DIALOG:
1036 nFrameStyle |= SalFrameStyleFlags::DIALOG;
1037 break;
1038 default:
1039 break;
1040 }
1041
1042 // tdf#144624 for the DefaultWindow, which is never visible, don't
1043 // create an icon for it so construction of a DefaultWindow cannot
1044 // trigger creation of a VirtualDevice which itself requires a
1045 // DefaultWindow to exist
1046 if( nStyle & WB_DEFAULTWIN )
1047 nFrameStyle |= SalFrameStyleFlags::NOICON;
1048
1049 SalFrame* pParentFrame = nullptr;
1050 if ( pParent )
1051 pParentFrame = pParent->mpWindowImpl->mpFrame;
1052 SalFrame* pFrame;
1053 if ( pSystemParentData )
1054 pFrame = pSVData->mpDefInst->CreateChildFrame( pSystemParentData, nFrameStyle | SalFrameStyleFlags::PLUG );
1055 else
1056 pFrame = pSVData->mpDefInst->CreateFrame( pParentFrame, nFrameStyle );
1057 if ( !pFrame )
1058 {
1059 // do not abort but throw an exception, may be the current thread terminates anyway (plugin-scenario)
1060 throw RuntimeException(
1061 "Could not create system window!",
1062 Reference< XInterface >() );
1063 }
1064
1065 pFrame->SetCallback( this, ImplWindowFrameProc );
1066
1067 // set window frame data
1068 mpWindowImpl->mpFrameData = new ImplFrameData( this );
1069 mpWindowImpl->mpFrame = pFrame;
1070 mpWindowImpl->mpFrameWindow = this;
1071 mpWindowImpl->mpOverlapWindow = this;
1072
1073 if (!(nStyle & WB_DEFAULTWIN) && mpWindowImpl->mbDoubleBufferingRequested)
1075
1076 if ( pRealParent && IsTopWindow() )
1077 {
1078 ImplWinData* pParentWinData = pRealParent->ImplGetWinData();
1079 pParentWinData->maTopWindowChildren.emplace_back(this );
1080 }
1081 }
1082
1083 // init data
1084 mpWindowImpl->mpRealParent = pRealParent;
1085
1086 // #99318: make sure fontcache and list is available before call to SetSettings
1087 mpWindowImpl->mxOutDev->mxFontCollection = mpWindowImpl->mpFrameData->mxFontCollection;
1088 mpWindowImpl->mxOutDev->mxFontCache = mpWindowImpl->mpFrameData->mxFontCache;
1089
1090 if ( mpWindowImpl->mbFrame )
1091 {
1092 if ( pParent )
1093 {
1094 mpWindowImpl->mpFrameData->mnDPIX = pParent->mpWindowImpl->mpFrameData->mnDPIX;
1095 mpWindowImpl->mpFrameData->mnDPIY = pParent->mpWindowImpl->mpFrameData->mnDPIY;
1096 }
1097 else
1098 {
1099 OutputDevice *pOutDev = GetOutDev();
1100 if ( pOutDev->AcquireGraphics() )
1101 {
1102 mpWindowImpl->mxOutDev->mpGraphics->GetResolution( mpWindowImpl->mpFrameData->mnDPIX, mpWindowImpl->mpFrameData->mnDPIY );
1103 }
1104 }
1105
1106 // add ownerdraw decorated frame windows to list in the top-most frame window
1107 // so they can be hidden on lose focus
1108 if( nStyle & WB_OWNERDRAWDECORATION )
1109 ImplGetOwnerDrawList().emplace_back(this );
1110
1111 // delay settings initialization until first "real" frame
1112 // this relies on the IntroWindow not needing any system settings
1113 if ( !pSVData->maAppData.mbSettingsInit &&
1114 ! (nStyle & (WB_INTROWIN|WB_DEFAULTWIN))
1115 )
1116 {
1117 // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings
1119 mpWindowImpl->mxOutDev->SetSettings( *pSVData->maAppData.mxSettings );
1120 pSVData->maAppData.mbSettingsInit = true;
1121 }
1122
1123 // If we create a Window with default size, query this
1124 // size directly, because we want resize all Controls to
1125 // the correct size before we display the window
1126 if ( nStyle & (WB_MOVEABLE | WB_SIZEABLE | WB_APP) )
1127 mpWindowImpl->mpFrame->GetClientSize( mpWindowImpl->mxOutDev->mnOutWidth, mpWindowImpl->mxOutDev->mnOutHeight );
1128 }
1129 else
1130 {
1131 if ( pParent )
1132 {
1133 if ( !ImplIsOverlapWindow() )
1134 {
1135 mpWindowImpl->mbDisabled = pParent->mpWindowImpl->mbDisabled;
1136 mpWindowImpl->mbInputDisabled = pParent->mpWindowImpl->mbInputDisabled;
1137 mpWindowImpl->meAlwaysInputMode = pParent->mpWindowImpl->meAlwaysInputMode;
1138 }
1139
1141 {
1142 // we don't want to call the WindowOutputDevice override of this because
1143 // it calls back into us.
1144 mpWindowImpl->mxOutDev->OutputDevice::SetSettings( pParent->GetSettings() );
1145 }
1146 }
1147
1148 }
1149
1150 // setup the scale factor for HiDPI displays
1151 mpWindowImpl->mxOutDev->mnDPIScalePercentage = CountDPIScaleFactor(mpWindowImpl->mpFrameData->mnDPIY);
1152 mpWindowImpl->mxOutDev->mnDPIX = mpWindowImpl->mpFrameData->mnDPIX;
1153 mpWindowImpl->mxOutDev->mnDPIY = mpWindowImpl->mpFrameData->mnDPIY;
1154
1156 {
1157 const StyleSettings& rStyleSettings = mpWindowImpl->mxOutDev->moSettings->GetStyleSettings();
1158 mpWindowImpl->mxOutDev->maFont = rStyleSettings.GetAppFont();
1159
1160 if ( nStyle & WB_3DLOOK )
1161 {
1162 SetTextColor( rStyleSettings.GetButtonTextColor() );
1163 SetBackground( Wallpaper( rStyleSettings.GetFaceColor() ) );
1164 }
1165 else
1166 {
1167 SetTextColor( rStyleSettings.GetWindowTextColor() );
1168 SetBackground( Wallpaper( rStyleSettings.GetWindowColor() ) );
1169 }
1170 }
1171 else
1172 {
1173 mpWindowImpl->mxOutDev->maFont = OutputDevice::GetDefaultFont( DefaultFontType::FIXED, LANGUAGE_ENGLISH_US, GetDefaultFontFlags::NONE );
1174 }
1175
1176 ImplPointToLogic(*GetOutDev(), mpWindowImpl->mxOutDev->maFont);
1177
1178 (void)ImplUpdatePos();
1179
1180 // calculate app font res (except for the Intro Window or the default window)
1181 if ( mpWindowImpl->mbFrame && !pSVData->maGDIData.mnAppFontX && ! (nStyle & (WB_INTROWIN|WB_DEFAULTWIN)) )
1182 ImplInitAppFontData( this );
1183}
1184
1186{
1187 ImplSVData* pSVData = ImplGetSVData();
1188 tools::Long nTextHeight = pWindow->GetTextHeight();
1189 tools::Long nTextWidth = pWindow->approximate_char_width() * 8;
1190 tools::Long nSymHeight = nTextHeight*4;
1191 // Make the basis wider if the font is too narrow
1192 // such that the dialog looks symmetrical and does not become too narrow.
1193 // Add some extra space when the dialog has the same width,
1194 // as a little more space is better.
1195 if ( nSymHeight > nTextWidth )
1196 nTextWidth = nSymHeight;
1197 else if ( nSymHeight+5 > nTextWidth )
1198 nTextWidth = nSymHeight+5;
1199 pSVData->maGDIData.mnAppFontX = nTextWidth * 10 / 8;
1200 pSVData->maGDIData.mnAppFontY = nTextHeight * 10;
1201
1202#ifdef MACOSX
1203 // FIXME: this is currently only on macOS, check with other
1204 // platforms
1205 if( pSVData->maNWFData.mbNoFocusRects )
1206 {
1207 // try to find out whether there is a large correction
1208 // of control sizes, if yes, make app font scalings larger
1209 // so dialog positioning is not completely off
1210 ImplControlValue aControlValue;
1211 tools::Rectangle aCtrlRegion( Point(), Size( nTextWidth < 10 ? 10 : nTextWidth, nTextHeight < 10 ? 10 : nTextHeight ) );
1212 tools::Rectangle aBoundingRgn( aCtrlRegion );
1213 tools::Rectangle aContentRgn( aCtrlRegion );
1215 ControlState::ENABLED, aControlValue,
1216 aBoundingRgn, aContentRgn ) )
1217 {
1218 // comment: the magical +6 is for the extra border in bordered
1219 // (which is the standard) edit fields
1220 if( aContentRgn.GetHeight() - nTextHeight > (nTextHeight+4)/4 )
1221 pSVData->maGDIData.mnAppFontY = (aContentRgn.GetHeight()-4) * 10;
1222 }
1223 }
1224#endif
1225}
1226
1228{
1229 if (!mpWindowImpl->mpWinData)
1230 {
1231 static const char* pNoNWF = getenv( "SAL_NO_NWF" );
1232
1233 const_cast<vcl::Window*>(this)->mpWindowImpl->mpWinData.reset(new ImplWinData);
1234 mpWindowImpl->mpWinData->mbEnableNativeWidget = !(pNoNWF && *pNoNWF); // true: try to draw this control with native theme API
1235 }
1236
1237 return mpWindowImpl->mpWinData.get();
1238}
1239
1240
1241void WindowOutputDevice::CopyDeviceArea( SalTwoRect& aPosAry, bool bWindowInvalidate )
1242{
1243 if (aPosAry.mnSrcWidth == 0 || aPosAry.mnSrcHeight == 0 || aPosAry.mnDestWidth == 0 || aPosAry.mnDestHeight == 0)
1244 return;
1245
1246 if (bWindowInvalidate)
1247 {
1248 const tools::Rectangle aSrcRect(Point(aPosAry.mnSrcX, aPosAry.mnSrcY),
1249 Size(aPosAry.mnSrcWidth, aPosAry.mnSrcHeight));
1250
1252 aPosAry.mnDestX-aPosAry.mnSrcX,
1253 aPosAry.mnDestY-aPosAry.mnSrcY,
1254 false);
1255
1256 mpGraphics->CopyArea(aPosAry.mnDestX, aPosAry.mnDestY,
1257 aPosAry.mnSrcX, aPosAry.mnSrcY,
1258 aPosAry.mnSrcWidth, aPosAry.mnSrcHeight,
1259 *this);
1260
1261 return;
1262 }
1263
1264 OutputDevice::CopyDeviceArea(aPosAry, bWindowInvalidate);
1265}
1266
1268{
1269 const OutputDevice* pSrcDevChecked;
1270 if ( this == &rSrcDev )
1271 pSrcDevChecked = nullptr;
1272 else if (GetOutDevType() != rSrcDev.GetOutDevType())
1273 pSrcDevChecked = &rSrcDev;
1274 else if (mxOwnerWindow->mpWindowImpl->mpFrameWindow == static_cast<const vcl::WindowOutputDevice&>(rSrcDev).mxOwnerWindow->mpWindowImpl->mpFrameWindow)
1275 pSrcDevChecked = nullptr;
1276 else
1277 pSrcDevChecked = &rSrcDev;
1278
1279 return pSrcDevChecked;
1280}
1281
1283{
1284 if (pSrcGraphics)
1285 mpGraphics->CopyBits(rPosAry, *pSrcGraphics, *this, rSrcDev);
1286 else
1287 mpGraphics->CopyBits(rPosAry, *this);
1288}
1289
1291{
1292 if ( mpWindowImpl->mpFrameWindow->GetOutDev()->mpGraphics )
1293 {
1294 mpWindowImpl->mpFrameWindow->GetOutDev()->mbInitClipRegion = true;
1295 }
1296 else
1297 {
1298 OutputDevice* pFrameWinOutDev = mpWindowImpl->mpFrameWindow->GetOutDev();
1299 if ( ! pFrameWinOutDev->AcquireGraphics() )
1300 {
1301 return nullptr;
1302 }
1303 }
1304 mpWindowImpl->mpFrameWindow->GetOutDev()->mpGraphics->ResetClipRegion();
1305 return mpWindowImpl->mpFrameWindow->GetOutDev()->mpGraphics;
1306}
1307
1309{
1310 // #i43594# it is possible that INITSHOW was never send, because the visibility state changed between
1311 // ImplCallInitShow() and ImplSetReallyVisible() when called from Show()
1312 // mbReallyShown is a useful indicator
1313 if( !mpWindowImpl->mbReallyShown )
1315
1316 bool bBecameReallyVisible = !mpWindowImpl->mbReallyVisible;
1317
1318 GetOutDev()->mbDevOutput = true;
1319 mpWindowImpl->mbReallyVisible = true;
1320 mpWindowImpl->mbReallyShown = true;
1321
1322 // the SHOW/HIDE events serve as indicators to send child creation/destroy events to the access bridge.
1323 // For this, the data member of the event must not be NULL.
1324 // Previously, we did this in Window::Show, but there some events got lost in certain situations. Now
1325 // we're doing it when the visibility really changes
1326 if( bBecameReallyVisible && ImplIsAccessibleCandidate() )
1328 // TODO. It's kind of a hack that we're re-using the VclEventId::WindowShow. Normally, we should
1329 // introduce another event which explicitly triggers the Accessibility implementations.
1330
1331 vcl::Window* pWindow = mpWindowImpl->mpFirstOverlap;
1332 while ( pWindow )
1333 {
1334 if ( pWindow->mpWindowImpl->mbVisible )
1335 pWindow->ImplSetReallyVisible();
1336 pWindow = pWindow->mpWindowImpl->mpNext;
1337 }
1338
1339 pWindow = mpWindowImpl->mpFirstChild;
1340 while ( pWindow )
1341 {
1342 if ( pWindow->mpWindowImpl->mbVisible )
1343 pWindow->ImplSetReallyVisible();
1344 pWindow = pWindow->mpWindowImpl->mpNext;
1345 }
1346}
1347
1349{
1350 // recalculate AppFont-resolution and DPI-resolution
1351 if (mpWindowImpl->mbFrame)
1352 {
1353 GetOutDev()->mnDPIX = mpWindowImpl->mpFrameData->mnDPIX;
1354 GetOutDev()->mnDPIY = mpWindowImpl->mpFrameData->mnDPIY;
1355
1356 // setup the scale factor for HiDPI displays
1358 const StyleSettings& rStyleSettings = GetOutDev()->moSettings->GetStyleSettings();
1359 SetPointFont(*GetOutDev(), rStyleSettings.GetAppFont());
1360 }
1361 else if ( mpWindowImpl->mpParent )
1362 {
1363 GetOutDev()->mnDPIX = mpWindowImpl->mpParent->GetOutDev()->mnDPIX;
1364 GetOutDev()->mnDPIY = mpWindowImpl->mpParent->GetOutDev()->mnDPIY;
1365 GetOutDev()->mnDPIScalePercentage = mpWindowImpl->mpParent->GetOutDev()->mnDPIScalePercentage;
1366 }
1367
1368 // update the recalculated values for logical units
1369 // and also tools belonging to the values
1370 if (IsMapModeEnabled())
1371 {
1372 MapMode aMapMode = GetMapMode();
1373 SetMapMode();
1374 SetMapMode( aMapMode );
1375 }
1376}
1377
1378void Window::ImplPointToLogic(vcl::RenderContext const & rRenderContext, vcl::Font& rFont) const
1379{
1380 Size aSize = rFont.GetFontSize();
1381
1382 if (aSize.Width())
1383 {
1384 aSize.setWidth( aSize.Width() * ( mpWindowImpl->mpFrameData->mnDPIX) );
1385 aSize.AdjustWidth(72 / 2 );
1386 aSize.setWidth( aSize.Width() / 72 );
1387 }
1388 aSize.setHeight( aSize.Height() * ( mpWindowImpl->mpFrameData->mnDPIY) );
1389 aSize.AdjustHeight(72/2 );
1390 aSize.setHeight( aSize.Height() / 72 );
1391
1392 if (rRenderContext.IsMapModeEnabled())
1393 aSize = rRenderContext.PixelToLogic(aSize);
1394
1395 rFont.SetFontSize(aSize);
1396}
1397
1398void Window::ImplLogicToPoint(vcl::RenderContext const & rRenderContext, vcl::Font& rFont) const
1399{
1400 Size aSize = rFont.GetFontSize();
1401
1402 if (rRenderContext.IsMapModeEnabled())
1403 aSize = rRenderContext.LogicToPixel(aSize);
1404
1405 if (aSize.Width())
1406 {
1407 aSize.setWidth( aSize.Width() * 72 );
1408 aSize.AdjustWidth(mpWindowImpl->mpFrameData->mnDPIX / 2 );
1409 aSize.setWidth( aSize.Width() / ( mpWindowImpl->mpFrameData->mnDPIX) );
1410 }
1411 aSize.setHeight( aSize.Height() * 72 );
1412 aSize.AdjustHeight(mpWindowImpl->mpFrameData->mnDPIY / 2 );
1413 aSize.setHeight( aSize.Height() / ( mpWindowImpl->mpFrameData->mnDPIY) );
1414
1415 rFont.SetFontSize(aSize);
1416}
1417
1419{
1420 bool bSysChild = false;
1421
1422 if ( ImplIsOverlapWindow() )
1423 {
1426 }
1427 else
1428 {
1429 vcl::Window* pParent = ImplGetParent();
1430
1431 GetOutDev()->mnOutOffX = mpWindowImpl->mnX + pParent->GetOutDev()->mnOutOffX;
1432 GetOutDev()->mnOutOffY = mpWindowImpl->mnY + pParent->GetOutDev()->mnOutOffY;
1433 }
1434
1435 VclPtr< vcl::Window > pChild = mpWindowImpl->mpFirstChild;
1436 while ( pChild )
1437 {
1438 if ( pChild->ImplUpdatePos() )
1439 bSysChild = true;
1440 pChild = pChild->mpWindowImpl->mpNext;
1441 }
1442
1443 if ( mpWindowImpl->mpSysObj )
1444 bSysChild = true;
1445
1446 return bSysChild;
1447}
1448
1450{
1451 if ( mpWindowImpl->mpSysObj )
1452 mpWindowImpl->mpSysObj->SetPosSize( GetOutDev()->mnOutOffX, GetOutDev()->mnOutOffY, GetOutDev()->mnOutWidth, GetOutDev()->mnOutHeight );
1453
1454 VclPtr< vcl::Window > pChild = mpWindowImpl->mpFirstChild;
1455 while ( pChild )
1456 {
1457 pChild->ImplUpdateSysObjPos();
1458 pChild = pChild->mpWindowImpl->mpNext;
1459 }
1460}
1461
1463 tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags )
1464{
1465 bool bNewPos = false;
1466 bool bNewSize = false;
1467 bool bCopyBits = false;
1468 tools::Long nOldOutOffX = GetOutDev()->mnOutOffX;
1469 tools::Long nOldOutOffY = GetOutDev()->mnOutOffY;
1470 tools::Long nOldOutWidth = GetOutDev()->mnOutWidth;
1471 tools::Long nOldOutHeight = GetOutDev()->mnOutHeight;
1472 std::unique_ptr<vcl::Region> pOverlapRegion;
1473 std::unique_ptr<vcl::Region> pOldRegion;
1474
1475 if ( IsReallyVisible() )
1476 {
1477 tools::Rectangle aOldWinRect( Point( nOldOutOffX, nOldOutOffY ),
1478 Size( nOldOutWidth, nOldOutHeight ) );
1479 pOldRegion.reset( new vcl::Region( aOldWinRect ) );
1480 if ( mpWindowImpl->mbWinRegion )
1481 pOldRegion->Intersect( GetOutDev()->ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
1482
1483 if ( GetOutDev()->mnOutWidth && GetOutDev()->mnOutHeight && !mpWindowImpl->mbPaintTransparent &&
1484 !mpWindowImpl->mbInitWinClipRegion && !mpWindowImpl->maWinClipRegion.IsEmpty() &&
1485 !HasPaintEvent() )
1486 bCopyBits = true;
1487 }
1488
1489 bool bnXRecycled = false; // avoid duplicate mirroring in RTL case
1490 if ( nFlags & PosSizeFlags::Width )
1491 {
1492 if(!( nFlags & PosSizeFlags::X ))
1493 {
1494 nX = mpWindowImpl->mnX;
1495 nFlags |= PosSizeFlags::X;
1496 bnXRecycled = true; // we're using a mnX which was already mirrored in RTL case
1497 }
1498
1499 if ( nWidth < 0 )
1500 nWidth = 0;
1501 if ( nWidth != GetOutDev()->mnOutWidth )
1502 {
1503 GetOutDev()->mnOutWidth = nWidth;
1504 bNewSize = true;
1505 bCopyBits = false;
1506 }
1507 }
1508 if ( nFlags & PosSizeFlags::Height )
1509 {
1510 if ( nHeight < 0 )
1511 nHeight = 0;
1512 if ( nHeight != GetOutDev()->mnOutHeight )
1513 {
1514 GetOutDev()->mnOutHeight = nHeight;
1515 bNewSize = true;
1516 bCopyBits = false;
1517 }
1518 }
1519
1520 if ( nFlags & PosSizeFlags::X )
1521 {
1522 tools::Long nOrgX = nX;
1523 Point aPtDev( Point( nX+GetOutDev()->mnOutOffX, 0 ) );
1524 OutputDevice *pOutDev = GetOutDev();
1525 if( pOutDev->HasMirroredGraphics() )
1526 {
1527 aPtDev.setX( GetOutDev()->mpGraphics->mirror2( aPtDev.X(), *GetOutDev() ) );
1528
1529 // #106948# always mirror our pos if our parent is not mirroring, even
1530 // if we are also not mirroring
1531 // RTL: check if parent is in different coordinates
1532 if( !bnXRecycled && mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->GetOutDev()->ImplIsAntiparallel() )
1533 {
1534 nX = mpWindowImpl->mpParent->GetOutDev()->mnOutWidth - GetOutDev()->mnOutWidth - nX;
1535 }
1536 /* #i99166# An LTR window in RTL UI that gets sized only would be
1537 expected to not moved its upper left point
1538 */
1539 if( bnXRecycled )
1540 {
1541 if( GetOutDev()->ImplIsAntiparallel() )
1542 {
1543 aPtDev.setX( mpWindowImpl->mnAbsScreenX );
1544 nOrgX = mpWindowImpl->maPos.X();
1545 }
1546 }
1547 }
1548 else if( !bnXRecycled && mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->GetOutDev()->ImplIsAntiparallel() )
1549 {
1550 // mirrored window in LTR UI
1551 nX = mpWindowImpl->mpParent->GetOutDev()->mnOutWidth - GetOutDev()->mnOutWidth - nX;
1552 }
1553
1554 // check maPos as well, as it could have been changed for client windows (ImplCallMove())
1555 if ( mpWindowImpl->mnAbsScreenX != aPtDev.X() || nX != mpWindowImpl->mnX || nOrgX != mpWindowImpl->maPos.X() )
1556 {
1557 if ( bCopyBits && !pOverlapRegion )
1558 {
1559 pOverlapRegion.reset( new vcl::Region() );
1561 *pOverlapRegion, false, true );
1562 }
1563 mpWindowImpl->mnX = nX;
1564 mpWindowImpl->maPos.setX( nOrgX );
1565 mpWindowImpl->mnAbsScreenX = aPtDev.X();
1566 bNewPos = true;
1567 }
1568 }
1569 if ( nFlags & PosSizeFlags::Y )
1570 {
1571 // check maPos as well, as it could have been changed for client windows (ImplCallMove())
1572 if ( nY != mpWindowImpl->mnY || nY != mpWindowImpl->maPos.Y() )
1573 {
1574 if ( bCopyBits && !pOverlapRegion )
1575 {
1576 pOverlapRegion.reset( new vcl::Region() );
1578 *pOverlapRegion, false, true );
1579 }
1580 mpWindowImpl->mnY = nY;
1581 mpWindowImpl->maPos.setY( nY );
1582 bNewPos = true;
1583 }
1584 }
1585
1586 if ( !(bNewPos || bNewSize) )
1587 return;
1588
1589 bool bUpdateSysObjPos = false;
1590 if ( bNewPos )
1591 bUpdateSysObjPos = ImplUpdatePos();
1592
1593 // the borderwindow always specifies the position for its client window
1594 if ( mpWindowImpl->mpBorderWindow )
1595 mpWindowImpl->maPos = mpWindowImpl->mpBorderWindow->mpWindowImpl->maPos;
1596
1597 if ( mpWindowImpl->mpClientWindow )
1598 {
1599 mpWindowImpl->mpClientWindow->ImplPosSizeWindow( mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder,
1600 mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder,
1601 GetOutDev()->mnOutWidth - mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnRightBorder,
1602 GetOutDev()->mnOutHeight - mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnBottomBorder,
1605 // If we have a client window, then this is the position
1606 // of the Application's floating windows
1607 mpWindowImpl->mpClientWindow->mpWindowImpl->maPos = mpWindowImpl->maPos;
1608 if ( bNewPos )
1609 {
1610 if ( mpWindowImpl->mpClientWindow->IsVisible() )
1611 {
1612 mpWindowImpl->mpClientWindow->ImplCallMove();
1613 }
1614 else
1615 {
1616 mpWindowImpl->mpClientWindow->mpWindowImpl->mbCallMove = true;
1617 }
1618 }
1619 }
1620
1621 // Move()/Resize() will be called only for Show(), such that
1622 // at least one is called before Show()
1623 if ( IsVisible() )
1624 {
1625 if ( bNewPos )
1626 {
1627 ImplCallMove();
1628 }
1629 if ( bNewSize )
1630 {
1632 }
1633 }
1634 else
1635 {
1636 if ( bNewPos )
1637 mpWindowImpl->mbCallMove = true;
1638 if ( bNewSize )
1639 mpWindowImpl->mbCallResize = true;
1640 }
1641
1642 bool bUpdateSysObjClip = false;
1643 if ( IsReallyVisible() )
1644 {
1645 if ( bNewPos || bNewSize )
1646 {
1647 // set Clip-Flag
1648 bUpdateSysObjClip = !ImplSetClipFlag( true );
1649 }
1650
1651 // invalidate window content ?
1652 if ( bNewPos || (GetOutDev()->mnOutWidth > nOldOutWidth) || (GetOutDev()->mnOutHeight > nOldOutHeight) )
1653 {
1654 if ( bNewPos )
1655 {
1656 bool bInvalidate = false;
1657 bool bParentPaint = true;
1658 if ( !ImplIsOverlapWindow() )
1659 bParentPaint = mpWindowImpl->mpParent->IsPaintEnabled();
1660 if ( bCopyBits && bParentPaint && !HasPaintEvent() )
1661 {
1662 vcl::Region aRegion( GetOutputRectPixel() );
1663 if ( mpWindowImpl->mbWinRegion )
1664 aRegion.Intersect( GetOutDev()->ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
1665 ImplClipBoundaries( aRegion, false, true );
1666 if ( !pOverlapRegion->IsEmpty() )
1667 {
1668 pOverlapRegion->Move( GetOutDev()->mnOutOffX - nOldOutOffX, GetOutDev()->mnOutOffY - nOldOutOffY );
1669 aRegion.Exclude( *pOverlapRegion );
1670 }
1671 if ( !aRegion.IsEmpty() )
1672 {
1673 // adapt Paint areas
1674 ImplMoveAllInvalidateRegions( tools::Rectangle( Point( nOldOutOffX, nOldOutOffY ),
1675 Size( nOldOutWidth, nOldOutHeight ) ),
1676 GetOutDev()->mnOutOffX - nOldOutOffX, GetOutDev()->mnOutOffY - nOldOutOffY,
1677 true );
1678 SalGraphics* pGraphics = ImplGetFrameGraphics();
1679 if ( pGraphics )
1680 {
1681
1682 OutputDevice *pOutDev = GetOutDev();
1683 const bool bSelectClipRegion = pOutDev->SelectClipRegion( aRegion, pGraphics );
1684 if ( bSelectClipRegion )
1685 {
1686 pGraphics->CopyArea( GetOutDev()->mnOutOffX, GetOutDev()->mnOutOffY,
1687 nOldOutOffX, nOldOutOffY,
1688 nOldOutWidth, nOldOutHeight,
1689 *GetOutDev() );
1690 }
1691 else
1692 bInvalidate = true;
1693 }
1694 else
1695 bInvalidate = true;
1696 if ( !bInvalidate )
1697 {
1698 if ( !pOverlapRegion->IsEmpty() )
1700 }
1701 }
1702 else
1703 bInvalidate = true;
1704 }
1705 else
1706 bInvalidate = true;
1707 if ( bInvalidate )
1709 }
1710 else
1711 {
1712 vcl::Region aRegion( GetOutputRectPixel() );
1713 aRegion.Exclude( *pOldRegion );
1714 if ( mpWindowImpl->mbWinRegion )
1715 aRegion.Intersect( GetOutDev()->ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
1716 ImplClipBoundaries( aRegion, false, true );
1717 if ( !aRegion.IsEmpty() )
1719 }
1720 }
1721
1722 // invalidate Parent or Overlaps
1723 if ( bNewPos ||
1724 (GetOutDev()->mnOutWidth < nOldOutWidth) || (GetOutDev()->mnOutHeight < nOldOutHeight) )
1725 {
1726 vcl::Region aRegion( *pOldRegion );
1727 if ( !mpWindowImpl->mbPaintTransparent )
1728 ImplExcludeWindowRegion( aRegion );
1729 ImplClipBoundaries( aRegion, false, true );
1730 if ( !aRegion.IsEmpty() && !mpWindowImpl->mpBorderWindow )
1732 }
1733 }
1734
1735 // adapt system objects
1736 if ( bUpdateSysObjClip )
1738 if ( bUpdateSysObjPos )
1740 if ( bNewSize && mpWindowImpl->mpSysObj )
1741 mpWindowImpl->mpSysObj->SetPosSize( GetOutDev()->mnOutOffX, GetOutDev()->mnOutOffY, GetOutDev()->mnOutWidth, GetOutDev()->mnOutHeight );
1742}
1743
1745{
1746 ImplSVData* pSVData = ImplGetSVData();
1747 vcl::Window* pFocusWin = pSVData->mpWinData->mpFocusWin;
1748 if ( !pFocusWin || !pFocusWin->mpWindowImpl || pFocusWin->isDisposed() )
1749 return;
1750
1751 // Is InputContext changed?
1752 const InputContext& rInputContext = pFocusWin->GetInputContext();
1753 if ( rInputContext == pFocusWin->mpWindowImpl->mpFrameData->maOldInputContext )
1754 return;
1755
1756 pFocusWin->mpWindowImpl->mpFrameData->maOldInputContext = rInputContext;
1757
1758 SalInputContext aNewContext;
1759 const vcl::Font& rFont = rInputContext.GetFont();
1760 const OUString& rFontName = rFont.GetFamilyName();
1762 aNewContext.mpFont = nullptr;
1763 if (!rFontName.isEmpty())
1764 {
1765 OutputDevice *pFocusWinOutDev = pFocusWin->GetOutDev();
1766 Size aSize = pFocusWinOutDev->ImplLogicToDevicePixel( rFont.GetFontSize() );
1767 if ( !aSize.Height() )
1768 {
1769 // only set default sizes if the font height in logical
1770 // coordinates equals 0
1771 if ( rFont.GetFontSize().Height() )
1772 aSize.setHeight( 1 );
1773 else
1774 aSize.setHeight( (12*pFocusWin->GetOutDev()->mnDPIY)/72 );
1775 }
1776 pFontInstance = pFocusWin->GetOutDev()->mxFontCache->GetFontInstance(
1777 pFocusWin->GetOutDev()->mxFontCollection.get(),
1778 rFont, aSize, static_cast<float>(aSize.Height()) );
1779 if ( pFontInstance )
1780 aNewContext.mpFont = pFontInstance;
1781 }
1782 aNewContext.mnOptions = rInputContext.GetOptions();
1783 pFocusWin->ImplGetFrame()->SetInputContext( &aNewContext );
1784}
1785
1787{
1788 if (mpWindowImpl) // may be called after dispose
1789 {
1790 mpWindowImpl->maDumpAsPropertyTreeHdl = rLink;
1791 }
1792}
1793
1795{
1797}
1798
1800{
1801 return mpWindowImpl->mpFrame->GetIndicatorState();
1802}
1803
1804void Window::SimulateKeyPress( sal_uInt16 nKeyCode ) const
1805{
1806 mpWindowImpl->mpFrame->SimulateKeyPress(nKeyCode);
1807}
1808
1809void Window::KeyInput( const KeyEvent& rKEvt )
1810{
1811 KeyCode cod = rKEvt.GetKeyCode ();
1812 bool autoacc = ImplGetSVData()->maNWFData.mbAutoAccel;
1813
1814 // do not respond to accelerators unless Alt or Ctrl is held
1815 if (cod.GetCode () >= 0x200 && cod.GetCode () <= 0x219)
1816 {
1817 if (autoacc && cod.GetModifier () != KEY_MOD2 && !(cod.GetModifier() & KEY_MOD1))
1818 return;
1819 }
1820
1821 NotifyEvent aNEvt( NotifyEventType::KEYINPUT, this, &rKEvt );
1822 if ( !CompatNotify( aNEvt ) )
1823 mpWindowImpl->mbKeyInput = true;
1824}
1825
1826void Window::KeyUp( const KeyEvent& rKEvt )
1827{
1828 NotifyEvent aNEvt( NotifyEventType::KEYUP, this, &rKEvt );
1829 if ( !CompatNotify( aNEvt ) )
1830 mpWindowImpl->mbKeyUp = true;
1831}
1832
1834{
1835}
1836
1838
1840
1842
1844
1846{
1847 if ( HasFocus() && mpWindowImpl->mpLastFocusWindow && !(mpWindowImpl->mnDlgCtrlFlags & DialogControlFlags::WantFocus) )
1848 {
1849 VclPtr<vcl::Window> xWindow(this);
1850 mpWindowImpl->mpLastFocusWindow->GrabFocus();
1851 if( xWindow->isDisposed() )
1852 return;
1853 }
1854
1856 CompatNotify( aNEvt );
1857}
1858
1860{
1862 CompatNotify( aNEvt );
1863}
1864
1866{
1867 if (mpWindowImpl) // may be called after dispose
1868 {
1869 mpWindowImpl->maHelpRequestHdl = rLink;
1870 }
1871}
1872
1873void Window::RequestHelp( const HelpEvent& rHEvt )
1874{
1875 // if Balloon-Help is requested, show the balloon
1876 // with help text set
1877 if ( rHEvt.GetMode() & HelpEventMode::BALLOON )
1878 {
1879 OUString rStr = GetHelpText();
1880 if ( rStr.isEmpty() )
1881 rStr = GetQuickHelpText();
1882 if ( rStr.isEmpty() && ImplGetParent() && !ImplIsOverlapWindow() )
1883 ImplGetParent()->RequestHelp( rHEvt );
1884 else
1885 {
1886 Point aPos = GetPosPixel();
1887 if ( ImplGetParent() && !ImplIsOverlapWindow() )
1888 aPos = OutputToScreenPixel(Point(0, 0));
1889 tools::Rectangle aRect( aPos, GetSizePixel() );
1890
1891 Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), aRect, rStr );
1892 }
1893 }
1894 else if ( rHEvt.GetMode() & HelpEventMode::QUICK )
1895 {
1896 const OUString& rStr = GetQuickHelpText();
1897 if ( rStr.isEmpty() && ImplGetParent() && !ImplIsOverlapWindow() )
1898 ImplGetParent()->RequestHelp( rHEvt );
1899 else
1900 {
1901 Point aPos = GetPosPixel();
1902 if ( ImplGetParent() && !ImplIsOverlapWindow() )
1903 aPos = OutputToScreenPixel(Point(0, 0));
1904 tools::Rectangle aRect( aPos, GetSizePixel() );
1905 Help::ShowQuickHelp( this, aRect, rStr, QuickHelpFlags::CtrlText );
1906 }
1907 }
1908 else if (!mpWindowImpl->maHelpRequestHdl.IsSet() || mpWindowImpl->maHelpRequestHdl.Call(*this))
1909 {
1910 OUString aStrHelpId( OStringToOUString( GetHelpId(), RTL_TEXTENCODING_UTF8 ) );
1911 if ( aStrHelpId.isEmpty() && ImplGetParent() )
1912 ImplGetParent()->RequestHelp( rHEvt );
1913 else
1914 {
1915 Help* pHelp = Application::GetHelp();
1916 if ( pHelp )
1917 {
1918 if( !aStrHelpId.isEmpty() )
1919 pHelp->Start( aStrHelpId, this );
1920 else
1921 pHelp->Start( OOO_HELP_INDEX, this );
1922 }
1923 }
1924 }
1925}
1926
1927void Window::Command( const CommandEvent& rCEvt )
1928{
1930
1931 NotifyEvent aNEvt( NotifyEventType::COMMAND, this, &rCEvt );
1932 if ( !CompatNotify( aNEvt ) )
1933 mpWindowImpl->mbCommand = true;
1934}
1935
1937{
1938
1940 if( pWrapper )
1941 pWrapper->Tracking( rTEvt );
1942}
1943
1945{
1946 switch (eType)
1947 {
1948 //stuff that doesn't invalidate the layout
1958 break;
1959 //stuff that does invalidate the layout
1960 default:
1962 break;
1963 }
1964}
1965
1967{
1968 if ( mpWindowImpl && mpWindowImpl->mnStyle != nStyle )
1969 {
1970 mpWindowImpl->mnPrevStyle = mpWindowImpl->mnStyle;
1971 mpWindowImpl->mnStyle = nStyle;
1973 }
1974}
1975
1977{
1978
1979 if ( mpWindowImpl->mnExtendedStyle == nExtendedStyle )
1980 return;
1981
1982 vcl::Window* pWindow = ImplGetBorderWindow();
1983 if( ! pWindow )
1984 pWindow = this;
1985 if( pWindow->mpWindowImpl->mbFrame )
1986 {
1987 SalExtStyle nExt = 0;
1988 if( nExtendedStyle & WindowExtendedStyle::Document )
1990 if( nExtendedStyle & WindowExtendedStyle::DocModified )
1992
1993 pWindow->ImplGetFrame()->SetExtendedFrameStyle( nExt );
1994 }
1995 mpWindowImpl->mnExtendedStyle = nExtendedStyle;
1996}
1997
1999{
2000
2001 if ( !mpWindowImpl->mpBorderWindow )
2002 return;
2003
2004 if( nBorderStyle == WindowBorderStyle::REMOVEBORDER &&
2005 ! mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame &&
2006 mpWindowImpl->mpBorderWindow->mpWindowImpl->mpParent
2007 )
2008 {
2009 // this is a little awkward: some controls (e.g. svtools ProgressBar)
2010 // cannot avoid getting constructed with WB_BORDER but want to disable
2011 // borders in case of NWF drawing. So they need a method to remove their border window
2012 VclPtr<vcl::Window> pBorderWin = mpWindowImpl->mpBorderWindow;
2013 // remove us as border window's client
2014 pBorderWin->mpWindowImpl->mpClientWindow = nullptr;
2015 mpWindowImpl->mpBorderWindow = nullptr;
2016 mpWindowImpl->mpRealParent = pBorderWin->mpWindowImpl->mpParent;
2017 // reparent us above the border window
2018 SetParent( pBorderWin->mpWindowImpl->mpParent );
2019 // set us to the position and size of our previous border
2020 Point aBorderPos( pBorderWin->GetPosPixel() );
2021 Size aBorderSize( pBorderWin->GetSizePixel() );
2022 setPosSizePixel( aBorderPos.X(), aBorderPos.Y(), aBorderSize.Width(), aBorderSize.Height() );
2023 // release border window
2024 pBorderWin.disposeAndClear();
2025
2026 // set new style bits
2027 SetStyle( GetStyle() & (~WB_BORDER) );
2028 }
2029 else
2030 {
2031 if ( mpWindowImpl->mpBorderWindow->GetType() == WindowType::BORDERWINDOW )
2032 static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetBorderStyle( nBorderStyle );
2033 else
2034 mpWindowImpl->mpBorderWindow->SetBorderStyle( nBorderStyle );
2035 }
2036}
2037
2039{
2040
2041 if ( mpWindowImpl->mpBorderWindow )
2042 {
2043 if ( mpWindowImpl->mpBorderWindow->GetType() == WindowType::BORDERWINDOW )
2044 return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->GetBorderStyle();
2045 else
2046 return mpWindowImpl->mpBorderWindow->GetBorderStyle();
2047 }
2048
2050}
2051
2053{
2054
2055 if ( mpWindowImpl->mpBorderWindow )
2056 {
2057 if ( mpWindowImpl->mpBorderWindow->GetType() == WindowType::BORDERWINDOW )
2058 return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->CalcTitleWidth();
2059 else
2060 return mpWindowImpl->mpBorderWindow->CalcTitleWidth();
2061 }
2062 else if ( mpWindowImpl->mbFrame && (mpWindowImpl->mnStyle & WB_MOVEABLE) )
2063 {
2064 // we guess the width for frame windows as we do not know the
2065 // border of external dialogs
2066 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
2067 vcl::Font aFont = GetFont();
2068 const_cast<vcl::Window*>(this)->SetPointFont(const_cast<::OutputDevice&>(*GetOutDev()), rStyleSettings.GetTitleFont());
2069 tools::Long nTitleWidth = GetTextWidth( GetText() );
2070 const_cast<vcl::Window*>(this)->SetFont( aFont );
2071 nTitleWidth += rStyleSettings.GetTitleHeight() * 3;
2072 nTitleWidth += StyleSettings::GetBorderSize() * 2;
2073 nTitleWidth += 10;
2074 return nTitleWidth;
2075 }
2076
2077 return 0;
2078}
2079
2080void Window::SetInputContext( const InputContext& rInputContext )
2081{
2082
2083 mpWindowImpl->maInputContext = rInputContext;
2084 if ( !mpWindowImpl->mbInFocusHdl && HasFocus() )
2086}
2087
2088void Window::PostExtTextInputEvent(VclEventId nType, const OUString& rText)
2089{
2090 switch (nType)
2091 {
2093 {
2094 std::unique_ptr<ExtTextInputAttr[]> pAttr(new ExtTextInputAttr[rText.getLength()]);
2095 for (int i = 0; i < rText.getLength(); ++i) {
2097 }
2098 SalExtTextInputEvent aEvent { rText, pAttr.get(), rText.getLength(), EXTTEXTINPUT_CURSOR_OVERWRITE };
2100 }
2101 break;
2104 break;
2105 default:
2106 assert(false);
2107 }
2108}
2109
2111{
2112 if ( mpWindowImpl->mbExtTextInput )
2114}
2115
2116void Window::SetCursorRect( const tools::Rectangle* pRect, tools::Long nExtTextInputWidth )
2117{
2118
2119 ImplWinData* pWinData = ImplGetWinData();
2120 if ( pWinData->mpCursorRect )
2121 {
2122 if ( pRect )
2123 pWinData->mpCursorRect = *pRect;
2124 else
2125 pWinData->mpCursorRect.reset();
2126 }
2127 else
2128 {
2129 if ( pRect )
2130 pWinData->mpCursorRect = *pRect;
2131 }
2132
2133 pWinData->mnCursorExtWidth = nExtTextInputWidth;
2134
2135}
2136
2138{
2139
2140 ImplWinData* pWinData = ImplGetWinData();
2141 return pWinData->mpCursorRect ? &*pWinData->mpCursorRect : nullptr;
2142}
2143
2145{
2146
2147 ImplWinData* pWinData = ImplGetWinData();
2148 return pWinData->mnCursorExtWidth;
2149}
2150
2151void Window::SetCompositionCharRect( const tools::Rectangle* pRect, tools::Long nCompositionLength, bool bVertical ) {
2152
2153 ImplWinData* pWinData = ImplGetWinData();
2154 pWinData->mpCompositionCharRects.reset();
2155 pWinData->mbVertical = bVertical;
2156 pWinData->mnCompositionCharRects = nCompositionLength;
2157 if ( pRect && (nCompositionLength > 0) )
2158 {
2159 pWinData->mpCompositionCharRects.reset( new tools::Rectangle[nCompositionLength] );
2160 for (tools::Long i = 0; i < nCompositionLength; ++i)
2161 pWinData->mpCompositionCharRects[i] = pRect[i];
2162 }
2163}
2164
2165void Window::CollectChildren(::std::vector<vcl::Window *>& rAllChildren )
2166{
2167 rAllChildren.push_back( this );
2168
2169 VclPtr< vcl::Window > pChild = mpWindowImpl->mpFirstChild;
2170 while ( pChild )
2171 {
2172 pChild->CollectChildren( rAllChildren );
2173 pChild = pChild->mpWindowImpl->mpNext;
2174 }
2175}
2176
2177void Window::SetPointFont(vcl::RenderContext& rRenderContext, const vcl::Font& rFont)
2178{
2179 vcl::Font aFont = rFont;
2180 ImplPointToLogic(rRenderContext, aFont);
2181 rRenderContext.SetFont(aFont);
2182}
2183
2185{
2186 vcl::Font aFont = rRenderContext.GetFont();
2187 ImplLogicToPoint(rRenderContext, aFont);
2188 return aFont;
2189}
2190
2191void Window::Show(bool bVisible, ShowFlags nFlags)
2192{
2193 if ( !mpWindowImpl || mpWindowImpl->mbVisible == bVisible )
2194 return;
2195
2196 VclPtr<vcl::Window> xWindow(this);
2197
2198 bool bRealVisibilityChanged = false;
2199 mpWindowImpl->mbVisible = bVisible;
2200
2201 if ( !bVisible )
2202 {
2204 if( !xWindow->mpWindowImpl )
2205 return;
2206
2207 if ( mpWindowImpl->mpBorderWindow )
2208 {
2209 bool bOldUpdate = mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate;
2210 if ( mpWindowImpl->mbNoParentUpdate )
2211 mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate = true;
2212 mpWindowImpl->mpBorderWindow->Show( false, nFlags );
2213 mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate = bOldUpdate;
2214 }
2215 else if ( mpWindowImpl->mbFrame )
2216 {
2217 mpWindowImpl->mbSuppressAccessibilityEvents = true;
2218 mpWindowImpl->mpFrame->Show( false );
2219 }
2220
2222
2223 if ( mpWindowImpl->mbReallyVisible )
2224 {
2225 if ( mpWindowImpl->mbInitWinClipRegion )
2227
2228 vcl::Region aInvRegion = mpWindowImpl->maWinClipRegion;
2229
2230 if( !xWindow->mpWindowImpl )
2231 return;
2232
2233 bRealVisibilityChanged = mpWindowImpl->mbReallyVisible;
2236
2237 if ( ImplIsOverlapWindow() && !mpWindowImpl->mbFrame )
2238 {
2239 // convert focus
2240 if ( !(nFlags & ShowFlags::NoFocusChange) && HasChildPathFocus() )
2241 {
2242 if ( mpWindowImpl->mpOverlapWindow->IsEnabled() &&
2243 mpWindowImpl->mpOverlapWindow->IsInputEnabled() &&
2244 ! mpWindowImpl->mpOverlapWindow->IsInModalMode()
2245 )
2246 mpWindowImpl->mpOverlapWindow->GrabFocus();
2247 }
2248 }
2249
2250 if ( !mpWindowImpl->mbFrame )
2251 {
2252 if (mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mbEnableNativeWidget)
2253 {
2254 /*
2255 * #i48371# native theming: some themes draw outside the control
2256 * area we tell them to (bad thing, but we cannot do much about it ).
2257 * On hiding these controls they get invalidated with their window rectangle
2258 * which leads to the parts outside the control area being left and not
2259 * invalidated. Workaround: invalidate an area on the parent, too
2260 */
2261 const int workaround_border = 5;
2262 tools::Rectangle aBounds( aInvRegion.GetBoundRect() );
2263 aBounds.AdjustLeft( -workaround_border );
2264 aBounds.AdjustTop( -workaround_border );
2265 aBounds.AdjustRight(workaround_border );
2266 aBounds.AdjustBottom(workaround_border );
2267 aInvRegion = aBounds;
2268 }
2269 if ( !mpWindowImpl->mbNoParentUpdate )
2270 {
2271 if ( !aInvRegion.IsEmpty() )
2272 ImplInvalidateParentFrameRegion( aInvRegion );
2273 }
2275 }
2276 }
2277 }
2278 else
2279 {
2280 // inherit native widget flag for form controls
2281 // required here, because frames never show up in the child hierarchy - which should be fixed...
2282 // eg, the drop down of a combobox which is a system floating window
2283 if( mpWindowImpl->mbFrame && GetParent() && !GetParent()->isDisposed() &&
2286 !(GetStyle() & WB_TOOLTIPWIN) )
2287 {
2289 }
2290
2291 if ( mpWindowImpl->mbCallMove )
2292 {
2293 ImplCallMove();
2294 }
2295 if ( mpWindowImpl->mbCallResize )
2296 {
2298 }
2299
2301
2302 vcl::Window* pTestParent;
2303 if ( ImplIsOverlapWindow() )
2304 pTestParent = mpWindowImpl->mpOverlapWindow;
2305 else
2306 pTestParent = ImplGetParent();
2307 if ( mpWindowImpl->mbFrame || pTestParent->mpWindowImpl->mbReallyVisible )
2308 {
2309 // if a window becomes visible, send all child windows a StateChange,
2310 // such that these can initialise themselves
2312
2313 // If it is a SystemWindow it automatically pops up on top of
2314 // all other windows if needed.
2315 if ( ImplIsOverlapWindow() && !(nFlags & ShowFlags::NoActivate) )
2316 {
2319 }
2320
2321 // adjust mpWindowImpl->mbReallyVisible
2322 bRealVisibilityChanged = !mpWindowImpl->mbReallyVisible;
2324
2325 // assure clip rectangles will be recalculated
2327
2328 if ( !mpWindowImpl->mbFrame )
2329 {
2330 InvalidateFlags nInvalidateFlags = InvalidateFlags::Children;
2331 if( ! IsPaintTransparent() )
2332 nInvalidateFlags |= InvalidateFlags::NoTransparent;
2333 ImplInvalidate( nullptr, nInvalidateFlags );
2335 }
2336 }
2337
2338 if ( mpWindowImpl->mpBorderWindow )
2339 mpWindowImpl->mpBorderWindow->Show( true, nFlags );
2340 else if ( mpWindowImpl->mbFrame )
2341 {
2342 // #106431#, hide SplashScreen
2343 ImplSVData* pSVData = ImplGetSVData();
2344 if ( !pSVData->mpIntroWindow )
2345 {
2346 // The right way would be just to call this (not even in the 'if')
2347 auto pApp = GetpApp();
2348 if ( pApp )
2349 pApp->InitFinished();
2350 }
2351 else if ( !ImplIsWindowOrChild( pSVData->mpIntroWindow ) )
2352 {
2353 // ... but the VCL splash is broken, and it needs this
2354 // (for ./soffice .uno:NewDoc)
2355 pSVData->mpIntroWindow->Hide();
2356 }
2357
2358 //SAL_WARN_IF( mpWindowImpl->mbSuppressAccessibilityEvents, "vcl", "Window::Show() - Frame reactivated");
2359 mpWindowImpl->mbSuppressAccessibilityEvents = false;
2360
2361 mpWindowImpl->mbPaintFrame = true;
2363 {
2364 bool bNoActivate(nFlags & (ShowFlags::NoActivate|ShowFlags::NoFocusChange));
2365 mpWindowImpl->mpFrame->Show( true, bNoActivate );
2366 }
2367 if( !xWindow->mpWindowImpl )
2368 return;
2369
2370 // Query the correct size of the window, if we are waiting for
2371 // a system resize
2372 if ( mpWindowImpl->mbWaitSystemResize )
2373 {
2374 tools::Long nOutWidth;
2375 tools::Long nOutHeight;
2376 mpWindowImpl->mpFrame->GetClientSize( nOutWidth, nOutHeight );
2377 ImplHandleResize( this, nOutWidth, nOutHeight );
2378 }
2379
2380 if (mpWindowImpl->mpFrameData->mpBuffer && mpWindowImpl->mpFrameData->mpBuffer->GetOutputSizePixel() != GetOutputSizePixel())
2381 // Make sure that the buffer size matches the window size, even if no resize was needed.
2382 mpWindowImpl->mpFrameData->mpBuffer->SetOutputSizePixel(GetOutputSizePixel());
2383 }
2384
2385 if( !xWindow->mpWindowImpl )
2386 return;
2387
2389 }
2390
2391 if( !xWindow->mpWindowImpl )
2392 return;
2393
2394 // the SHOW/HIDE events also serve as indicators to send child creation/destroy events to the access bridge
2395 // However, the access bridge only uses this event if the data member is not NULL (it's kind of a hack that
2396 // we re-use the SHOW/HIDE events this way, with this particular semantics).
2397 // Since #104887#, the notifications for the access bridge are done in Impl(Set|Reset)ReallyVisible. Here, we
2398 // now only notify with a NULL data pointer, for all other clients except the access bridge.
2399 if ( !bRealVisibilityChanged )
2401 if( xWindow->isDisposed() )
2402 return;
2403
2404}
2405
2407{
2408 if (!mpWindowImpl)
2409 {
2410 SAL_WARN("vcl.layout", "WTF no windowimpl");
2411 return Size(0,0);
2412 }
2413
2414 // #i43257# trigger pending resize handler to assure correct window sizes
2415 if( mpWindowImpl->mpFrameData->maResizeIdle.IsActive() )
2416 {
2417 VclPtr<vcl::Window> xWindow( const_cast<Window*>(this) );
2418 mpWindowImpl->mpFrameData->maResizeIdle.Stop();
2419 mpWindowImpl->mpFrameData->maResizeIdle.Invoke( nullptr );
2420 if( xWindow->isDisposed() )
2421 return Size(0,0);
2422 }
2423
2424 return Size( GetOutDev()->mnOutWidth + mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder,
2425 GetOutDev()->mnOutHeight + mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder );
2426}
2427
2428void Window::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
2429 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
2430{
2431 rLeftBorder = mpWindowImpl->mnLeftBorder;
2432 rTopBorder = mpWindowImpl->mnTopBorder;
2433 rRightBorder = mpWindowImpl->mnRightBorder;
2434 rBottomBorder = mpWindowImpl->mnBottomBorder;
2435}
2436
2437void Window::Enable( bool bEnable, bool bChild )
2438{
2439 if ( isDisposed() )
2440 return;
2441
2442 if ( !bEnable )
2443 {
2444 // the tracking mode will be stopped or the capture will be stolen
2445 // when a window is disabled,
2446 if ( IsTracking() )
2448 if ( IsMouseCaptured() )
2449 ReleaseMouse();
2450 // try to pass focus to the next control
2451 // if the window has focus and is contained in the dialog control
2452 // mpWindowImpl->mbDisabled should only be set after a call of ImplDlgCtrlNextWindow().
2453 // Otherwise ImplDlgCtrlNextWindow() should be used
2454 if ( HasFocus() )
2456 }
2457
2458 if ( mpWindowImpl->mpBorderWindow )
2459 {
2460 mpWindowImpl->mpBorderWindow->Enable( bEnable, false );
2461 if ( (mpWindowImpl->mpBorderWindow->GetType() == WindowType::BORDERWINDOW) &&
2462 static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow )
2463 static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow->Enable( bEnable );
2464 }
2465
2466 // #i56102# restore app focus win in case the
2467 // window was disabled when the frame focus changed
2468 ImplSVData* pSVData = ImplGetSVData();
2469 if (bEnable && pSVData->mpWinData->mpFocusWin == nullptr
2470 && mpWindowImpl->mpFrameData->mbHasFocus && mpWindowImpl->mpFrameData->mpFocusWin == this)
2471 pSVData->mpWinData->mpFocusWin = this;
2472
2473 if ( mpWindowImpl->mbDisabled != !bEnable )
2474 {
2475 mpWindowImpl->mbDisabled = !bEnable;
2476 if ( mpWindowImpl->mpSysObj )
2477 mpWindowImpl->mpSysObj->Enable( bEnable && !mpWindowImpl->mbInputDisabled );
2479
2481 }
2482
2483 if ( bChild )
2484 {
2485 VclPtr< vcl::Window > pChild = mpWindowImpl->mpFirstChild;
2486 while ( pChild )
2487 {
2488 pChild->Enable( bEnable, bChild );
2489 pChild = pChild->mpWindowImpl->mpNext;
2490 }
2491 }
2492
2493 if ( IsReallyVisible() )
2495}
2496
2497void Window::EnableInput( bool bEnable, bool bChild )
2498{
2499 if (!mpWindowImpl)
2500 return;
2501
2502 if ( mpWindowImpl->mpBorderWindow )
2503 {
2504 mpWindowImpl->mpBorderWindow->EnableInput( bEnable, false );
2505 if ( (mpWindowImpl->mpBorderWindow->GetType() == WindowType::BORDERWINDOW) &&
2506 static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow )
2507 static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow->EnableInput( bEnable );
2508 }
2509
2510 if ( (!bEnable && mpWindowImpl->meAlwaysInputMode != AlwaysInputEnabled) || bEnable )
2511 {
2512 // automatically stop the tracking mode or steal capture
2513 // if the window is disabled
2514 if ( !bEnable )
2515 {
2516 if ( IsTracking() )
2518 if ( IsMouseCaptured() )
2519 ReleaseMouse();
2520 }
2521
2522 if ( mpWindowImpl->mbInputDisabled != !bEnable )
2523 {
2524 mpWindowImpl->mbInputDisabled = !bEnable;
2525 if ( mpWindowImpl->mpSysObj )
2526 mpWindowImpl->mpSysObj->Enable( !mpWindowImpl->mbDisabled && bEnable );
2527 }
2528 }
2529
2530 // #i56102# restore app focus win in case the
2531 // window was disabled when the frame focus changed
2532 ImplSVData* pSVData = ImplGetSVData();
2533 if (bEnable && pSVData->mpWinData->mpFocusWin == nullptr
2534 && mpWindowImpl->mpFrameData->mbHasFocus && mpWindowImpl->mpFrameData->mpFocusWin == this)
2535 pSVData->mpWinData->mpFocusWin = this;
2536
2537 if ( bChild )
2538 {
2539 VclPtr< vcl::Window > pChild = mpWindowImpl->mpFirstChild;
2540 while ( pChild )
2541 {
2542 pChild->EnableInput( bEnable, bChild );
2543 pChild = pChild->mpWindowImpl->mpNext;
2544 }
2545 }
2546
2547 if ( IsReallyVisible() )
2549}
2550
2551void Window::EnableInput( bool bEnable, const vcl::Window* pExcludeWindow )
2552{
2553 if (!mpWindowImpl)
2554 return;
2555
2556 EnableInput( bEnable );
2557
2558 // pExecuteWindow is the first Overlap-Frame --> if this
2559 // shouldn't be the case, then this must be changed in dialog.cxx
2560 if( pExcludeWindow )
2561 pExcludeWindow = pExcludeWindow->ImplGetFirstOverlapWindow();
2562 vcl::Window* pSysWin = mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrameData->mpFirstOverlap;
2563 while ( pSysWin )
2564 {
2565 // Is Window in the path from this window
2566 if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( pSysWin, true ) )
2567 {
2568 // Is Window not in the exclude window path or not the
2569 // exclude window, then change the status
2570 if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( pSysWin, true ) )
2571 pSysWin->EnableInput( bEnable );
2572 }
2573 pSysWin = pSysWin->mpWindowImpl->mpNextOverlap;
2574 }
2575
2576 // enable/disable floating system windows as well
2578 while ( pFrameWin )
2579 {
2580 if( pFrameWin->ImplIsFloatingWindow() )
2581 {
2582 // Is Window in the path from this window
2583 if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( pFrameWin, true ) )
2584 {
2585 // Is Window not in the exclude window path or not the
2586 // exclude window, then change the status
2587 if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( pFrameWin, true ) )
2588 pFrameWin->EnableInput( bEnable );
2589 }
2590 }
2591 pFrameWin = pFrameWin->mpWindowImpl->mpFrameData->mpNextFrame;
2592 }
2593
2594 // the same for ownerdraw floating windows
2595 if( !mpWindowImpl->mbFrame )
2596 return;
2597
2598 ::std::vector< VclPtr<vcl::Window> >& rList = mpWindowImpl->mpFrameData->maOwnerDrawList;
2599 for (auto const& elem : rList)
2600 {
2601 // Is Window in the path from this window
2602 if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( elem, true ) )
2603 {
2604 // Is Window not in the exclude window path or not the
2605 // exclude window, then change the status
2606 if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( elem, true ) )
2607 elem->EnableInput( bEnable );
2608 }
2609 }
2610}
2611
2612void Window::AlwaysEnableInput( bool bAlways, bool bChild )
2613{
2614
2615 if ( mpWindowImpl->mpBorderWindow )
2616 mpWindowImpl->mpBorderWindow->AlwaysEnableInput( bAlways, false );
2617
2618 if( bAlways && mpWindowImpl->meAlwaysInputMode != AlwaysInputEnabled )
2619 {
2620 mpWindowImpl->meAlwaysInputMode = AlwaysInputEnabled;
2621 EnableInput(true, false);
2622 }
2623 else if( ! bAlways && mpWindowImpl->meAlwaysInputMode == AlwaysInputEnabled )
2624 {
2625 mpWindowImpl->meAlwaysInputMode = AlwaysInputNone;
2626 }
2627
2628 if ( bChild )
2629 {
2630 VclPtr< vcl::Window > pChild = mpWindowImpl->mpFirstChild;
2631 while ( pChild )
2632 {
2633 pChild->AlwaysEnableInput( bAlways, bChild );
2634 pChild = pChild->mpWindowImpl->mpNext;
2635 }
2636 }
2637}
2638
2640{
2641
2642 if ( mpWindowImpl->mpBorderWindow )
2643 mpWindowImpl->mpBorderWindow->SetActivateMode( nMode );
2644
2645 if ( mpWindowImpl->mnActivateMode == nMode )
2646 return;
2647
2648 mpWindowImpl->mnActivateMode = nMode;
2649
2650 // possibly trigger Deactivate/Activate
2651 if ( mpWindowImpl->mnActivateMode != ActivateModeFlags::NONE )
2652 {
2653 if ( (mpWindowImpl->mbActive || (GetType() == WindowType::BORDERWINDOW)) &&
2654 !HasChildPathFocus( true ) )
2655 {
2656 mpWindowImpl->mbActive = false;
2657 Deactivate();
2658 }
2659 }
2660 else
2661 {
2662 if ( !mpWindowImpl->mbActive || (GetType() == WindowType::BORDERWINDOW) )
2663 {
2664 mpWindowImpl->mbActive = true;
2665 Activate();
2666 }
2667 }
2668}
2669
2671 tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags )
2672{
2673 bool bHasValidSize = !mpWindowImpl->mbDefSize;
2674
2675 if ( nFlags & PosSizeFlags::Pos )
2676 mpWindowImpl->mbDefPos = false;
2677 if ( nFlags & PosSizeFlags::Size )
2678 mpWindowImpl->mbDefSize = false;
2679
2680 // The top BorderWindow is the window which is to be positioned
2681 VclPtr<vcl::Window> pWindow = this;
2682 while ( pWindow->mpWindowImpl->mpBorderWindow )
2683 pWindow = pWindow->mpWindowImpl->mpBorderWindow;
2684
2685 if ( pWindow->mpWindowImpl->mbFrame )
2686 {
2687 // Note: if we're positioning a frame, the coordinates are interpreted
2688 // as being the top-left corner of the window's client area and NOT
2689 // as the position of the border ! (due to limitations of several UNIX window managers)
2690 tools::Long nOldWidth = pWindow->GetOutDev()->mnOutWidth;
2691
2692 if ( !(nFlags & PosSizeFlags::Width) )
2693 nWidth = pWindow->GetOutDev()->mnOutWidth;
2694 if ( !(nFlags & PosSizeFlags::Height) )
2695 nHeight = pWindow->GetOutDev()->mnOutHeight;
2696
2697 sal_uInt16 nSysFlags=0;
2698 VclPtr<vcl::Window> pParent = GetParent();
2699 VclPtr<vcl::Window> pWinParent = pWindow->GetParent();
2700
2701 if( nFlags & PosSizeFlags::Width )
2702 nSysFlags |= SAL_FRAME_POSSIZE_WIDTH;
2703 if( nFlags & PosSizeFlags::Height )
2704 nSysFlags |= SAL_FRAME_POSSIZE_HEIGHT;
2705 if( nFlags & PosSizeFlags::X )
2706 {
2707 nSysFlags |= SAL_FRAME_POSSIZE_X;
2708 if( pWinParent && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) )
2709 {
2710 nX += pWinParent->GetOutDev()->mnOutOffX;
2711 }
2712 if( pParent && pParent->GetOutDev()->ImplIsAntiparallel() )
2713 {
2714 tools::Rectangle aRect( Point ( nX, nY ), Size( nWidth, nHeight ) );
2715 const OutputDevice *pParentOutDev = pParent->GetOutDev();
2717 pParentOutDev->ReMirror( aRect );
2718 nX = aRect.Left();
2719 }
2720 }
2722 !(nFlags & PosSizeFlags::X) && bHasValidSize &&
2723 pWindow->mpWindowImpl->mpFrame->maGeometry.width() )
2724 {
2725 // RTL: make sure the old right aligned position is not changed
2726 // system windows will always grow to the right
2727 if ( pWinParent )
2728 {
2729 OutputDevice *pParentOutDev = pWinParent->GetOutDev();
2730 if( pParentOutDev->HasMirroredGraphics() )
2731 {
2732 const SalFrameGeometry& aSysGeometry = mpWindowImpl->mpFrame->GetUnmirroredGeometry();
2733 const SalFrameGeometry& aParentSysGeometry =
2734 pWinParent->mpWindowImpl->mpFrame->GetUnmirroredGeometry();
2735 tools::Long myWidth = nOldWidth;
2736 if( !myWidth )
2737 myWidth = aSysGeometry.width();
2738 if( !myWidth )
2739 myWidth = nWidth;
2740 nFlags |= PosSizeFlags::X;
2741 nSysFlags |= SAL_FRAME_POSSIZE_X;
2742 nX = aParentSysGeometry.x() - aSysGeometry.leftDecoration() + aParentSysGeometry.width()
2743 - myWidth - 1 - aSysGeometry.x();
2744 }
2745 }
2746 }
2747 if( nFlags & PosSizeFlags::Y )
2748 {
2749 nSysFlags |= SAL_FRAME_POSSIZE_Y;
2750 if( pWinParent && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) )
2751 {
2752 nY += pWinParent->GetOutDev()->mnOutOffY;
2753 }
2754 }
2755
2757 {
2758 // check for min/max client size and adjust size accordingly
2759 // otherwise it may happen that the resize event is ignored, i.e. the old size remains
2760 // unchanged but ImplHandleResize() is called with the wrong size
2761 SystemWindow *pSystemWindow = dynamic_cast< SystemWindow* >( pWindow.get() );
2762 if( pSystemWindow )
2763 {
2764 Size aMinSize = pSystemWindow->GetMinOutputSizePixel();
2765 Size aMaxSize = pSystemWindow->GetMaxOutputSizePixel();
2766 if( nWidth < aMinSize.Width() )
2767 nWidth = aMinSize.Width();
2768 if( nHeight < aMinSize.Height() )
2769 nHeight = aMinSize.Height();
2770
2771 if( nWidth > aMaxSize.Width() )
2772 nWidth = aMaxSize.Width();
2773 if( nHeight > aMaxSize.Height() )
2774 nHeight = aMaxSize.Height();
2775 }
2776 }
2777
2778 pWindow->mpWindowImpl->mpFrame->SetPosSize( nX, nY, nWidth, nHeight, nSysFlags );
2779
2780 // Adjust resize with the hack of different client size and frame geometries to fix
2781 // native menu bars. Eventually this should be replaced by proper mnTopBorder usage.
2782 pWindow->mpWindowImpl->mpFrame->GetClientSize(nWidth, nHeight);
2783
2784 // Resize should be called directly. If we haven't
2785 // set the correct size, we get a second resize from
2786 // the system with the correct size. This can be happened
2787 // if the size is too small or too large.
2788 ImplHandleResize( pWindow, nWidth, nHeight );
2789 }
2790 else
2791 {
2792 pWindow->ImplPosSizeWindow( nX, nY, nWidth, nHeight, nFlags );
2793 if ( IsReallyVisible() )
2795 }
2796}
2797
2799{
2800 return mpWindowImpl->maPos;
2801}
2802
2804{
2805 tools::Rectangle rRect;
2806 mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrame->GetWorkArea( rRect );
2807 return rRect;
2808}
2809
2810Point Window::OutputToScreenPixel( const Point& rPos ) const
2811{
2812 // relative to top level parent
2813 return Point( rPos.X() + GetOutDev()->mnOutOffX, rPos.Y() + GetOutDev()->mnOutOffY );
2814}
2815
2816Point Window::ScreenToOutputPixel( const Point& rPos ) const
2817{
2818 // relative to top level parent
2819 return Point( rPos.X() - GetOutDev()->mnOutOffX, rPos.Y() - GetOutDev()->mnOutOffY );
2820}
2821
2823{
2824 // revert mnOutOffX changes that were potentially made in ImplPosSizeWindow
2826 OutputDevice *pOutDev = GetOutDev();
2827 if( pOutDev->HasMirroredGraphics() )
2828 {
2829 if( mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->GetOutDev()->ImplIsAntiparallel() )
2830 {
2831 if ( !ImplIsOverlapWindow() )
2832 offx -= mpWindowImpl->mpParent->GetOutDev()->mnOutOffX;
2833
2834 offx = mpWindowImpl->mpParent->GetOutDev()->mnOutWidth - GetOutDev()->mnOutWidth - offx;
2835
2836 if ( !ImplIsOverlapWindow() )
2837 offx += mpWindowImpl->mpParent->GetOutDev()->mnOutOffX;
2838
2839 }
2840 }
2841 return offx;
2842}
2843
2844// normalized screen pixel are independent of mirroring
2846{
2847 // relative to top level parent
2848 tools::Long offx = const_cast<vcl::Window*>(this)->ImplGetUnmirroredOutOffX();
2849 return Point( rPos.X()+offx, rPos.Y() + GetOutDev()->mnOutOffY );
2850}
2851
2853{
2854 // relative to top level parent
2855 tools::Long offx = const_cast<vcl::Window*>(this)->ImplGetUnmirroredOutOffX();
2856 return Point( rPos.X()-offx, rPos.Y() - GetOutDev()->mnOutOffY );
2857}
2858
2860{
2861 // relative to the screen
2862 Point p = OutputToScreenPixel( rPos );
2863 SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
2864 p.AdjustX(g.x() );
2865 p.AdjustY(g.y() );
2866 return p;
2867}
2868
2870{
2871 // relative to the screen
2872 Point p = ScreenToOutputPixel( rPos );
2873 SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
2874 p.AdjustX( -(g.x()) );
2875 p.AdjustY( -(g.y()) );
2876 return p;
2877}
2878
2880{
2881 // this method creates unmirrored screen coordinates to be compared with the desktop
2882 // and is used for positioning of RTL popup windows correctly on the screen
2883 SalFrameGeometry g = mpWindowImpl->mpFrame->GetUnmirroredGeometry();
2884
2885 Point p1 = rRect.TopRight();
2886 p1 = OutputToScreenPixel(p1);
2887 p1.setX( g.x()+g.width()-p1.X() );
2888 p1.AdjustY(g.y() );
2889
2890 Point p2 = rRect.BottomLeft();
2891 p2 = OutputToScreenPixel(p2);
2892 p2.setX( g.x()+g.width()-p2.X() );
2893 p2.AdjustY(g.y() );
2894
2895 return tools::Rectangle( p1, p2 );
2896}
2897
2899{
2900 // undo ImplOutputToUnmirroredAbsoluteScreenPixel
2901 SalFrameGeometry g = mpWindowImpl->mpFrame->GetUnmirroredGeometry();
2902
2903 Point p1 = rRect.TopRight();
2904 p1.AdjustY(-g.y() );
2905 p1.setX( g.x()+g.width()-p1.X() );
2906 p1 = ScreenToOutputPixel(p1);
2907
2908 Point p2 = rRect.BottomLeft();
2909 p2.AdjustY(-g.y());
2910 p2.setX( g.x()+g.width()-p2.X() );
2911 p2 = ScreenToOutputPixel(p2);
2912
2913 return tools::Rectangle( p1, p2 );
2914}
2915
2916
2918{
2919 // with decoration
2920 return ImplGetWindowExtentsRelative( pRelativeWindow );
2921}
2922
2924{
2925 SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
2926 // make sure we use the extent of our border window,
2927 // otherwise we miss a few pixels
2928 const vcl::Window *pWin = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow : this;
2929
2930 Point aPos( pWin->OutputToScreenPixel( Point(0,0) ) );
2931 aPos.AdjustX(g.x() );
2932 aPos.AdjustY(g.y() );
2933 Size aSize ( pWin->GetSizePixel() );
2934 // #104088# do not add decoration to the workwindow to be compatible to java accessibility api
2935 if( mpWindowImpl->mbFrame || (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame && GetType() != WindowType::WORKWINDOW) )
2936 {
2937 aPos.AdjustX( -sal_Int32(g.leftDecoration()) );
2938 aPos.AdjustY( -sal_Int32(g.topDecoration()) );
2939 aSize.AdjustWidth(g.leftDecoration() + g.rightDecoration() );
2941 }
2942 if( pRelativeWindow )
2943 {
2944 // #106399# express coordinates relative to borderwindow
2945 const vcl::Window *pRelWin = pRelativeWindow->mpWindowImpl->mpBorderWindow ? pRelativeWindow->mpWindowImpl->mpBorderWindow.get() : pRelativeWindow;
2946 aPos = pRelWin->AbsoluteScreenToOutputPixel( aPos );
2947 }
2948 return tools::Rectangle( aPos, aSize );
2949}
2950
2951void Window::Scroll( tools::Long nHorzScroll, tools::Long nVertScroll, ScrollFlags nFlags )
2952{
2953
2955 nHorzScroll, nVertScroll, nFlags & ~ScrollFlags::Clip );
2956}
2957
2958void Window::Scroll( tools::Long nHorzScroll, tools::Long nVertScroll,
2959 const tools::Rectangle& rRect, ScrollFlags nFlags )
2960{
2961 OutputDevice *pOutDev = GetOutDev();
2962 tools::Rectangle aRect = pOutDev->ImplLogicToDevicePixel( rRect );
2964 if ( !aRect.IsEmpty() )
2965 ImplScroll( aRect, nHorzScroll, nVertScroll, nFlags );
2966}
2967
2969{
2971 mxOwnerWindow->mpWindowImpl->mpFrame->Flush( GetOutputRectPixel() );
2972}
2973
2974void Window::SetUpdateMode( bool bUpdate )
2975{
2976 if (mpWindowImpl)
2977 {
2978 mpWindowImpl->mbNoUpdate = !bUpdate;
2980 }
2981}
2982
2984{
2986}
2987
2989{
2990 return (this == ImplGetSVData()->mpWinData->mpFocusWin);
2991}
2992
2994{
2996}
2997
2999{
3000 if (mpWindowImpl && mpWindowImpl->mpFrameData)
3001 return mpWindowImpl->mpFrameData->mpFocusWin;
3002 else
3003 return VclPtr<vcl::Window>();
3004}
3005
3006void Window::SetFakeFocus( bool bFocus )
3007{
3009}
3010
3011bool Window::HasChildPathFocus( bool bSystemWindow ) const
3012{
3013
3015 if ( pFocusWin )
3016 return ImplIsWindowOrChild( pFocusWin, bSystemWindow );
3017 return false;
3018}
3019
3021{
3022
3023 if ( mpWindowImpl->mpCursor != pCursor )
3024 {
3025 if ( mpWindowImpl->mpCursor )
3026 mpWindowImpl->mpCursor->ImplHide();
3027 mpWindowImpl->mpCursor = pCursor;
3028 if ( pCursor )
3029 pCursor->ImplShow();
3030 }
3031}
3032
3033void Window::SetText( const OUString& rStr )
3034{
3035 if (!mpWindowImpl || rStr == mpWindowImpl->maText)
3036 return;
3037
3038 OUString oldTitle( mpWindowImpl->maText );
3039 mpWindowImpl->maText = rStr;
3040
3041 if ( mpWindowImpl->mpBorderWindow )
3042 mpWindowImpl->mpBorderWindow->SetText( rStr );
3043 else if ( mpWindowImpl->mbFrame )
3044 mpWindowImpl->mpFrame->SetTitle( rStr );
3045
3047
3048 // #107247# needed for accessibility
3049 // The VclEventId::WindowFrameTitleChanged is (mis)used to notify accessible name changes.
3050 // Therefore a window, which is labeled by this window, must also notify an accessible
3051 // name change.
3052 if ( IsReallyVisible() )
3053 {
3055 if ( pWindow && pWindow != this )
3057 }
3058
3060}
3061
3062OUString Window::GetText() const
3063{
3064
3065 return mpWindowImpl->maText;
3066}
3067
3069{
3070
3071 return GetText();
3072}
3073
3075{
3076 // FIXME: fix issue 52349, need to fix this really in
3077 // all NWF enabled controls
3078 const ToolBox* pTB = dynamic_cast<const ToolBox*>(this);
3079 if( pTB && IsNativeWidgetEnabled() )
3081
3082 if( !IsBackground() )
3083 {
3084 if( mpWindowImpl->mpParent )
3085 return mpWindowImpl->mpParent->GetDisplayBackground();
3086 }
3087
3088 const Wallpaper& rBack = GetBackground();
3089 if( ! rBack.IsBitmap() &&
3090 ! rBack.IsGradient() &&
3091 rBack.GetColor()== COL_TRANSPARENT &&
3092 mpWindowImpl->mpParent )
3093 return mpWindowImpl->mpParent->GetDisplayBackground();
3094 return rBack;
3095}
3096
3097const OUString& Window::GetHelpText() const
3098{
3099 OUString aStrHelpId( OStringToOUString( GetHelpId(), RTL_TEXTENCODING_UTF8 ) );
3100 bool bStrHelpId = !aStrHelpId.isEmpty();
3101
3102 if ( !mpWindowImpl->maHelpText.getLength() && bStrHelpId )
3103 {
3104 if ( !IsDialog() && (mpWindowImpl->mnType != WindowType::TABPAGE) && (mpWindowImpl->mnType != WindowType::FLOATINGWINDOW) )
3105 {
3106 Help* pHelp = Application::GetHelp();
3107 if ( pHelp )
3108 {
3109 mpWindowImpl->maHelpText = pHelp->GetHelpText(aStrHelpId, this);
3110 mpWindowImpl->mbHelpTextDynamic = false;
3111 }
3112 }
3113 }
3114 else if( mpWindowImpl->mbHelpTextDynamic && bStrHelpId )
3115 {
3116 static const char* pEnv = getenv( "HELP_DEBUG" );
3117 if( pEnv && *pEnv )
3118 {
3119 OUString aTxt = mpWindowImpl->maHelpText + "\n------------------\n" + aStrHelpId;
3120 mpWindowImpl->maHelpText = aTxt;
3121 }
3122 mpWindowImpl->mbHelpTextDynamic = false;
3123 }
3124
3125 //Fallback to Window::GetAccessibleDescription without reentry to GetHelpText()
3126 if (mpWindowImpl->maHelpText.isEmpty() && mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pAccessibleDescription)
3127 return *mpWindowImpl->mpAccessibleInfos->pAccessibleDescription;
3128 return mpWindowImpl->maHelpText;
3129}
3130
3131void Window::SetWindowPeer( Reference< css::awt::XWindowPeer > const & xPeer, VCLXWindow* pVCLXWindow )
3132{
3133 if (!mpWindowImpl || mpWindowImpl->mbInDispose)
3134 return;
3135
3136 // be safe against re-entrance: first clear the old ref, then assign the new one
3137 if (mpWindowImpl->mxWindowPeer)
3138 {
3139 // first, disconnect the peer from ourself, otherwise disposing it, will dispose us
3141 SAL_WARN_IF( !pWrapper, "vcl.window", "SetComponentInterface: No Wrapper!" );
3142 if ( pWrapper )
3143 pWrapper->SetWindowInterface( nullptr, mpWindowImpl->mxWindowPeer );
3144 mpWindowImpl->mxWindowPeer->dispose();
3145 mpWindowImpl->mxWindowPeer.clear();
3146 }
3147 mpWindowImpl->mxWindowPeer = xPeer;
3148
3149 mpWindowImpl->mpVCLXWindow = pVCLXWindow;
3150}
3151
3152Reference< css::awt::XWindowPeer > Window::GetComponentInterface( bool bCreate )
3153{
3154 if ( !mpWindowImpl->mxWindowPeer.is() && bCreate )
3155 {
3157 if ( pWrapper )
3158 mpWindowImpl->mxWindowPeer = pWrapper->GetWindowInterface( this );
3159 }
3160 return mpWindowImpl->mxWindowPeer;
3161}
3162
3163void Window::SetComponentInterface( Reference< css::awt::XWindowPeer > const & xIFace )
3164{
3166 SAL_WARN_IF( !pWrapper, "vcl.window", "SetComponentInterface: No Wrapper!" );
3167 if ( pWrapper )
3168 pWrapper->SetWindowInterface( this, xIFace );
3169}
3170
3171typedef std::map<vcl::LOKWindowId, VclPtr<vcl::Window>> LOKWindowsMap;
3172
3173namespace {
3174
3175LOKWindowsMap& GetLOKWindowsMap()
3176{
3177 // Map to remember the LOKWindowId <-> Window binding.
3178 static LOKWindowsMap s_aLOKWindowsMap;
3179
3180 return s_aLOKWindowsMap;
3181}
3182
3183}
3184
3185void Window::SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier, bool bParent)
3186{
3187 // don't allow setting this twice
3188 assert(mpWindowImpl->mpLOKNotifier == nullptr);
3189 assert(pNotifier);
3190 // never use this in the desktop case
3192
3193 if (!bParent)
3194 {
3195 // Counter to be able to have unique id's for each window.
3196 static vcl::LOKWindowId sLastLOKWindowId = 1;
3197
3198 // assign the LOK window id
3199 assert(mpWindowImpl->mnLOKWindowId == 0);
3200 mpWindowImpl->mnLOKWindowId = sLastLOKWindowId++;
3201 GetLOKWindowsMap().emplace(mpWindowImpl->mnLOKWindowId, this);
3202 }
3203 else
3204 mpWindowImpl->mbLOKParentNotifier = true;
3205
3206 mpWindowImpl->mpLOKNotifier = pNotifier;
3207}
3208
3210{
3211 const auto it = GetLOKWindowsMap().find(nWindowId);
3212 if (it != GetLOKWindowsMap().end())
3213 return it->second;
3214
3215 return VclPtr<Window>();
3216}
3217
3219{
3220 return GetLOKWindowsMap().empty();
3221}
3222
3224{
3225 // unregister the LOK window binding
3226 if (mpWindowImpl->mnLOKWindowId > 0)
3227 GetLOKWindowsMap().erase(mpWindowImpl->mnLOKWindowId);
3228
3229 mpWindowImpl->mpLOKNotifier = nullptr;
3230 mpWindowImpl->mnLOKWindowId = 0;
3231}
3232
3233ILibreOfficeKitNotifier::~ILibreOfficeKitNotifier()
3234{
3236 {
3237 return;
3238 }
3239
3240 for (auto it = GetLOKWindowsMap().begin(); it != GetLOKWindowsMap().end();)
3241 {
3242 WindowImpl* pWindowImpl = it->second->ImplGetWindowImpl();
3243 if (pWindowImpl && pWindowImpl->mpLOKNotifier == this)
3244 {
3245 pWindowImpl->mpLOKNotifier = nullptr;
3246 pWindowImpl->mnLOKWindowId = 0;
3247 it = GetLOKWindowsMap().erase(it);
3248 continue;
3249 }
3250
3251 ++it;
3252 }
3253}
3254
3255const vcl::ILibreOfficeKitNotifier* Window::GetLOKNotifier() const
3256{
3257 return mpWindowImpl ? mpWindowImpl->mpLOKNotifier : nullptr;
3258}
3259
3261{
3262 return mpWindowImpl ? mpWindowImpl->mnLOKWindowId : 0;
3263}
3264
3266{
3267 VclPtr<vcl::Window> pWindow(this);
3268
3269 while (pWindow && !pWindow->GetLOKNotifier())
3270 pWindow = pWindow->GetParent();
3271
3272 return pWindow;
3273}
3274
3275namespace
3276{
3277
3278std::string_view windowTypeName(WindowType nWindowType)
3279{
3280 switch (nWindowType)
3281 {
3282 case WindowType::NONE: return "none";
3283 case WindowType::MESSBOX: return "messagebox";
3284 case WindowType::INFOBOX: return "infobox";
3285 case WindowType::WARNINGBOX: return "warningbox";
3286 case WindowType::ERRORBOX: return "errorbox";
3287 case WindowType::QUERYBOX: return "querybox";
3288 case WindowType::WINDOW: return "window";
3289 case WindowType::WORKWINDOW: return "workwindow";
3290 case WindowType::CONTAINER: return "container";
3291 case WindowType::FLOATINGWINDOW: return "floatingwindow";
3292 case WindowType::DIALOG: return "dialog";
3293 case WindowType::MODELESSDIALOG: return "modelessdialog";
3294 case WindowType::CONTROL: return "control";
3295 case WindowType::PUSHBUTTON: return "pushbutton";
3296 case WindowType::OKBUTTON: return "okbutton";
3297 case WindowType::CANCELBUTTON: return "cancelbutton";
3298 case WindowType::HELPBUTTON: return "helpbutton";
3299 case WindowType::IMAGEBUTTON: return "imagebutton";
3300 case WindowType::MENUBUTTON: return "menubutton";
3301 case WindowType::MOREBUTTON: return "morebutton";
3302 case WindowType::SPINBUTTON: return "spinbutton";
3303 case WindowType::RADIOBUTTON: return "radiobutton";
3304 case WindowType::CHECKBOX: return "checkbox";
3305 case WindowType::TRISTATEBOX: return "tristatebox";
3306 case WindowType::EDIT: return "edit";
3307 case WindowType::MULTILINEEDIT: return "multilineedit";
3308 case WindowType::COMBOBOX: return "combobox";
3309 case WindowType::LISTBOX: return "listbox";
3310 case WindowType::MULTILISTBOX: return "multilistbox";
3311 case WindowType::FIXEDTEXT: return "fixedtext";
3312 case WindowType::FIXEDLINE: return "fixedline";
3313 case WindowType::FIXEDBITMAP: return "fixedbitmap";
3314 case WindowType::FIXEDIMAGE: return "fixedimage";
3315 case WindowType::GROUPBOX: return "groupbox";
3316 case WindowType::SCROLLBAR: return "scrollbar";
3317 case WindowType::SCROLLBARBOX: return "scrollbarbox";
3318 case WindowType::SPLITTER: return "splitter";
3319 case WindowType::SPLITWINDOW: return "splitwindow";
3320 case WindowType::SPINFIELD: return "spinfield";
3321 case WindowType::PATTERNFIELD: return "patternfield";
3322 case WindowType::METRICFIELD: return "metricfield";
3323 case WindowType::FORMATTEDFIELD: return "formattedfield";
3324 case WindowType::CURRENCYFIELD: return "currencyfield";
3325 case WindowType::DATEFIELD: return "datefield";
3326 case WindowType::TIMEFIELD: return "timefield";
3327 case WindowType::PATTERNBOX: return "patternbox";
3328 case WindowType::NUMERICBOX: return "numericbox";
3329 case WindowType::METRICBOX: return "metricbox";
3330 case WindowType::CURRENCYBOX: return "currencybox";
3331 case WindowType::DATEBOX: return "datebox";
3332 case WindowType::TIMEBOX: return "timebox";
3333 case WindowType::LONGCURRENCYBOX: return "longcurrencybox";
3334 case WindowType::SCROLLWINDOW: return "scrollwindow";
3335 case WindowType::TOOLBOX: return "toolbox";
3336 case WindowType::DOCKINGWINDOW: return "dockingwindow";
3337 case WindowType::STATUSBAR: return "statusbar";
3338 case WindowType::TABPAGE: return "tabpage";
3339 case WindowType::TABCONTROL: return "tabcontrol";
3340 case WindowType::TABDIALOG: return "tabdialog";
3341 case WindowType::BORDERWINDOW: return "borderwindow";
3342 case WindowType::BUTTONDIALOG: return "buttondialog";
3343 case WindowType::SYSTEMCHILDWINDOW: return "systemchildwindow";
3344 case WindowType::SLIDER: return "slider";
3345 case WindowType::MENUBARWINDOW: return "menubarwindow";
3346 case WindowType::TREELISTBOX: return "treelistbox";
3347 case WindowType::HELPTEXTWINDOW: return "helptextwindow";
3348 case WindowType::INTROWINDOW: return "introwindow";
3349 case WindowType::LISTBOXWINDOW: return "listboxwindow";
3350 case WindowType::DOCKINGAREA: return "dockingarea";
3351 case WindowType::RULER: return "ruler";
3352 case WindowType::HEADERBAR: return "headerbar";
3353 case WindowType::VERTICALTABCONTROL: return "verticaltabcontrol";
3354
3355 // nothing to do here, but for completeness
3356 case WindowType::TOOLKIT_FRAMEWINDOW: return "toolkit_framewindow";
3357 case WindowType::TOOLKIT_SYSTEMCHILDWINDOW: return "toolkit_systemchildwindow";
3358 }
3359
3360 return "none";
3361}
3362
3363}
3364
3366{
3367 if (!mpWindowImpl)
3368 return;
3369
3370 rJsonWriter.put("id", get_id()); // TODO could be missing - sort out
3371 rJsonWriter.put("type", windowTypeName(GetType()));
3372 rJsonWriter.put("text", GetText());
3373 rJsonWriter.put("enabled", IsEnabled());
3374 if (!IsVisible())
3375 rJsonWriter.put("visible", false);
3376
3377 if (vcl::Window* pChild = mpWindowImpl->mpFirstChild)
3378 {
3379 auto childrenNode = rJsonWriter.startArray("children");
3380 while (pChild)
3381 {
3382 {
3383 auto childNode = rJsonWriter.startStruct();
3384 pChild->DumpAsPropertyTree(rJsonWriter);
3385 sal_Int32 nLeft = pChild->get_grid_left_attach();
3386 sal_Int32 nTop = pChild->get_grid_top_attach();
3387 if (nLeft != -1 && nTop != -1)
3388 {
3389 rJsonWriter.put("left", nLeft);
3390 rJsonWriter.put("top", nTop);
3391 }
3392
3393 sal_Int32 nWidth = pChild->get_grid_width();
3394 if (nWidth > 1)
3395 rJsonWriter.put("width", nWidth);
3396 }
3397 pChild = pChild->mpWindowImpl->mpNext;
3398 }
3399 }
3400
3401 mpWindowImpl->maDumpAsPropertyTreeHdl.Call(rJsonWriter);
3402}
3403
3405{
3406 // no deactivation if the newly activated window is my child
3407 if ( !pNew || !ImplIsChild( pNew ) )
3408 {
3409 VclPtr<vcl::Window> xWindow(this);
3411 if( !xWindow->mpWindowImpl )
3412 return;
3413
3414 // #100759#, avoid walking the wrong frame's hierarchy
3415 // eg, undocked docking windows (ImplDockFloatWin)
3417 mpWindowImpl->mpFrameWindow == ImplGetParent()->mpWindowImpl->mpFrameWindow )
3419 }
3420}
3421
3423{
3424 // no activation if the old active window is my child
3425 if ( pOld && ImplIsChild( pOld ))
3426 return;
3427
3428 VclPtr<vcl::Window> xWindow(this);
3430 if( !xWindow->mpWindowImpl )
3431 return;
3432
3433 if ( ImplGetParent() )
3435 else if( (mpWindowImpl->mnStyle & WB_INTROWIN) == 0 )
3436 {
3437 // top level frame reached: store hint for DefModalDialogParent
3439 }
3440}
3441
3442void Window::SetClipboard(Reference<XClipboard> const & xClipboard)
3443{
3444 if (mpWindowImpl->mpFrameData)
3445 mpWindowImpl->mpFrameData->mxClipboard = xClipboard;
3446}
3447
3448Reference< XClipboard > Window::GetClipboard()
3449{
3450 if (!mpWindowImpl->mpFrameData)
3451 return static_cast<XClipboard*>(nullptr);
3452 if (!mpWindowImpl->mpFrameData->mxClipboard.is())
3453 mpWindowImpl->mpFrameData->mxClipboard = GetSystemClipboard();
3454 return mpWindowImpl->mpFrameData->mxClipboard;
3455}
3456
3458{
3459 assert(GetOutDev()->mpOutDevData);
3460 GetOutDev()->mpOutDevData->mpRecordLayout = pLayout;
3461 GetOutDev()->mpOutDevData->maRecordRect = rRect;
3462 Paint(*GetOutDev(), rRect);
3463 GetOutDev()->mpOutDevData->mpRecordLayout = nullptr;
3464}
3465
3467 sal_uInt16 highlight,
3468 bool bChecked,
3469 bool bDrawBorder
3470 )
3471{
3472 if( rRect.IsEmpty() )
3473 return;
3474
3475 const StyleSettings& rStyles = GetSettings().GetStyleSettings();
3476
3477 // colors used for item highlighting
3478 Color aSelectionBorderCol( rStyles.GetHighlightColor() );
3479 Color aSelectionFillCol( aSelectionBorderCol );
3480
3481 bool bDark = rStyles.GetFaceColor().IsDark();
3482 bool bBright = ( rStyles.GetFaceColor() == COL_WHITE );
3483
3484 int c1 = aSelectionBorderCol.GetLuminance();
3485 int c2 = GetBackgroundColor().GetLuminance();
3486
3487 if( !bDark && !bBright && abs( c2-c1 ) < 75 )
3488 {
3489 // contrast too low
3490 sal_uInt16 h,s,b;
3491 aSelectionFillCol.RGBtoHSB( h, s, b );
3492 if( b > 50 ) b -= 40;
3493 else b += 40;
3494 aSelectionFillCol = Color::HSBtoRGB( h, s, b );
3495 aSelectionBorderCol = aSelectionFillCol;
3496 }
3497
3498 tools::Rectangle aRect( rRect );
3499 Color oldFillCol = GetOutDev()->GetFillColor();
3500 Color oldLineCol = GetOutDev()->GetLineColor();
3501
3502 if( bDrawBorder )
3503 GetOutDev()->SetLineColor( bDark ? COL_WHITE : ( bBright ? COL_BLACK : aSelectionBorderCol ) );
3504 else
3506
3507 sal_uInt16 nPercent = 0;
3508 if( !highlight )
3509 {
3510 if( bDark )
3511 aSelectionFillCol = COL_BLACK;
3512 else
3513 nPercent = 80; // just checked (light)
3514 }
3515 else
3516 {
3517 if( bChecked && highlight == 2 )
3518 {
3519 if( bDark )
3520 aSelectionFillCol = COL_LIGHTGRAY;
3521 else if ( bBright )
3522 {
3523 aSelectionFillCol = COL_BLACK;
3525 nPercent = 0;
3526 }
3527 else
3528 nPercent = 20; // selected, pressed or checked ( very dark )
3529 }
3530 else if( bChecked || highlight == 1 )
3531 {
3532 if( bDark )
3533 aSelectionFillCol = COL_GRAY;
3534 else if ( bBright )
3535 {
3536 aSelectionFillCol = COL_BLACK;
3538 nPercent = 0;
3539 }
3540 else
3541 nPercent = 35; // selected, pressed or checked ( very dark )
3542 }
3543 else
3544 {
3545 if( bDark )
3546 aSelectionFillCol = COL_LIGHTGRAY;
3547 else if ( bBright )
3548 {
3549 aSelectionFillCol = COL_BLACK;
3551 if( highlight == 3 )
3552 nPercent = 80;
3553 else
3554 nPercent = 0;
3555 }
3556 else
3557 nPercent = 70; // selected ( dark )
3558 }
3559 }
3560
3561 GetOutDev()->SetFillColor( aSelectionFillCol );
3562
3563 if( bDark )
3564 {
3565 GetOutDev()->DrawRect( aRect );
3566 }
3567 else
3568 {
3569 tools::Polygon aPoly( aRect );
3570 tools::PolyPolygon aPolyPoly( aPoly );
3571 GetOutDev()->DrawTransparent( aPolyPoly, nPercent );
3572 }
3573
3574 GetOutDev()->SetFillColor( oldFillCol );
3575 GetOutDev()->SetLineColor( oldLineCol );
3576}
3577
3579{
3580 // check for scrollbars
3581 VclPtr< vcl::Window > pChild = mpWindowImpl->mpFirstChild;
3582 while( pChild )
3583 {
3584 if( pChild->GetType() == WindowType::SCROLLBAR )
3585 return true;
3586 else
3587 pChild = pChild->mpWindowImpl->mpNext;
3588 }
3589 return false;
3590}
3591
3592void Window::ImplMirrorFramePos( Point &pt ) const
3593{
3594 pt.setX( mpWindowImpl->mpFrame->maGeometry.width()-1-pt.X() );
3595}
3596
3597// frame based modal counter (dialogs are not modal to the whole application anymore)
3599{
3600 return (mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrameData->mnModalMode != 0);
3601}
3602
3604{
3605 vcl::Window* pFrameWindow = mpWindowImpl->mpFrameWindow;
3606 vcl::Window* pParent = pFrameWindow;
3607 while( pFrameWindow )
3608 {
3609 pFrameWindow->mpWindowImpl->mpFrameData->mnModalMode++;
3610 while( pParent && pParent->mpWindowImpl->mpFrameWindow == pFrameWindow )
3611 {
3612 pParent = pParent->GetParent();
3613 }
3614 pFrameWindow = pParent ? pParent->mpWindowImpl->mpFrameWindow.get() : nullptr;
3615 }
3616}
3618{
3619 vcl::Window* pFrameWindow = mpWindowImpl->mpFrameWindow;
3620 vcl::Window* pParent = pFrameWindow;
3621 while( pFrameWindow )
3622 {
3623 pFrameWindow->mpWindowImpl->mpFrameData->mnModalMode--;
3624 while( pParent && pParent->mpWindowImpl->mpFrameWindow == pFrameWindow )
3625 {
3626 pParent = pParent->GetParent();
3627 }
3628 pFrameWindow = pParent ? pParent->mpWindowImpl->mpFrameWindow.get() : nullptr;
3629 }
3630}
3631
3632void Window::ImplIsInTaskPaneList( bool mbIsInTaskList )
3633{
3634 mpWindowImpl->mbIsInTaskPaneList = mbIsInTaskList;
3635}
3636
3638{
3639 mpWindowImpl->mpFrameWindow->CallEventListeners( bIconified ? VclEventId::WindowMinimize : VclEventId::WindowNormalize );
3640 // #109206# notify client window as well to have toolkit topwindow listeners notified
3641 if( mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow && mpWindowImpl->mpFrameWindow != mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow )
3642 mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow->CallEventListeners( bIconified ? VclEventId::WindowMinimize : VclEventId::WindowNormalize );
3643}
3644
3646{
3647 bool bRet = false;
3649 while( pFrameWin )
3650 {
3651 if( pFrameWin != mpWindowImpl->mpFrameWindow )
3652 {
3653 bool bDecorated = false;
3654 VclPtr< vcl::Window > pChildFrame = pFrameWin->ImplGetWindow();
3655 // #i15285# unfortunately WB_MOVEABLE is the same as WB_TABSTOP which can
3656 // be removed for ToolBoxes to influence the keyboard accessibility
3657 // thus WB_MOVEABLE is no indicator for decoration anymore
3658 // but FloatingWindows carry this information in their TitleType...
3659 // TODO: avoid duplicate WinBits !!!
3660 if( pChildFrame && pChildFrame->ImplIsFloatingWindow() )
3661 bDecorated = static_cast<FloatingWindow*>(pChildFrame.get())->GetTitleType() != FloatWinTitleType::NONE;
3662 if( bDecorated || (pFrameWin->mpWindowImpl->mnStyle & (WB_MOVEABLE | WB_SIZEABLE) ) )
3663 if( pChildFrame && pChildFrame->IsVisible() && pChildFrame->IsActive() )
3664 {
3665 if( ImplIsChild( pChildFrame, true ) )
3666 {
3667 bRet = true;
3668 break;
3669 }
3670 }
3671 }
3672 pFrameWin = pFrameWin->mpWindowImpl->mpFrameData->mpNextFrame;
3673 }
3674 return bRet;
3675}
3676
3678{
3679 return mpWindowImpl->mpFrame->GetInputLanguage();
3680}
3681
3682void Window::EnableNativeWidget( bool bEnable )
3683{
3684 static const char* pNoNWF = getenv( "SAL_NO_NWF" );
3685 if( pNoNWF && *pNoNWF )
3686 bEnable = false;
3687
3688 if( bEnable != ImplGetWinData()->mbEnableNativeWidget )
3689 {
3691
3692 // send datachanged event to allow for internal changes required for NWF
3693 // like clipmode, transparency, etc.
3695 CompatDataChanged( aDCEvt );
3696
3697 // sometimes the borderwindow is queried, so keep it in sync
3698 if( mpWindowImpl->mpBorderWindow )
3699 mpWindowImpl->mpBorderWindow->ImplGetWinData()->mbEnableNativeWidget = bEnable;
3700 }
3701
3702 // push down, useful for compound controls
3703 VclPtr< vcl::Window > pChild = mpWindowImpl->mpFirstChild;
3704 while( pChild )
3705 {
3706 pChild->EnableNativeWidget( bEnable );
3707 pChild = pChild->mpWindowImpl->mpNext;
3708 }
3709}
3710
3712{
3714}
3715
3716Reference< css::rendering::XCanvas > WindowOutputDevice::ImplGetCanvas( bool bSpriteCanvas ) const
3717{
3718 // Feed any with operating system's window handle
3719
3720 // common: first any is VCL pointer to window (for VCL canvas)
3721 Sequence< Any > aArg{
3722 Any(reinterpret_cast<sal_Int64>(this)),
3723 Any(css::awt::Rectangle( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight )),
3724 Any(mxOwnerWindow->mpWindowImpl->mbAlwaysOnTop),
3725 Any(Reference< css::awt::XWindow >(
3727 UNO_QUERY )),
3729 };
3730
3731 Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
3732
3733 // Create canvas instance with window handle
3734
3736 css::rendering::CanvasFactory::create( xContext ) );
3737 Reference<XMultiComponentFactory> xCanvasFactory(xStaticCanvasFactory.get());
3738 Reference< css::rendering::XCanvas > xCanvas;
3739
3740 if(xCanvasFactory.is())
3741 {
3742#ifdef _WIN32
3743 // see #140456# - if we're running on a multiscreen setup,
3744 // request special, multi-screen safe sprite canvas
3745 // implementation (not DX5 canvas, as it cannot cope with
3746 // surfaces spanning multiple displays). Note: canvas
3747 // (without sprite) stays the same)
3748 const sal_uInt32 nDisplay = static_cast< WinSalFrame* >( mxOwnerWindow->mpWindowImpl->mpFrame )->mnDisplay;
3749 if( nDisplay >= Application::GetScreenCount() )
3750 {
3751 xCanvas.set( xCanvasFactory->createInstanceWithArgumentsAndContext(
3752 bSpriteCanvas ?
3753 OUString( "com.sun.star.rendering.SpriteCanvas.MultiScreen" ) :
3754 OUString( "com.sun.star.rendering.Canvas.MultiScreen" ),
3755 aArg,
3756 xContext ),
3757 UNO_QUERY );
3758
3759 }
3760 else
3761#endif
3762 {
3763 xCanvas.set( xCanvasFactory->createInstanceWithArgumentsAndContext(
3764 bSpriteCanvas ?
3765 OUString( "com.sun.star.rendering.SpriteCanvas" ) :
3766 OUString( "com.sun.star.rendering.Canvas" ),
3767 aArg,
3768 xContext ),
3769 UNO_QUERY );
3770
3771 }
3772 }
3773
3774 // no factory??? Empty reference, then.
3775 return xCanvas;
3776}
3777
3779{
3780 return OUString();
3781}
3782
3784{
3785 return Selection( 0, 0 );
3786}
3787
3788namespace
3789{
3790 using namespace com::sun::star;
3791
3792 uno::Reference<accessibility::XAccessibleEditableText> lcl_GetxText(vcl::Window *pFocusWin)
3793 {
3794 uno::Reference<accessibility::XAccessibleEditableText> xText;
3795 try
3796 {
3797 uno::Reference< accessibility::XAccessible > xAccessible( pFocusWin->GetAccessible() );
3798 if (xAccessible.is())
3799 xText = FindFocusedEditableText(xAccessible->getAccessibleContext());
3800 }
3801 catch(const uno::Exception&)
3802 {
3803 TOOLS_WARN_EXCEPTION( "vcl.gtk3", "Exception in getting input method surrounding text");
3804 }
3805 return xText;
3806 }
3807}
3808
3809// this is a rubbish implementation using a11y, ideally all subclasses implementing
3810// GetSurroundingText/GetSurroundingTextSelection should implement this and then this
3811// should be removed in favor of a stub that returns false
3813{
3814 uno::Reference<accessibility::XAccessibleEditableText> xText = lcl_GetxText(this);
3815 if (xText.is())
3816 {
3817 sal_Int32 nPosition = xText->getCaretPosition();
3818 // #i111768# range checking
3819 sal_Int32 nDeletePos = rSelection.Min();
3820 sal_Int32 nDeleteEnd = rSelection.Max();
3821 if (nDeletePos < 0)
3822 nDeletePos = 0;
3823 if (nDeleteEnd < 0)
3824 nDeleteEnd = 0;
3825 if (nDeleteEnd > xText->getCharacterCount())
3826 nDeleteEnd = xText->getCharacterCount();
3827
3828 xText->deleteText(nDeletePos, nDeleteEnd);
3829 //tdf91641 adjust cursor if deleted chars shift it forward (normal case)
3830 if (nDeletePos < nPosition)
3831 {
3832 if (nDeleteEnd <= nPosition)
3833 nPosition = nPosition - (nDeleteEnd - nDeletePos);
3834 else
3835 nPosition = nDeletePos;
3836
3837 if (xText->getCharacterCount() >= nPosition)
3838 xText->setCaretPosition( nPosition );
3839 }
3840 return true;
3841 }
3842
3843 return false;
3844}
3845
3847{
3849}
3850
3852{
3853}
3854
3856{
3857
3858 return mpWindowImpl->mpFrame ? mpWindowImpl->mpFrame->GetSystemData() : nullptr;
3859}
3860
3862{
3863 return mpWindowImpl->mpFrameData->mpBuffer;
3864}
3865
3867{
3868 if (bRequest)
3869 {
3870 mpWindowImpl->mpFrameData->mpBuffer = VclPtrInstance<VirtualDevice>();
3871 // Make sure that the buffer size matches the frame size.
3872 mpWindowImpl->mpFrameData->mpBuffer->SetOutputSizePixel(mpWindowImpl->mpFrameWindow->GetOutputSizePixel());
3873 }
3874 else
3875 mpWindowImpl->mpFrameData->mpBuffer.reset();
3876}
3877
3878/*
3879 * The rationale here is that we moved destructors to
3880 * dispose and this altered a lot of code paths, that
3881 * are better left unchanged for now.
3882 */
3884{
3885 if (!mpWindowImpl || mpWindowImpl->mbInDispose)
3887 else
3888 GetFocus();
3889}
3890
3892{
3893 if (!mpWindowImpl || mpWindowImpl->mbInDispose)
3895 else
3896 LoseFocus();
3897}
3898
3900{
3901 if (!mpWindowImpl || mpWindowImpl->mbInDispose)
3902 Window::StateChanged(nStateChange);
3903 else
3904 StateChanged(nStateChange);
3905}
3906
3908{
3909 if (!mpWindowImpl || mpWindowImpl->mbInDispose)
3910 Window::DataChanged(rDCEvt);
3911 else
3912 DataChanged(rDCEvt);
3913}
3914
3916{
3917 if (!mpWindowImpl || mpWindowImpl->mbInDispose)
3918 return Window::PreNotify( rNEvt );
3919 else
3920 return PreNotify( rNEvt );
3921}
3922
3924{
3925 if (!mpWindowImpl || mpWindowImpl->mbInDispose)
3926 return Window::EventNotify( rNEvt );
3927 else
3928 return EventNotify( rNEvt );
3929}
3930
3931void Window::set_id(const OUString& rID)
3932{
3933 mpWindowImpl->maID = rID;
3934}
3935
3936const OUString& Window::get_id() const
3937{
3938 static OUString empty;
3939 return mpWindowImpl ? mpWindowImpl->maID : empty;
3940}
3941
3943{
3945}
3946
3949 mxOwnerWindow(&rOwnerWindow)
3950{
3951 assert(mxOwnerWindow);
3952}
3953
3955{
3956 disposeOnce();
3957}
3958
3960{
3961 assert((!mxOwnerWindow || mxOwnerWindow->isDisposed()) && "This belongs to the associated window and must be disposed after it");
3963 // need to do this after OutputDevice::dispose so that the call to WindowOutputDevice::ReleaseGraphics
3964 // can release the graphics properly
3966}
3967
3968css::awt::DeviceInfo WindowOutputDevice::GetDeviceInfo() const
3969{
3970 css::awt::DeviceInfo aInfo = GetCommonDeviceInfo(mxOwnerWindow->GetSizePixel());
3971 mxOwnerWindow->GetBorder(aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset);
3972 return aInfo;
3973}
3974
3975
3976} /* namespace vcl */
3977
3978/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SystemTextColorFlags
uno::Reference< accessibility::XAccessibleEditableText > FindFocusedEditableText(uno::Reference< accessibility::XAccessibleContext > const &xContext)
AnyEventRef aEvent
BorderWindowStyle
Definition: brdwin.hxx:33
const StyleSettings & GetStyleSettings() const
static bool GetLayoutRTL()
static unsigned int GetScreenCount()
Get the number of screens available for the display.
Definition: svapp.cxx:1342
static void Abort(const OUString &rErrorText)
Ends the program prematurely with an error message.
Definition: svapp.cxx:257
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
Remove user event based on event ID.
Definition: svapp.cxx:1146
static void RemoveMouseAndKeyEvents(vcl::Window *pWin)
Remove mouse and keypress events from a window... any also zoom and scroll events if the platform sup...
Definition: svapp.cxx:1099
static Help * GetHelp()
Gets the application's help.
Definition: svapp.cxx:1484
static bool IsHeadlessModeEnabled()
Determines if headless mode is enabled.
Definition: svapp.cxx:1671
sal_uInt8 GetLuminance() const
void RGBtoHSB(sal_uInt16 &nHue, sal_uInt16 &nSaturation, sal_uInt16 &nBrightness) const
bool IsDark() const
static Color HSBtoRGB(sal_uInt16 nHue, sal_uInt16 nSaturation, sal_uInt16 nBrightness)
void RemoveWindow(const vcl::Window *pWin)
Definition: dockmgr.cxx:394
ImplDockingWindowWrapper * GetDockingWindowWrapper(const vcl::Window *pWin)
Definition: dockmgr.cxx:280
HelpEventMode GetMode() const
Definition: event.hxx:208
const Point & GetMousePosPixel() const
Definition: event.hxx:207
Definition: help.hxx:61
virtual bool Start(const OUString &rHelpId, weld::Widget *pWidget=nullptr)
Definition: help.cxx:58
virtual OUString GetHelpText(const OUString &aHelpURL, const weld::Widget *pWidget)
Definition: help.cxx:72
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
Definition: help.cxx:180
static void ShowBalloon(vcl::Window *pParent, const Point &rScreenPos, const tools::Rectangle &, const OUString &rHelpText)
Definition: help.cxx:157
VclPtr< vcl::Window > mpMenuBarWindow
Definition: brdwin.hxx:86
ImplDockingWindowWrapper.
void Tracking(const TrackingEvent &rTEvt)
Definition: dockmgr.cxx:562
InputContextFlags GetOptions() const
Definition: inputctx.hxx:59
const vcl::Font & GetFont() const
Definition: inputctx.hxx:56
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:57
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
tools::Rectangle GetOutputRectPixel() const
Definition: outdev.hxx:324
const vcl::Font & GetFont() const
Definition: outdev.hxx:529
sal_Int32 mnDPIY
Definition: outdev.hxx:213
virtual void ReleaseGraphics(bool bRelease=true)=0
Release the graphics device, and remove it from the graphics device list.
SAL_DLLPRIVATE bool ImplIsAntiparallel() const
Definition: outdev.cxx:655
tools::Long mnOutOffY
Output offset for device output in pixel (pseudo window offset within window system's frames)
Definition: outdev.hxx:209
css::awt::DeviceInfo GetCommonDeviceInfo(Size const &aDevSize) const
Definition: outdev.cxx:716
void SetFont(const vcl::Font &rNewFont)
Definition: outdev/font.cxx:56
bool mbDevOutput
Definition: outdev.hxx:244
SAL_DLLPRIVATE tools::Rectangle ImplLogicToDevicePixel(const tools::Rectangle &rLogicRect) const
Convert a logical rectangle to a rectangle in physical device pixel units.
Definition: map.cxx:347
std::shared_ptr< ImplFontCache > mxFontCache
Definition: outdev.hxx:262
virtual void dispose() override
Definition: outdev.cxx:144
virtual bool AcquireGraphics() const =0
Acquire a graphics device that the output device uses to draw on.
tools::Long mnOutOffX
Output offset for device output in pixel (pseudo window offset within window system's frames)
Definition: outdev.hxx:207
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
Definition: map.cxx:1123
std::unique_ptr< ImplOutDevData > mpOutDevData
Definition: outdev.hxx:189
std::shared_ptr< vcl::font::PhysicalFontCollection > mxFontCollection
Definition: outdev.hxx:261
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:50
void SetLineColor()
Definition: line.cxx:37
virtual void ImplReleaseFonts()
bool mbInitLineColor
Definition: outdev.hxx:248
tools::Long mnOutWidth
Definition: outdev.hxx:210
SalGraphics * mpGraphics
Graphics context to draw on.
Definition: outdev.hxx:182
bool mbInitFont
Definition: outdev.hxx:250
VclPtr< OutputDevice > mpNextGraphics
Next output device in list.
Definition: outdev.hxx:184
bool mbInitTextColor
Definition: outdev.hxx:251
bool mbInitClipRegion
Definition: outdev.hxx:252
RasterOp meRasterOp
Definition: outdev.hxx:232
SAL_DLLPRIVATE void ImplDisposeCanvas()
Definition: outdev.cxx:809
void SetFillColor()
Definition: fill.cxx:29
css::uno::Any GetSystemGfxDataAny() const
Definition: outdev.cxx:286
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:892
AntialiasingFlags mnAntialiasing
Definition: outdev.hxx:237
SAL_DLLPRIVATE void ReMirror(Point &rPoint) const
Definition: outdev.cxx:671
virtual bool HasMirroredGraphics() const
Definition: outdev.cxx:703
const Color & GetLineColor() const
Definition: outdev.hxx:510
sal_Int32 mnDPIScalePercentage
For HiDPI displays, we want to draw elements for a percentage larger.
Definition: outdev.hxx:214
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
std::optional< AllSettings > moSettings
Definition: outdev.hxx:234
OutDevType GetOutDevType() const
Definition: outdev.hxx:406
bool SelectClipRegion(const vcl::Region &, SalGraphics *pGraphics=nullptr)
void DrawTransparent(const tools::PolyPolygon &rPolyPoly, sal_uInt16 nTransparencePercent)
sal_Int32 mnDPIX
Definition: outdev.hxx:212
bool mbInitFillColor
Definition: outdev.hxx:249
VclPtr< OutputDevice > mpPrevGraphics
Previous output device in list.
Definition: outdev.hxx:183
virtual void CopyDeviceArea(SalTwoRect &aPosAry, bool bWindowInvalidate)
Definition: outdev.cxx:579
tools::Long mnOutHeight
Definition: outdev.hxx:211
bool IsMapModeEnabled() const
Definition: outdev.hxx:1551
const Color & GetFillColor() const
Definition: outdev.hxx:515
constexpr sal_uInt32 leftDecoration() const
Definition: salgeom.hxx:46
constexpr sal_uInt32 bottomDecoration() const
Definition: salgeom.hxx:52
constexpr sal_uInt32 topDecoration() const
Definition: salgeom.hxx:48
constexpr sal_uInt32 rightDecoration() const
Definition: salgeom.hxx:50
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:115
virtual void SetInputContext(SalInputContext *pContext)=0
virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle)=0
void SetModalHierarchyHdl(const Link< bool, void > &rLink)
Definition: salframe.hxx:299
void SetCallback(vcl::Window *pWindow, SALFRAMEPROC pProc)
Definition: salvtables.cxx:99
virtual void EndExtTextInput(EndExtTextInputFlags nFlags)=0
virtual void SetXORMode(bool bSet, bool bInvertOnly)=0
void setAntiAlias(bool bNew)
Definition: salgdi.hxx:83
void CopyBits(const SalTwoRect &rPosAry, const OutputDevice &rOutDev)
void CopyArea(tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX, tools::Long nSrcY, tools::Long nSrcWidth, tools::Long nSrcHeight, const OutputDevice &rOutDev)
virtual void DestroyFrame(SalFrame *pFrame)=0
virtual SalFrame * CreateFrame(SalFrame *pParent, SalFrameStyleFlags nStyle)=0
virtual SalFrame * CreateChildFrame(SystemParentData *pParent, SalFrameStyleFlags nStyle)=0
tools::Long Min() const
tools::Long Max() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
sal_Int32 GetTitleHeight() const
const Color & GetWindowColor() const
const Color & GetWindowTextColor() const
static sal_Int32 GetBorderSize()
const Color & GetHighlightColor() const
const Color & GetFaceColor() const
const vcl::Font & GetAppFont() const
const vcl::Font & GetTitleFont() const
const Color & GetButtonTextColor() const
const Size & GetMinOutputSizePixel() const
Definition: syswin.hxx:175
SAL_DLLPRIVATE bool ImplIsInTaskPaneList(vcl::Window *pWin)
Definition: syswin.cxx:955
const Size & GetMaxOutputSizePixel() const
Definition: syswin.cxx:397
TaskPaneList * GetTaskPaneList()
Definition: syswin.cxx:240
void RemoveWindow(vcl::Window *pWindow)
void SetPriority(TaskPriority ePriority)
Definition: scheduler.cxx:607
void SetInvokeHandler(const Link< Timer *, void > &rLink)
Definition: timer.hxx:56
A toolbar: contains all those icons, typically below the menu bar.
Definition: toolbox.hxx:74
SAL_DLLPRIVATE ImplToolBoxPrivateData * ImplGetToolBoxPrivateData() const
Definition: toolbox.hxx:250
virtual css::uno::Reference< css::awt::XWindowPeer > GetWindowInterface(vcl::Window *pWindow)=0
virtual void WindowDestroyed(vcl::Window *pWindow)=0
static UnoWrapperBase * GetUnoWrapper(bool bCreateIfNotExists=true)
Get the application's UNO wrapper object.
Definition: svapp.cxx:1605
virtual void SetWindowInterface(vcl::Window *pWindow, const css::uno::Reference< css::awt::XWindowPeer > &xIFace)=0
A construction helper for a temporary VclPtr.
Definition: vclptr.hxx:276
void disposeAndClear()
Definition: vclptr.hxx:200
void clear()
Definition: vclptr.hxx:190
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
static VclPtr< reference_type > Create(Arg &&... arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
bool isDisposed() const
virtual void dispose()
const Color & GetColor() const
Definition: wall.hxx:71
bool IsBitmap() const
Definition: wall.cxx:189
bool IsGradient() const
Definition: wall.cxx:213
bool mbCompoundControlHasFocus
Definition: window.h:369
sal_Int32 mnGridTopAttach
Definition: window.h:312
bool mbToolBox
Definition: window.h:377
bool mbSysWin
Definition: window.h:322
bool mbFocusVisible
Definition: window.h:359
bool mbFill
Definition: window.h:389
tools::Long mnAbsScreenX
Definition: window.h:276
bool mbFrame
Definition: window.h:319
ControlPart mnNativeBackground
Definition: window.h:298
bool mbAlwaysOnTop
Definition: window.h:367
bool mbNonHomogeneous
Definition: window.h:391
bool mbVisible
Definition: window.h:327
bool mbDisabled
Definition: window.h:328
bool mbMouseButtonUp
Definition: window.h:341
bool mbClipChildren
Definition: window.h:353
VclPtr< vcl::Window > mpRealParent
Definition: window.h:236
bool mbCreatedWithToolkit
Definition: window.h:376
bool mbInitChildRegion
Definition: window.h:351
bool mbIsInTaskPaneList
Definition: window.h:382
bool mbOverlapWin
Definition: window.h:321
bool mbWinRegion
Definition: window.h:352
bool mbExpand
Definition: window.h:388
WindowType mnType
Definition: window.h:297
VclPtr< vcl::Window > mpNext
Definition: window.h:242
bool mbExtTextInput
Definition: window.h:373
std::unique_ptr< vcl::Region > mpChildClipRegion
Definition: window.h:292
WinBits mnStyle
Definition: window.h:294
ActivateModeFlags mnActivateMode
Definition: window.h:303
bool mbClipSiblings
Definition: window.h:354
bool mbActive
Definition: window.h:332
VclPtr< vcl::Window > mpBorderWindow
Definition: window.h:233
tools::Long mnX
Definition: window.h:274
VclPackType mePackType
Definition: window.h:308
VclPtr< vcl::Window > mpFirstChild
Definition: window.h:237
bool mbDefPos
Definition: window.h:345
bool mbInDispose
Definition: window.h:372
bool mbLOKParentNotifier
Definition: window.h:398
Fraction maZoom
Definition: window.h:258
bool mbInHideFocus
Definition: window.h:364
VclPtr< vcl::Window > mpParent
Definition: window.h:235
sal_Int32 mnTopBorder
Definition: window.h:267
bool mbInitWinClipRegion
Definition: window.h:350
bool mbMouseButtonDown
Definition: window.h:340
bool mbVexpand
Definition: window.h:387
sal_Int32 mnGridLeftAttach
Definition: window.h:311
SalFrame * mpFrame
Definition: window.h:229
bool mbMenuFloatingWindow
Definition: window.h:380
bool mbMouseTransparent
Definition: window.h:357
sal_Int32 mnGridHeight
Definition: window.h:310
VclPtr< vcl::Window > mpOverlapWindow
Definition: window.h:232
sal_Int32 mnOptimalWidthCache
Definition: window.h:272
bool mbCallResize
Definition: window.h:348
bool mbDockWin
Definition: window.h:324
bool mbInPaint
Definition: window.h:339
bool mbTrackVisible
Definition: window.h:360
SalObject * mpSysObj
Definition: window.h:230
bool mbControlBackground
Definition: window.h:366
VclPtr< vcl::WindowOutputDevice > mxOutDev
Definition: window.h:226
bool mbFakeFocusSet
Definition: window.h:385
int mnEventListenersIteratingCount
Definition: window.h:247
bool mbKeyUp
Definition: window.h:343
double mfPartialScrollY
Definition: window.h:260
bool mbUseFrameData
Definition: window.h:399
bool mbSecondary
Definition: window.h:390
WindowExtendedStyle mnExtendedStyle
Definition: window.h:296
VclPtr< vcl::Window > mpFrameWindow
Definition: window.h:231
bool mbDrawSelectionBackground
Definition: window.h:381
ImplFrameData * mpFrameData
Definition: window.h:228
bool mbPaintDisabled
Definition: window.h:370
sal_Int32 mnPadding
Definition: window.h:309
vcl::Region maWinClipRegion
Definition: window.h:290
sal_Int32 mnLeftBorder
Definition: window.h:266
vcl::Region * mpPaintRegion
Definition: window.h:293
sal_Int32 mnOptimalHeightCache
Definition: window.h:273
sal_Int32 mnWidthRequest
Definition: window.h:270
bool mbPaintTransparent
Definition: window.h:356
bool mbKeyInput
Definition: window.h:342
bool mbNativeFocusVisible
Definition: window.h:362
bool mbFloatWin
Definition: window.h:325
bool mbNoPtrVisible
Definition: window.h:337
bool mbOverlapVisible
Definition: window.h:375
ImplPaintFlags mnPaintFlags
Definition: window.h:300
double mfPartialScrollX
Definition: window.h:259
bool mbHexpand
Definition: window.h:386
VCLXWindow * mpVCLXWindow
Definition: window.h:288
sal_Int32 mnMarginLeft
Definition: window.h:315
bool mbDlgCtrlStart
Definition: window.h:358
VclPtr< vcl::Window > mpClientWindow
Definition: window.h:234
bool mbDoubleBufferingRequested
Definition: window.h:392
VclPtr< vcl::Window > mpDlgCtrlDownWindow
Definition: window.h:245
GetFocusFlags mnGetFocusFlags
Definition: window.h:301
sal_uInt16 mnWaitCount
Definition: window.h:299
bool mbToolbarFloatingWindow
Definition: window.h:383
vcl::Region maWinRegion
Definition: window.h:289
ParentClipMode mnParentClipMode
Definition: window.h:302
bool mbSplitter
Definition: window.h:378
sal_Int32 mnMarginRight
Definition: window.h:316
Color maControlBackground
Definition: window.h:265
std::unique_ptr< ImplAccessibleInfos > mpAccessibleInfos
Definition: window.h:287
bool mbNoParentUpdate
Definition: window.h:331
bool mbInFocusHdl
Definition: window.h:374
int mnChildEventListenersIteratingCount
Definition: window.h:250
std::unique_ptr< ImplWinData > mpWinData
Definition: window.h:227
vcl::Cursor * mpCursor
Definition: window.h:256
sal_Int32 mnHeightRequest
Definition: window.h:271
VclPtr< vcl::Window > mpNextOverlap
Definition: window.h:243
bool mbDialog
Definition: window.h:323
bool mbCompoundControl
Definition: window.h:368
VclAlign meHalign
Definition: window.h:306
bool mbDefSize
Definition: window.h:346
bool mbReallyShown
Definition: window.h:334
WindowImpl(const WindowImpl &)=delete
bool mbCallMove
Definition: window.h:347
AlwaysInputMode meAlwaysInputMode
Definition: window.h:305
bool mbSuppressAccessibilityEvents
Definition: window.h:379
WinBits mnPrevStyle
Definition: window.h:295
VclPtr< vcl::Window > mpLastChild
Definition: window.h:238
bool mbNoUpdate
Definition: window.h:330
tools::Long mnY
Definition: window.h:275
bool mbUseNativeFocus
Definition: window.h:361
bool mbChildTransparent
Definition: window.h:355
sal_Int32 mnMarginBottom
Definition: window.h:318
bool mbAllResize
Definition: window.h:371
vcl::LOKWindowId mnLOKWindowId
ID of this specific window.
Definition: window.h:397
sal_Int32 mnGridWidth
Definition: window.h:313
bool mbPushButton
Definition: window.h:326
bool mbInShowFocus
Definition: window.h:363
sal_Int32 mnBorderWidth
Definition: window.h:314
Color maControlForeground
Definition: window.h:264
VclPtr< vcl::Window > mpPrev
Definition: window.h:241
sal_Int32 mnRightBorder
Definition: window.h:268
DialogControlFlags mnDlgCtrlFlags
Definition: window.h:304
sal_Int32 mnMarginTop
Definition: window.h:317
bool mbHelpTextDynamic
Definition: window.h:384
bool mbCommand
Definition: window.h:344
bool mbWaitSystemResize
Definition: window.h:349
~WindowImpl()
Definition: window.cxx:743
bool mbReallyVisible
Definition: window.h:333
bool mbPaintFrame
Definition: window.h:338
bool mbInInitShow
Definition: window.h:335
PointerStyle maPointer
Definition: window.h:257
VclPtr< vcl::Window > mpLastOverlap
Definition: window.h:240
VclPtr< vcl::Window > mpLastFocusWindow
Definition: window.h:244
bool mbInputDisabled
Definition: window.h:329
sal_Int32 mnBottomBorder
Definition: window.h:269
VclAlign meValign
Definition: window.h:307
VclPtr< vcl::Window > mpFirstOverlap
Definition: window.h:239
bool mbBorderWin
Definition: window.h:320
bool mbChildPtrOverwrite
Definition: window.h:336
bool mbControlForeground
Definition: window.h:365
const vcl::ILibreOfficeKitNotifier * mpLOKNotifier
To emit the LOK callbacks eg. for dialog tunneling.
Definition: window.h:396
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
void put(const char *pPropName, const OUString &rPropValue)
ScopedJsonWriterArray startArray(const char *)
ScopedJsonWriterStruct startStruct()
tools::Long AdjustTop(tools::Long nVertMoveDelta)
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
constexpr Point TopRight() const
constexpr tools::Long GetHeight() const
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
tools::Rectangle & Intersection(const tools::Rectangle &rRect)
constexpr tools::Long Left() const
constexpr bool IsEmpty() const
constexpr Point BottomLeft() const
static bool IsFuzzing()
SAL_DLLPRIVATE void ImplShow()
Definition: cursor.cxx:308
Similar to DeleteOnDeinit, the DeleteUnoReferenceOnDeinit template class makes sure that a static UNO...
Definition: lazydelete.hxx:114
css::uno::Reference< I > get()
Definition: lazydelete.hxx:121
void SetFontSize(const Size &)
Definition: font/font.cxx:149
const OUString & GetFamilyName() const
Definition: font/font.cxx:904
const Size & GetFontSize() const
Definition: font/font.cxx:907
sal_uInt16 GetCode() const
Definition: keycod.hxx:49
sal_uInt16 GetModifier() const
Definition: keycod.hxx:52
void Intersect(const tools::Rectangle &rRegion)
Definition: region.cxx:583
bool IsEmpty() const
Definition: region.cxx:229
tools::Rectangle GetBoundRect() const
Definition: region.cxx:1219
void Exclude(const tools::Rectangle &rRegion)
Definition: region.cxx:680
virtual void CopyDeviceArea(SalTwoRect &aPosAry, bool bWindowInvalidate) override
Definition: window.cxx:1241
virtual void DrawOutDevDirectProcess(const OutputDevice &rSrcDev, SalTwoRect &rPosAry, SalGraphics *pSrcGraphics) override
Definition: window.cxx:1282
virtual bool UsePolyPolygonForComplexGradient() override
Definition: window.cxx:3846
virtual void dispose() override
Definition: window.cxx:3959
virtual void ReleaseGraphics(bool bRelease=true) override
Release the graphics device, and remove it from the graphics device list.
Definition: window.cxx:887
void Flush() override
Definition: window.cxx:2968
virtual const OutputDevice * DrawOutDevDirectCheck(const OutputDevice &rSrcDev) const override
Definition: window.cxx:1267
VclPtr< vcl::Window > mxOwnerWindow
Definition: windowdev.hxx:77
virtual ~WindowOutputDevice() override
Definition: window.cxx:3954
WindowOutputDevice(vcl::Window &rOwnerWindow)
Definition: window.cxx:3947
virtual bool AcquireGraphics() const override
Acquire a graphics device that the output device uses to draw on.
Definition: window.cxx:820
virtual css::uno::Reference< css::rendering::XCanvas > ImplGetCanvas(bool bSpriteCanvas) const override
Definition: window.cxx:3716
bool CanEnableNativeWidget() const override
Determine if native widgets can be enabled.
Definition: window.cxx:582
Color GetBackgroundColor() const override
Definition: window.cxx:577
css::awt::DeviceInfo GetDeviceInfo() const override
Definition: window.cxx:3968
constexpr sal_Int32 y() const
constexpr sal_Int32 x() const
constexpr sal_Int32 width() const
static SAL_DLLPRIVATE void ImplInitAppFontData(vcl::Window const *pWindow)
Definition: window.cxx:1185
Point AbsoluteScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2869
Point OutputToScreenPixel(const Point &rPos) const
Definition: window.cxx:2810
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: window.cxx:140
const Wallpaper & GetBackground() const
Definition: window3.cxx:63
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
Definition: window3.cxx:66
void SetStyle(WinBits nStyle)
Definition: window.cxx:1966
SAL_DLLPRIVATE void ImplPosSizeWindow(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags)
Definition: window.cxx:1462
void SetFont(const vcl::Font &rNewFont)
Definition: window3.cxx:59
void SetCursorRect(const tools::Rectangle *pRect=nullptr, tools::Long nExtTextInputWidth=0)
Definition: window.cxx:2116
void SetUpdateMode(bool bUpdate)
Definition: window.cxx:2974
SAL_DLLPRIVATE bool ImplIsWindowOrChild(const vcl::Window *pWindow, bool bSystemWindow=false) const
Definition: stacking.cxx:699
SAL_DLLPRIVATE tools::Rectangle ImplOutputToUnmirroredAbsoluteScreenPixel(const tools::Rectangle &rRect) const
Definition: window.cxx:2879
static SAL_DLLPRIVATE void ImplNewInputContext()
Definition: window.cxx:1744
void SetActivateMode(ActivateModeFlags nMode)
Definition: window.cxx:2639
SAL_DLLPRIVATE void ImplGrabFocus(GetFocusFlags nFlags)
Definition: mouse.cxx:195
bool IsNativeWidgetEnabled() const
Definition: window.cxx:3711
void SetInputContext(const InputContext &rInputContext)
Definition: window.cxx:2080
SAL_DLLPRIVATE void ImplScroll(const tools::Rectangle &rRect, tools::Long nHorzScroll, tools::Long nVertScroll, ScrollFlags nFlags)
Definition: paint.cxx:1636
bool IsReallyVisible() const
Definition: window2.cxx:1138
virtual void GetFocus()
Definition: window.cxx:1845
void SimulateKeyPress(sal_uInt16 nKeyCode) const
Definition: window.cxx:1804
vcl::Window * GetParent() const
Definition: window2.cxx:1128
virtual void RequestHelp(const HelpEvent &rHEvt)
Definition: window.cxx:1873
SAL_DLLPRIVATE void ImplStartToTop(ToTopFlags nFlags)
Definition: stacking.cxx:312
virtual void StateChanged(StateChangedType nStateChange)
Definition: window.cxx:1944
virtual Selection GetSurroundingTextSelection() const
Definition: window.cxx:3783
bool IsInputEnabled() const
Definition: window2.cxx:1158
void SetLOKNotifier(const vcl::ILibreOfficeKitNotifier *pNotifier, bool bParent=false)
Interface to register for dialog / window tunneling.
Definition: window.cxx:3185
void DecModalCount()
Definition: window.cxx:3617
bool IsMouseCaptured() const
Definition: mouse.cxx:481
bool HasActiveChildFrame() const
Definition: window.cxx:3645
const InputContext & GetInputContext() const
Definition: window2.cxx:1093
bool HasChildPathFocus(bool bSystemWindow=false) const
Definition: window.cxx:3011
bool IsTracking() const
Definition: window2.cxx:340
SAL_DLLPRIVATE void ImplCallDeactivateListeners(vcl::Window *)
Definition: window.cxx:3404
SAL_DLLPRIVATE bool ImplIsAccessibleCandidate() const
SAL_DLLPRIVATE void ImplClipBoundaries(vcl::Region &rRegion, bool bThis, bool bOverlaps)
tools::Rectangle GetDesktopRectPixel() const
Definition: window.cxx:2803
virtual const Wallpaper & GetDisplayBackground() const
Definition: window.cxx:3074
KeyIndicatorState GetIndicatorState() const
Query the states of keyboard indicators - Caps Lock, Num Lock and Scroll Lock.
Definition: window.cxx:1799
void EndTracking(TrackingEventFlags nFlags=TrackingEventFlags::NONE)
Definition: window2.cxx:293
SAL_DLLPRIVATE void ImplCalcOverlapRegion(const tools::Rectangle &rSourceRect, vcl::Region &rRegion, bool bChildren, bool bSiblings)
LanguageType GetInputLanguage() const
Definition: window.cxx:3677
SAL_DLLPRIVATE void ImplExcludeWindowRegion(vcl::Region &rRegion)
SAL_DLLPRIVATE tools::Rectangle ImplUnmirroredAbsoluteScreenToOutputPixel(const tools::Rectangle &rRect) const
Definition: window.cxx:2898
VclPtr< vcl::Window > GetFocusedWindow() const
Definition: window.cxx:2998
bool IsBackground() const
Definition: window3.cxx:64
const OUString & get_id() const
Get the ID of the window.
Definition: window.cxx:3936
bool IsPaintTransparent() const
Definition: window2.cxx:1068
WindowType GetType() const
Definition: window2.cxx:1005
bool SupportsDoubleBuffering() const
Can the widget derived from this Window do the double-buffering via RenderContext properly?
Definition: window.cxx:3861
SAL_DLLPRIVATE ::std::vector< VclPtr< vcl::Window > > & ImplGetOwnerDrawList()
Definition: window2.cxx:844
virtual void Tracking(const TrackingEvent &rTEvt)
Definition: window.cxx:1936
virtual void Resize()
Definition: window.cxx:1839
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: window.cxx:2428
SAL_DLLPRIVATE void ImplGenerateMouseMove()
Definition: mouse.cxx:157
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1927
SAL_DLLPRIVATE bool ImplIsOverlapWindow() const
Definition: window2.cxx:957
SAL_DLLPRIVATE bool CompatNotify(NotifyEvent &rNEvt)
Definition: window.cxx:3923
SAL_DLLPRIVATE void ImplInitWinClipRegion()
void SetCursor(vcl::Cursor *pCursor)
Definition: window.cxx:3020
SAL_DLLPRIVATE vcl::Window * ImplGetBorderWindow() const
Definition: window2.cxx:901
SAL_DLLPRIVATE bool ImplIsChild(const vcl::Window *pWindow, bool bSystemWindow=false) const
Definition: stacking.cxx:682
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1358
void SetClipboard(css::uno::Reference< css::datatransfer::clipboard::XClipboard > const &xClipboard)
Sets a custom clipboard for the window's frame, instead of creating it on-demand using css::datatrans...
Definition: window.cxx:3442
void GrabFocus()
Definition: window.cxx:2983
bool IsCompoundControl() const
Definition: window2.cxx:1224
void set_id(const OUString &rID)
Sets an ID.
Definition: window.cxx:3931
SAL_DLLPRIVATE void ImplHideAllOverlaps()
Definition: stacking.cxx:403
SAL_DLLPRIVATE void ImplPointToLogic(vcl::RenderContext const &rRenderContext, vcl::Font &rFont) const
Definition: window.cxx:1378
bool HasFocus() const
Definition: window.cxx:2988
void ReleaseLOKNotifier()
Indicate that LOK is not going to use this dialog any more.
Definition: window.cxx:3223
bool GetNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion) const
Query the native control's actual drawing region (including adornment)
Definition: window3.cxx:79
SAL_DLLPRIVATE void ImplInvalidate(const vcl::Region *rRegion, InvalidateFlags nFlags)
Definition: paint.cxx:780
void remove_mnemonic_label(FixedText *pLabel)
Definition: window2.cxx:2018
void SetHelpHdl(const Link< vcl::Window &, bool > &rLink)
Definition: window.cxx:1865
vcl::Window * GetAccessibleParentWindow() const
virtual Point GetPosPixel() const
Definition: window.cxx:2798
void SetParent(vcl::Window *pNewParent)
Definition: stacking.cxx:831
SAL_DLLPRIVATE void ImplInsertWindow(vcl::Window *pParent)
Definition: stacking.cxx:58
void SetMapMode()
Definition: window3.cxx:125
SAL_DLLPRIVATE bool ImplUpdatePos()
Definition: window.cxx:1418
SAL_DLLPRIVATE bool CompatPreNotify(NotifyEvent &rNEvt)
Definition: window.cxx:3915
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: window3.cxx:65
SAL_DLLPRIVATE void ImplNotifyIconifiedState(bool bIconified)
Definition: window.cxx:3637
SAL_DLLPRIVATE void ImplInvalidateParentFrameRegion(const vcl::Region &rRegion)
Definition: paint.cxx:769
void Enable(bool bEnable=true, bool bChild=true)
Definition: window.cxx:2437
Point NormalizedScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2852
SAL_DLLPRIVATE void ImplUpdateSysObjPos()
Definition: window.cxx:1449
SAL_DLLPRIVATE void CollectChildren(::std::vector< vcl::Window * > &rAllChildren)
Add all children to rAllChildren recursively.
Definition: window.cxx:2165
virtual ~Window() override
Definition: window.cxx:556
bool IsMapModeEnabled() const
Definition: window3.cxx:106
void SetFakeFocus(bool bFocus)
Set this when you need to act as if the window has focus even if it doesn't.
Definition: window.cxx:3006
void GrabFocusToDocument()
Definition: window.cxx:2993
WinBits GetStyle() const
Definition: window2.cxx:984
const AllSettings & GetSettings() const
Definition: window3.cxx:129
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2191
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1809
SAL_DLLPRIVATE bool ImplSetClipFlag(bool bSysObjOnlySmaller=false)