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/salmenu.h"
30 #include "osx/saldata.hxx"
31 #include "osx/osxvcltypes.h"
33 #include "salframe.hxx"
39 class AquaSalGraphics
;
42 class AquaSalInstance
;
46 typedef struct SalFrame::SalPointerState SalPointerState
;
50 class AquaSalFrame
: public SalFrame
53 NSWindow
* mpNSWindow
; // Cocoa window
54 NSView
* mpNSView
; // Cocoa view (actually a custom view)
55 NSMenuItem
* mpDockMenuEntry
; // entry in the dynamic dock menu
56 NSRect maScreenRect
; // for mirroring purposes
57 AquaSalGraphics
* mpGraphics
; // current frame graphics
58 AquaSalFrame
* mpParent
; // pointer to parent frame
59 SystemEnvData maSysData
; // system data
60 int mnMinWidth
; // min. client width in pixels
61 int mnMinHeight
; // min. client height in pixels
62 int mnMaxWidth
; // max. client width in pixels
63 int mnMaxHeight
; // max. client height in pixels
64 NSRect maFullScreenRect
; // old window size when in FullScreen
65 bool mbGraphics
:1; // is Graphics used?
66 bool mbFullScreen
:1; // is Window in FullScreen?
71 bool mbPresentation
:1;
74 unsigned int mnStyleMask
; // our style mask from NSWindow creation
76 sal_uInt64 mnLastEventTime
;
77 unsigned int mnLastModifierFlags
;
80 SalExtStyle mnExtStyle
; // currently document frames are marked this way
82 PointerStyle mePointerStyle
; // currently active pointer style
84 NSTrackingRectTag mnTrackingRectTag
; // used to get enter/leave messages
86 CGMutablePathRef mrClippingPath
; // used for "shaping"
87 std::vector
< CGRect
> maClippingRects
;
89 std::list
<AquaBlinker
*> maBlinkers
;
91 Rectangle maInvalidRect
;
93 InputContextFlags mnICOptions
;
95 // To prevent display sleep during presentation
96 IOPMAssertionID mnAssertionID
;
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
, sal_uLong salFrameStyle
);
107 virtual ~AquaSalFrame();
109 virtual SalGraphics
* AcquireGraphics() SAL_OVERRIDE
;
110 virtual void ReleaseGraphics( SalGraphics
* pGraphics
) SAL_OVERRIDE
;
111 virtual bool PostEvent( void* pData
) SAL_OVERRIDE
;
112 virtual void SetTitle( const OUString
& rTitle
) SAL_OVERRIDE
;
113 virtual void SetIcon( sal_uInt16 nIcon
) SAL_OVERRIDE
;
114 virtual void SetRepresentedURL( const OUString
& ) SAL_OVERRIDE
;
115 virtual void SetMenu( SalMenu
* pSalMenu
) SAL_OVERRIDE
;
116 virtual void DrawMenuBar() SAL_OVERRIDE
;
117 virtual void Show( bool bVisible
, bool bNoActivate
= false ) SAL_OVERRIDE
;
118 virtual void SetMinClientSize( long nWidth
, long nHeight
) SAL_OVERRIDE
;
119 virtual void SetMaxClientSize( long nWidth
, long nHeight
) SAL_OVERRIDE
;
120 virtual void SetPosSize( long nX
, long nY
, long nWidth
, long nHeight
, sal_uInt16 nFlags
) SAL_OVERRIDE
;
121 virtual void GetClientSize( long& rWidth
, long& rHeight
) SAL_OVERRIDE
;
122 virtual void GetWorkArea( Rectangle
& rRect
) SAL_OVERRIDE
;
123 virtual SalFrame
* GetParent() const SAL_OVERRIDE
;
124 virtual void SetWindowState( const SalFrameState
* pState
) SAL_OVERRIDE
;
125 virtual bool GetWindowState( SalFrameState
* pState
) SAL_OVERRIDE
;
126 virtual void ShowFullScreen( bool bFullScreen
, sal_Int32 nDisplay
) SAL_OVERRIDE
;
127 virtual void StartPresentation( bool bStart
) SAL_OVERRIDE
;
128 virtual void SetAlwaysOnTop( bool bOnTop
) SAL_OVERRIDE
;
129 virtual void ToTop( sal_uInt16 nFlags
) SAL_OVERRIDE
;
130 virtual void SetPointer( PointerStyle ePointerStyle
) SAL_OVERRIDE
;
131 virtual void CaptureMouse( bool bMouse
) SAL_OVERRIDE
;
132 virtual void SetPointerPos( long nX
, long nY
) SAL_OVERRIDE
;
133 virtual void Flush( void ) SAL_OVERRIDE
;
134 virtual void Flush( const Rectangle
& ) SAL_OVERRIDE
;
135 virtual void Sync() SAL_OVERRIDE
;
136 virtual void SetInputContext( SalInputContext
* pContext
) SAL_OVERRIDE
;
137 virtual void EndExtTextInput( sal_uInt16 nFlags
) SAL_OVERRIDE
;
138 virtual OUString
GetKeyName( sal_uInt16 nKeyCode
) SAL_OVERRIDE
;
139 virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode
, LanguageType aLangType
, vcl::KeyCode
& rKeyCode
) SAL_OVERRIDE
;
140 virtual LanguageType
GetInputLanguage() SAL_OVERRIDE
;
141 virtual void UpdateSettings( AllSettings
& rSettings
) SAL_OVERRIDE
;
142 virtual void Beep() SAL_OVERRIDE
;
143 virtual const SystemEnvData
* GetSystemData() const SAL_OVERRIDE
;
144 virtual SalPointerState
GetPointerState() SAL_OVERRIDE
;
145 virtual KeyIndicatorState
GetIndicatorState() SAL_OVERRIDE
;
146 virtual void SimulateKeyPress( sal_uInt16 nKeyCode
) SAL_OVERRIDE
;
147 virtual void SetParent( SalFrame
* pNewParent
) SAL_OVERRIDE
;
148 virtual bool SetPluginParent( SystemParentData
* pNewParent
) SAL_OVERRIDE
;
149 virtual void SetExtendedFrameStyle( SalExtStyle
) SAL_OVERRIDE
;
150 virtual void SetScreenNumber(unsigned int) SAL_OVERRIDE
;
151 virtual void SetApplicationID( const OUString
&rApplicationID
) SAL_OVERRIDE
;
153 // shaped system windows
154 // set clip region to none (-> rectangular windows, normal state)
155 virtual void ResetClipRegion() SAL_OVERRIDE
;
156 // start setting the clipregion consisting of nRects rectangles
157 virtual void BeginSetClipRegion( sal_uLong nRects
) SAL_OVERRIDE
;
158 // add a rectangle to the clip region
159 virtual void UnionClipRegion( long nX
, long nY
, long nWidth
, long nHeight
) SAL_OVERRIDE
;
160 // done setting up the clipregion
161 virtual void EndSetClipRegion() SAL_OVERRIDE
;
163 void UpdateFrameGeometry();
165 // trigger painting of the window
166 void SendPaintEvent( const Rectangle
* pRect
= NULL
);
168 static bool isAlive( const AquaSalFrame
* pFrame
)
169 { return GetSalData()->maFrameCheck
.find( pFrame
) != GetSalData()->maFrameCheck
.end(); }
171 static AquaSalFrame
* GetCaptureFrame() { return s_pCaptureFrame
; }
173 NSWindow
* getNSWindow() const { return mpNSWindow
; }
174 NSView
* getNSView() const { return mpNSView
; }
175 unsigned int getStyleMask() const { return mnStyleMask
; }
177 void getResolution( sal_Int32
& o_rDPIX
, sal_Int32
& o_rDPIY
);
179 // actually the following methods do the same thing: flipping y coordinates
180 // but having two of them makes clearer what the coordinate system
181 // is supposed to be before and after
182 void VCLToCocoa( NSRect
& io_rRect
, bool bRelativeToScreen
= true );
183 void CocoaToVCL( NSRect
& io_rRect
, bool bRelativeToScreen
= true );
185 void VCLToCocoa( NSPoint
& io_rPoint
, bool bRelativeToScreen
= true );
186 void CocoaToVCL( NSPoint
& io_Point
, bool bRelativeToScreen
= true );
188 NSCursor
* getCurrentCursor() const;
190 CGMutablePathRef
getClipPath() const { return mrClippingPath
; }
192 // called by VCL_NSApplication to indicate screen settings have changed
193 void screenParametersChanged();
196 /** do things on initial show (like centering on parent or on screen)
200 void initWindowAndView();
203 static AquaSalFrame
* s_pCaptureFrame
;
205 AquaSalFrame( const AquaSalFrame
& ) SAL_DELETED_FUNCTION
;
206 AquaSalFrame
& operator=(const AquaSalFrame
&) SAL_DELETED_FUNCTION
;
209 #endif // INCLUDED_VCL_INC_OSX_SALFRAME_H
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */