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