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 _SV_SALFRAME_H
21 #define _SV_SALFRAME_H
23 #include "vcl/sysdata.hxx"
25 #include "aqua/salmenu.h"
26 #include "aqua/saldata.hxx"
27 #include "aqua/aquavcltypes.h"
29 #include "salframe.hxx"
35 #include <boost/shared_ptr.hpp>
37 class AquaSalGraphics
;
40 class AquaSalInstance
;
44 typedef struct SalFrame::SalPointerState SalPointerState
;
50 class AquaSalFrame
: public SalFrame
53 NSWindow
* mpWindow
; // Cocoa window
54 NSView
* mpView
; // Cocoa view (actually a custom view, see below
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_uLong 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 sal_uLong mnICOptions
;
95 boost::shared_ptr
< Timer
> mpActivityTimer
; // Timer to prevent system sleep during presentation
99 Creates a system window and connects this frame with it.
101 @throws std::runtime_error in case window creation fails
103 AquaSalFrame( SalFrame
* pParent
, sal_uLong salFrameStyle
);
105 virtual ~AquaSalFrame();
107 virtual SalGraphics
* GetGraphics();
108 virtual void ReleaseGraphics( SalGraphics
* pGraphics
);
109 virtual sal_Bool
PostEvent( void* pData
);
110 virtual void SetTitle( const rtl::OUString
& rTitle
);
111 virtual void SetIcon( sal_uInt16 nIcon
);
112 virtual void SetRepresentedURL( const rtl::OUString
& );
113 virtual void SetMenu( SalMenu
* pSalMenu
);
114 virtual void DrawMenuBar();
115 virtual void Show( sal_Bool bVisible
, sal_Bool bNoActivate
= sal_False
);
116 virtual void Enable( sal_Bool bEnable
);
117 virtual void SetMinClientSize( long nWidth
, long nHeight
);
118 virtual void SetMaxClientSize( long nWidth
, long nHeight
);
119 virtual void SetPosSize( long nX
, long nY
, long nWidth
, long nHeight
, sal_uInt16 nFlags
);
120 virtual void GetClientSize( long& rWidth
, long& rHeight
);
121 virtual void GetWorkArea( Rectangle
& rRect
);
122 virtual SalFrame
* GetParent() const;
123 virtual void SetWindowState( const SalFrameState
* pState
);
124 virtual sal_Bool
GetWindowState( SalFrameState
* pState
);
125 virtual void ShowFullScreen( sal_Bool bFullScreen
, sal_Int32 nDisplay
);
126 virtual void StartPresentation( sal_Bool bStart
);
127 virtual void SetAlwaysOnTop( sal_Bool bOnTop
);
128 virtual void ToTop( sal_uInt16 nFlags
);
129 virtual void SetPointer( PointerStyle ePointerStyle
);
130 virtual void CaptureMouse( sal_Bool bMouse
);
131 virtual void SetPointerPos( long nX
, long nY
);
132 virtual void Flush( void );
133 virtual void Flush( const Rectangle
& );
135 virtual void SetInputContext( SalInputContext
* pContext
);
136 virtual void EndExtTextInput( sal_uInt16 nFlags
);
137 virtual rtl::OUString
GetKeyName( sal_uInt16 nKeyCode
);
138 virtual sal_Bool
MapUnicodeToKeyCode( sal_Unicode aUnicode
, LanguageType aLangType
, KeyCode
& rKeyCode
);
139 virtual LanguageType
GetInputLanguage();
140 virtual void UpdateSettings( AllSettings
& rSettings
);
141 virtual const SystemEnvData
* GetSystemData() const;
142 virtual SalPointerState
GetPointerState();
143 virtual SalIndicatorState
GetIndicatorState();
144 virtual void SimulateKeyPress( sal_uInt16 nKeyCode
);
145 virtual void SetParent( SalFrame
* pNewParent
);
146 virtual bool SetPluginParent( SystemParentData
* pNewParent
);
147 virtual void SetExtendedFrameStyle( SalExtStyle
);
148 virtual void SetScreenNumber(unsigned int);
149 virtual void SetApplicationID( const rtl::OUString
&rApplicationID
);
151 // shaped system windows
152 // set clip region to none (-> rectangular windows, normal state)
153 virtual void ResetClipRegion();
154 // start setting the clipregion consisting of nRects rectangles
155 virtual void BeginSetClipRegion( sal_uLong nRects
);
156 // add a rectangle to the clip region
157 virtual void UnionClipRegion( long nX
, long nY
, long nWidth
, long nHeight
);
158 // done setting up the clipregion
159 virtual void EndSetClipRegion();
161 virtual void SetClientSize( long nWidth
, long nHeight
);
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
* getWindow() const { return mpWindow
; }
174 NSView
* getView() const { return mpView
; }
175 unsigned int getStyleMask() const { return mnStyleMask
; }
177 void getResolution( sal_Int32
& o_rDPIX
, sal_Int32
& o_rDPIY
);
179 // actually the follwing 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 // make AquaSalFrame non copyable
206 AquaSalFrame( const AquaSalFrame
& );
207 AquaSalFrame
& operator=(const AquaSalFrame
&);
210 #endif // _SV_SALFRAME_H
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */