sw a11y: clang-format SidebarWinAccessible code
[LibreOffice.git] / vcl / osx / salsys.cxx
blob37ad48e7dcbd31e7c589bdb3e01f694dc56b73b0
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 #include <rtl/ustrbuf.hxx>
21 #include <tools/long.hxx>
22 #include <vcl/stdtext.hxx>
24 #include <osx/salsys.h>
25 #include <osx/saldata.hxx>
26 #include <osx/salinst.h>
27 #include <quartz/utils.h>
29 #include <strings.hrc>
31 AquaSalSystem::~AquaSalSystem()
35 unsigned int AquaSalSystem::GetDisplayScreenCount()
37 NSArray* pScreens = [NSScreen screens];
38 return pScreens ? [pScreens count] : 1;
41 AbsoluteScreenPixelRectangle AquaSalSystem::GetDisplayScreenPosSizePixel( unsigned int nScreen )
43 if (Application::IsBitmapRendering())
45 AbsoluteScreenPixelRectangle aRect;
46 if (nScreen == 0)
47 aRect = AbsoluteScreenPixelRectangle(AbsoluteScreenPixelPoint(0,0), AbsoluteScreenPixelSize(1024, 768));
48 return aRect;
51 NSArray* pScreens = [NSScreen screens];
52 AbsoluteScreenPixelRectangle aRet;
53 NSScreen* pScreen = nil;
54 if( pScreens && nScreen < [pScreens count] )
55 pScreen = [pScreens objectAtIndex: nScreen];
56 else
57 pScreen = [NSScreen mainScreen];
59 if( pScreen )
61 NSRect aFrame = [pScreen frame];
62 aRet = AbsoluteScreenPixelRectangle(
63 AbsoluteScreenPixelPoint( static_cast<tools::Long>(aFrame.origin.x), static_cast<tools::Long>(aFrame.origin.y) ),
64 AbsoluteScreenPixelSize( static_cast<tools::Long>(aFrame.size.width), static_cast<tools::Long>(aFrame.size.height) ) );
66 return aRet;
69 static NSString* getStandardString( StandardButtonType nButtonId, bool bUseResources )
71 OUString aText;
72 if( bUseResources )
74 aText = GetStandardText( nButtonId );
76 if( aText.isEmpty() ) // this is for bad cases, we might be missing the vcl resource
78 switch( nButtonId )
80 case StandardButtonType::OK: aText = "OK";break;
81 case StandardButtonType::Abort: aText = "Abort";break;
82 case StandardButtonType::Cancel: aText = "Cancel";break;
83 case StandardButtonType::Retry: aText = "Retry";break;
84 case StandardButtonType::Yes: aText = "Yes";break;
85 case StandardButtonType::No: aText = "No";break;
86 default: break;
89 return aText.isEmpty() ? nil : CreateNSString( aText);
92 int AquaSalSystem::ShowNativeMessageBox( const OUString& rTitle,
93 const OUString& rMessage )
95 NSString* pTitle = CreateNSString( rTitle );
96 NSString* pMessage = CreateNSString( rMessage );
98 NSString* pDefText = getStandardString( StandardButtonType::OK, false/*bUseResources*/ );
100 SAL_WNODEPRECATED_DECLARATIONS_PUSH //TODO: 10.10 NSRunAlertPanel
101 int nResult = NSRunAlertPanel( pTitle, @"%@", pDefText, nil, nil, pMessage );
102 SAL_WNODEPRECATED_DECLARATIONS_POP
104 if( pTitle )
105 [pTitle release];
106 if( pMessage )
107 [pMessage release];
108 if( pDefText )
109 [pDefText release];
111 int nRet = 0;
112 if( nResult == 1 )
113 nRet = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK;
115 return nRet;
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */