bump product version to 6.4.0.3
[LibreOffice.git] / vcl / inc / salframe.hxx
blob4b540d61ca0e9d88201009155f344df4012914a9
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_SALFRAME_HXX
21 #define INCLUDED_VCL_INC_SALFRAME_HXX
23 #include "impdel.hxx"
24 #include "salwtype.hxx"
25 #include "salgeom.hxx"
27 #include <vcl/help.hxx>
28 #include <o3tl/typed_flags_set.hxx>
30 #include <vcl/window.hxx>
31 // complete vcl::Window for SalFrame::CallCallback under -fsanitize=function
33 class AllSettings;
34 class SalGraphics;
35 class SalBitmap;
36 class SalMenu;
38 struct SalFrameState;
39 struct SalInputContext;
40 struct SystemEnvData;
42 // SalFrame types
43 enum class SalFrameToTop {
44 NONE = 0x00,
45 RestoreWhenMin = 0x01,
46 ForegroundTask = 0x02,
47 GrabFocus = 0x04,
48 GrabFocusOnly = 0x08
50 namespace o3tl {
51 template<> struct typed_flags<SalFrameToTop> : is_typed_flags<SalFrameToTop, 0x0f> {};
54 namespace vcl { class KeyCode; }
56 namespace weld
58 class Window;
61 enum class FloatWinPopupFlags;
63 // SalFrame styles
64 enum class SalFrameStyleFlags
66 NONE = 0x00000000,
67 DEFAULT = 0x00000001,
68 MOVEABLE = 0x00000002,
69 SIZEABLE = 0x00000004,
70 CLOSEABLE = 0x00000008,
71 // no shadow effect on Windows XP
72 NOSHADOW = 0x00000010,
73 // indicate tooltip windows, so they can always be topmost
74 TOOLTIP = 0x00000020,
75 // windows without windowmanager decoration, this typically only applies to floating windows
76 OWNERDRAWDECORATION = 0x00000040,
77 // dialogs
78 DIALOG = 0x00000080,
79 // the window containing the intro bitmap, aka splashscreen
80 INTRO = 0x00000100,
81 // partial fullscreen: fullscreen on one monitor of a multimonitor display
82 PARTIAL_FULLSCREEN = 0x00800000,
83 // system child window inside another SalFrame
84 SYSTEMCHILD = 0x08000000,
85 // plugged system child window
86 PLUG = 0x10000000,
87 // floating window
88 FLOAT = 0x20000000,
89 // toolwindows should be painted with a smaller decoration
90 TOOLWINDOW = 0x40000000,
93 namespace o3tl {
94 template<> struct typed_flags<SalFrameStyleFlags> : is_typed_flags<SalFrameStyleFlags, 0x788001ff> {};
97 // Extended frame style (sal equivalent to extended WinBits)
98 typedef sal_uInt64 SalExtStyle;
99 #define SAL_FRAME_EXT_STYLE_DOCUMENT SalExtStyle(0x00000001)
100 #define SAL_FRAME_EXT_STYLE_DOCMODIFIED SalExtStyle(0x00000002)
102 // Flags for SetPosSize
103 #define SAL_FRAME_POSSIZE_X (sal_uInt16(0x0001))
104 #define SAL_FRAME_POSSIZE_Y (sal_uInt16(0x0002))
105 #define SAL_FRAME_POSSIZE_WIDTH (sal_uInt16(0x0004))
106 #define SAL_FRAME_POSSIZE_HEIGHT (sal_uInt16(0x0008))
108 struct SystemParentData;
109 struct ImplSVEvent;
111 /// A SalFrame is a system window (e.g. an X11 window).
112 class VCL_PLUGIN_PUBLIC SalFrame
113 : public vcl::DeletionNotifier
114 , public SalGeometryProvider
116 private:
117 // the VCL window corresponding to this frame
118 VclPtr<vcl::Window> m_pWindow;
119 SALFRAMEPROC m_pProc;
120 Link<bool, void> m_aModalHierarchyHdl;
121 protected:
122 mutable std::unique_ptr<weld::Window> m_xFrameWeld;
123 public:
124 SalFrame();
125 virtual ~SalFrame() override;
127 SalFrameGeometry maGeometry = {}; ///< absolute, unmirrored values
129 // SalGeometryProvider
130 virtual long GetWidth() const override { return maGeometry.nWidth; }
131 virtual long GetHeight() const override { return maGeometry.nHeight; }
132 virtual bool IsOffScreen() const override { return false; }
134 // SalGraphics or NULL, but two Graphics for all SalFrames
135 // must be returned
136 virtual SalGraphics* AcquireGraphics() = 0;
137 virtual void ReleaseGraphics( SalGraphics* pGraphics ) = 0;
139 // Event must be destroyed, when Frame is destroyed
140 // When Event is called, SalInstance::Yield() must be returned
141 virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) = 0;
143 virtual void SetTitle( const OUString& rTitle ) = 0;
144 virtual void SetIcon( sal_uInt16 nIcon ) = 0;
145 virtual void SetRepresentedURL( const OUString& );
146 virtual void SetMenu( SalMenu *pSalMenu ) = 0;
147 virtual void DrawMenuBar() = 0;
149 virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle ) = 0;
151 // Before the window is visible, a resize event
152 // must be sent with the correct size
153 virtual void Show( bool bVisible, bool bNoActivate = false ) = 0;
155 // Set ClientSize and Center the Window to the desktop
156 // and send/post a resize message
157 virtual void SetMinClientSize( long nWidth, long nHeight ) = 0;
158 virtual void SetMaxClientSize( long nWidth, long nHeight ) = 0;
159 virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags ) = 0;
160 virtual void GetClientSize( long& rWidth, long& rHeight ) = 0;
161 virtual void GetWorkArea( tools::Rectangle& rRect ) = 0;
162 virtual SalFrame* GetParent() const = 0;
163 // Note: x will be mirrored at parent if UI mirroring is active
164 SalFrameGeometry GetGeometry() const;
165 const SalFrameGeometry& GetUnmirroredGeometry() const { return maGeometry; }
167 virtual void SetWindowState( const SalFrameState* pState ) = 0;
168 // return the absolute, unmirrored system frame state
169 // if this returns false the structure is uninitialised
170 [[nodiscard]]
171 virtual bool GetWindowState( SalFrameState* pState ) = 0;
172 virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) = 0;
173 virtual void PositionByToolkit( const tools::Rectangle&, FloatWinPopupFlags ) {};
175 // Enable/Disable ScreenSaver, SystemAgents, ...
176 virtual void StartPresentation( bool bStart ) = 0;
177 // Show Window over all other Windows
178 virtual void SetAlwaysOnTop( bool bOnTop ) = 0;
180 // Window to top and grab focus
181 virtual void ToTop( SalFrameToTop nFlags ) = 0;
183 // this function can call with the same
184 // pointer style
185 virtual void SetPointer( PointerStyle ePointerStyle ) = 0;
186 virtual void CaptureMouse( bool bMouse ) = 0;
187 virtual void SetPointerPos( long nX, long nY ) = 0;
189 // flush output buffer
190 virtual void Flush() = 0;
191 virtual void Flush( const tools::Rectangle& );
193 virtual void SetInputContext( SalInputContext* pContext ) = 0;
194 virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) = 0;
196 virtual OUString GetKeyName( sal_uInt16 nKeyCode ) = 0;
198 // returns in 'rKeyCode' the single keycode that translates to the given unicode when using a keyboard layout of language 'aLangType'
199 // returns false if no mapping exists or function not supported
200 // this is required for advanced menu support
201 virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) = 0;
203 // returns the input language used for the last key stroke
204 // may be LANGUAGE_DONTKNOW if not supported by the OS
205 virtual LanguageType GetInputLanguage() = 0;
207 virtual void UpdateSettings( AllSettings& rSettings ) = 0;
209 virtual void Beep() = 0;
211 // returns system data (most prominent: window handle)
212 virtual const SystemEnvData*
213 GetSystemData() const = 0;
215 // get current modifier, button mask and mouse position
216 struct SalPointerState
218 sal_uLong mnState;
219 Point maPos; // in frame coordinates
222 virtual SalPointerState GetPointerState() = 0;
224 virtual KeyIndicatorState GetIndicatorState() = 0;
226 virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) = 0;
228 // set new parent window
229 virtual void SetParent( SalFrame* pNewParent ) = 0;
230 // reparent window to act as a plugin; implementation
231 // may choose to use a new system window internally
232 // return false to indicate failure
233 virtual bool SetPluginParent( SystemParentData* pNewParent ) = 0;
235 // move the frame to a new screen
236 virtual void SetScreenNumber( unsigned int nScreen ) = 0;
238 virtual void SetApplicationID( const OUString &rApplicationID) = 0;
240 // shaped system windows
241 // set clip region to none (-> rectangular windows, normal state)
242 virtual void ResetClipRegion() = 0;
243 // start setting the clipregion consisting of nRects rectangles
244 virtual void BeginSetClipRegion( sal_uInt32 nRects ) = 0;
245 // add a rectangle to the clip region
246 virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) = 0;
247 // done setting up the clipregion
248 virtual void EndSetClipRegion() = 0;
250 virtual void SetModal(bool /*bModal*/)
254 virtual bool GetModal() const
256 return false;
259 // return true to indicate tooltips are shown natively, false otherwise
260 virtual bool ShowTooltip(const OUString& /*rHelpText*/, const tools::Rectangle& /*rHelpArea*/)
262 return false;
265 // return !0 to indicate popovers are shown natively, 0 otherwise
266 virtual void* ShowPopover(const OUString& /*rHelpText*/, vcl::Window* /*pParent*/, const tools::Rectangle& /*rHelpArea*/, QuickHelpFlags /*nFlags*/)
268 return nullptr;
271 // return true to indicate popovers are shown natively, false otherwise
272 virtual bool UpdatePopover(void* /*nId*/, const OUString& /*rHelpText*/, vcl::Window* /*pParent*/, const tools::Rectangle& /*rHelpArea*/)
274 return false;
277 // return true to indicate popovers are shown natively, false otherwise
278 virtual bool HidePopover(void* /*nId*/)
280 return false;
283 virtual weld::Window* GetFrameWeld() const;
285 // Callbacks (independent part in vcl/source/window/winproc.cxx)
286 // for default message handling return 0
287 void SetCallback( vcl::Window* pWindow, SALFRAMEPROC pProc );
289 // returns the instance set
290 vcl::Window* GetWindow() const { return m_pWindow; }
292 void SetModalHierarchyHdl(const Link<bool, void>& rLink) { m_aModalHierarchyHdl = rLink; }
293 void NotifyModalHierarchy(bool bModal) { m_aModalHierarchyHdl.Call(bModal); }
295 // Call the callback set; this sometimes necessary for implementation classes
296 // that should not know more than necessary about the SalFrame implementation
297 // (e.g. input methods, printer update handlers).
298 bool CallCallback( SalEvent nEvent, const void* pEvent ) const
299 { return m_pProc && m_pProc( m_pWindow, nEvent, pEvent ); }
302 #ifdef _WIN32
303 bool HasAtHook();
304 #endif
306 #endif // INCLUDED_VCL_INC_SALFRAME_HXX
308 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */