LibreOffice Module vcl (master)  1
osx/salframe.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_VCL_INC_OSX_SALFRAME_H
21 #define INCLUDED_VCL_INC_OSX_SALFRAME_H
22 
23 #include <premac.h>
24 #include <IOKit/pwr_mgt/IOPMLib.h>
25 #include <postmac.h>
26 
27 #include <vcl/sysdata.hxx>
28 
29 #include <osx/salinst.h>
30 #include <osx/salmenu.h>
31 #include <osx/saldata.hxx>
32 #include <osx/osxvcltypes.h>
33 
34 #include <salframe.hxx>
35 
36 #include <vector>
37 #include <utility>
38 #include <stdexcept>
39 
40 class AquaSalGraphics;
41 class AquaSalFrame;
42 class AquaSalTimer;
43 class AquaSalInstance;
44 class AquaSalMenu;
45 
46 class AquaSalFrame : public SalFrame
47 {
48 public:
49  NSWindow* mpNSWindow; // Cocoa window
50  NSView* mpNSView; // Cocoa view (actually a custom view)
51  NSMenuItem* mpDockMenuEntry; // entry in the dynamic dock menu
52  NSRect maScreenRect; // for mirroring purposes
53  AquaSalGraphics* mpGraphics; // current frame graphics
54  AquaSalFrame* mpParent; // pointer to parent frame
55  SystemEnvData maSysData; // system data
56  int mnMinWidth; // min. client width in pixels
57  int mnMinHeight; // min. client height in pixels
58  int mnMaxWidth; // max. client width in pixels
59  int mnMaxHeight; // max. client height in pixels
60  NSRect maFullScreenRect; // old window size when in FullScreen
61  bool mbGraphics; // is Graphics used?
62  bool mbFullScreen; // is Window in FullScreen?
63  bool mbShown;
64  bool mbInitShow;
66  bool mbSized;
68 
70  unsigned int mnStyleMask; // our style mask from NSWindow creation
71 
72  sal_uInt64 mnLastEventTime;
73  unsigned int mnLastModifierFlags;
75 
76  SalExtStyle mnExtStyle; // currently document frames are marked this way
77 
78  PointerStyle mePointerStyle; // currently active pointer style
79 
80  NSTrackingRectTag mnTrackingRectTag; // used to get enter/leave messages
82 
83  CGMutablePathRef mrClippingPath; // used for "shaping"
84  std::vector< CGRect > maClippingRects;
85 
87 
89 
90  // To prevent display sleep during presentation
91  IOPMAssertionID mnAssertionID;
92 
93  NSRect maFrameRect;
94  NSRect maContentRect;
95 
97 
98 public:
105  AquaSalFrame( SalFrame* pParent, SalFrameStyleFlags salFrameStyle );
106 
107  virtual ~AquaSalFrame() override;
108 
109  virtual SalGraphics* AcquireGraphics() override;
110  virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
111  virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
112  virtual void SetTitle( const OUString& rTitle ) override;
113  virtual void SetIcon( sal_uInt16 nIcon ) override;
114  virtual void SetRepresentedURL( const OUString& ) override;
115  virtual void SetMenu( SalMenu* pSalMenu ) override;
116  virtual void DrawMenuBar() override;
117  virtual void Show( bool bVisible, bool bNoActivate = false ) override;
118  virtual void SetMinClientSize( long nWidth, long nHeight ) override;
119  virtual void SetMaxClientSize( long nWidth, long nHeight ) override;
120  virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags ) override;
121  virtual void GetClientSize( long& rWidth, long& rHeight ) override;
122  virtual void GetWorkArea( tools::Rectangle& rRect ) override;
123  virtual SalFrame* GetParent() const override;
124  virtual void SetWindowState( const SalFrameState* pState ) override;
125  virtual bool GetWindowState( SalFrameState* pState ) override;
126  virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) override;
127  virtual void StartPresentation( bool bStart ) override;
128  virtual void SetAlwaysOnTop( bool bOnTop ) override;
129  virtual void ToTop( SalFrameToTop nFlags ) override;
130  virtual void SetPointer( PointerStyle ePointerStyle ) override;
131  virtual void CaptureMouse( bool bMouse ) override;
132  virtual void SetPointerPos( long nX, long nY ) override;
133  virtual void Flush( void ) override;
134  virtual void Flush( const tools::Rectangle& ) override;
135  virtual void SetInputContext( SalInputContext* pContext ) override;
136  virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) override;
137  virtual OUString GetKeyName( sal_uInt16 nKeyCode ) override;
138  virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) override;
139  virtual LanguageType GetInputLanguage() override;
140  virtual void UpdateSettings( AllSettings& rSettings ) override;
141  virtual void Beep() override;
142  virtual const SystemEnvData* GetSystemData() const override;
143  virtual SalPointerState GetPointerState() override;
144  virtual KeyIndicatorState GetIndicatorState() override;
145  virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) override;
146  virtual void SetParent( SalFrame* pNewParent ) override;
147  virtual bool SetPluginParent( SystemParentData* pNewParent ) override;
148  virtual void SetExtendedFrameStyle( SalExtStyle ) override;
149  virtual void SetScreenNumber(unsigned int) override;
150  virtual void SetApplicationID( const OUString &rApplicationID ) override;
151 
152  // shaped system windows
153  // set clip region to none (-> rectangular windows, normal state)
154  virtual void ResetClipRegion() override;
155  // start setting the clipregion consisting of nRects rectangles
156  virtual void BeginSetClipRegion( sal_uInt32 nRects ) override;
157  // add a rectangle to the clip region
158  virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) override;
159  // done setting up the clipregion
160  virtual void EndSetClipRegion() override;
161 
162  void UpdateFrameGeometry();
163 
164  // trigger painting of the window
165  void SendPaintEvent( const tools::Rectangle* pRect = nullptr );
166 
167  static inline bool isAlive( const AquaSalFrame* pFrame );
168 
170 
171  NSWindow* getNSWindow() const { return mpNSWindow; }
172  NSView* getNSView() const { return mpNSView; }
173  unsigned int getStyleMask() const { return mnStyleMask; }
174 
175  void getResolution( sal_Int32& o_rDPIX, sal_Int32& o_rDPIY );
176 
177  // actually the following methods do the same thing: flipping y coordinates
178  // but having two of them makes clearer what the coordinate system
179  // is supposed to be before and after
180  void VCLToCocoa( NSRect& io_rRect, bool bRelativeToScreen = true );
181  void CocoaToVCL( NSRect& io_rRect, bool bRelativeToScreen = true );
182 
183  void VCLToCocoa( NSPoint& io_rPoint, bool bRelativeToScreen = true );
184  void CocoaToVCL( NSPoint& io_Point, bool bRelativeToScreen = true );
185 
186  NSCursor* getCurrentCursor();
187 
188  CGMutablePathRef getClipPath() const { return mrClippingPath; }
189 
190  // called by VCL_NSApplication to indicate screen settings have changed
192 
193 protected:
194  SalEvent PreparePosSize(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags);
195 
196 private: // methods
199  void initShow();
200 
201  void initWindowAndView();
202 
203  void doShowFullScreen( bool bFullScreen, sal_Int32 nDisplay );
204 
205  void doResetClipRegion();
206 
207 private: // data
209 
210  AquaSalFrame( const AquaSalFrame& ) = delete;
211  AquaSalFrame& operator=(const AquaSalFrame&) = delete;
212 };
213 
214 inline bool AquaSalFrame::isAlive( const AquaSalFrame* pFrame )
215 {
217  return pInst && pInst->isFrameAlive( pFrame );
218 }
219 
220 #endif // INCLUDED_VCL_INC_OSX_SALFRAME_H
221 
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SalExtStyle mnExtStyle
Definition: osx/salframe.h:76
virtual void SetApplicationID(const OUString &rApplicationID) override
AquaSalMenu * mpMenu
Definition: osx/salframe.h:74
virtual void ReleaseGraphics(SalGraphics *pGraphics) override
virtual SalFrame * GetParent() const override
bool mbPositioned
Definition: osx/salframe.h:65
virtual SalGraphics * AcquireGraphics() override
CGMutablePathRef mrClippingPath
Definition: osx/salframe.h:83
AquaSalInstance * mpInstance
Definition: osx/saldata.hxx:66
NSView * getNSView() const
Definition: osx/salframe.h:172
virtual void SetParent(SalFrame *pNewParent) override
void screenParametersChanged()
virtual KeyIndicatorState GetIndicatorState() override
NSTrackingRectTag mnTrackingRectTag
Definition: osx/salframe.h:80
static AquaSalFrame * s_pCaptureFrame
Definition: osx/salframe.h:208
void CocoaToVCL(NSRect &io_rRect, bool bRelativeToScreen=true)
virtual void SetMaxClientSize(long nWidth, long nHeight) override
void SendPaintEvent(const tools::Rectangle *pRect=nullptr)
virtual void SetPosSize(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags) override
InputContextFlags mnICOptions
Definition: osx/salframe.h:88
static bool isAlive(const AquaSalFrame *pFrame)
Definition: osx/salframe.h:214
virtual bool PostEvent(std::unique_ptr< ImplSVEvent > pData) override
virtual void EndSetClipRegion() override
virtual void EndExtTextInput(EndExtTextInputFlags nFlags) override
sal_uInt16 sal_Unicode
virtual void GetWorkArea(tools::Rectangle &rRect) override
CGMutablePathRef getClipPath() const
Definition: osx/salframe.h:188
virtual bool GetWindowState(SalFrameState *pState) override
sal_uInt64 SalExtStyle
Definition: salframe.hxx:95
virtual void BeginSetClipRegion(sal_uInt32 nRects) override
void doResetClipRegion()
virtual void Beep() override
virtual void SetIcon(sal_uInt16 nIcon) override
virtual void SetMenu(SalMenu *pSalMenu) override
SalFrameToTop
Definition: salframe.hxx:43
NSRect maTrackingRect
Definition: osx/salframe.h:81
NSRect maContentRect
Definition: osx/salframe.h:94
virtual SalPointerState GetPointerState() override
virtual void SimulateKeyPress(sal_uInt16 nKeyCode) override
virtual OUString GetKeyName(sal_uInt16 nKeyCode) override
void doShowFullScreen(bool bFullScreen, sal_Int32 nDisplay)
KeyIndicatorState
Definition: keycodes.hxx:180
tools::Rectangle maInvalidRect
Definition: osx/salframe.h:86
virtual bool MapUnicodeToKeyCode(sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode &rKeyCode) override
virtual void SetWindowState(const SalFrameState *pState) override
virtual void SetMinClientSize(long nWidth, long nHeight) override
SalData * GetSalData()
virtual void SetPointerPos(long nX, long nY) override
EndExtTextInputFlags
Definition: window.hxx:379
virtual void DrawMenuBar() override
virtual void SetTitle(const OUString &rTitle) override
static AquaSalFrame * GetCaptureFrame()
Definition: osx/salframe.h:169
NSCursor * getCurrentCursor()
virtual void SetPointer(PointerStyle ePointerStyle) override
void VCLToCocoa(NSRect &io_rRect, bool bRelativeToScreen=true)
unsigned int getStyleMask() const
Definition: osx/salframe.h:173
SalEvent
Definition: salwtype.hxx:40
virtual const SystemEnvData * GetSystemData() const override
virtual void StartPresentation(bool bStart) override
IOPMAssertionID mnAssertionID
Definition: osx/salframe.h:91
bool mbGeometryDidChange
Definition: osx/salframe.h:96
virtual void UnionClipRegion(long nX, long nY, long nWidth, long nHeight) override
NSRect maScreenRect
Definition: osx/salframe.h:52
virtual void UpdateSettings(AllSettings &rSettings) override
virtual void SetExtendedFrameStyle(SalExtStyle) override
NSMenuItem * mpDockMenuEntry
Definition: osx/salframe.h:51
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:112
void initWindowAndView()
virtual void SetRepresentedURL(const OUString &) override
virtual void ShowFullScreen(bool bFullScreen, sal_Int32 nDisplay) override
virtual void GetClientSize(long &rWidth, long &rHeight) override
void initShow()
do things on initial show (like centering on parent or on screen)
AquaSalFrame(SalFrame *pParent, SalFrameStyleFlags salFrameStyle)
Constructor.
PointerStyle mePointerStyle
Definition: osx/salframe.h:78
bool isFrameAlive(const SalFrame *pFrame) const
void UpdateFrameGeometry()
virtual void SetInputContext(SalInputContext *pContext) override
NSWindow * mpNSWindow
Definition: osx/salframe.h:49
virtual void CaptureMouse(bool bMouse) override
SalEvent PreparePosSize(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags)
SalFrameStyleFlags
Definition: salframe.hxx:64
AquaSalFrame & operator=(const AquaSalFrame &)=delete
std::vector< CGRect > maClippingRects
Definition: osx/salframe.h:84
virtual void ResetClipRegion() override
virtual ~AquaSalFrame() override
unsigned int mnStyleMask
Definition: osx/salframe.h:70
NSRect maFrameRect
Definition: osx/salframe.h:93
void getResolution(sal_Int32 &o_rDPIX, sal_Int32 &o_rDPIY)
unsigned int mnLastModifierFlags
Definition: osx/salframe.h:73
virtual void Flush(void) override
PointerStyle
Definition: ptrstyle.hxx:25
sal_uInt64 mnLastEventTime
Definition: osx/salframe.h:72
bool mbFullScreen
Definition: osx/salframe.h:62
virtual void SetAlwaysOnTop(bool bOnTop) override
virtual LanguageType GetInputLanguage() override
NSRect maFullScreenRect
Definition: osx/salframe.h:60
virtual bool SetPluginParent(SystemParentData *pNewParent) override
bool mbPresentation
Definition: osx/salframe.h:67
AquaSalGraphics * mpGraphics
Definition: osx/salframe.h:53
SalFrameStyleFlags mnStyle
Definition: osx/salframe.h:69
NSView * mpNSView
Definition: osx/salframe.h:50
AquaSalFrame * mpParent
Definition: osx/salframe.h:54
virtual void Show(bool bVisible, bool bNoActivate=false) override
NSWindow * getNSWindow() const
Definition: osx/salframe.h:171
virtual void SetScreenNumber(unsigned int) override
InputContextFlags
Definition: inputctx.hxx:28
virtual void ToTop(SalFrameToTop nFlags) override
SystemEnvData maSysData
Definition: osx/salframe.h:55