1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <UIKit/UIKit.h>
24 #include "ios/iosinst.hxx"
25 #include "headless/svpdummies.hxx"
26 #include "unx/gendata.hxx"
27 #include "quartz/utils.h"
28 #include <vcl/layout.hxx>
29 #include <vcl/settings.hxx>
31 // Totally wrong of course but doesn't seem to harm much in the iOS app.
32 static int viewWidth
= 1, viewHeight
= 1;
34 class IosSalData
: public GenericUnixSalData
37 explicit IosSalData(SalInstance
*pInstance
)
38 : GenericUnixSalData(SAL_DATA_IOS
, pInstance
)
41 virtual void ErrorTrapPush() {}
42 virtual bool ErrorTrapPop( bool ) { return false; }
45 void IosSalInstance::GetWorkArea( tools::Rectangle
& rRect
)
47 rRect
= tools::Rectangle( Point( 0, 0 ),
48 Size( viewWidth
, viewHeight
) );
51 IosSalInstance
*IosSalInstance::getInstance()
55 IosSalData
*pData
= static_cast<IosSalData
*>(ImplGetSVData()->mpSalData
);
58 return static_cast<IosSalInstance
*>(pData
->m_pInstance
);
61 IosSalInstance::IosSalInstance( std::unique_ptr
<SalYieldMutex
> pMutex
)
62 : SvpSalInstance( std::move(pMutex
) )
66 IosSalInstance::~IosSalInstance()
70 class IosSalSystem
: public SvpSalSystem
{
72 IosSalSystem() : SvpSalSystem() {}
73 virtual ~IosSalSystem() {}
74 virtual int ShowNativeDialog( const OUString
& rTitle
,
75 const OUString
& rMessage
,
76 const std::vector
< OUString
>& rButtons
);
79 SalSystem
*IosSalInstance::CreateSalSystem()
81 return new IosSalSystem();
84 class IosSalFrame
: public SvpSalFrame
87 IosSalFrame( IosSalInstance
*pInstance
,
89 SalFrameStyleFlags nSalFrameStyle
)
90 : SvpSalFrame( pInstance
, pParent
, nSalFrameStyle
)
92 if (pParent
== NULL
&& viewWidth
> 1 && viewHeight
> 1)
93 SetPosSize(0, 0, viewWidth
, viewHeight
, SAL_FRAME_POSSIZE_WIDTH
| SAL_FRAME_POSSIZE_HEIGHT
);
96 virtual void GetWorkArea( tools::Rectangle
& rRect
) override
98 IosSalInstance::getInstance()->GetWorkArea( rRect
);
101 virtual void ShowFullScreen( bool, sal_Int32
) override
103 SetPosSize( 0, 0, viewWidth
, viewHeight
,
104 SAL_FRAME_POSSIZE_WIDTH
| SAL_FRAME_POSSIZE_HEIGHT
);
107 virtual void UpdateSettings( AllSettings
&rSettings
) override
109 // Clobber the UI fonts
110 vcl::Font
aFont( "Helvetica", Size( 0, 10 ) );
112 StyleSettings aStyleSet
= rSettings
.GetStyleSettings();
113 aStyleSet
.SetAppFont( aFont
);
114 aStyleSet
.SetHelpFont( aFont
);
115 aStyleSet
.SetMenuFont( aFont
);
116 aStyleSet
.SetToolFont( aFont
);
117 aStyleSet
.SetLabelFont( aFont
);
118 aStyleSet
.SetRadioCheckFont( aFont
);
119 aStyleSet
.SetPushButtonFont( aFont
);
120 aStyleSet
.SetFieldFont( aFont
);
121 aStyleSet
.SetIconFont( aFont
);
122 aStyleSet
.SetTabFont( aFont
);
123 aStyleSet
.SetGroupFont( aFont
);
125 Color
aBackgroundColor( 0xff, 0xff, 0xff );
126 aStyleSet
.BatchSetBackgrounds( aBackgroundColor
, false );
127 aStyleSet
.SetMenuColor( aBackgroundColor
);
128 aStyleSet
.SetMenuBarColor( aBackgroundColor
);
129 aStyleSet
.SetDialogColor( aBackgroundColor
);
131 rSettings
.SetStyleSettings( aStyleSet
);
135 SalFrame
*IosSalInstance::CreateChildFrame( SystemParentData
* pParent
, SalFrameStyleFlags nStyle
)
138 return new IosSalFrame( this, NULL
, nStyle
);
141 SalFrame
*IosSalInstance::CreateFrame( SalFrame
* pParent
, SalFrameStyleFlags nStyle
)
143 return new IosSalFrame( this, pParent
, nStyle
);
146 void SalAbort( const OUString
& rErrorText
, bool bDumpCore
)
150 NSLog(@
"SalAbort: %s", OUStringToOString(rErrorText
, osl_getThreadTextEncoding()).getStr() );
153 const OUString
& SalGetDesktopEnvironment()
155 static OUString
aEnv( "iOS" );
162 mxRGBSpace( CGColorSpaceCreateDeviceRGB() ),
163 mxGraySpace( CGColorSpaceCreateDeviceGray() )
171 // This is our main entry point:
172 SalInstance
*CreateSalInstance()
174 IosSalInstance
* pInstance
= new IosSalInstance( std::make_unique
<SvpSalYieldMutex
>() );
175 new IosSalData( pInstance
);
176 pInstance
->AcquireYieldMutex();
180 void DestroySalInstance( SalInstance
*pInst
)
182 pInst
->ReleaseYieldMutexAll();
186 int IosSalSystem::ShowNativeDialog( const OUString
& rTitle
,
187 const OUString
& rMessage
,
188 const std::vector
< OUString
>& rButtons
)
192 NSLog(@
"%@: %@", CreateNSString(rTitle
), CreateNSString(rMessage
));
197 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */