bump product version to 6.4.0.3
[LibreOffice.git] / vcl / inc / window.h
bloba328abf75c0e00359d8b297f0f21eba404f80af8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_VCL_INC_WINDOW_H
21 #define INCLUDED_VCL_INC_WINDOW_H
23 #include <sal/config.h>
25 #include <tools/fract.hxx>
26 #include <vcl/commandevent.hxx>
27 #include <vcl/idle.hxx>
28 #include <vcl/inputctx.hxx>
29 #include <vcl/window.hxx>
30 #include <vcl/settings.hxx>
31 #include <o3tl/typed_flags_set.hxx>
32 #include <cppuhelper/weakref.hxx>
34 #include <boost/optional.hpp>
35 #include <list>
36 #include <memory>
37 #include <vector>
38 #include <set>
40 class FixedText;
41 class VclSizeGroup;
42 class VirtualDevice;
43 class PhysicalFontCollection;
44 class ImplFontCache;
45 class VCLXWindow;
46 class WindowStateData;
47 class SalFrame;
48 class SalObject;
49 enum class MouseEventModifiers;
50 enum class MouseNotifyEvent;
51 enum class ActivateModeFlags;
52 enum class DialogControlFlags;
53 enum class GetFocusFlags;
54 enum class ParentClipMode;
55 enum class SalEvent;
57 namespace com { namespace sun { namespace star {
59 namespace accessibility {
60 class XAccessible;
61 class XAccessibleContext;
62 class XAccessibleEditableText;
65 namespace rendering {
66 class XCanvas;
69 namespace awt {
70 class XWindowPeer;
71 class XWindow;
73 namespace uno {
74 class Any;
75 class XInterface;
77 namespace datatransfer { namespace clipboard {
78 class XClipboard;
81 namespace dnd {
82 class XDropTargetListener;
83 class XDragGestureRecognizer;
84 class XDragSource;
85 class XDropTarget;
86 }}}}}
88 VCL_DLLPUBLIC Size bestmaxFrameSizeForScreenSize(const Size &rScreenSize);
90 //return true if this window and its stack of containers are all shown
91 bool isVisibleInLayout(const vcl::Window *pWindow);
93 //return true if this window and its stack of containers are all enabled
94 bool isEnabledInLayout(const vcl::Window *pWindow);
96 bool ImplWindowFrameProc( vcl::Window* pInst, SalEvent nEvent, const void* pEvent );
98 struct ImplWinData
100 boost::optional<OUString>
101 mpExtOldText;
102 std::unique_ptr<ExtTextInputAttr[]>
103 mpExtOldAttrAry;
104 boost::optional<tools::Rectangle>
105 mpCursorRect;
106 long mnCursorExtWidth;
107 bool mbVertical;
108 std::unique_ptr<tools::Rectangle[]>
109 mpCompositionCharRects;
110 long mnCompositionCharRects;
111 boost::optional<tools::Rectangle>
112 mpFocusRect;
113 boost::optional<tools::Rectangle>
114 mpTrackRect;
115 ShowTrackFlags mnTrackFlags;
116 sal_uInt16 mnIsTopWindow;
117 bool mbMouseOver; //< tracks mouse over for native widget paint effect
118 bool mbEnableNativeWidget; //< toggle native widget rendering
119 ::std::list< VclPtr<vcl::Window> >
120 maTopWindowChildren;
122 ImplWinData();
123 ~ImplWinData();
126 struct ImplFrameData
128 Idle maPaintIdle; //< paint idle handler
129 Idle maResizeIdle; //< resize timer
130 InputContext maOldInputContext; //< last set Input Context
131 VclPtr<vcl::Window> mpNextFrame; //< next frame window
132 VclPtr<vcl::Window> mpFirstOverlap; //< first overlap vcl::Window
133 VclPtr<vcl::Window> mpFocusWin; //< focus window (is also set, when frame doesn't have the focus)
134 VclPtr<vcl::Window> mpMouseMoveWin; //< last window, where MouseMove() called
135 VclPtr<vcl::Window> mpMouseDownWin; //< last window, where MouseButtonDown() called
136 std::vector<VclPtr<vcl::Window> > maOwnerDrawList; //< List of system windows with owner draw decoration
137 std::shared_ptr<PhysicalFontCollection> mxFontCollection; //< Font-List for this frame
138 std::shared_ptr<ImplFontCache> mxFontCache; //< Font-Cache for this frame
139 sal_Int32 mnDPIX; //< Original Screen Resolution
140 sal_Int32 mnDPIY; //< Original Screen Resolution
141 ImplSVEvent * mnFocusId; //< FocusId for PostUserLink
142 ImplSVEvent * mnMouseMoveId; //< MoveId for PostUserLink
143 long mnLastMouseX; //< last x mouse position
144 long mnLastMouseY; //< last y mouse position
145 long mnBeforeLastMouseX; //< last but one x mouse position
146 long mnBeforeLastMouseY; //< last but one y mouse position
147 long mnFirstMouseX; //< first x mouse position by mousebuttondown
148 long mnFirstMouseY; //< first y mouse position by mousebuttondown
149 long mnLastMouseWinX; //< last x mouse position, rel. to pMouseMoveWin
150 long mnLastMouseWinY; //< last y mouse position, rel. to pMouseMoveWin
151 sal_uInt16 mnModalMode; //< frame based modal count (app based makes no sense anymore)
152 sal_uInt64 mnMouseDownTime; //< mouse button down time for double click
153 sal_uInt16 mnClickCount; //< mouse click count
154 sal_uInt16 mnFirstMouseCode; //< mouse code by mousebuttondown
155 sal_uInt16 mnMouseCode; //< mouse code
156 MouseEventModifiers mnMouseMode; //< mouse mode
157 bool mbHasFocus; //< focus
158 bool mbInMouseMove; //< is MouseMove on stack
159 bool mbMouseIn; //> is Mouse inside the frame
160 bool mbStartDragCalled; //< is command startdrag called
161 bool mbNeedSysWindow; //< set, when FrameSize <= IMPL_MIN_NEEDSYSWIN
162 bool mbMinimized; //< set, when FrameSize <= 0
163 bool mbStartFocusState; //< FocusState, when sending the event
164 bool mbInSysObjFocusHdl; //< within a SysChildren's GetFocus handler
165 bool mbInSysObjToTopHdl; //< within a SysChildren's ToTop handler
166 bool mbSysObjFocus; //< does a SysChild have focus
167 sal_Int32 mnTouchPanPosition;
169 css::uno::Reference< css::datatransfer::dnd::XDragSource > mxDragSource;
170 css::uno::Reference< css::datatransfer::dnd::XDropTarget > mxDropTarget;
171 css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > mxDropTargetListener;
172 css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxClipboard;
173 css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxSelection;
175 bool mbInternalDragGestureRecognizer;
176 VclPtr<VirtualDevice> mpBuffer; ///< Buffer for the double-buffering
177 bool mbInBufferedPaint; ///< PaintHelper is in the process of painting into this buffer.
178 tools::Rectangle maBufferedRect; ///< Rectangle in the buffer that has to be painted to the screen.
180 ImplFrameData( vcl::Window *pWindow );
183 struct ImplAccessibleInfos
185 sal_uInt16 nAccessibleRole;
186 boost::optional<OUString>
187 pAccessibleName;
188 boost::optional<OUString>
189 pAccessibleDescription;
190 VclPtr<vcl::Window> pLabeledByWindow;
191 VclPtr<vcl::Window> pLabelForWindow;
192 VclPtr<vcl::Window> pMemberOfWindow;
194 ImplAccessibleInfos();
195 ~ImplAccessibleInfos();
198 enum AlwaysInputMode { AlwaysInputNone = 0, AlwaysInputEnabled = 1, AlwaysInputDisabled =2 };
200 enum class ImplPaintFlags {
201 NONE = 0x0000,
202 Paint = 0x0001,
203 PaintAll = 0x0002,
204 PaintAllChildren = 0x0004,
205 PaintChildren = 0x0008,
206 Erase = 0x0010,
207 CheckRtl = 0x0020,
209 namespace o3tl {
210 template<> struct typed_flags<ImplPaintFlags> : is_typed_flags<ImplPaintFlags, 0x003f> {};
214 class WindowImpl
216 private:
217 WindowImpl(const WindowImpl&) = delete;
218 WindowImpl& operator=(const WindowImpl&) = delete;
219 public:
220 WindowImpl( WindowType );
221 ~WindowImpl();
223 ImplWinData* mpWinData;
224 ImplFrameData* mpFrameData;
225 SalFrame* mpFrame;
226 SalObject* mpSysObj;
227 VclPtr<vcl::Window> mpFrameWindow;
228 VclPtr<vcl::Window> mpOverlapWindow;
229 VclPtr<vcl::Window> mpBorderWindow;
230 VclPtr<vcl::Window> mpClientWindow;
231 VclPtr<vcl::Window> mpParent;
232 VclPtr<vcl::Window> mpRealParent;
233 VclPtr<vcl::Window> mpFirstChild;
234 VclPtr<vcl::Window> mpLastChild;
235 VclPtr<vcl::Window> mpFirstOverlap;
236 VclPtr<vcl::Window> mpLastOverlap;
237 VclPtr<vcl::Window> mpPrev;
238 VclPtr<vcl::Window> mpNext;
239 VclPtr<vcl::Window> mpNextOverlap;
240 VclPtr<vcl::Window> mpLastFocusWindow;
241 VclPtr<vcl::Window> mpDlgCtrlDownWindow;
242 std::vector<Link<VclWindowEvent&,void>> maEventListeners;
243 int mnEventListenersIteratingCount;
244 std::set<Link<VclWindowEvent&,void>> maEventListenersDeleted;
245 std::vector<Link<VclWindowEvent&,void>> maChildEventListeners;
246 int mnChildEventListenersIteratingCount;
247 std::set<Link<VclWindowEvent&,void>> maChildEventListenersDeleted;
248 Link<vcl::Window&, bool> maHelpRequestHdl;
249 Link<vcl::Window&, bool> maMnemonicActivateHdl;
251 // The canvas interface for this VCL window. Is persistent after the first GetCanvas() call
252 css::uno::WeakReference< css::rendering::XCanvas > mxCanvas;
254 vcl::Cursor* mpCursor;
255 PointerStyle maPointer;
256 Fraction maZoom;
257 OUString maText;
258 std::unique_ptr<vcl::Font>
259 mpControlFont;
260 Color maControlForeground;
261 Color maControlBackground;
262 sal_Int32 mnLeftBorder;
263 sal_Int32 mnTopBorder;
264 sal_Int32 mnRightBorder;
265 sal_Int32 mnBottomBorder;
266 sal_Int32 mnWidthRequest;
267 sal_Int32 mnHeightRequest;
268 sal_Int32 mnOptimalWidthCache;
269 sal_Int32 mnOptimalHeightCache;
270 long mnX;
271 long mnY;
272 long mnAbsScreenX;
273 Point maPos;
274 OString maHelpId;
275 OUString maHelpText;
276 OUString maQuickHelpText;
277 OUString maID;
278 InputContext maInputContext;
279 css::uno::Reference< css::awt::XWindowPeer > mxWindowPeer;
280 css::uno::Reference< css::accessibility::XAccessible > mxAccessible;
281 std::shared_ptr< VclSizeGroup > m_xSizeGroup;
282 std::vector<VclPtr<FixedText>> m_aMnemonicLabels;
283 std::vector<css::accessibility::AccessibleRelation> m_aExtraAccessibleRelations;
284 std::unique_ptr<ImplAccessibleInfos> mpAccessibleInfos;
285 VCLXWindow* mpVCLXWindow;
286 vcl::Region maWinRegion; //< region to 'shape' the VCL window (frame coordinates)
287 vcl::Region maWinClipRegion; //< the (clipping) region that finally corresponds to the VCL window (frame coordinates)
288 vcl::Region maInvalidateRegion; //< region that has to be redrawn (frame coordinates)
289 std::unique_ptr<vcl::Region> mpChildClipRegion; //< child clip region if CLIPCHILDREN is set (frame coordinates)
290 vcl::Region* mpPaintRegion; //< only set during Paint() method call (window coordinates)
291 WinBits mnStyle;
292 WinBits mnPrevStyle;
293 WindowExtendedStyle mnExtendedStyle;
294 WindowType mnType;
295 ControlPart mnNativeBackground;
296 sal_uInt16 mnWaitCount;
297 ImplPaintFlags mnPaintFlags;
298 GetFocusFlags mnGetFocusFlags;
299 ParentClipMode mnParentClipMode;
300 ActivateModeFlags mnActivateMode;
301 DialogControlFlags mnDlgCtrlFlags;
302 AlwaysInputMode meAlwaysInputMode;
303 VclAlign meHalign;
304 VclAlign meValign;
305 VclPackType mePackType;
306 sal_Int32 mnPadding;
307 sal_Int32 mnGridHeight;
308 sal_Int32 mnGridLeftAttach;
309 sal_Int32 mnGridTopAttach;
310 sal_Int32 mnGridWidth;
311 sal_Int32 mnBorderWidth;
312 sal_Int32 mnMarginLeft;
313 sal_Int32 mnMarginRight;
314 sal_Int32 mnMarginTop;
315 sal_Int32 mnMarginBottom;
316 bool mbFrame:1,
317 mbBorderWin:1,
318 mbOverlapWin:1,
319 mbSysWin:1,
320 mbDialog:1,
321 mbDockWin:1,
322 mbFloatWin:1,
323 mbPushButton:1,
324 mbVisible:1,
325 mbDisabled:1,
326 mbInputDisabled:1,
327 mbNoUpdate:1,
328 mbNoParentUpdate:1,
329 mbActive:1,
330 mbReallyVisible:1,
331 mbReallyShown:1,
332 mbInInitShow:1,
333 mbChildPtrOverwrite:1,
334 mbNoPtrVisible:1,
335 mbPaintFrame:1,
336 mbInPaint:1,
337 mbMouseButtonDown:1,
338 mbMouseButtonUp:1,
339 mbKeyInput:1,
340 mbKeyUp:1,
341 mbCommand:1,
342 mbDefPos:1,
343 mbDefSize:1,
344 mbCallMove:1,
345 mbCallResize:1,
346 mbWaitSystemResize:1,
347 mbInitWinClipRegion:1,
348 mbInitChildRegion:1,
349 mbWinRegion:1,
350 mbClipChildren:1,
351 mbClipSiblings:1,
352 mbChildTransparent:1,
353 mbPaintTransparent:1,
354 mbMouseTransparent:1,
355 mbDlgCtrlStart:1,
356 mbFocusVisible:1,
357 mbTrackVisible:1,
358 mbUseNativeFocus:1,
359 mbNativeFocusVisible:1,
360 mbInShowFocus:1,
361 mbInHideFocus:1,
362 mbControlForeground:1,
363 mbControlBackground:1,
364 mbAlwaysOnTop:1,
365 mbCompoundControl:1,
366 mbCompoundControlHasFocus:1,
367 mbPaintDisabled:1,
368 mbAllResize:1,
369 mbInDispose:1,
370 mbExtTextInput:1,
371 mbInFocusHdl:1,
372 mbOverlapVisible:1,
373 mbCreatedWithToolkit:1,
374 mbToolBox:1,
375 mbSplitter:1,
376 mbSuppressAccessibilityEvents:1,
377 mbMenuFloatingWindow:1,
378 mbDrawSelectionBackground:1,
379 mbIsInTaskPaneList:1,
380 mbToolbarFloatingWindow:1,
381 mbCallHandlersDuringInputDisabled:1,
382 mbHelpTextDynamic:1,
383 mbFakeFocusSet:1,
384 mbHexpand:1,
385 mbVexpand:1,
386 mbExpand:1,
387 mbFill:1,
388 mbSecondary:1,
389 mbNonHomogeneous:1,
390 mbDoubleBufferingRequested:1;
392 css::uno::Reference< css::uno::XInterface > mxDNDListenerContainer;
394 const vcl::ILibreOfficeKitNotifier* mpLOKNotifier; ///< To emit the LOK callbacks eg. for dialog tunneling.
395 vcl::LOKWindowId mnLOKWindowId; ///< ID of this specific window.
396 bool mbLOKParentNotifier;
399 namespace vcl
401 /// Sets up the buffer to have settings matching the window, and restores the original state in the dtor.
402 class VCL_DLLPUBLIC PaintBufferGuard
404 ImplFrameData* mpFrameData;
405 VclPtr<vcl::Window> m_pWindow;
406 bool mbBackground;
407 Wallpaper maBackground;
408 AllSettings maSettings;
409 long mnOutOffX;
410 long mnOutOffY;
411 tools::Rectangle m_aPaintRect;
412 public:
413 PaintBufferGuard(ImplFrameData* pFrameData, vcl::Window* pWindow);
414 ~PaintBufferGuard();
415 /// If this is called, then the dtor will also copy rRectangle to the window from the buffer, before restoring the state.
416 void SetPaintRect(const tools::Rectangle& rRectangle);
417 /// Returns either the frame's buffer or the window, in case of no buffering.
418 vcl::RenderContext* GetRenderContext();
422 // helper methods
424 bool ImplHandleMouseEvent( const VclPtr<vcl::Window>& xWindow, MouseNotifyEvent nSVEvent, bool bMouseLeave,
425 long nX, long nY, sal_uInt64 nMsgTime,
426 sal_uInt16 nCode, MouseEventModifiers nMode );
427 void ImplHandleResize( vcl::Window* pWindow, long nNewWidth, long nNewHeight );
429 VCL_DLLPUBLIC void ImplWindowStateFromStr(WindowStateData& rData, const OString& rStr);
431 VCL_DLLPUBLIC css::uno::Reference<css::accessibility::XAccessibleEditableText>
432 FindFocusedEditableText(css::uno::Reference<css::accessibility::XAccessibleContext> const&);
434 #endif // INCLUDED_VCL_INC_WINDOW_H
436 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */