calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / vcl / inc / window.h
blob6f10445abf391832bd68bf6e2f54c9d4460d7ea3
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 #pragma once
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"
36 #include <optional>
37 #include <list>
38 #include <memory>
39 #include <vector>
40 #include <set>
42 class FixedText;
43 class VclSizeGroup;
44 class VirtualDevice;
45 namespace vcl::font { class PhysicalFontCollection; }
46 class ImplFontCache;
47 class VCLXWindow;
48 namespace vcl { class WindowData; }
49 class SalFrame;
50 class SalObject;
51 enum class MouseEventModifiers;
52 enum class NotifyEventType;
53 enum class ActivateModeFlags;
54 enum class DialogControlFlags;
55 enum class GetFocusFlags;
56 enum class ParentClipMode;
57 enum class SalEvent;
59 namespace com::sun::star {
60 namespace accessibility {
61 class XAccessible;
62 class XAccessibleContext;
63 class XAccessibleEditableText;
66 namespace awt {
67 class XWindowPeer;
68 class XWindow;
70 namespace uno {
71 class Any;
72 class XInterface;
74 namespace datatransfer {
75 namespace clipboard {
76 class XClipboard;
78 namespace dnd {
79 class XDropTargetListener;
80 class XDragGestureRecognizer;
81 class XDragSource;
82 class XDropTarget;
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 );
101 struct ImplWinData
103 std::optional<OUString>
104 mpExtOldText;
105 std::unique_ptr<ExtTextInputAttr[]>
106 mpExtOldAttrAry;
107 std::optional<tools::Rectangle>
108 mpCursorRect;
109 tools::Long mnCursorExtWidth;
110 bool mbVertical;
111 std::unique_ptr<tools::Rectangle[]>
112 mpCompositionCharRects;
113 tools::Long mnCompositionCharRects;
114 std::optional<tools::Rectangle>
115 mpFocusRect;
116 std::optional<tools::Rectangle>
117 mpTrackRect;
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> >
123 maTopWindowChildren;
125 ImplWinData();
126 ~ImplWinData();
129 struct ImplFrameData
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;
179 bool mbDragging;
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>
191 pAccessibleName;
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 {
204 NONE = 0x0000,
205 Paint = 0x0001,
206 PaintAll = 0x0002,
207 PaintAllChildren = 0x0004,
208 PaintChildren = 0x0008,
209 Erase = 0x0010,
210 CheckRtl = 0x0020,
212 namespace o3tl {
213 template<> struct typed_flags<ImplPaintFlags> : is_typed_flags<ImplPaintFlags, 0x003f> {};
217 class WindowImpl
219 private:
220 WindowImpl(const WindowImpl&) = delete;
221 WindowImpl& operator=(const WindowImpl&) = delete;
222 public:
223 WindowImpl( vcl::Window& rWindow, WindowType );
224 ~WindowImpl();
226 VclPtr<vcl::WindowOutputDevice> mxOutDev;
227 std::unique_ptr<ImplWinData> mpWinData;
228 ImplFrameData* mpFrameData;
229 SalFrame* mpFrame;
230 SalObject* mpSysObj;
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;
258 Fraction maZoom;
259 double mfPartialScrollX;
260 double mfPartialScrollY;
261 OUString maText;
262 std::optional<vcl::Font>
263 mpControlFont;
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;
274 tools::Long mnX;
275 tools::Long mnY;
276 tools::Long mnAbsScreenX;
277 Point maPos;
278 OString maHelpId;
279 OUString maHelpText;
280 OUString maQuickHelpText;
281 OUString maID;
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)
294 WinBits mnStyle;
295 WinBits mnPrevStyle;
296 WindowExtendedStyle mnExtendedStyle;
297 WindowType mnType;
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;
306 VclAlign meHalign;
307 VclAlign meValign;
308 VclPackType mePackType;
309 sal_Int32 mnPadding;
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;
319 bool mbFrame:1,
320 mbBorderWin:1,
321 mbOverlapWin:1,
322 mbSysWin:1,
323 mbDialog:1,
324 mbDockWin:1,
325 mbFloatWin:1,
326 mbPushButton:1,
327 mbVisible:1,
328 mbDisabled:1,
329 mbInputDisabled:1,
330 mbNoUpdate:1,
331 mbNoParentUpdate:1,
332 mbActive:1,
333 mbReallyVisible:1,
334 mbReallyShown:1,
335 mbInInitShow:1,
336 mbChildPtrOverwrite:1,
337 mbNoPtrVisible:1,
338 mbPaintFrame:1,
339 mbInPaint:1,
340 mbMouseButtonDown:1,
341 mbMouseButtonUp:1,
342 mbKeyInput:1,
343 mbKeyUp:1,
344 mbCommand:1,
345 mbDefPos:1,
346 mbDefSize:1,
347 mbCallMove:1,
348 mbCallResize:1,
349 mbWaitSystemResize:1,
350 mbInitWinClipRegion:1,
351 mbInitChildRegion:1,
352 mbWinRegion:1,
353 mbClipChildren:1,
354 mbClipSiblings:1,
355 mbChildTransparent:1,
356 mbPaintTransparent:1,
357 mbMouseTransparent:1,
358 mbDlgCtrlStart:1,
359 mbFocusVisible:1,
360 mbTrackVisible:1,
361 mbUseNativeFocus:1,
362 mbNativeFocusVisible:1,
363 mbInShowFocus:1,
364 mbInHideFocus:1,
365 mbControlForeground:1,
366 mbControlBackground:1,
367 mbAlwaysOnTop:1,
368 mbCompoundControl:1,
369 mbCompoundControlHasFocus:1,
370 mbPaintDisabled:1,
371 mbAllResize:1,
372 mbInDispose:1,
373 mbExtTextInput:1,
374 mbInFocusHdl:1,
375 mbOverlapVisible:1,
376 mbCreatedWithToolkit:1,
377 mbToolBox:1,
378 mbSplitter:1,
379 mbSuppressAccessibilityEvents:1,
380 mbMenuFloatingWindow:1,
381 mbDrawSelectionBackground:1,
382 mbIsInTaskPaneList:1,
383 mbToolbarFloatingWindow:1,
384 mbHelpTextDynamic:1,
385 mbFakeFocusSet:1,
386 mbHexpand:1,
387 mbVexpand:1,
388 mbExpand:1,
389 mbFill:1,
390 mbSecondary:1,
391 mbNonHomogeneous: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;
399 bool mbUseFrameData;
402 namespace vcl
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;
409 bool mbBackground;
410 Wallpaper maBackground;
411 AllSettings maSettings;
412 tools::Long mnOutOffX;
413 tools::Long mnOutOffY;
414 tools::Rectangle m_aPaintRect;
415 public:
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;
426 // helper methods
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: */