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