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