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 
99 
100 public:
107  AquaSalFrame( SalFrame* pParent, SalFrameStyleFlags salFrameStyle );
108 
109  virtual ~AquaSalFrame() override;
110 
111  virtual SalGraphics* AcquireGraphics() override;
112  virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
113  virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
114  virtual void SetTitle( const OUString& rTitle ) override;
115  virtual void SetIcon( sal_uInt16 nIcon ) override;
116  virtual void SetRepresentedURL( const OUString& ) override;
117  virtual void SetMenu( SalMenu* pSalMenu ) override;
118  virtual void DrawMenuBar() override;
119  virtual void Show( bool bVisible, bool bNoActivate = false ) override;
120  virtual void SetMinClientSize( long nWidth, long nHeight ) override;
121  virtual void SetMaxClientSize( long nWidth, long nHeight ) override;
122  virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags ) override;
123  virtual void GetClientSize( long& rWidth, long& rHeight ) override;
124  virtual void GetWorkArea( tools::Rectangle& rRect ) override;
125  virtual SalFrame* GetParent() const override;
126  virtual void SetWindowState( const SalFrameState* pState ) override;
127  virtual bool GetWindowState( SalFrameState* pState ) override;
128  virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) override;
129  virtual void StartPresentation( bool bStart ) override;
130  virtual void SetAlwaysOnTop( bool bOnTop ) override;
131  virtual void ToTop( SalFrameToTop nFlags ) override;
132  virtual void SetPointer( PointerStyle ePointerStyle ) override;
133  virtual void CaptureMouse( bool bMouse ) override;
134  virtual void SetPointerPos( long nX, long nY ) override;
135  virtual void Flush( void ) override;
136  virtual void Flush( const tools::Rectangle& ) override;
137  virtual void SetInputContext( SalInputContext* pContext ) override;
138  virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) override;
139  virtual OUString GetKeyName( sal_uInt16 nKeyCode ) override;
140  virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) override;
141  virtual LanguageType GetInputLanguage() override;
142  virtual void UpdateSettings( AllSettings& rSettings ) override;
143  virtual void Beep() override;
144  virtual const SystemEnvData* GetSystemData() const override;
145  virtual SalPointerState GetPointerState() override;
146  virtual KeyIndicatorState GetIndicatorState() override;
147  virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) override;
148  virtual void SetParent( SalFrame* pNewParent ) override;
149  virtual bool SetPluginParent( SystemParentData* pNewParent ) override;
150  virtual void SetExtendedFrameStyle( SalExtStyle ) override;
151  virtual void SetScreenNumber(unsigned int) override;
152  virtual void SetApplicationID( const OUString &rApplicationID ) override;
153 
154  // shaped system windows
155  // set clip region to none (-> rectangular windows, normal state)
156  virtual void ResetClipRegion() override;
157  // start setting the clipregion consisting of nRects rectangles
158  virtual void BeginSetClipRegion( sal_uInt32 nRects ) override;
159  // add a rectangle to the clip region
160  virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) override;
161  // done setting up the clipregion
162  virtual void EndSetClipRegion() override;
163 
164  void UpdateFrameGeometry();
165 
166  virtual void BeginSheet(SalFrame* pSheetFrame) const override;
167 
168  // trigger painting of the window
169  void SendPaintEvent( const tools::Rectangle* pRect = nullptr );
170 
171  static inline bool isAlive( const AquaSalFrame* pFrame );
172 
174 
175  NSWindow* getNSWindow() const { return mpNSWindow; }
176  NSView* getNSView() const { return mpNSView; }
177  unsigned int getStyleMask() const { return mnStyleMask; }
178 
179  void getResolution( sal_Int32& o_rDPIX, sal_Int32& o_rDPIY );
180 
181  // actually the following methods do the same thing: flipping y coordinates
182  // but having two of them makes clearer what the coordinate system
183  // is supposed to be before and after
184  void VCLToCocoa( NSRect& io_rRect, bool bRelativeToScreen = true );
185  void CocoaToVCL( NSRect& io_rRect, bool bRelativeToScreen = true );
186 
187  void VCLToCocoa( NSPoint& io_rPoint, bool bRelativeToScreen = true );
188  void CocoaToVCL( NSPoint& io_Point, bool bRelativeToScreen = true );
189 
190  NSCursor* getCurrentCursor();
191 
192  CGMutablePathRef getClipPath() const { return mrClippingPath; }
193 
194  // called by VCL_NSApplication to indicate screen settings have changed
196 
197 protected:
198  SalEvent PreparePosSize(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags);
199 
200 private: // methods
203  void initShow();
204 
205  void initWindowAndView();
206 
207  void doShowFullScreen( bool bFullScreen, sal_Int32 nDisplay );
208 
209  void doResetClipRegion();
210 
211 private: // data
213 
214  AquaSalFrame( const AquaSalFrame& ) = delete;
215  AquaSalFrame& operator=(const AquaSalFrame&) = delete;
216 };
217 
218 inline bool AquaSalFrame::isAlive( const AquaSalFrame* pFrame )
219 {
221  return pInst && pInst->isFrameAlive( pFrame );
222 }
223 
224 #endif // INCLUDED_VCL_INC_OSX_SALFRAME_H
225 
226 /* 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:176
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:212
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:218
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:192
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
int mnBlinkCursorDelay
Definition: osx/salframe.h:98
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:173
NSCursor * getCurrentCursor()
virtual void SetPointer(PointerStyle ePointerStyle) override
void VCLToCocoa(NSRect &io_rRect, bool bRelativeToScreen=true)
unsigned int getStyleMask() const
Definition: osx/salframe.h:177
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
virtual void BeginSheet(SalFrame *pSheetFrame) const override
only does anything on MACOSX where it indicates to the OS that this window is a modal-dialog and shou...
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:175
virtual void SetScreenNumber(unsigned int) override
InputContextFlags
Definition: inputctx.hxx:28
virtual void ToTop(SalFrameToTop nFlags) override
SystemEnvData maSysData
Definition: osx/salframe.h:55