1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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
38 namespace vcl
{ class WindowData
; }
39 struct SalInputContext
;
43 enum class SalFrameToTop
{
45 RestoreWhenMin
= 0x01,
46 ForegroundTask
= 0x02,
51 template<> struct typed_flags
<SalFrameToTop
> : is_typed_flags
<SalFrameToTop
, 0x0f> {};
54 namespace vcl
{ class KeyCode
; }
61 enum class FloatWinPopupFlags
;
64 enum class SalFrameStyleFlags
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
75 // windows without windowmanager decoration, this typically only applies to floating windows
76 OWNERDRAWDECORATION
= 0x00000040,
79 // the window containing the intro bitmap, aka splashscreen
81 // tdf#144624: don't set icon
83 // system child window inside another SalFrame
84 SYSTEMCHILD
= 0x08000000,
85 // plugged system child window
89 // toolwindows should be painted with a smaller decoration
90 TOOLWINDOW
= 0x40000000,
94 template<> struct typed_flags
<SalFrameStyleFlags
> : is_typed_flags
<SalFrameStyleFlags
, 0x798001ff> {};
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
;
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
117 // the VCL window corresponding to this frame
118 VclPtr
<vcl::Window
> m_pWindow
;
119 SALFRAMEPROC m_pProc
;
120 Link
<bool, void> m_aModalHierarchyHdl
;
122 // subclasses need to either keep this up to date
123 // or override GetUnmirroredGeometry()
124 SalFrameGeometry maGeometry
; ///< absolute, unmirrored values
126 mutable std::unique_ptr
<weld::Window
> m_xFrameWeld
;
129 virtual ~SalFrame() override
;
131 // SalGeometryProvider
132 virtual tools::Long
GetWidth() const override
{ return GetUnmirroredGeometry().width(); }
133 virtual tools::Long
GetHeight() const override
{ return GetUnmirroredGeometry().height(); }
134 virtual bool IsOffScreen() const override
{ return false; }
136 // SalGraphics or NULL, but two Graphics for all SalFrames
138 virtual SalGraphics
* AcquireGraphics() = 0;
139 virtual void ReleaseGraphics( SalGraphics
* pGraphics
) = 0;
141 // Event must be destroyed, when Frame is destroyed
142 // When Event is called, SalInstance::Yield() must be returned
143 virtual bool PostEvent(std::unique_ptr
<ImplSVEvent
> pData
) = 0;
145 virtual void SetTitle( const OUString
& rTitle
) = 0;
146 virtual void SetIcon( sal_uInt16 nIcon
) = 0;
147 virtual void SetRepresentedURL( const OUString
& );
148 virtual void SetMenu( SalMenu
*pSalMenu
) = 0;
150 virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle
) = 0;
152 // Before the window is visible, a resize event
153 // must be sent with the correct size
154 virtual void Show( bool bVisible
, bool bNoActivate
= false ) = 0;
156 // Set ClientSize and Center the Window to the desktop
157 // and send/post a resize message
158 virtual void SetMinClientSize( tools::Long nWidth
, tools::Long nHeight
) = 0;
159 virtual void SetMaxClientSize( tools::Long nWidth
, tools::Long nHeight
) = 0;
160 virtual void SetPosSize( tools::Long nX
, tools::Long nY
, tools::Long nWidth
, tools::Long nHeight
, sal_uInt16 nFlags
) = 0;
161 static OUString
DumpSetPosSize(tools::Long nX
, tools::Long nY
, tools::Long nWidth
, tools::Long nHeight
, sal_uInt16 nFlags
);
162 virtual void GetClientSize( tools::Long
& rWidth
, tools::Long
& rHeight
) = 0;
163 virtual void GetWorkArea( AbsoluteScreenPixelRectangle
& rRect
) = 0;
164 virtual SalFrame
* GetParent() const = 0;
165 // Note: x will be mirrored at parent if UI mirroring is active
166 SalFrameGeometry
GetGeometry() const;
168 // subclasses either have to keep maGeometry up to date or override this
169 // method to return an up-to-date SalFrameGeometry
170 virtual SalFrameGeometry
GetUnmirroredGeometry() const { return maGeometry
; }
172 virtual void SetWindowState(const vcl::WindowData
*) = 0;
173 // return the absolute, unmirrored system frame state
174 // if this returns false the structure is uninitialised
176 virtual bool GetWindowState(vcl::WindowData
*) = 0;
177 virtual void ShowFullScreen( bool bFullScreen
, sal_Int32 nDisplay
) = 0;
178 virtual void PositionByToolkit( const tools::Rectangle
&, FloatWinPopupFlags
) {};
180 // Enable/Disable ScreenSaver, SystemAgents, ...
181 virtual void StartPresentation( bool bStart
) = 0;
182 // Show Window over all other Windows
183 virtual void SetAlwaysOnTop( bool bOnTop
) = 0;
185 // Window to top and grab focus
186 virtual void ToTop( SalFrameToTop nFlags
) = 0;
188 // grab focus to the main widget, can be no-op if the vclplug only uses one widget
189 virtual void GrabFocus() {}
191 // this function can call with the same
193 virtual void SetPointer( PointerStyle ePointerStyle
) = 0;
194 virtual void CaptureMouse( bool bMouse
) = 0;
195 virtual void SetPointerPos( tools::Long nX
, tools::Long nY
) = 0;
197 // flush output buffer
198 virtual void Flush() = 0;
199 virtual void Flush( const tools::Rectangle
& );
201 virtual void SetInputContext( SalInputContext
* pContext
) = 0;
202 virtual void EndExtTextInput( EndExtTextInputFlags nFlags
) = 0;
204 virtual OUString
GetKeyName( sal_uInt16 nKeyCode
) = 0;
206 // returns in 'rKeyCode' the single keycode that translates to the given unicode when using a keyboard layout of language 'aLangType'
207 // returns false if no mapping exists or function not supported
208 // this is required for advanced menu support
209 virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode
, LanguageType aLangType
, vcl::KeyCode
& rKeyCode
) = 0;
211 // returns the input language used for the last key stroke
212 // may be LANGUAGE_DONTKNOW if not supported by the OS
213 virtual LanguageType
GetInputLanguage() = 0;
215 virtual void UpdateSettings( AllSettings
& rSettings
) = 0;
217 virtual void Beep() = 0;
219 virtual void FlashWindow() const {};
221 // returns system data (most prominent: window handle)
222 virtual const SystemEnvData
& GetSystemData() const = 0;
224 // tdf#139609 SystemEnvData::GetWindowHandle() calls this to on-demand fill the aWindow
225 // member of SystemEnvData for backends that want to defer doing that
226 virtual void ResolveWindowHandle(SystemEnvData
& /*rData*/) const {};
228 // get current modifier, button mask and mouse position
229 struct SalPointerState
232 Point maPos
; // in frame coordinates
235 virtual SalPointerState
GetPointerState() = 0;
237 virtual KeyIndicatorState
GetIndicatorState() = 0;
239 virtual void SimulateKeyPress( sal_uInt16 nKeyCode
) = 0;
241 // set new parent window
242 virtual void SetParent( SalFrame
* pNewParent
) = 0;
243 // reparent window to act as a plugin; implementation
244 // may choose to use a new system window internally
245 // return false to indicate failure
246 virtual void SetPluginParent( SystemParentData
* pNewParent
) = 0;
248 // move the frame to a new screen
249 virtual void SetScreenNumber( unsigned int nScreen
) = 0;
251 virtual void SetApplicationID( const OUString
&rApplicationID
) = 0;
253 // shaped system windows
254 // set clip region to none (-> rectangular windows, normal state)
255 virtual void ResetClipRegion() = 0;
256 // start setting the clipregion consisting of nRects rectangles
257 virtual void BeginSetClipRegion( sal_uInt32 nRects
) = 0;
258 // add a rectangle to the clip region
259 virtual void UnionClipRegion( tools::Long nX
, tools::Long nY
, tools::Long nWidth
, tools::Long nHeight
) = 0;
260 // done setting up the clipregion
261 virtual void EndSetClipRegion() = 0;
263 virtual void SetModal(bool /*bModal*/)
267 // return true to indicate tooltips are shown natively, false otherwise
268 virtual bool ShowTooltip(const OUString
& /*rHelpText*/, const tools::Rectangle
& /*rHelpArea*/)
273 // return !0 to indicate popovers are shown natively, 0 otherwise
274 virtual void* ShowPopover(const OUString
& /*rHelpText*/, vcl::Window
* /*pParent*/, const tools::Rectangle
& /*rHelpArea*/, QuickHelpFlags
/*nFlags*/)
279 // return true to indicate popovers are shown natively, false otherwise
280 virtual bool UpdatePopover(void* /*nId*/, const OUString
& /*rHelpText*/, vcl::Window
* /*pParent*/, const tools::Rectangle
& /*rHelpArea*/)
285 // return true to indicate popovers are shown natively, false otherwise
286 virtual bool HidePopover(void* /*nId*/)
291 virtual weld::Window
* GetFrameWeld() const;
293 // Callbacks (independent part in vcl/source/window/winproc.cxx)
294 // for default message handling return 0
295 void SetCallback( vcl::Window
* pWindow
, SALFRAMEPROC pProc
);
297 // returns the instance set
298 vcl::Window
* GetWindow() const { return m_pWindow
; }
300 void SetModalHierarchyHdl(const Link
<bool, void>& rLink
) { m_aModalHierarchyHdl
= rLink
; }
301 void NotifyModalHierarchy(bool bModal
) { m_aModalHierarchyHdl
.Call(bModal
); }
303 virtual void UpdateDarkMode() {}
304 virtual bool GetUseDarkMode() const { return false; }
305 virtual bool GetUseReducedAnimation() const { return false; };
307 // Call the callback set; this sometimes necessary for implementation classes
308 // that should not know more than necessary about the SalFrame implementation
309 // (e.g. input methods, printer update handlers).
310 bool CallCallback( SalEvent nEvent
, const void* pEvent
) const
311 { return m_pProc
&& m_pProc( m_pWindow
, nEvent
, pEvent
); }
313 // Helper method for input method handling: Calculate cursor index in (UTF-16) OUString,
314 // starting at nCursorIndex, moving number of characters (not UTF-16 codepoints) specified
315 // in nOffset, nChars.
316 static Selection
CalcDeleteSurroundingSelection(std::u16string_view rSurroundingText
,
317 sal_Int32 nCursorIndex
, int nOffset
, int nChars
);
319 virtual void SetTaskBarProgress(int /*nCurrentProgress*/) {}
320 virtual void SetTaskBarState(VclTaskBarStates
/*eTaskBarState*/) {}
323 #endif // INCLUDED_VCL_INC_SALFRAME_HXX
325 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */