xref: /trunk/main/vcl/inc/aqua/salframe.h (revision fe474d85aac87b57c0ff45107f280d06337c5f69) !
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     float                           mfBackingScale;         // window pixels per point
91 
92     CGMutablePathRef                mrClippingPath;         // used for "shaping"
93     std::vector< CGRect >           maClippingRects;
94 
95     std::list<AquaBlinker*>         maBlinkers;
96 
97     Rectangle                       maInvalidRect;
98 
99     sal_uLong                           mnICOptions;
100 
101     boost::shared_ptr< Timer >      mpActivityTimer; // Timer to prevent system sleep during presentation
102 public:
103     /** Constructor
104 
105         Creates a system window and connects this frame with it.
106 
107         @throws std::runtime_error in case window creation fails
108     */
109     AquaSalFrame( SalFrame* pParent, sal_uLong salFrameStyle );
110 
111     virtual ~AquaSalFrame();
112 
113     virtual SalGraphics*        GetGraphics();
114     virtual void                ReleaseGraphics( SalGraphics* pGraphics );
115     virtual sal_Bool                PostEvent( void* pData );
116     virtual void                SetTitle( const XubString& rTitle );
117     virtual void                SetIcon( sal_uInt16 nIcon );
118     virtual void                SetRepresentedURL( const rtl::OUString& );
119     virtual void                SetMenu( SalMenu* pSalMenu );
120     virtual void                DrawMenuBar();
121     virtual void                Show( sal_Bool bVisible, sal_Bool bNoActivate = sal_False );
122     virtual void                Enable( sal_Bool bEnable );
123     virtual void                SetMinClientSize( long nWidth, long nHeight );
124     virtual void                SetMaxClientSize( long nWidth, long nHeight );
125     virtual void                SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags );
126     virtual void                GetClientSize( long& rWidth, long& rHeight );
127     virtual void                GetWorkArea( Rectangle& rRect );
128     virtual SalFrame*           GetParent() const;
129     virtual void                SetWindowState( const SalFrameState* pState );
130     virtual sal_Bool                GetWindowState( SalFrameState* pState );
131     virtual void                ShowFullScreen( sal_Bool bFullScreen, sal_Int32 nDisplay );
132     virtual void                StartPresentation( sal_Bool bStart );
133     virtual void                SetAlwaysOnTop( sal_Bool bOnTop );
134     virtual void                ToTop( sal_uInt16 nFlags );
135     virtual void                SetPointer( PointerStyle ePointerStyle );
136     virtual void                CaptureMouse( sal_Bool bMouse );
137     virtual void                SetPointerPos( long nX, long nY );
138     virtual void                Flush( void );
139     virtual void                Flush( const Rectangle& );
140     virtual void                Sync();
141     virtual void                SetInputContext( SalInputContext* pContext );
142     virtual void                EndExtTextInput( sal_uInt16 nFlags );
143     virtual String              GetKeyName( sal_uInt16 nKeyCode );
144     virtual String              GetSymbolKeyName( const XubString& rFontName, sal_uInt16 nKeyCode );
145     virtual sal_Bool                MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, KeyCode& rKeyCode );
146     virtual LanguageType        GetInputLanguage();
147     virtual SalBitmap*          SnapShot();
148     virtual void                UpdateSettings( AllSettings& rSettings );
149     virtual void                Beep( SoundType eSoundType );
150     virtual const SystemEnvData*    GetSystemData() const;
151     virtual SalPointerState     GetPointerState();
152     virtual void                SetParent( SalFrame* pNewParent );
153     virtual bool                SetPluginParent( SystemParentData* pNewParent );
154     virtual void                SetExtendedFrameStyle( SalExtStyle );
155     virtual void                SetBackgroundBitmap( SalBitmap* );
156     virtual void                SetScreenNumber(unsigned int);
157 
158     // shaped system windows
159     // set clip region to none (-> rectangular windows, normal state)
160     virtual void ResetClipRegion();
161     // start setting the clipregion consisting of nRects rectangles
162     virtual void BeginSetClipRegion( sal_uLong nRects );
163     // add a rectangle to the clip region
164     virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight );
165     // done setting up the clipregion
166     virtual void EndSetClipRegion();
167 
168     virtual void SetClientSize( long nWidth, long nHeight );
169 
170     void UpdateFrameGeometry();
171 
172     // trigger painting of the window
173     void SendPaintEvent( const Rectangle* pRect = NULL );
174 
isAlive(const AquaSalFrame * pFrame)175     static bool isAlive( const AquaSalFrame* pFrame )
176     { return GetSalData()->maFrameCheck.find( pFrame ) != GetSalData()->maFrameCheck.end(); }
177 
GetCaptureFrame()178     static AquaSalFrame* GetCaptureFrame() { return s_pCaptureFrame; }
179 
getNSWindow()180     NSWindow* getNSWindow() const { return mpNSWindow; }
getBackingScale()181     float getBackingScale() const { return mfBackingScale; }
182     // returns true if the scale changed
183     bool UpdateBackingScale();
getNSView()184     NSView* getNSView() const { return mpNSView; }
getStyleMask()185     unsigned int getStyleMask() const { return mnStyleMask; }
186 
187     void getResolution( sal_Int32& o_rDPIX, sal_Int32& o_rDPIY );
188 
189     // actually the following methods do the same thing: flipping y coordinates
190     // but having two of them makes clearer what the coordinate system
191     // is supposed to be before and after
192     void VCLToCocoa( NSRect& io_rRect, bool bRelativeToScreen = true );
193     void CocoaToVCL( NSRect& io_rRect, bool bRelativeToScreen = true );
194 
195     void VCLToCocoa( NSPoint& io_rPoint, bool bRelativeToScreen = true );
196     void CocoaToVCL( NSPoint& io_Point, bool bRelativeToScreen = true );
197 
198     NSCursor* getCurrentCursor() const;
199 
getClipPath()200     CGMutablePathRef getClipPath() const { return mrClippingPath; }
201 
202     // called by VCL_NSApplication to indicate screen settings have changed
203     void screenParametersChanged();
204 
205  private: // methods
206     /** do things on initial show (like centering on parent or on screen)
207     */
208     void initShow();
209 
210     void initWindowAndView();
211 
212  private: // data
213     static AquaSalFrame*                   s_pCaptureFrame;
214 
215     // make AquaSalFrame non copyable
216     AquaSalFrame( const AquaSalFrame& );
217     AquaSalFrame& operator=(const AquaSalFrame&);
218 };
219 
220 #endif // _SV_SALFRAME_H
221