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>
32 static int viewWidth
= 1, viewHeight
= 1;
34 class IosSalData
: public SalGenericData
37 explicit IosSalData(SalInstance
*pInstance
)
38 : SalGenericData(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( SalYieldMutex
*pMutex
)
62 : SvpSalInstance( 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::list
< OUString
>& rButtons
,
80 SalSystem
*IosSalInstance::CreateSalSystem()
82 return new IosSalSystem();
85 class IosSalFrame
: public SvpSalFrame
88 IosSalFrame( IosSalInstance
*pInstance
,
90 SalFrameStyleFlags nSalFrameStyle
)
91 : SvpSalFrame( pInstance
, pParent
, nSalFrameStyle
)
93 if (pParent
== NULL
&& viewWidth
> 1 && viewHeight
> 1)
94 SetPosSize(0, 0, viewWidth
, viewHeight
, SAL_FRAME_POSSIZE_WIDTH
| SAL_FRAME_POSSIZE_HEIGHT
);
97 virtual void GetWorkArea( tools::Rectangle
& rRect
) override
99 IosSalInstance::getInstance()->GetWorkArea( rRect
);
102 virtual void ShowFullScreen( bool, sal_Int32
) override
104 SetPosSize( 0, 0, viewWidth
, viewHeight
,
105 SAL_FRAME_POSSIZE_WIDTH
| SAL_FRAME_POSSIZE_HEIGHT
);
108 virtual void UpdateSettings( AllSettings
&rSettings
) override
110 // Clobber the UI fonts
111 vcl::Font
aFont( OUString( "Helvetica" ), Size( 0, 14 ) );
113 StyleSettings aStyleSet
= rSettings
.GetStyleSettings();
114 aStyleSet
.SetAppFont( aFont
);
115 aStyleSet
.SetHelpFont( aFont
);
116 aStyleSet
.SetMenuFont( aFont
);
117 aStyleSet
.SetToolFont( aFont
);
118 aStyleSet
.SetLabelFont( aFont
);
119 aStyleSet
.SetRadioCheckFont( aFont
);
120 aStyleSet
.SetPushButtonFont( aFont
);
121 aStyleSet
.SetFieldFont( aFont
);
122 aStyleSet
.SetIconFont( aFont
);
123 aStyleSet
.SetTabFont( aFont
);
124 aStyleSet
.SetGroupFont( aFont
);
126 rSettings
.SetStyleSettings( aStyleSet
);
130 SalFrame
*IosSalInstance::CreateChildFrame( SystemParentData
* pParent
, SalFrameStyleFlags nStyle
)
133 return new IosSalFrame( this, NULL
, nStyle
);
136 SalFrame
*IosSalInstance::CreateFrame( SalFrame
* pParent
, SalFrameStyleFlags nStyle
)
138 return new IosSalFrame( this, pParent
, nStyle
);
141 // All the interesting stuff is slaved from the IosSalInstance
142 void InitSalData() {}
143 void DeInitSalData() {}
144 void InitSalMain() {}
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( new SalYieldMutex() );
175 new IosSalData( pInstance
);
176 pInstance
->AcquireYieldMutex(1);
180 void DestroySalInstance( SalInstance
*pInst
)
182 pInst
->ReleaseYieldMutex();
186 int IosSalSystem::ShowNativeDialog( const OUString
& rTitle
,
187 const OUString
& rMessage
,
188 const std::list
< OUString
>& rButtons
,
194 NSLog(@
"%@: %@", CreateNSString(rTitle
), CreateNSString(rMessage
));
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */