LibreOffice Module vcl (master) 1
salframe.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_VCL_INC_SALFRAME_HXX
21#define INCLUDED_VCL_INC_SALFRAME_HXX
22
23#include "impdel.hxx"
24#include "salwtype.hxx"
25#include "salgeom.hxx"
26
27#include <vcl/help.hxx>
29
30#include <vcl/window.hxx>
31 // complete vcl::Window for SalFrame::CallCallback under -fsanitize=function
32
33class AllSettings;
34class SalGraphics;
35class SalBitmap;
36class SalMenu;
37
38namespace vcl { class WindowData; }
39struct SalInputContext;
40struct SystemEnvData;
41
42// SalFrame types
43enum class SalFrameToTop {
44 NONE = 0x00,
45 RestoreWhenMin = 0x01,
46 ForegroundTask = 0x02,
47 GrabFocus = 0x04,
48 GrabFocusOnly = 0x08
49};
50namespace o3tl {
51 template<> struct typed_flags<SalFrameToTop> : is_typed_flags<SalFrameToTop, 0x0f> {};
52};
53
54namespace vcl { class KeyCode; }
55
56namespace weld
57{
58 class Window;
59}
60
61enum class FloatWinPopupFlags;
62
63// SalFrame styles
65{
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 // tdf#144624: don't set icon
82 NOICON = 0x01000000,
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,
91};
92
93namespace o3tl {
94 template<> struct typed_flags<SalFrameStyleFlags> : is_typed_flags<SalFrameStyleFlags, 0x798001ff> {};
95};
96
97// Extended frame style (sal equivalent to extended WinBits)
98typedef sal_uInt64 SalExtStyle;
99#define SAL_FRAME_EXT_STYLE_DOCUMENT SalExtStyle(0x00000001)
100#define SAL_FRAME_EXT_STYLE_DOCMODIFIED SalExtStyle(0x00000002)
101
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))
107
108struct SystemParentData;
109struct ImplSVEvent;
110
113 : public vcl::DeletionNotifier
114 , public SalGeometryProvider
115{
116private:
117 // the VCL window corresponding to this frame
121protected:
122 mutable std::unique_ptr<weld::Window> m_xFrameWeld;
123public:
124 SalFrame();
125 virtual ~SalFrame() override;
126
128
129 // SalGeometryProvider
130 virtual tools::Long GetWidth() const override { return maGeometry.width(); }
131 virtual tools::Long GetHeight() const override { return maGeometry.height(); }
132 virtual bool IsOffScreen() const override { return false; }
133
134 // SalGraphics or NULL, but two Graphics for all SalFrames
135 // must be returned
137 virtual void ReleaseGraphics( SalGraphics* pGraphics ) = 0;
138
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;
142
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
148 virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle ) = 0;
149
150 // Before the window is visible, a resize event
151 // must be sent with the correct size
152 virtual void Show( bool bVisible, bool bNoActivate = false ) = 0;
153
154 // Set ClientSize and Center the Window to the desktop
155 // and send/post a resize message
156 virtual void SetMinClientSize( tools::Long nWidth, tools::Long nHeight ) = 0;
157 virtual void SetMaxClientSize( tools::Long nWidth, tools::Long nHeight ) = 0;
158 virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags ) = 0;
159 static OUString DumpSetPosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags);
160 virtual void GetClientSize( tools::Long& rWidth, tools::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; }
166
167 virtual void SetWindowState(const vcl::WindowData*) = 0;
168 // return the absolute, unmirrored system frame state
169 // if this returns false the structure is uninitialised
170 [[nodiscard]]
171 virtual bool GetWindowState(vcl::WindowData*) = 0;
172 virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) = 0;
174
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;
179
180 // Window to top and grab focus
181 virtual void ToTop( SalFrameToTop nFlags ) = 0;
182
183 // grab focus to the main widget, can be no-op if the vclplug only uses one widget
184 virtual void GrabFocus() {}
185
186 // this function can call with the same
187 // pointer style
188 virtual void SetPointer( PointerStyle ePointerStyle ) = 0;
189 virtual void CaptureMouse( bool bMouse ) = 0;
190 virtual void SetPointerPos( tools::Long nX, tools::Long nY ) = 0;
191
192 // flush output buffer
193 virtual void Flush() = 0;
194 virtual void Flush( const tools::Rectangle& );
195
196 virtual void SetInputContext( SalInputContext* pContext ) = 0;
197 virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) = 0;
198
199 virtual OUString GetKeyName( sal_uInt16 nKeyCode ) = 0;
200
201 // returns in 'rKeyCode' the single keycode that translates to the given unicode when using a keyboard layout of language 'aLangType'
202 // returns false if no mapping exists or function not supported
203 // this is required for advanced menu support
204 virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) = 0;
205
206 // returns the input language used for the last key stroke
207 // may be LANGUAGE_DONTKNOW if not supported by the OS
209
210 virtual void UpdateSettings( AllSettings& rSettings ) = 0;
211
212 virtual void Beep() = 0;
213
214 // returns system data (most prominent: window handle)
215 virtual const SystemEnvData*
216 GetSystemData() const = 0;
217
218 // tdf#139609 SystemEnvData::GetWindowHandle() calls this to on-demand fill the aWindow
219 // member of SystemEnvData for backends that want to defer doing that
220 virtual void ResolveWindowHandle(SystemEnvData& /*rData*/) const {};
221
222 // get current modifier, button mask and mouse position
224 {
225 sal_Int32 mnState;
226 Point maPos; // in frame coordinates
227 };
228
230
232
233 virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) = 0;
234
235 // set new parent window
236 virtual void SetParent( SalFrame* pNewParent ) = 0;
237 // reparent window to act as a plugin; implementation
238 // may choose to use a new system window internally
239 // return false to indicate failure
240 virtual void SetPluginParent( SystemParentData* pNewParent ) = 0;
241
242 // move the frame to a new screen
243 virtual void SetScreenNumber( unsigned int nScreen ) = 0;
244
245 virtual void SetApplicationID( const OUString &rApplicationID) = 0;
246
247 // shaped system windows
248 // set clip region to none (-> rectangular windows, normal state)
249 virtual void ResetClipRegion() = 0;
250 // start setting the clipregion consisting of nRects rectangles
251 virtual void BeginSetClipRegion( sal_uInt32 nRects ) = 0;
252 // add a rectangle to the clip region
253 virtual void UnionClipRegion( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) = 0;
254 // done setting up the clipregion
255 virtual void EndSetClipRegion() = 0;
256
257 virtual void SetModal(bool /*bModal*/)
258 {
259 }
260
261 virtual bool GetModal() const
262 {
263 return false;
264 }
265
266 // return true to indicate tooltips are shown natively, false otherwise
267 virtual bool ShowTooltip(const OUString& /*rHelpText*/, const tools::Rectangle& /*rHelpArea*/)
268 {
269 return false;
270 }
271
272 // return !0 to indicate popovers are shown natively, 0 otherwise
273 virtual void* ShowPopover(const OUString& /*rHelpText*/, vcl::Window* /*pParent*/, const tools::Rectangle& /*rHelpArea*/, QuickHelpFlags /*nFlags*/)
274 {
275 return nullptr;
276 }
277
278 // return true to indicate popovers are shown natively, false otherwise
279 virtual bool UpdatePopover(void* /*nId*/, const OUString& /*rHelpText*/, vcl::Window* /*pParent*/, const tools::Rectangle& /*rHelpArea*/)
280 {
281 return false;
282 }
283
284 // return true to indicate popovers are shown natively, false otherwise
285 virtual bool HidePopover(void* /*nId*/)
286 {
287 return false;
288 }
289
290 virtual weld::Window* GetFrameWeld() const;
291
292 // Callbacks (independent part in vcl/source/window/winproc.cxx)
293 // for default message handling return 0
294 void SetCallback( vcl::Window* pWindow, SALFRAMEPROC pProc );
295
296 // returns the instance set
297 vcl::Window* GetWindow() const { return m_pWindow; }
298
299 void SetModalHierarchyHdl(const Link<bool, void>& rLink) { m_aModalHierarchyHdl = rLink; }
300 void NotifyModalHierarchy(bool bModal) { m_aModalHierarchyHdl.Call(bModal); }
301
302 virtual void UpdateDarkMode() {}
303 virtual bool GetUseDarkMode() const { return false; }
304 virtual bool GetUseReducedAnimation() const { return false; };
305
306 // Call the callback set; this sometimes necessary for implementation classes
307 // that should not know more than necessary about the SalFrame implementation
308 // (e.g. input methods, printer update handlers).
309 bool CallCallback( SalEvent nEvent, const void* pEvent ) const
310 { return m_pProc && m_pProc( m_pWindow, nEvent, pEvent ); }
311
312 // Helper method for input method handling: Calculate cursor index in (UTF-16) OUString,
313 // starting at nCursorIndex, moving number of characters (not UTF-16 codepoints) specified
314 // in nOffset, nChars.
315 static Selection CalcDeleteSurroundingSelection(const OUString& rSurroundingText,
316 sal_Int32 nCursorIndex, int nOffset, int nChars);
317};
318
319#ifdef _WIN32
320bool HasAtHook();
321#endif
322
323#endif // INCLUDED_VCL_INC_SALFRAME_HXX
324
325/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:115
virtual void UnionClipRegion(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight)=0
virtual void ToTop(SalFrameToTop nFlags)=0
virtual void GrabFocus()
Definition: salframe.hxx:184
virtual void Flush()=0
virtual LanguageType GetInputLanguage()=0
bool CallCallback(SalEvent nEvent, const void *pEvent) const
Definition: salframe.hxx:309
Link< bool, void > m_aModalHierarchyHdl
Definition: salframe.hxx:120
virtual bool GetWindowState(vcl::WindowData *)=0
virtual void UpdateSettings(AllSettings &rSettings)=0
virtual void GetWorkArea(tools::Rectangle &rRect)=0
SalFrameGeometry maGeometry
absolute, unmirrored values
Definition: salframe.hxx:127
virtual void SetMaxClientSize(tools::Long nWidth, tools::Long nHeight)=0
virtual bool PostEvent(std::unique_ptr< ImplSVEvent > pData)=0
virtual bool HidePopover(void *)
Definition: salframe.hxx:285
virtual void SetIcon(sal_uInt16 nIcon)=0
virtual void CaptureMouse(bool bMouse)=0
VclPtr< vcl::Window > m_pWindow
Definition: salframe.hxx:118
virtual tools::Long GetWidth() const override
Definition: salframe.hxx:130
void NotifyModalHierarchy(bool bModal)
Definition: salframe.hxx:300
virtual void SetMenu(SalMenu *pSalMenu)=0
virtual void SetInputContext(SalInputContext *pContext)=0
virtual void SetParent(SalFrame *pNewParent)=0
virtual void Beep()=0
virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle)=0
virtual void ResetClipRegion()=0
virtual void ReleaseGraphics(SalGraphics *pGraphics)=0
virtual void GetClientSize(tools::Long &rWidth, tools::Long &rHeight)=0
virtual void BeginSetClipRegion(sal_uInt32 nRects)=0
virtual void SetPointer(PointerStyle ePointerStyle)=0
virtual void EndSetClipRegion()=0
virtual bool UpdatePopover(void *, const OUString &, vcl::Window *, const tools::Rectangle &)
Definition: salframe.hxx:279
virtual void StartPresentation(bool bStart)=0
virtual void * ShowPopover(const OUString &, vcl::Window *, const tools::Rectangle &, QuickHelpFlags)
Definition: salframe.hxx:273
virtual bool GetUseDarkMode() const
Definition: salframe.hxx:303
const SalFrameGeometry & GetUnmirroredGeometry() const
Definition: salframe.hxx:165
virtual void ShowFullScreen(bool bFullScreen, sal_Int32 nDisplay)=0
virtual bool GetUseReducedAnimation() const
Definition: salframe.hxx:304
virtual void SetWindowState(const vcl::WindowData *)=0
void SetModalHierarchyHdl(const Link< bool, void > &rLink)
Definition: salframe.hxx:299
SALFRAMEPROC m_pProc
Definition: salframe.hxx:119
virtual bool ShowTooltip(const OUString &, const tools::Rectangle &)
Definition: salframe.hxx:267
virtual tools::Long GetHeight() const override
Definition: salframe.hxx:131
virtual bool MapUnicodeToKeyCode(sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode &rKeyCode)=0
virtual void SetTitle(const OUString &rTitle)=0
virtual SalFrame * GetParent() const =0
virtual void SetModal(bool)
Definition: salframe.hxx:257
virtual void SetScreenNumber(unsigned int nScreen)=0
virtual bool IsOffScreen() const override
Definition: salframe.hxx:132
virtual void EndExtTextInput(EndExtTextInputFlags nFlags)=0
virtual const SystemEnvData * GetSystemData() const =0
virtual void UpdateDarkMode()
Definition: salframe.hxx:302
vcl::Window * GetWindow() const
Definition: salframe.hxx:297
virtual SalPointerState GetPointerState()=0
std::unique_ptr< weld::Window > m_xFrameWeld
Definition: salframe.hxx:122
virtual SalGraphics * AcquireGraphics()=0
virtual void SetPluginParent(SystemParentData *pNewParent)=0
virtual void Show(bool bVisible, bool bNoActivate=false)=0
virtual void SetAlwaysOnTop(bool bOnTop)=0
virtual void SetMinClientSize(tools::Long nWidth, tools::Long nHeight)=0
virtual void SetPointerPos(tools::Long nX, tools::Long nY)=0
virtual OUString GetKeyName(sal_uInt16 nKeyCode)=0
virtual void PositionByToolkit(const tools::Rectangle &, FloatWinPopupFlags)
Definition: salframe.hxx:173
virtual KeyIndicatorState GetIndicatorState()=0
virtual void SetPosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags)=0
virtual bool GetModal() const
Definition: salframe.hxx:261
virtual void ResolveWindowHandle(SystemEnvData &) const
Definition: salframe.hxx:220
virtual void SimulateKeyPress(sal_uInt16 nKeyCode)=0
virtual void SetApplicationID(const OUString &rApplicationID)=0
Interface used to share logic on sizing between SalVirtualDevices and SalFrames.
Definition: salgeom.hxx:80
constexpr sal_Int32 height() const
constexpr sal_Int32 width() const
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
#define VCL_PLUGIN_PUBLIC
Definition: dllapi.h:40
QuickHelpFlags
Definition: help.hxx:33
KeyIndicatorState
Definition: keycodes.hxx:187
NONE
long Long
PointerStyle
Definition: ptrstyle.hxx:26
sal_uInt64 SalExtStyle
Definition: salframe.hxx:95
SalFrameToTop
Definition: salframe.hxx:43
SalFrameStyleFlags
Definition: salframe.hxx:65
bool(* SALFRAMEPROC)(vcl::Window *pInst, SalEvent nEvent, const void *pEvent)
Definition: salwtype.hxx:233
SalEvent
Definition: salwtype.hxx:46
sal_uInt16 sal_Unicode
FloatWinPopupFlags
Definition: vclenum.hxx:323
EndExtTextInputFlags
Definition: window.hxx:346