calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / vcl / inc / osx / salframe.h
blobb79d317ad55ff05b62b1f09675cce1290652ba15
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_INC_OSX_SALFRAME_H
21 #define INCLUDED_VCL_INC_OSX_SALFRAME_H
23 #include <premac.h>
24 #include <IOKit/pwr_mgt/IOPMLib.h>
25 #include <postmac.h>
27 #include <tools/long.hxx>
28 #include <vcl/sysdata.hxx>
30 #include <osx/salinst.h>
31 #include <osx/salmenu.h>
32 #include <osx/saldata.hxx>
33 #include <osx/osxvcltypes.h>
35 #include <salframe.hxx>
37 #include <vector>
38 #include <utility>
39 #include <stdexcept>
41 class AquaSalGraphics;
42 class AquaSalFrame;
43 class AquaSalTimer;
44 class AquaSalInstance;
45 class AquaSalMenu;
47 class AquaSalFrame : public SalFrame
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;
66 bool mbPositioned;
67 bool mbSized;
68 bool mbPresentation;
70 SalFrameStyleFlags mnStyle;
71 unsigned int mnStyleMask; // our style mask from NSWindow creation
73 sal_uInt64 mnLastEventTime;
74 unsigned int mnLastModifierFlags;
75 AquaSalMenu* mpMenu;
77 SalExtStyle mnExtStyle; // currently document frames are marked this way
79 PointerStyle mePointerStyle; // currently active pointer style
81 NSTrackingRectTag mnTrackingRectTag; // used to get enter/leave messages
82 NSRect maTrackingRect;
84 CGMutablePathRef mrClippingPath; // used for "shaping"
85 std::vector< CGRect > maClippingRects;
87 tools::Rectangle maInvalidRect;
89 InputContextFlags mnICOptions;
91 // To prevent display sleep during presentation
92 IOPMAssertionID mnAssertionID;
94 NSRect maFrameRect;
95 NSRect maContentRect;
97 bool mbGeometryDidChange;
99 int mnBlinkCursorDelay;
101 // tdf#155266 force flush after scrolling
102 bool mbForceFlush;
104 public:
105 /** Constructor
107 Creates a system window and connects this frame with it.
109 @throws std::runtime_error in case window creation fails
111 AquaSalFrame( SalFrame* pParent, SalFrameStyleFlags salFrameStyle );
113 virtual ~AquaSalFrame() override;
115 virtual SalGraphics* AcquireGraphics() override;
116 virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
117 virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
118 virtual void SetTitle( const OUString& rTitle ) override;
119 virtual void SetIcon( sal_uInt16 nIcon ) override;
120 virtual void SetRepresentedURL( const OUString& ) override;
121 virtual void SetMenu( SalMenu* pSalMenu ) override;
122 virtual void Show( bool bVisible, bool bNoActivate = false ) override;
123 virtual void SetMinClientSize( tools::Long nWidth, tools::Long nHeight )
124 override;
125 virtual void SetMaxClientSize( tools::Long nWidth, tools::Long nHeight )
126 override;
127 virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags ) override;
128 virtual void GetClientSize( tools::Long& rWidth, tools::Long& rHeight ) override;
129 virtual void GetWorkArea( tools::Rectangle& rRect ) override;
130 virtual SalFrame* GetParent() const override;
131 virtual void SetWindowState(const vcl::WindowData*) override;
132 virtual bool GetWindowState(vcl::WindowData*) override;
133 virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) override;
134 virtual void StartPresentation( bool bStart ) override;
135 virtual void SetAlwaysOnTop( bool bOnTop ) override;
136 virtual void ToTop( SalFrameToTop nFlags ) override;
137 virtual void SetPointer( PointerStyle ePointerStyle ) override;
138 virtual void CaptureMouse( bool bMouse ) override;
139 virtual void SetPointerPos( tools::Long nX, tools::Long nY ) override;
140 virtual void Flush( void ) override;
141 virtual void Flush( const tools::Rectangle& ) override;
142 virtual void SetInputContext( SalInputContext* pContext ) override;
143 virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) override;
144 virtual OUString GetKeyName( sal_uInt16 nKeyCode ) override;
145 virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) override;
146 virtual LanguageType GetInputLanguage() override;
147 virtual void UpdateSettings( AllSettings& rSettings ) override;
148 virtual void Beep() override;
149 virtual const SystemEnvData* GetSystemData() const override;
150 virtual SalPointerState GetPointerState() override;
151 virtual KeyIndicatorState GetIndicatorState() override;
152 virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) override;
153 virtual void SetParent( SalFrame* pNewParent ) override;
154 virtual void SetPluginParent( SystemParentData* pNewParent ) override;
155 virtual void SetExtendedFrameStyle( SalExtStyle ) override;
156 virtual void SetScreenNumber(unsigned int) override;
157 virtual void SetApplicationID( const OUString &rApplicationID ) override;
159 // shaped system windows
160 // set clip region to none (-> rectangular windows, normal state)
161 virtual void ResetClipRegion() override;
162 // start setting the clipregion consisting of nRects rectangles
163 virtual void BeginSetClipRegion( sal_uInt32 nRects ) override;
164 // add a rectangle to the clip region
165 virtual void UnionClipRegion(
166 tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override;
167 // done setting up the clipregion
168 virtual void EndSetClipRegion() override;
169 virtual void UpdateDarkMode() override;
171 void UpdateFrameGeometry();
173 // trigger painting of the window
174 void SendPaintEvent( const tools::Rectangle* pRect = nullptr );
176 static inline bool isAlive( const AquaSalFrame* pFrame );
178 static AquaSalFrame* GetCaptureFrame() { return s_pCaptureFrame; }
180 NSWindow* getNSWindow() const { return mpNSWindow; }
181 NSView* getNSView() const { return mpNSView; }
182 unsigned int getStyleMask() const { return mnStyleMask; }
184 void getResolution( sal_Int32& o_rDPIX, sal_Int32& o_rDPIY );
186 // actually the following methods do the same thing: flipping y coordinates
187 // but having two of them makes clearer what the coordinate system
188 // is supposed to be before and after
189 void VCLToCocoa( NSRect& io_rRect, bool bRelativeToScreen = true );
190 void CocoaToVCL( NSRect& io_rRect, bool bRelativeToScreen = true );
192 void VCLToCocoa( NSPoint& io_rPoint, bool bRelativeToScreen = true );
193 void CocoaToVCL( NSPoint& io_Point, bool bRelativeToScreen = true );
195 NSCursor* getCurrentCursor();
197 CGMutablePathRef getClipPath() const { return mrClippingPath; }
199 // called by VCL_NSApplication to indicate screen settings have changed
200 void screenParametersChanged();
202 protected:
203 SalEvent PreparePosSize(
204 tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags);
206 private: // methods
207 /** do things on initial show (like centering on parent or on screen)
209 void initShow();
211 void initWindowAndView();
213 void doShowFullScreen( bool bFullScreen, sal_Int32 nDisplay );
215 void doResetClipRegion();
217 private: // data
218 static AquaSalFrame* s_pCaptureFrame;
220 AquaSalFrame( const AquaSalFrame& ) = delete;
221 AquaSalFrame& operator=(const AquaSalFrame&) = delete;
224 inline bool AquaSalFrame::isAlive( const AquaSalFrame* pFrame )
226 AquaSalInstance *pInst = GetSalData()->mpInstance;
227 return pInst && pInst->isFrameAlive( pFrame );
230 #endif // INCLUDED_VCL_INC_OSX_SALFRAME_H
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */