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