xref: /aoo41x/main/vcl/inc/aqua/salframe.h (revision 8a718ffc)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_SALFRAME_H
25 #define _SV_SALFRAME_H
26 
27 #include "vcl/sysdata.hxx"
28 
29 #include "aqua/salmenu.h"
30 #include "aqua/saldata.hxx"
31 #include "aqua/aquavcltypes.h"
32 
33 #include "salframe.hxx"
34 
35 #include <vector>
36 #include <utility>
37 #include <stdexcept>
38 
39 #include <boost/shared_ptr.hpp>
40 
41 class AquaSalGraphics;
42 class AquaSalFrame;
43 class AquaSalTimer;
44 class AquaSalInstance;
45 class AquaSalMenu;
46 class AquaBlinker;
47 
48 typedef struct SalFrame::SalPointerState SalPointerState;
49 
50 // ----------------
51 // - AquaSalFrame -
52 // ----------------
53 
54 class AquaSalFrame : public SalFrame
55 {
56 public:
57 	NSWindow*                       mpNSWindow;             // Cocoa window
58 	NSView*                         mpNSView;               // Cocoa view (actually a custom view)
59     NSMenuItem*                     mpDockMenuEntry;        // entry in the dynamic dock menu
60     NSRect                          maScreenRect;           // for mirroring purposes
61 	AquaSalGraphics*		        mpGraphics; 			// current frame graphics
62 	AquaSalFrame*			        mpParent;				// pointer to parent frame
63  	SystemEnvData			        maSysData;				// system data
64 	int                             mnMinWidth;             // min. client width in pixels
65 	int                             mnMinHeight;            // min. client height in pixels
66 	int                             mnMaxWidth;             // max. client width in pixels
67 	int                             mnMaxHeight;            // max. client height in pixels
68 	NSRect                          maFullScreenRect;       // old window size when in FullScreen
69 	bool					        mbGraphics:1; 			// is Graphics used?
70 	bool                            mbFullScreen:1;         // is Window in FullScreen?
71     bool                            mbShown:1;
72     bool                            mbInitShow:1;
73     bool                            mbPositioned:1;
74     bool                            mbSized:1;
75     bool                            mbPresentation:1;
76 
77     sal_uLong                           mnStyle;
78     unsigned int                    mnStyleMask;            // our style mask from NSWindow creation
79 
80     sal_uLong                           mnLastEventTime;
81     unsigned int                    mnLastModifierFlags;
82     AquaSalMenu*                    mpMenu;
83 
84     SalExtStyle                     mnExtStyle;             // currently document frames are marked this way
85 
86     PointerStyle                    mePointerStyle;         // currently active pointer style
87 
88     NSTrackingRectTag               mnTrackingRectTag;      // used to get enter/leave messages
89 
90     CGMutablePathRef                mrClippingPath;         // used for "shaping"
91     std::vector< CGRect >           maClippingRects;
92 
93     std::list<AquaBlinker*>         maBlinkers;
94 
95     Rectangle                       maInvalidRect;
96 
97     sal_uLong                           mnICOptions;
98 
99     boost::shared_ptr< Timer >      mpActivityTimer; // Timer to prevent system sleep during presentation
100 public:
101     /** Constructor
102 
103         Creates a system window and connects this frame with it.
104 
105         @throws std::runtime_error in case window creation fails
106     */
107     AquaSalFrame( SalFrame* pParent, sal_uLong salFrameStyle );
108 
109     virtual ~AquaSalFrame();
110 
111     virtual SalGraphics*		GetGraphics();
112     virtual void				ReleaseGraphics( SalGraphics* pGraphics );
113     virtual sal_Bool				PostEvent( void* pData );
114     virtual void				SetTitle( const XubString& rTitle );
115     virtual void				SetIcon( sal_uInt16 nIcon );
116     virtual void                SetRepresentedURL( const rtl::OUString& );
117     virtual void                SetMenu( SalMenu* pSalMenu );
118     virtual void                DrawMenuBar();
119     virtual void				Show( sal_Bool bVisible, sal_Bool bNoActivate = sal_False );
120     virtual void				Enable( sal_Bool bEnable );
121     virtual void                SetMinClientSize( long nWidth, long nHeight );
122     virtual void                SetMaxClientSize( long nWidth, long nHeight );
123     virtual void				SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags );
124     virtual void				GetClientSize( long& rWidth, long& rHeight );
125     virtual void				GetWorkArea( Rectangle& rRect );
126     virtual SalFrame*			GetParent() const;
127     virtual void				SetWindowState( const SalFrameState* pState );
128     virtual sal_Bool				GetWindowState( SalFrameState* pState );
129     virtual void				ShowFullScreen( sal_Bool bFullScreen, sal_Int32 nDisplay );
130     virtual void				StartPresentation( sal_Bool bStart );
131     virtual void				SetAlwaysOnTop( sal_Bool bOnTop );
132     virtual void				ToTop( sal_uInt16 nFlags );
133     virtual void				SetPointer( PointerStyle ePointerStyle );
134     virtual void				CaptureMouse( sal_Bool bMouse );
135     virtual void				SetPointerPos( long nX, long nY );
136     virtual void				Flush( void );
137     virtual void				Flush( const Rectangle& );
138     virtual void				Sync();
139     virtual void				SetInputContext( SalInputContext* pContext );
140     virtual void				EndExtTextInput( sal_uInt16 nFlags );
141     virtual String				GetKeyName( sal_uInt16 nKeyCode );
142     virtual String				GetSymbolKeyName( const XubString& rFontName, sal_uInt16 nKeyCode );
143     virtual sal_Bool                MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, KeyCode& rKeyCode );
144     virtual LanguageType		GetInputLanguage();
145     virtual SalBitmap*			SnapShot();
146     virtual void				UpdateSettings( AllSettings& rSettings );
147     virtual void				Beep( SoundType eSoundType );
148     virtual const SystemEnvData*	GetSystemData() const;
149     virtual SalPointerState		GetPointerState();
150     virtual void				SetParent( SalFrame* pNewParent );
151     virtual bool				SetPluginParent( SystemParentData* pNewParent );
152     virtual void                SetExtendedFrameStyle( SalExtStyle );
153     virtual void                SetBackgroundBitmap( SalBitmap* );
154     virtual void                SetScreenNumber(unsigned int);
155 
156     // shaped system windows
157     // set clip region to none (-> rectangular windows, normal state)
158     virtual void ResetClipRegion();
159     // start setting the clipregion consisting of nRects rectangles
160     virtual void BeginSetClipRegion( sal_uLong nRects );
161     // add a rectangle to the clip region
162     virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight );
163     // done setting up the clipregion
164     virtual void EndSetClipRegion();
165 
166     virtual void SetClientSize( long nWidth, long nHeight );
167 
168     void UpdateFrameGeometry();
169 
170     // trigger painting of the window
171     void SendPaintEvent( const Rectangle* pRect = NULL );
172 
isAlive(const AquaSalFrame * pFrame)173     static bool isAlive( const AquaSalFrame* pFrame )
174     { return GetSalData()->maFrameCheck.find( pFrame ) != GetSalData()->maFrameCheck.end(); }
175 
GetCaptureFrame()176     static AquaSalFrame* GetCaptureFrame() { return s_pCaptureFrame; }
177 
getNSWindow() const178     NSWindow* getNSWindow() const { return mpNSWindow; }
getNSView() const179     NSView* getNSView() const { return mpNSView; }
getStyleMask() const180     unsigned int getStyleMask() const { return mnStyleMask; }
181 
182     void getResolution( sal_Int32& o_rDPIX, sal_Int32& o_rDPIY );
183 
184     // actually the follwing methods do the same thing: flipping y coordinates
185     // but having two of them makes clearer what the coordinate system
186     // is supposed to be before and after
187     void VCLToCocoa( NSRect& io_rRect, bool bRelativeToScreen = true );
188     void CocoaToVCL( NSRect& io_rRect, bool bRelativeToScreen = true );
189 
190     void VCLToCocoa( NSPoint& io_rPoint, bool bRelativeToScreen = true );
191     void CocoaToVCL( NSPoint& io_Point, bool bRelativeToScreen = true );
192 
193     NSCursor* getCurrentCursor() const;
194 
getClipPath() const195     CGMutablePathRef getClipPath() const { return mrClippingPath; }
196 
197     // called by VCL_NSApplication to indicate screen settings have changed
198     void screenParametersChanged();
199 
200  private: // methods
201     /** do things on initial show (like centering on parent or on screen)
202     */
203     void initShow();
204 
205     void initWindowAndView();
206 
207  private: // data
208     static AquaSalFrame*                   s_pCaptureFrame;
209 
210     // make AquaSalFrame non copyable
211     AquaSalFrame( const AquaSalFrame& );
212     AquaSalFrame& operator=(const AquaSalFrame&);
213 };
214 
215 #endif // _SV_SALFRAME_H
216