1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: salframe.h,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SV_SALFRAME_H
32 #define _SV_SALFRAME_H
36 #include "vcl/salframe.hxx"
37 #include "vcl/sysdata.hxx"
40 #include "saldata.hxx"
41 #include "aquavcltypes.h"
47 #include <boost/shared_ptr.hpp>
49 class AquaSalGraphics
;
52 class AquaSalInstance
;
56 typedef struct SalFrame::SalPointerState SalPointerState
;
62 class AquaSalFrame
: public SalFrame
65 NSWindow
* mpWindow
; // Cocoa window
66 NSView
* mpView
; // Cocoa view (actually a custom view, see below
67 NSMenuItem
* mpDockMenuEntry
; // entry in the dynamic dock menu
68 NSRect maScreenRect
; // for mirroring purposes
69 AquaSalGraphics
* mpGraphics
; // current frame graphics
70 AquaSalFrame
* mpParent
; // pointer to parent frame
71 SystemEnvData maSysData
; // system data
72 int mnMinWidth
; // min. client width in pixels
73 int mnMinHeight
; // min. client height in pixels
74 int mnMaxWidth
; // max. client width in pixels
75 int mnMaxHeight
; // max. client height in pixels
76 NSRect maFullScreenRect
; // old window size when in FullScreen
77 bool mbGraphics
:1; // is Graphics used?
78 bool mbFullScreen
:1; // is Window in FullScreen?
83 bool mbPresentation
:1;
86 unsigned int mnStyleMask
; // our style mask from NSWindow creation
88 ULONG mnLastEventTime
;
89 unsigned int mnLastModifierFlags
;
92 SalExtStyle mnExtStyle
; // currently document frames are marked this way
94 PointerStyle mePointerStyle
; // currently active pointer style
96 NSTrackingRectTag mnTrackingRectTag
; // used to get enter/leave messages
98 CGMutablePathRef mrClippingPath
; // used for "shaping"
99 std::vector
< CGRect
> maClippingRects
;
101 std::list
<AquaBlinker
*> maBlinkers
;
103 Rectangle maInvalidRect
;
107 boost::shared_ptr
< Timer
> mpActivityTimer
; // Timer to prevent system sleep during presentation
111 Creates a system window and connects this frame with it.
113 @throws std::runtime_error in case window creation fails
115 AquaSalFrame( SalFrame
* pParent
, ULONG salFrameStyle
);
117 virtual ~AquaSalFrame();
119 virtual SalGraphics
* GetGraphics();
120 virtual void ReleaseGraphics( SalGraphics
* pGraphics
);
121 virtual BOOL
PostEvent( void* pData
);
122 virtual void SetTitle( const XubString
& rTitle
);
123 virtual void SetIcon( USHORT nIcon
);
124 virtual void SetMenu( SalMenu
* pSalMenu
);
125 virtual void DrawMenuBar();
126 virtual void Show( BOOL bVisible
, BOOL bNoActivate
= FALSE
);
127 virtual void Enable( BOOL bEnable
);
128 virtual void SetMinClientSize( long nWidth
, long nHeight
);
129 virtual void SetMaxClientSize( long nWidth
, long nHeight
);
130 virtual void SetPosSize( long nX
, long nY
, long nWidth
, long nHeight
, USHORT nFlags
);
131 virtual void GetClientSize( long& rWidth
, long& rHeight
);
132 virtual void GetWorkArea( Rectangle
& rRect
);
133 virtual SalFrame
* GetParent() const;
134 virtual void SetWindowState( const SalFrameState
* pState
);
135 virtual BOOL
GetWindowState( SalFrameState
* pState
);
136 virtual void ShowFullScreen( BOOL bFullScreen
, sal_Int32 nDisplay
);
137 virtual void StartPresentation( BOOL bStart
);
138 virtual void SetAlwaysOnTop( BOOL bOnTop
);
139 virtual void ToTop( USHORT nFlags
);
140 virtual void SetPointer( PointerStyle ePointerStyle
);
141 virtual void CaptureMouse( BOOL bMouse
);
142 virtual void SetPointerPos( long nX
, long nY
);
143 virtual void Flush( void);
144 virtual void Flush( const Rectangle
& );
146 virtual void SetInputContext( SalInputContext
* pContext
);
147 virtual void EndExtTextInput( USHORT nFlags
);
148 virtual String
GetKeyName( USHORT nKeyCode
);
149 virtual String
GetSymbolKeyName( const XubString
& rFontName
, USHORT nKeyCode
);
150 virtual BOOL
MapUnicodeToKeyCode( sal_Unicode aUnicode
, LanguageType aLangType
, KeyCode
& rKeyCode
);
151 virtual LanguageType
GetInputLanguage();
152 virtual SalBitmap
* SnapShot();
153 virtual void UpdateSettings( AllSettings
& rSettings
);
154 virtual void Beep( SoundType eSoundType
);
155 virtual const SystemEnvData
* GetSystemData() const;
156 virtual SalPointerState
GetPointerState();
157 virtual SalIndicatorState
GetIndicatorState();
158 virtual void SimulateKeyPress( USHORT nKeyCode
);
159 virtual void SetParent( SalFrame
* pNewParent
);
160 virtual bool SetPluginParent( SystemParentData
* pNewParent
);
161 virtual void SetExtendedFrameStyle( SalExtStyle
);
162 virtual void SetBackgroundBitmap( SalBitmap
* );
163 virtual void SetScreenNumber(unsigned int);
165 // shaped system windows
166 // set clip region to none (-> rectangular windows, normal state)
167 virtual void ResetClipRegion();
168 // start setting the clipregion consisting of nRects rectangles
169 virtual void BeginSetClipRegion( ULONG nRects
);
170 // add a rectangle to the clip region
171 virtual void UnionClipRegion( long nX
, long nY
, long nWidth
, long nHeight
);
172 // done setting up the clipregion
173 virtual void EndSetClipRegion();
175 virtual void SetClientSize( long nWidth
, long nHeight
);
177 void UpdateFrameGeometry();
179 // trigger painting of the window
180 void SendPaintEvent( const Rectangle
* pRect
= NULL
);
182 static bool isAlive( const AquaSalFrame
* pFrame
)
183 { return GetSalData()->maFrameCheck
.find( pFrame
) != GetSalData()->maFrameCheck
.end(); }
185 static AquaSalFrame
* GetCaptureFrame() { return s_pCaptureFrame
; }
187 NSWindow
* getWindow() const { return mpWindow
; }
188 NSView
* getView() const { return mpView
; }
189 unsigned int getStyleMask() const { return mnStyleMask
; }
191 // actually the follwing methods do the same thing: flipping y coordinates
192 // but having two of them makes clearer what the coordinate system
193 // is supposed to be before and after
194 void VCLToCocoa( NSRect
& io_rRect
, bool bRelativeToScreen
= true );
195 void CocoaToVCL( NSRect
& io_rRect
, bool bRelativeToScreen
= true );
197 void VCLToCocoa( NSPoint
& io_rPoint
, bool bRelativeToScreen
= true );
198 void CocoaToVCL( NSPoint
& io_Point
, bool bRelativeToScreen
= true );
200 NSCursor
* getCurrentCursor() const;
202 CGMutablePathRef
getClipPath() const { return mrClippingPath
; }
204 // called by VCL_NSApplication to indicate screen settings have changed
205 void screenParametersChanged();
208 /** do things on initial show (like centering on parent or on screen)
212 void initWindowAndView();
215 static AquaSalFrame
* s_pCaptureFrame
;
217 // make AquaSalFrame non copyable
218 AquaSalFrame( const AquaSalFrame
& );
219 AquaSalFrame
& operator=(const AquaSalFrame
&);
222 #endif // _SV_SALFRAME_H