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 <basebmp/scanlineformats.hxx>
26 #include "ios/iosinst.hxx"
27 #include "headless/svpdummies.hxx"
28 #include "generic/gendata.hxx"
29 #include "quartz/utils.h"
30 #include <vcl/layout.hxx>
31 #include <vcl/settings.hxx>
34 static int viewWidth
= 1, viewHeight
= 1;
36 class IosSalData
: public SalGenericData
39 IosSalData( SalInstance
*pInstance
) : SalGenericData( SAL_DATA_IOS
, pInstance
) {}
40 virtual void ErrorTrapPush() {}
41 virtual bool ErrorTrapPop( bool ) { return false; }
44 void IosSalInstance::GetWorkArea( Rectangle
& rRect
)
46 rRect
= Rectangle( Point( 0, 0 ),
47 Size( viewWidth
, viewHeight
) );
51 * Try too hard to get a frame, in the absence of anything better to do
53 SalFrame
*IosSalInstance::getFocusFrame() const
55 SalFrame
*pFocus
= SvpSalFrame::GetFocusFrame();
57 const std::list
< SalFrame
* >& rFrames( getFrames() );
58 for( std::list
< SalFrame
* >::const_iterator it
= rFrames
.begin(); it
!= rFrames
.end(); ++it
)
60 SvpSalFrame
*pFrame
= const_cast<SvpSalFrame
*>(static_cast<const SvpSalFrame
*>(*it
));
61 if( pFrame
->IsVisible() )
72 IosSalInstance
*IosSalInstance::getInstance()
76 IosSalData
*pData
= static_cast<IosSalData
*>(ImplGetSVData()->mpSalData
);
79 return static_cast<IosSalInstance
*>(pData
->m_pInstance
);
82 IosSalInstance::IosSalInstance( SalYieldMutex
*pMutex
)
83 : SvpSalInstance( pMutex
)
87 IosSalInstance::~IosSalInstance()
93 bool IosSalInstance::AnyInput( VclInputFlags nType
)
95 if( nType
& VclInputFlags::TIMER
)
96 return CheckTimeout( false );
98 // Unfortunately there is no way to check for a specific type of
99 // input being queued. That information is too hidden, sigh.
100 return SvpSalInstance::s_pDefaultInstance
->PostedEventsInQueue();
105 class IosSalSystem
: public SvpSalSystem
{
107 IosSalSystem() : SvpSalSystem() {}
108 virtual ~IosSalSystem() {}
109 virtual int ShowNativeDialog( const OUString
& rTitle
,
110 const OUString
& rMessage
,
111 const std::list
< OUString
>& rButtons
,
115 SalSystem
*IosSalInstance::CreateSalSystem()
117 return new IosSalSystem();
120 class IosSalFrame
: public SvpSalFrame
123 IosSalFrame( IosSalInstance
*pInstance
,
125 sal_uLong nSalFrameStyle
,
126 SystemParentData
*pSysParent
)
127 : SvpSalFrame( pInstance
, pParent
, nSalFrameStyle
,
128 true, basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA
,
131 if (pParent
== NULL
&& viewWidth
> 1 && viewHeight
> 1)
132 SetPosSize(0, 0, viewWidth
, viewHeight
, SAL_FRAME_POSSIZE_WIDTH
| SAL_FRAME_POSSIZE_HEIGHT
);
135 virtual void GetWorkArea( Rectangle
& rRect
) SAL_OVERRIDE
137 IosSalInstance::getInstance()->GetWorkArea( rRect
);
140 virtual void ShowFullScreen( bool, sal_Int32
) SAL_OVERRIDE
142 SetPosSize( 0, 0, viewWidth
, viewHeight
,
143 SAL_FRAME_POSSIZE_WIDTH
| SAL_FRAME_POSSIZE_HEIGHT
);
146 virtual void UpdateSettings( AllSettings
&rSettings
) SAL_OVERRIDE
148 // Clobber the UI fonts
149 vcl::Font
aFont( OUString( "Helvetica" ), Size( 0, 14 ) );
151 StyleSettings aStyleSet
= rSettings
.GetStyleSettings();
152 aStyleSet
.SetAppFont( aFont
);
153 aStyleSet
.SetHelpFont( aFont
);
154 aStyleSet
.SetMenuFont( aFont
);
155 aStyleSet
.SetToolFont( aFont
);
156 aStyleSet
.SetLabelFont( aFont
);
157 aStyleSet
.SetInfoFont( aFont
);
158 aStyleSet
.SetRadioCheckFont( aFont
);
159 aStyleSet
.SetPushButtonFont( aFont
);
160 aStyleSet
.SetFieldFont( aFont
);
161 aStyleSet
.SetIconFont( aFont
);
162 aStyleSet
.SetTabFont( aFont
);
163 aStyleSet
.SetGroupFont( aFont
);
165 rSettings
.SetStyleSettings( aStyleSet
);
169 SalFrame
*IosSalInstance::CreateChildFrame( SystemParentData
* pParent
, sal_uLong nStyle
)
171 return new IosSalFrame( this, NULL
, nStyle
, pParent
);
174 SalFrame
*IosSalInstance::CreateFrame( SalFrame
* pParent
, sal_uLong nStyle
)
176 return new IosSalFrame( this, pParent
, nStyle
, NULL
);
179 // All the interesting stuff is slaved from the IosSalInstance
180 void InitSalData() {}
181 void DeInitSalData() {}
182 void InitSalMain() {}
184 void SalAbort( const OUString
& rErrorText
, bool bDumpCore
)
188 NSLog(@
"SalAbort: %s", OUStringToOString(rErrorText
, osl_getThreadTextEncoding()).getStr() );
191 const OUString
& SalGetDesktopEnvironment()
193 static OUString
aEnv( "iOS" );
200 mxRGBSpace( CGColorSpaceCreateDeviceRGB() ),
201 mxGraySpace( CGColorSpaceCreateDeviceGray() )
209 // This is our main entry point:
210 SalInstance
*CreateSalInstance()
212 IosSalInstance
* pInstance
= new IosSalInstance( new SalYieldMutex() );
213 new IosSalData( pInstance
);
214 pInstance
->AcquireYieldMutex(1);
215 ImplGetSVData()->maWinData
.mbNoSaveBackground
= true;
219 void DestroySalInstance( SalInstance
*pInst
)
221 pInst
->ReleaseYieldMutex();
225 int IosSalSystem::ShowNativeDialog( const OUString
& rTitle
,
226 const OUString
& rMessage
,
227 const std::list
< OUString
>& rButtons
,
233 NSLog(@
"%@: %@", CreateNSString(rTitle
), CreateNSString(rMessage
));
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */