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 <tools/long.hxx>
28 #include <vcl/sysdata.hxx>
29 
30 #include <osx/salinst.h>
31 #include <osx/salmenu.h>
32 #include <osx/saldata.hxx>
33 #include <osx/osxvcltypes.h>
34 
35 #include <salframe.hxx>
36 
37 #include <vector>
38 #include <utility>
39 #include <stdexcept>
40 
41 class AquaSalGraphics;
42 class AquaSalFrame;
43 class AquaSalTimer;
44 class AquaSalInstance;
45 class AquaSalMenu;
46 
47 class AquaSalFrame : public SalFrame
48 {
49 public:
50  NSWindow* mpNSWindow; // Cocoa window
51  NSView* mpNSView; // Cocoa view (actually a custom view)
52  NSMenuItem* mpDockMenuEntry; // entry in the dynamic dock menu
53  NSRect maScreenRect; // for mirroring purposes
54  AquaSalGraphics* mpGraphics; // current frame graphics
55  AquaSalFrame* mpParent; // pointer to parent frame
56  SystemEnvData maSysData; // system data
57  int mnMinWidth; // min. client width in pixels
58  int mnMinHeight; // min. client height in pixels
59  int mnMaxWidth; // max. client width in pixels
60  int mnMaxHeight; // max. client height in pixels
61  NSRect maFullScreenRect; // old window size when in FullScreen
62  bool mbGraphics; // is Graphics used?
63  bool mbFullScreen; // is Window in FullScreen?
64  bool mbShown;
65  bool mbInitShow;
67  bool mbSized;
69 
71  unsigned int mnStyleMask; // our style mask from NSWindow creation
72 
73  sal_uInt64 mnLastEventTime;
74  unsigned int mnLastModifierFlags;
76 
77  SalExtStyle mnExtStyle; // currently document frames are marked this way
78 
79  PointerStyle mePointerStyle; // currently active pointer style
80 
81  NSTrackingRectTag mnTrackingRectTag; // used to get enter/leave messages
83 
84  CGMutablePathRef mrClippingPath; // used for "shaping"
85  std::vector< CGRect > maClippingRects;
86 
88 
90 
91  // To prevent display sleep during presentation
92  IOPMAssertionID mnAssertionID;
93 
94  NSRect maFrameRect;
95  NSRect maContentRect;
96 
98 
100 
101 public:
108  AquaSalFrame( SalFrame* pParent, SalFrameStyleFlags salFrameStyle );
109 
110  virtual ~AquaSalFrame() override;
111 
112  virtual SalGraphics* AcquireGraphics() override;
113  virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
114  virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
115  virtual void SetTitle( const OUString& rTitle ) override;
116  virtual void SetIcon( sal_uInt16 nIcon ) override;
117  virtual void SetRepresentedURL( const OUString& ) override;
118  virtual void SetMenu( SalMenu* pSalMenu ) override;
119  virtual void DrawMenuBar() override;
120  virtual void Show( bool bVisible, bool bNoActivate = false ) override;
121  virtual void SetMinClientSize( tools::Long nWidth, tools::Long nHeight )
122  override;
123  virtual void SetMaxClientSize( tools::Long nWidth, tools::Long nHeight )
124  override;
125  virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags ) override;
126  virtual void GetClientSize( tools::Long& rWidth, tools::Long& rHeight ) override;
127  virtual void GetWorkArea( tools::Rectangle& rRect ) override;
128  virtual SalFrame* GetParent() const override;
129  virtual void SetWindowState( const SalFrameState* pState ) override;
130  virtual bool GetWindowState( SalFrameState* pState ) override;
131  virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) override;
132  virtual void StartPresentation( bool bStart ) override;
133  virtual void SetAlwaysOnTop( bool bOnTop ) override;
134  virtual void ToTop( SalFrameToTop nFlags ) override;
135  virtual void SetPointer( PointerStyle ePointerStyle ) override;
136  virtual void CaptureMouse( bool bMouse ) override;
137  virtual void SetPointerPos( tools::Long nX, tools::Long nY ) override;
138  virtual void Flush( void ) override;
139  virtual void Flush( const tools::Rectangle& ) override;
140  virtual void SetInputContext( SalInputContext* pContext ) override;
141  virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) override;
142  virtual OUString GetKeyName( sal_uInt16 nKeyCode ) override;
143  virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) override;
144  virtual LanguageType GetInputLanguage() override;
145  virtual void UpdateSettings( AllSettings& rSettings ) override;
146  virtual void Beep() override;
147  virtual const SystemEnvData* GetSystemData() const override;
148  virtual SalPointerState GetPointerState() override;
149  virtual KeyIndicatorState GetIndicatorState() override;
150  virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) override;
151  virtual void SetParent( SalFrame* pNewParent ) override;
152  virtual void SetPluginParent( SystemParentData* pNewParent ) override;
153  virtual void SetExtendedFrameStyle( SalExtStyle ) override;
154  virtual void SetScreenNumber(unsigned int) override;
155  virtual void SetApplicationID( const OUString &rApplicationID ) override;
156 
157  // shaped system windows
158  // set clip region to none (-> rectangular windows, normal state)
159  virtual void ResetClipRegion() override;
160  // start setting the clipregion consisting of nRects rectangles
161  virtual void BeginSetClipRegion( sal_uInt32 nRects ) override;
162  // add a rectangle to the clip region
163  virtual void UnionClipRegion(
164  tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override;
165  // done setting up the clipregion
166  virtual void EndSetClipRegion() override;
167 
168  void UpdateFrameGeometry();
169 
170  // trigger painting of the window
171  void SendPaintEvent( const tools::Rectangle* pRect = nullptr );
172 
173  static inline bool isAlive( const AquaSalFrame* pFrame );
174 
176 
177  NSWindow* getNSWindow() const { return mpNSWindow; }
178  NSView* getNSView() const { return mpNSView; }
179  unsigned int getStyleMask() const { return mnStyleMask; }
180 
181  void getResolution( sal_Int32& o_rDPIX, sal_Int32& o_rDPIY );
182 
183  // actually the following methods do the same thing: flipping y coordinates
184  // but having two of them makes clearer what the coordinate system
185  // is supposed to be before and after
186  void VCLToCocoa( NSRect& io_rRect, bool bRelativeToScreen = true );
187  void CocoaToVCL( NSRect& io_rRect, bool bRelativeToScreen = true );
188 
189  void VCLToCocoa( NSPoint& io_rPoint, bool bRelativeToScreen = true );
190  void CocoaToVCL( NSPoint& io_Point, bool bRelativeToScreen = true );
191 
192  NSCursor* getCurrentCursor();
193 
194  CGMutablePathRef getClipPath() const { return mrClippingPath; }
195 
196  // called by VCL_NSApplication to indicate screen settings have changed
198 
199 protected:
201  tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags);
202 
203 private: // methods
206  void initShow();
207 
208  void initWindowAndView();
209 
210  void doShowFullScreen( bool bFullScreen, sal_Int32 nDisplay );
211 
212  void doResetClipRegion();
213 
214 private: // data
216 
217  AquaSalFrame( const AquaSalFrame& ) = delete;
218  AquaSalFrame& operator=(const AquaSalFrame&) = delete;
219 };
220 
221 inline bool AquaSalFrame::isAlive( const AquaSalFrame* pFrame )
222 {
224  return pInst && pInst->isFrameAlive( pFrame );
225 }
226 
227 #endif // INCLUDED_VCL_INC_OSX_SALFRAME_H
228 
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SalExtStyle mnExtStyle
Definition: osx/salframe.h:77
virtual void SetApplicationID(const OUString &rApplicationID) override
AquaSalMenu * mpMenu
Definition: osx/salframe.h:75
virtual void ReleaseGraphics(SalGraphics *pGraphics) override
virtual SalFrame * GetParent() const override
bool mbPositioned
Definition: osx/salframe.h:66
virtual SalGraphics * AcquireGraphics() override
CGMutablePathRef mrClippingPath
Definition: osx/salframe.h:84
AquaSalInstance * mpInstance
Definition: osx/saldata.hxx:66
NSView * getNSView() const
Definition: osx/salframe.h:178
virtual void SetParent(SalFrame *pNewParent) override
void screenParametersChanged()
virtual KeyIndicatorState GetIndicatorState() override
long Long
NSTrackingRectTag mnTrackingRectTag
Definition: osx/salframe.h:81
static AquaSalFrame * s_pCaptureFrame
Definition: osx/salframe.h:215
void CocoaToVCL(NSRect &io_rRect, bool bRelativeToScreen=true)
void SendPaintEvent(const tools::Rectangle *pRect=nullptr)
InputContextFlags mnICOptions
Definition: osx/salframe.h:89
SalEvent PreparePosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags)
virtual void SetPluginParent(SystemParentData *pNewParent) override
static bool isAlive(const AquaSalFrame *pFrame)
Definition: osx/salframe.h:221
virtual void SetPosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags) override
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:194
virtual bool GetWindowState(SalFrameState *pState) override
sal_uInt64 SalExtStyle
Definition: salframe.hxx:95
virtual void BeginSetClipRegion(sal_uInt32 nRects) override
virtual void UnionClipRegion(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight) 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:82
NSRect maContentRect
Definition: osx/salframe.h:95
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:184
tools::Rectangle maInvalidRect
Definition: osx/salframe.h:87
int mnBlinkCursorDelay
Definition: osx/salframe.h:99
virtual bool MapUnicodeToKeyCode(sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode &rKeyCode) override
virtual void SetWindowState(const SalFrameState *pState) override
SalData * GetSalData()
EndExtTextInputFlags
Definition: window.hxx:357
virtual void DrawMenuBar() override
virtual void SetTitle(const OUString &rTitle) override
static AquaSalFrame * GetCaptureFrame()
Definition: osx/salframe.h:175
NSCursor * getCurrentCursor()
virtual void SetPointer(PointerStyle ePointerStyle) override
void VCLToCocoa(NSRect &io_rRect, bool bRelativeToScreen=true)
unsigned int getStyleMask() const
Definition: osx/salframe.h:179
virtual void SetMaxClientSize(tools::Long nWidth, tools::Long nHeight) override
SalEvent
Definition: salwtype.hxx:41
virtual const SystemEnvData * GetSystemData() const override
virtual void StartPresentation(bool bStart) override
IOPMAssertionID mnAssertionID
Definition: osx/salframe.h:92
bool mbGeometryDidChange
Definition: osx/salframe.h:97
NSRect maScreenRect
Definition: osx/salframe.h:53
virtual void UpdateSettings(AllSettings &rSettings) override
virtual void SetExtendedFrameStyle(SalExtStyle) override
NSMenuItem * mpDockMenuEntry
Definition: osx/salframe.h:52
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
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:79
bool isFrameAlive(const SalFrame *pFrame) const
virtual void SetMinClientSize(tools::Long nWidth, tools::Long nHeight) override
virtual void SetPointerPos(tools::Long nX, tools::Long nY) override
virtual void GetClientSize(tools::Long &rWidth, tools::Long &rHeight) override
void UpdateFrameGeometry()
virtual void SetInputContext(SalInputContext *pContext) override
NSWindow * mpNSWindow
Definition: osx/salframe.h:50
virtual void CaptureMouse(bool bMouse) override
SalFrameStyleFlags
Definition: salframe.hxx:64
AquaSalFrame & operator=(const AquaSalFrame &)=delete
std::vector< CGRect > maClippingRects
Definition: osx/salframe.h:85
virtual void ResetClipRegion() override
virtual ~AquaSalFrame() override
unsigned int mnStyleMask
Definition: osx/salframe.h:71
NSRect maFrameRect
Definition: osx/salframe.h:94
void getResolution(sal_Int32 &o_rDPIX, sal_Int32 &o_rDPIY)
unsigned int mnLastModifierFlags
Definition: osx/salframe.h:74
virtual void Flush(void) override
PointerStyle
Definition: ptrstyle.hxx:25
sal_uInt64 mnLastEventTime
Definition: osx/salframe.h:73
bool mbFullScreen
Definition: osx/salframe.h:63
virtual void SetAlwaysOnTop(bool bOnTop) override
virtual LanguageType GetInputLanguage() override
NSRect maFullScreenRect
Definition: osx/salframe.h:61
bool mbPresentation
Definition: osx/salframe.h:68
AquaSalGraphics * mpGraphics
Definition: osx/salframe.h:54
SalFrameStyleFlags mnStyle
Definition: osx/salframe.h:70
NSView * mpNSView
Definition: osx/salframe.h:51
AquaSalFrame * mpParent
Definition: osx/salframe.h:55
virtual void Show(bool bVisible, bool bNoActivate=false) override
NSWindow * getNSWindow() const
Definition: osx/salframe.h:177
virtual void SetScreenNumber(unsigned int) override
InputContextFlags
Definition: inputctx.hxx:28
virtual void ToTop(SalFrameToTop nFlags) override
SystemEnvData maSysData
Definition: osx/salframe.h:56