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