1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <sal/config.h>
24 #include <tools/fract.hxx>
25 #include <vcl/commandevent.hxx>
26 #include <vcl/idle.hxx>
27 #include <vcl/inputctx.hxx>
28 #include <vcl/window.hxx>
29 #include <vcl/settings.hxx>
30 #include <o3tl/deleter.hxx>
31 #include <o3tl/typed_flags_set.hxx>
32 #include <cppuhelper/weakref.hxx>
33 #include "windowdev.hxx"
34 #include "salwtype.hxx"
45 namespace vcl::font
{ class PhysicalFontCollection
; }
48 namespace vcl
{ class WindowData
; }
51 enum class MouseEventModifiers
;
52 enum class NotifyEventType
;
53 enum class ActivateModeFlags
;
54 enum class DialogControlFlags
;
55 enum class GetFocusFlags
;
56 enum class ParentClipMode
;
59 namespace com::sun::star
{
60 namespace accessibility
{
62 class XAccessibleContext
;
63 class XAccessibleEditableText
;
74 namespace datatransfer
{
79 class XDropTargetListener
;
80 class XDragGestureRecognizer
;
87 VCL_DLLPUBLIC Size
bestmaxFrameSizeForScreenSize(const Size
&rScreenSize
);
89 //return true if this window and its stack of containers are all shown
90 bool isVisibleInLayout(const vcl::Window
*pWindow
);
92 //return true if this window and its stack of containers are all enabled
93 bool isEnabledInLayout(const vcl::Window
*pWindow
);
95 bool ImplWindowFrameProc( vcl::Window
* pInst
, SalEvent nEvent
, const void* pEvent
);
97 MouseEventModifiers
ImplGetMouseMoveMode( SalMouseEvent
const * pEvent
);
99 MouseEventModifiers
ImplGetMouseButtonMode( SalMouseEvent
const * pEvent
);
103 std::optional
<OUString
>
105 std::unique_ptr
<ExtTextInputAttr
[]>
107 std::optional
<tools::Rectangle
>
109 tools::Long mnCursorExtWidth
;
111 std::unique_ptr
<tools::Rectangle
[]>
112 mpCompositionCharRects
;
113 tools::Long mnCompositionCharRects
;
114 std::optional
<tools::Rectangle
>
116 std::optional
<tools::Rectangle
>
118 ShowTrackFlags mnTrackFlags
;
119 sal_uInt16 mnIsTopWindow
;
120 bool mbMouseOver
; //< tracks mouse over for native widget paint effect
121 bool mbEnableNativeWidget
; //< toggle native widget rendering
122 ::std::list
< VclPtr
<vcl::Window
> >
131 Idle maPaintIdle
; //< paint idle handler
132 Idle maResizeIdle
; //< resize timer
133 InputContext maOldInputContext
; //< last set Input Context
134 VclPtr
<vcl::Window
> mpNextFrame
; //< next frame window
135 VclPtr
<vcl::Window
> mpFirstOverlap
; //< first overlap vcl::Window
136 VclPtr
<vcl::Window
> mpFocusWin
; //< focus window (is also set, when frame doesn't have the focus)
137 VclPtr
<vcl::Window
> mpMouseMoveWin
; //< last window, where MouseMove() called
138 VclPtr
<vcl::Window
> mpMouseDownWin
; //< last window, where MouseButtonDown() called
139 VclPtr
<vcl::Window
> mpTrackWin
; //< window, that is in tracking mode
140 std::vector
<VclPtr
<vcl::Window
> > maOwnerDrawList
; //< List of system windows with owner draw decoration
141 std::shared_ptr
<vcl::font::PhysicalFontCollection
> mxFontCollection
; //< Font-List for this frame
142 std::shared_ptr
<ImplFontCache
> mxFontCache
; //< Font-Cache for this frame
143 sal_Int32 mnDPIX
; //< Original Screen Resolution
144 sal_Int32 mnDPIY
; //< Original Screen Resolution
145 ImplSVEvent
* mnFocusId
; //< FocusId for PostUserLink
146 ImplSVEvent
* mnMouseMoveId
; //< MoveId for PostUserLink
147 tools::Long mnLastMouseX
; //< last x mouse position
148 tools::Long mnLastMouseY
; //< last y mouse position
149 tools::Long mnBeforeLastMouseX
; //< last but one x mouse position
150 tools::Long mnBeforeLastMouseY
; //< last but one y mouse position
151 tools::Long mnFirstMouseX
; //< first x mouse position by mousebuttondown
152 tools::Long mnFirstMouseY
; //< first y mouse position by mousebuttondown
153 tools::Long mnLastMouseWinX
; //< last x mouse position, rel. to pMouseMoveWin
154 tools::Long mnLastMouseWinY
; //< last y mouse position, rel. to pMouseMoveWin
155 sal_uInt16 mnModalMode
; //< frame based modal count (app based makes no sense anymore)
156 sal_uInt64 mnMouseDownTime
; //< mouse button down time for double click
157 sal_uInt16 mnClickCount
; //< mouse click count
158 sal_uInt16 mnFirstMouseCode
; //< mouse code by mousebuttondown
159 sal_uInt16 mnMouseCode
; //< mouse code
160 MouseEventModifiers mnMouseMode
; //< mouse mode
161 bool mbHasFocus
; //< focus
162 bool mbInMouseMove
; //< is MouseMove on stack
163 bool mbMouseIn
; //> is Mouse inside the frame
164 bool mbStartDragCalled
; //< is command startdrag called
165 bool mbNeedSysWindow
; //< set, when FrameSize <= IMPL_MIN_NEEDSYSWIN
166 bool mbMinimized
; //< set, when FrameSize <= 0
167 bool mbStartFocusState
; //< FocusState, when sending the event
168 bool mbInSysObjFocusHdl
; //< within a SysChildren's GetFocus handler
169 bool mbInSysObjToTopHdl
; //< within a SysChildren's ToTop handler
170 bool mbSysObjFocus
; //< does a SysChild have focus
171 sal_Int32 mnTouchPanPosition
;
173 css::uno::Reference
< css::datatransfer::dnd::XDragSource
> mxDragSource
;
174 css::uno::Reference
< css::datatransfer::dnd::XDropTarget
> mxDropTarget
;
175 css::uno::Reference
< css::datatransfer::dnd::XDropTargetListener
> mxDropTargetListener
;
176 css::uno::Reference
< css::datatransfer::clipboard::XClipboard
> mxClipboard
;
178 bool mbInternalDragGestureRecognizer
;
180 VclPtr
<VirtualDevice
> mpBuffer
; ///< Buffer for the double-buffering
181 bool mbInBufferedPaint
; ///< PaintHelper is in the process of painting into this buffer.
182 tools::Rectangle maBufferedRect
; ///< Rectangle in the buffer that has to be painted to the screen.
184 ImplFrameData( vcl::Window
*pWindow
);
187 struct ImplAccessibleInfos
189 sal_uInt16 nAccessibleRole
;
190 std::optional
<OUString
>
192 std::optional
<OUString
>
193 pAccessibleDescription
;
194 VclPtr
<vcl::Window
> pLabeledByWindow
;
195 VclPtr
<vcl::Window
> pLabelForWindow
;
197 ImplAccessibleInfos();
198 ~ImplAccessibleInfos();
201 enum AlwaysInputMode
{ AlwaysInputNone
= 0, AlwaysInputEnabled
= 1 };
203 enum class ImplPaintFlags
{
207 PaintAllChildren
= 0x0004,
208 PaintChildren
= 0x0008,
213 template<> struct typed_flags
<ImplPaintFlags
> : is_typed_flags
<ImplPaintFlags
, 0x003f> {};
220 WindowImpl(const WindowImpl
&) = delete;
221 WindowImpl
& operator=(const WindowImpl
&) = delete;
223 WindowImpl( vcl::Window
& rWindow
, WindowType
);
226 VclPtr
<vcl::WindowOutputDevice
> mxOutDev
;
227 std::unique_ptr
<ImplWinData
> mpWinData
;
228 ImplFrameData
* mpFrameData
;
231 VclPtr
<vcl::Window
> mpFrameWindow
;
232 VclPtr
<vcl::Window
> mpOverlapWindow
;
233 VclPtr
<vcl::Window
> mpBorderWindow
;
234 VclPtr
<vcl::Window
> mpClientWindow
;
235 VclPtr
<vcl::Window
> mpParent
;
236 VclPtr
<vcl::Window
> mpRealParent
;
237 VclPtr
<vcl::Window
> mpFirstChild
;
238 VclPtr
<vcl::Window
> mpLastChild
;
239 VclPtr
<vcl::Window
> mpFirstOverlap
;
240 VclPtr
<vcl::Window
> mpLastOverlap
;
241 VclPtr
<vcl::Window
> mpPrev
;
242 VclPtr
<vcl::Window
> mpNext
;
243 VclPtr
<vcl::Window
> mpNextOverlap
;
244 VclPtr
<vcl::Window
> mpLastFocusWindow
;
245 VclPtr
<vcl::Window
> mpDlgCtrlDownWindow
;
246 std::vector
<Link
<VclWindowEvent
&,void>> maEventListeners
;
247 int mnEventListenersIteratingCount
;
248 std::set
<Link
<VclWindowEvent
&,void>> maEventListenersDeleted
;
249 std::vector
<Link
<VclWindowEvent
&,void>> maChildEventListeners
;
250 int mnChildEventListenersIteratingCount
;
251 std::set
<Link
<VclWindowEvent
&,void>> maChildEventListenersDeleted
;
252 Link
<vcl::Window
&, bool> maHelpRequestHdl
;
253 Link
<vcl::Window
&, bool> maMnemonicActivateHdl
;
254 Link
<tools::JsonWriter
&, void> maDumpAsPropertyTreeHdl
;
256 vcl::Cursor
* mpCursor
;
257 PointerStyle maPointer
;
259 double mfPartialScrollX
;
260 double mfPartialScrollY
;
262 std::optional
<vcl::Font
>
264 Color maControlForeground
;
265 Color maControlBackground
;
266 sal_Int32 mnLeftBorder
;
267 sal_Int32 mnTopBorder
;
268 sal_Int32 mnRightBorder
;
269 sal_Int32 mnBottomBorder
;
270 sal_Int32 mnWidthRequest
;
271 sal_Int32 mnHeightRequest
;
272 sal_Int32 mnOptimalWidthCache
;
273 sal_Int32 mnOptimalHeightCache
;
276 tools::Long mnAbsScreenX
;
280 OUString maQuickHelpText
;
282 InputContext maInputContext
;
283 css::uno::Reference
< css::awt::XWindowPeer
> mxWindowPeer
;
284 css::uno::Reference
< css::accessibility::XAccessible
> mxAccessible
;
285 std::shared_ptr
< VclSizeGroup
> m_xSizeGroup
;
286 std::vector
<VclPtr
<FixedText
>> m_aMnemonicLabels
;
287 std::unique_ptr
<ImplAccessibleInfos
> mpAccessibleInfos
;
288 VCLXWindow
* mpVCLXWindow
;
289 vcl::Region maWinRegion
; //< region to 'shape' the VCL window (frame coordinates)
290 vcl::Region maWinClipRegion
; //< the (clipping) region that finally corresponds to the VCL window (frame coordinates)
291 vcl::Region maInvalidateRegion
; //< region that has to be redrawn (frame coordinates)
292 std::unique_ptr
<vcl::Region
> mpChildClipRegion
; //< child clip region if CLIPCHILDREN is set (frame coordinates)
293 vcl::Region
* mpPaintRegion
; //< only set during Paint() method call (window coordinates)
296 WindowExtendedStyle mnExtendedStyle
;
298 ControlPart mnNativeBackground
;
299 sal_uInt16 mnWaitCount
;
300 ImplPaintFlags mnPaintFlags
;
301 GetFocusFlags mnGetFocusFlags
;
302 ParentClipMode mnParentClipMode
;
303 ActivateModeFlags mnActivateMode
;
304 DialogControlFlags mnDlgCtrlFlags
;
305 AlwaysInputMode meAlwaysInputMode
;
308 VclPackType mePackType
;
310 sal_Int32 mnGridHeight
;
311 sal_Int32 mnGridLeftAttach
;
312 sal_Int32 mnGridTopAttach
;
313 sal_Int32 mnGridWidth
;
314 sal_Int32 mnBorderWidth
;
315 sal_Int32 mnMarginLeft
;
316 sal_Int32 mnMarginRight
;
317 sal_Int32 mnMarginTop
;
318 sal_Int32 mnMarginBottom
;
336 mbChildPtrOverwrite
:1,
349 mbWaitSystemResize
:1,
350 mbInitWinClipRegion
:1,
355 mbChildTransparent
:1,
356 mbPaintTransparent
:1,
357 mbMouseTransparent
:1,
362 mbNativeFocusVisible
:1,
365 mbControlForeground
:1,
366 mbControlBackground
:1,
369 mbCompoundControlHasFocus
:1,
376 mbCreatedWithToolkit
:1,
379 mbSuppressAccessibilityEvents
:1,
380 mbMenuFloatingWindow
:1,
381 mbDrawSelectionBackground
:1,
382 mbIsInTaskPaneList
:1,
383 mbToolbarFloatingWindow
:1,
392 mbDoubleBufferingRequested
:1;
394 css::uno::Reference
< css::uno::XInterface
> mxDNDListenerContainer
;
396 const vcl::ILibreOfficeKitNotifier
* mpLOKNotifier
; ///< To emit the LOK callbacks eg. for dialog tunneling.
397 vcl::LOKWindowId mnLOKWindowId
; ///< ID of this specific window.
398 bool mbLOKParentNotifier
;
404 /// Sets up the buffer to have settings matching the window, and restores the original state in the dtor.
405 class VCL_DLLPUBLIC PaintBufferGuard
407 ImplFrameData
* mpFrameData
;
408 VclPtr
<vcl::Window
> m_pWindow
;
410 Wallpaper maBackground
;
411 AllSettings maSettings
;
412 tools::Long mnOutOffX
;
413 tools::Long mnOutOffY
;
414 tools::Rectangle m_aPaintRect
;
416 PaintBufferGuard(ImplFrameData
* pFrameData
, vcl::Window
* pWindow
);
417 ~PaintBufferGuard() COVERITY_NOEXCEPT_FALSE
;
418 /// If this is called, then the dtor will also copy rRectangle to the window from the buffer, before restoring the state.
419 void SetPaintRect(const tools::Rectangle
& rRectangle
);
420 /// Returns either the frame's buffer or the window, in case of no buffering.
421 vcl::RenderContext
* GetRenderContext();
423 typedef std::unique_ptr
<PaintBufferGuard
, o3tl::default_delete
<PaintBufferGuard
>> PaintBufferGuardPtr
;
428 bool ImplHandleMouseEvent( const VclPtr
<vcl::Window
>& xWindow
, NotifyEventType nSVEvent
, bool bMouseLeave
,
429 tools::Long nX
, tools::Long nY
, sal_uInt64 nMsgTime
,
430 sal_uInt16 nCode
, MouseEventModifiers nMode
);
432 bool ImplLOKHandleMouseEvent( const VclPtr
<vcl::Window
>& xWindow
, NotifyEventType nSVEvent
, bool bMouseLeave
,
433 tools::Long nX
, tools::Long nY
, sal_uInt64 nMsgTime
,
434 sal_uInt16 nCode
, MouseEventModifiers nMode
, sal_uInt16 nClicks
);
436 void ImplHandleResize( vcl::Window
* pWindow
, tools::Long nNewWidth
, tools::Long nNewHeight
);
438 VCL_DLLPUBLIC
css::uno::Reference
<css::accessibility::XAccessibleEditableText
>
439 FindFocusedEditableText(css::uno::Reference
<css::accessibility::XAccessibleContext
> const&);
441 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */