LibreOffice Module vcl (master) 1
osx/salframe.h
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_OSX_SALFRAME_H
21#define INCLUDED_VCL_INC_OSX_SALFRAME_H
22
23#include <premac.h>
24#include <IOKit/pwr_mgt/IOPMLib.h>
25#include <postmac.h>
26
27#include <tools/long.hxx>
28#include <vcl/sysdata.hxx>
29
30#include <osx/salinst.h>
31#include <osx/salmenu.h>
32#include <osx/saldata.hxx>
33#include <osx/osxvcltypes.h>
34
35#include <salframe.hxx>
36
37#include <vector>
38#include <utility>
39#include <stdexcept>
40
41class AquaSalGraphics;
42class AquaSalFrame;
43class AquaSalTimer;
44class AquaSalInstance;
45class AquaSalMenu;
46
47class AquaSalFrame : public SalFrame
48{
49public:
50 NSWindow* mpNSWindow; // Cocoa window
51 NSView* mpNSView; // Cocoa view (actually a custom view)
52 NSMenuItem* mpDockMenuEntry; // entry in the dynamic dock menu
53 NSRect maScreenRect; // for mirroring purposes
54 AquaSalGraphics* mpGraphics; // current frame graphics
55 AquaSalFrame* mpParent; // pointer to parent frame
56 SystemEnvData maSysData; // system data
57 int mnMinWidth; // min. client width in pixels
58 int mnMinHeight; // min. client height in pixels
59 int mnMaxWidth; // max. client width in pixels
60 int mnMaxHeight; // max. client height in pixels
61 NSRect maFullScreenRect; // old window size when in FullScreen
62 bool mbGraphics; // is Graphics used?
63 bool mbFullScreen; // is Window in FullScreen?
64 bool mbShown;
67 bool mbSized;
69
71 unsigned int mnStyleMask; // our style mask from NSWindow creation
72
73 sal_uInt64 mnLastEventTime;
74 unsigned int mnLastModifierFlags;
76
77 SalExtStyle mnExtStyle; // currently document frames are marked this way
78
79 PointerStyle mePointerStyle; // currently active pointer style
80
81 NSTrackingRectTag mnTrackingRectTag; // used to get enter/leave messages
83
84 CGMutablePathRef mrClippingPath; // used for "shaping"
85 std::vector< CGRect > maClippingRects;
86
88
90
91 // To prevent display sleep during presentation
92 IOPMAssertionID mnAssertionID;
93
96
98
100
101public:
108 AquaSalFrame( SalFrame* pParent, SalFrameStyleFlags salFrameStyle );
109
110 virtual ~AquaSalFrame() override;
111
112 virtual SalGraphics* AcquireGraphics() override;
113 virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
114 virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
115 virtual void SetTitle( const OUString& rTitle ) override;
116 virtual void SetIcon( sal_uInt16 nIcon ) override;
117 virtual void SetRepresentedURL( const OUString& ) override;
118 virtual void SetMenu( SalMenu* pSalMenu ) override;
119 virtual void Show( bool bVisible, bool bNoActivate = false ) override;
120 virtual void SetMinClientSize( tools::Long nWidth, tools::Long nHeight )
121 override;
122 virtual void SetMaxClientSize( tools::Long nWidth, tools::Long nHeight )
123 override;
124 virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags ) override;
125 virtual void GetClientSize( tools::Long& rWidth, tools::Long& rHeight ) override;
126 virtual void GetWorkArea( tools::Rectangle& rRect ) override;
127 virtual SalFrame* GetParent() const override;
128 virtual void SetWindowState(const vcl::WindowData*) override;
129 virtual bool GetWindowState(vcl::WindowData*) override;
130 virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) override;
131 virtual void StartPresentation( bool bStart ) override;
132 virtual void SetAlwaysOnTop( bool bOnTop ) override;
133 virtual void ToTop( SalFrameToTop nFlags ) override;
134 virtual void SetPointer( PointerStyle ePointerStyle ) override;
135 virtual void CaptureMouse( bool bMouse ) override;
136 virtual void SetPointerPos( tools::Long nX, tools::Long nY ) override;
137 virtual void Flush( void ) override;
138 virtual void Flush( const tools::Rectangle& ) override;
139 virtual void SetInputContext( SalInputContext* pContext ) override;
140 virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) override;
141 virtual OUString GetKeyName( sal_uInt16 nKeyCode ) override;
142 virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) override;
143 virtual LanguageType GetInputLanguage() override;
144 virtual void UpdateSettings( AllSettings& rSettings ) override;
145 virtual void Beep() override;
146 virtual const SystemEnvData* GetSystemData() const override;
149 virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) override;
150 virtual void SetParent( SalFrame* pNewParent ) override;
151 virtual void SetPluginParent( SystemParentData* pNewParent ) override;
152 virtual void SetExtendedFrameStyle( SalExtStyle ) override;
153 virtual void SetScreenNumber(unsigned int) override;
154 virtual void SetApplicationID( const OUString &rApplicationID ) override;
155
156 // shaped system windows
157 // set clip region to none (-> rectangular windows, normal state)
158 virtual void ResetClipRegion() override;
159 // start setting the clipregion consisting of nRects rectangles
160 virtual void BeginSetClipRegion( sal_uInt32 nRects ) override;
161 // add a rectangle to the clip region
162 virtual void UnionClipRegion(
163 tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override;
164 // done setting up the clipregion
165 virtual void EndSetClipRegion() override;
166 virtual void UpdateDarkMode() override;
167 virtual bool GetUseDarkMode() const override;
168 virtual bool GetUseReducedAnimation() const override;
169
171
172 // trigger painting of the window
173 void SendPaintEvent( const tools::Rectangle* pRect = nullptr );
174
175 static inline bool isAlive( const AquaSalFrame* pFrame );
176
178
179 NSWindow* getNSWindow() const { return mpNSWindow; }
180 NSView* getNSView() const { return mpNSView; }
181 unsigned int getStyleMask() const { return mnStyleMask; }
182
183 void getResolution( sal_Int32& o_rDPIX, sal_Int32& o_rDPIY );
184
185 // actually the following methods do the same thing: flipping y coordinates
186 // but having two of them makes clearer what the coordinate system
187 // is supposed to be before and after
188 void VCLToCocoa( NSRect& io_rRect, bool bRelativeToScreen = true );
189 void CocoaToVCL( NSRect& io_rRect, bool bRelativeToScreen = true );
190
191 void VCLToCocoa( NSPoint& io_rPoint, bool bRelativeToScreen = true );
192 void CocoaToVCL( NSPoint& io_Point, bool bRelativeToScreen = true );
193
194 NSCursor* getCurrentCursor();
195
196 CGMutablePathRef getClipPath() const { return mrClippingPath; }
197
198 // called by VCL_NSApplication to indicate screen settings have changed
200
201protected:
203 tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags);
204
205private: // methods
208 void initShow();
209
211
212 void doShowFullScreen( bool bFullScreen, sal_Int32 nDisplay );
213
215
216private: // data
218
219 AquaSalFrame( const AquaSalFrame& ) = delete;
221};
222
223inline bool AquaSalFrame::isAlive( const AquaSalFrame* pFrame )
224{
226 return pInst && pInst->isFrameAlive( pFrame );
227}
228
229#endif // INCLUDED_VCL_INC_OSX_SALFRAME_H
230
231/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SetTitle(const OUString &rTitle) override
SalExtStyle mnExtStyle
Definition: osx/salframe.h:77
virtual void GetClientSize(tools::Long &rWidth, tools::Long &rHeight) override
virtual void SetPluginParent(SystemParentData *pNewParent) override
std::vector< CGRect > maClippingRects
Definition: osx/salframe.h:85
virtual ~AquaSalFrame() override
virtual void SimulateKeyPress(sal_uInt16 nKeyCode) override
void CocoaToVCL(NSRect &io_rRect, bool bRelativeToScreen=true)
void doResetClipRegion()
virtual void ResetClipRegion() override
virtual void SetScreenNumber(unsigned int) override
virtual const SystemEnvData * GetSystemData() const override
void SendPaintEvent(const tools::Rectangle *pRect=nullptr)
NSRect maFrameRect
Definition: osx/salframe.h:94
virtual void GetWorkArea(tools::Rectangle &rRect) override
virtual void SetIcon(sal_uInt16 nIcon) override
virtual void Flush(void) override
virtual SalFrame * GetParent() const override
virtual void EndSetClipRegion() override
virtual void CaptureMouse(bool bMouse) override
void screenParametersChanged()
virtual void ReleaseGraphics(SalGraphics *pGraphics) override
virtual void Beep() override
bool mbFullScreen
Definition: osx/salframe.h:63
virtual void SetParent(SalFrame *pNewParent) override
virtual bool GetUseReducedAnimation() const override
NSRect maTrackingRect
Definition: osx/salframe.h:82
void VCLToCocoa(NSPoint &io_rPoint, bool bRelativeToScreen=true)
virtual void SetMenu(SalMenu *pSalMenu) override
virtual SalGraphics * AcquireGraphics() override
static AquaSalFrame * GetCaptureFrame()
Definition: osx/salframe.h:177
virtual void UpdateDarkMode() override
NSView * mpNSView
Definition: osx/salframe.h:51
virtual bool PostEvent(std::unique_ptr< ImplSVEvent > pData) override
virtual void SetAlwaysOnTop(bool bOnTop) override
void initWindowAndView()
AquaSalFrame(SalFrame *pParent, SalFrameStyleFlags salFrameStyle)
Constructor.
virtual void SetInputContext(SalInputContext *pContext) override
NSRect maContentRect
Definition: osx/salframe.h:95
NSMenuItem * mpDockMenuEntry
Definition: osx/salframe.h:52
tools::Rectangle maInvalidRect
Definition: osx/salframe.h:87
sal_uInt64 mnLastEventTime
Definition: osx/salframe.h:73
SalFrameStyleFlags mnStyle
Definition: osx/salframe.h:70
PointerStyle mePointerStyle
Definition: osx/salframe.h:79
virtual void SetPosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags) override
NSWindow * mpNSWindow
Definition: osx/salframe.h:50
virtual void Flush(const tools::Rectangle &) override
virtual bool GetUseDarkMode() const override
virtual void SetPointer(PointerStyle ePointerStyle) override
virtual void SetRepresentedURL(const OUString &) override
void getResolution(sal_Int32 &o_rDPIX, sal_Int32 &o_rDPIY)
void UpdateFrameGeometry()
void CocoaToVCL(NSPoint &io_Point, bool bRelativeToScreen=true)
virtual bool MapUnicodeToKeyCode(sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode &rKeyCode) override
NSCursor * getCurrentCursor()
NSRect maScreenRect
Definition: osx/salframe.h:53
int mnBlinkCursorDelay
Definition: osx/salframe.h:99
SystemEnvData maSysData
Definition: osx/salframe.h:56
void doShowFullScreen(bool bFullScreen, sal_Int32 nDisplay)
CGMutablePathRef mrClippingPath
Definition: osx/salframe.h:84
NSRect maFullScreenRect
Definition: osx/salframe.h:61
NSView * getNSView() const
Definition: osx/salframe.h:180
static bool isAlive(const AquaSalFrame *pFrame)
Definition: osx/salframe.h:223
virtual KeyIndicatorState GetIndicatorState() override
virtual void Show(bool bVisible, bool bNoActivate=false) override
virtual void SetExtendedFrameStyle(SalExtStyle) override
virtual void UnionClipRegion(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight) override
unsigned int mnStyleMask
Definition: osx/salframe.h:71
NSWindow * getNSWindow() const
Definition: osx/salframe.h:179
virtual bool GetWindowState(vcl::WindowData *) override
IOPMAssertionID mnAssertionID
Definition: osx/salframe.h:92
virtual void EndExtTextInput(EndExtTextInputFlags nFlags) override
AquaSalGraphics * mpGraphics
Definition: osx/salframe.h:54
AquaSalFrame * mpParent
Definition: osx/salframe.h:55
virtual void ShowFullScreen(bool bFullScreen, sal_Int32 nDisplay) override
virtual SalPointerState GetPointerState() override
virtual void UpdateSettings(AllSettings &rSettings) override
static AquaSalFrame * s_pCaptureFrame
Definition: osx/salframe.h:217
AquaSalMenu * mpMenu
Definition: osx/salframe.h:75
virtual void SetPointerPos(tools::Long nX, tools::Long nY) override
virtual OUString GetKeyName(sal_uInt16 nKeyCode) override
virtual void SetApplicationID(const OUString &rApplicationID) override
bool mbPositioned
Definition: osx/salframe.h:66
NSTrackingRectTag mnTrackingRectTag
Definition: osx/salframe.h:81
void VCLToCocoa(NSRect &io_rRect, bool bRelativeToScreen=true)
bool mbGeometryDidChange
Definition: osx/salframe.h:97
virtual LanguageType GetInputLanguage() override
AquaSalFrame & operator=(const AquaSalFrame &)=delete
virtual void StartPresentation(bool bStart) override
InputContextFlags mnICOptions
Definition: osx/salframe.h:89
virtual void SetMaxClientSize(tools::Long nWidth, tools::Long nHeight) override
unsigned int getStyleMask() const
Definition: osx/salframe.h:181
AquaSalFrame(const AquaSalFrame &)=delete
CGMutablePathRef getClipPath() const
Definition: osx/salframe.h:196
virtual void SetWindowState(const vcl::WindowData *) override
bool mbPresentation
Definition: osx/salframe.h:68
unsigned int mnLastModifierFlags
Definition: osx/salframe.h:74
virtual void ToTop(SalFrameToTop nFlags) override
SalEvent PreparePosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags)
virtual void SetMinClientSize(tools::Long nWidth, tools::Long nHeight) override
virtual void BeginSetClipRegion(sal_uInt32 nRects) override
void initShow()
do things on initial show (like centering on parent or on screen)
AquaSalInstance * mpInstance
Definition: osx/saldata.hxx:67
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:115
bool isFrameAlive(const SalFrame *pFrame) const
InputContextFlags
Definition: inputctx.hxx:30
KeyIndicatorState
Definition: keycodes.hxx:187
long Long
PointerStyle
Definition: ptrstyle.hxx:26
sal_uInt64 SalExtStyle
Definition: salframe.hxx:95
SalFrameToTop
Definition: salframe.hxx:43
SalFrameStyleFlags
Definition: salframe.hxx:65
SalEvent
Definition: salwtype.hxx:46
SalData * GetSalData()
Definition: svdata.hxx:471
sal_uInt16 sal_Unicode
EndExtTextInputFlags
Definition: window.hxx:346