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