Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / vcl / inc / salframe.hxx
blob7555526ba3ea8d5e5579c6a551e17a1b3e67b144
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 <vcl/window.hxx>
29 #include <o3tl/typed_flags_set.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 // SalFrame styles
55 enum class SalFrameStyleFlags
57 NONE = 0x00000000,
58 DEFAULT = 0x00000001,
59 MOVEABLE = 0x00000002,
60 SIZEABLE = 0x00000004,
61 CLOSEABLE = 0x00000008,
62 // no shadow effect on Windows XP
63 NOSHADOW = 0x00000010,
64 // indicate tooltip windows, so they can always be topmost
65 TOOLTIP = 0x00000020,
66 // windows without windowmanager decoration, this typically only applies to floating windows
67 OWNERDRAWDECORATION = 0x00000040,
68 // dialogs
69 DIALOG = 0x00000080,
70 // the window containing the intro bitmap, aka splashscreen
71 INTRO = 0x00000100,
72 // partial fullscreen: fullscreen on one monitor of a multimonitor display
73 PARTIAL_FULLSCREEN = 0x00800000,
74 // system child window inside another SalFrame
75 SYSTEMCHILD = 0x08000000,
76 // plugged system child window
77 PLUG = 0x10000000,
78 // floating window
79 FLOAT = 0x20000000,
80 // toolwindows should be painted with a smaller decoration
81 TOOLWINDOW = 0x40000000,
83 namespace o3tl {
84 template<> struct typed_flags<SalFrameStyleFlags> : is_typed_flags<SalFrameStyleFlags, 0x7c8001ff> {};
87 // - extended frame style -
88 // - (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;
112 public:
113 SalFrame();
114 virtual ~SalFrame();
116 SalFrameGeometry maGeometry;
118 // SalGeometryProvider
119 virtual long GetWidth() const override { return maGeometry.nWidth; }
120 virtual long GetHeight() const override { return maGeometry.nHeight; }
121 virtual bool IsOffScreen() const override { return false; }
123 // SalGraphics or NULL, but two Graphics for all SalFrames
124 // must be returned
125 virtual SalGraphics* AcquireGraphics() = 0;
126 virtual void ReleaseGraphics( SalGraphics* pGraphics ) = 0;
128 // Event must be destroyed, when Frame is destroyed
129 // When Event is called, SalInstance::Yield() must be returned
130 virtual bool PostEvent(ImplSVEvent* pData) = 0;
132 virtual void SetTitle( const OUString& rTitle ) = 0;
133 virtual void SetIcon( sal_uInt16 nIcon ) = 0;
134 virtual void SetRepresentedURL( const OUString& );
135 virtual void SetMenu( SalMenu *pSalMenu ) = 0;
136 virtual void DrawMenuBar() = 0;
138 virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle ) = 0;
140 // Before the window is visible, a resize event
141 // must be sent with the correct size
142 virtual void Show( bool bVisible, bool bNoActivate = false ) = 0;
144 // Set ClientSize and Center the Window to the desktop
145 // and send/post a resize message
146 virtual void SetMinClientSize( long nWidth, long nHeight ) = 0;
147 virtual void SetMaxClientSize( long nWidth, long nHeight ) = 0;
148 virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags ) = 0;
149 virtual void GetClientSize( long& rWidth, long& rHeight ) = 0;
150 virtual void GetWorkArea( Rectangle& rRect ) = 0;
151 virtual SalFrame* GetParent() const = 0;
152 // Note: x will be mirrored at parent if UI mirroring is active
153 SalFrameGeometry GetGeometry();
154 const SalFrameGeometry& GetUnmirroredGeometry() const { return maGeometry; }
156 virtual void SetWindowState( const SalFrameState* pState ) = 0;
157 // if this returns false the structure is uninitialised
158 SAL_WARN_UNUSED_RESULT
159 virtual bool GetWindowState( SalFrameState* pState ) = 0;
160 virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) = 0;
162 // Enable/Disable ScreenSaver, SystemAgents, ...
163 virtual void StartPresentation( bool bStart ) = 0;
164 // Show Window over all other Windows
165 virtual void SetAlwaysOnTop( bool bOnTop ) = 0;
167 // Window to top and grab focus
168 virtual void ToTop( SalFrameToTop nFlags ) = 0;
170 // this function can call with the same
171 // pointer style
172 virtual void SetPointer( PointerStyle ePointerStyle ) = 0;
173 virtual void CaptureMouse( bool bMouse ) = 0;
174 virtual void SetPointerPos( long nX, long nY ) = 0;
176 // flush output buffer
177 virtual void Flush() = 0;
178 virtual void Flush( const Rectangle& );
180 virtual void SetInputContext( SalInputContext* pContext ) = 0;
181 virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) = 0;
183 virtual OUString GetKeyName( sal_uInt16 nKeyCode ) = 0;
185 // returns in 'rKeyCode' the single keycode that translates to the given unicode when using a keyboard layout of language 'aLangType'
186 // returns false if no mapping exists or function not supported
187 // this is required for advanced menu support
188 virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) = 0;
190 // returns the input language used for the last key stroke
191 // may be LANGUAGE_DONTKNOW if not supported by the OS
192 virtual LanguageType GetInputLanguage() = 0;
194 virtual void UpdateSettings( AllSettings& rSettings ) = 0;
196 virtual void Beep() = 0;
198 // returns system data (most prominent: window handle)
199 virtual const SystemEnvData*
200 GetSystemData() const = 0;
202 // get current modifier, button mask and mouse position
203 struct SalPointerState
205 sal_uLong mnState;
206 Point maPos; // in frame coordinates
209 virtual SalPointerState GetPointerState() = 0;
211 virtual KeyIndicatorState GetIndicatorState() = 0;
213 virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) = 0;
215 // set new parent window
216 virtual void SetParent( SalFrame* pNewParent ) = 0;
217 // reparent window to act as a plugin; implementation
218 // may choose to use a new system window internally
219 // return false to indicate failure
220 virtual bool SetPluginParent( SystemParentData* pNewParent ) = 0;
222 // move the frame to a new screen
223 virtual void SetScreenNumber( unsigned int nScreen ) = 0;
225 virtual void SetApplicationID( const OUString &rApplicationID) = 0;
227 // shaped system windows
228 // set clip region to none (-> rectangular windows, normal state)
229 virtual void ResetClipRegion() = 0;
230 // start setting the clipregion consisting of nRects rectangles
231 virtual void BeginSetClipRegion( sal_uLong nRects ) = 0;
232 // add a rectangle to the clip region
233 virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) = 0;
234 // done setting up the clipregion
235 virtual void EndSetClipRegion() = 0;
237 virtual void SetModal(bool /*bModal*/)
241 // return true to indicate tooltips are shown natively, false otherwise
242 virtual bool ShowTooltip(const OUString& /*rHelpText*/, const Rectangle& /*rHelpArea*/)
244 return false;
247 // return !0 to indicate popovers are shown natively, 0 otherwise
248 virtual sal_uIntPtr ShowPopover(const OUString& /*rHelpText*/, const Rectangle& /*rHelpArea*/, QuickHelpFlags /*nFlags*/)
250 return 0;
253 // return true to indicate popovers are shown natively, false otherwise
254 virtual bool UpdatePopover(sal_uIntPtr /*nId*/, const OUString& /*rHelpText*/, const Rectangle& /*rHelpArea*/)
256 return false;
259 // return true to indicate popovers are shown natively, false otherwise
260 virtual bool HidePopover(sal_uIntPtr /*nId*/)
262 return false;
265 virtual void StartToolKitMoveBy()
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 long CallCallback( SalEvent nEvent, const void* pEvent ) const
280 { return m_pProc ? long(m_pProc( m_pWindow, nEvent, pEvent )) : 0; }
283 #endif // INCLUDED_VCL_INC_SALFRAME_HXX
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */