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_OSX_SALFRAME_H
21 #define INCLUDED_VCL_INC_OSX_SALFRAME_H
24 #include <IOKit/pwr_mgt/IOPMLib.h>
27 #include <vcl/sysdata.hxx>
29 #include <osx/salinst.h>
30 #include <osx/salmenu.h>
31 #include <osx/saldata.hxx>
32 #include <osx/osxvcltypes.h>
34 #include <salframe.hxx>
40 class AquaSalGraphics
;
43 class AquaSalInstance
;
46 class AquaSalFrame
: public SalFrame
49 NSWindow
* mpNSWindow
; // Cocoa window
50 NSView
* mpNSView
; // Cocoa view (actually a custom view)
51 NSMenuItem
* mpDockMenuEntry
; // entry in the dynamic dock menu
52 NSRect maScreenRect
; // for mirroring purposes
53 AquaSalGraphics
* mpGraphics
; // current frame graphics
54 AquaSalFrame
* mpParent
; // pointer to parent frame
55 SystemEnvData maSysData
; // system data
56 int mnMinWidth
; // min. client width in pixels
57 int mnMinHeight
; // min. client height in pixels
58 int mnMaxWidth
; // max. client width in pixels
59 int mnMaxHeight
; // max. client height in pixels
60 NSRect maFullScreenRect
; // old window size when in FullScreen
61 bool mbGraphics
; // is Graphics used?
62 bool mbFullScreen
; // is Window in FullScreen?
69 SalFrameStyleFlags mnStyle
;
70 unsigned int mnStyleMask
; // our style mask from NSWindow creation
72 sal_uInt64 mnLastEventTime
;
73 unsigned int mnLastModifierFlags
;
76 SalExtStyle mnExtStyle
; // currently document frames are marked this way
78 PointerStyle mePointerStyle
; // currently active pointer style
80 NSTrackingRectTag mnTrackingRectTag
; // used to get enter/leave messages
81 NSRect maTrackingRect
;
83 CGMutablePathRef mrClippingPath
; // used for "shaping"
84 std::vector
< CGRect
> maClippingRects
;
86 tools::Rectangle maInvalidRect
;
88 InputContextFlags mnICOptions
;
90 // To prevent display sleep during presentation
91 IOPMAssertionID mnAssertionID
;
96 bool mbGeometryDidChange
;
101 Creates a system window and connects this frame with it.
103 @throws std::runtime_error in case window creation fails
105 AquaSalFrame( SalFrame
* pParent
, SalFrameStyleFlags salFrameStyle
);
107 virtual ~AquaSalFrame() override
;
109 virtual SalGraphics
* AcquireGraphics() override
;
110 virtual void ReleaseGraphics( SalGraphics
* pGraphics
) override
;
111 virtual bool PostEvent(std::unique_ptr
<ImplSVEvent
> pData
) override
;
112 virtual void SetTitle( const OUString
& rTitle
) override
;
113 virtual void SetIcon( sal_uInt16 nIcon
) override
;
114 virtual void SetRepresentedURL( const OUString
& ) override
;
115 virtual void SetMenu( SalMenu
* pSalMenu
) override
;
116 virtual void DrawMenuBar() override
;
117 virtual void Show( bool bVisible
, bool bNoActivate
= false ) override
;
118 virtual void SetMinClientSize( long nWidth
, long nHeight
) override
;
119 virtual void SetMaxClientSize( long nWidth
, long nHeight
) override
;
120 virtual void SetPosSize( long nX
, long nY
, long nWidth
, long nHeight
, sal_uInt16 nFlags
) override
;
121 virtual void GetClientSize( long& rWidth
, long& rHeight
) override
;
122 virtual void GetWorkArea( tools::Rectangle
& rRect
) override
;
123 virtual SalFrame
* GetParent() const override
;
124 virtual void SetWindowState( const SalFrameState
* pState
) override
;
125 virtual bool GetWindowState( SalFrameState
* pState
) override
;
126 virtual void ShowFullScreen( bool bFullScreen
, sal_Int32 nDisplay
) override
;
127 virtual void StartPresentation( bool bStart
) override
;
128 virtual void SetAlwaysOnTop( bool bOnTop
) override
;
129 virtual void ToTop( SalFrameToTop nFlags
) override
;
130 virtual void SetPointer( PointerStyle ePointerStyle
) override
;
131 virtual void CaptureMouse( bool bMouse
) override
;
132 virtual void SetPointerPos( long nX
, long nY
) override
;
133 virtual void Flush( void ) override
;
134 virtual void Flush( const tools::Rectangle
& ) override
;
135 virtual void SetInputContext( SalInputContext
* pContext
) override
;
136 virtual void EndExtTextInput( EndExtTextInputFlags nFlags
) override
;
137 virtual OUString
GetKeyName( sal_uInt16 nKeyCode
) override
;
138 virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode
, LanguageType aLangType
, vcl::KeyCode
& rKeyCode
) override
;
139 virtual LanguageType
GetInputLanguage() override
;
140 virtual void UpdateSettings( AllSettings
& rSettings
) override
;
141 virtual void Beep() override
;
142 virtual const SystemEnvData
* GetSystemData() const override
;
143 virtual SalPointerState
GetPointerState() override
;
144 virtual KeyIndicatorState
GetIndicatorState() override
;
145 virtual void SimulateKeyPress( sal_uInt16 nKeyCode
) override
;
146 virtual void SetParent( SalFrame
* pNewParent
) override
;
147 virtual bool SetPluginParent( SystemParentData
* pNewParent
) override
;
148 virtual void SetExtendedFrameStyle( SalExtStyle
) override
;
149 virtual void SetScreenNumber(unsigned int) override
;
150 virtual void SetApplicationID( const OUString
&rApplicationID
) override
;
152 // shaped system windows
153 // set clip region to none (-> rectangular windows, normal state)
154 virtual void ResetClipRegion() override
;
155 // start setting the clipregion consisting of nRects rectangles
156 virtual void BeginSetClipRegion( sal_uInt32 nRects
) override
;
157 // add a rectangle to the clip region
158 virtual void UnionClipRegion( long nX
, long nY
, long nWidth
, long nHeight
) override
;
159 // done setting up the clipregion
160 virtual void EndSetClipRegion() override
;
162 void UpdateFrameGeometry();
164 // trigger painting of the window
165 void SendPaintEvent( const tools::Rectangle
* pRect
= nullptr );
167 static inline bool isAlive( const AquaSalFrame
* pFrame
);
169 static AquaSalFrame
* GetCaptureFrame() { return s_pCaptureFrame
; }
171 NSWindow
* getNSWindow() const { return mpNSWindow
; }
172 NSView
* getNSView() const { return mpNSView
; }
173 unsigned int getStyleMask() const { return mnStyleMask
; }
175 void getResolution( sal_Int32
& o_rDPIX
, sal_Int32
& o_rDPIY
);
177 // actually the following methods do the same thing: flipping y coordinates
178 // but having two of them makes clearer what the coordinate system
179 // is supposed to be before and after
180 void VCLToCocoa( NSRect
& io_rRect
, bool bRelativeToScreen
= true );
181 void CocoaToVCL( NSRect
& io_rRect
, bool bRelativeToScreen
= true );
183 void VCLToCocoa( NSPoint
& io_rPoint
, bool bRelativeToScreen
= true );
184 void CocoaToVCL( NSPoint
& io_Point
, bool bRelativeToScreen
= true );
186 NSCursor
* getCurrentCursor();
188 CGMutablePathRef
getClipPath() const { return mrClippingPath
; }
190 // called by VCL_NSApplication to indicate screen settings have changed
191 void screenParametersChanged();
194 SalEvent
PreparePosSize(long nX
, long nY
, long nWidth
, long nHeight
, sal_uInt16 nFlags
);
197 /** do things on initial show (like centering on parent or on screen)
201 void initWindowAndView();
203 void doShowFullScreen( bool bFullScreen
, sal_Int32 nDisplay
);
205 void doResetClipRegion();
208 static AquaSalFrame
* s_pCaptureFrame
;
210 AquaSalFrame( const AquaSalFrame
& ) = delete;
211 AquaSalFrame
& operator=(const AquaSalFrame
&) = delete;
214 inline bool AquaSalFrame::isAlive( const AquaSalFrame
* pFrame
)
216 AquaSalInstance
*pInst
= GetSalData()->mpInstance
;
217 return pInst
&& pInst
->isFrameAlive( pFrame
);
220 #endif // INCLUDED_VCL_INC_OSX_SALFRAME_H
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */