Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / vcl / ios / iosinst.cxx
blob6ca639eaba483254f164d2b8463d3f7d56e8c65b
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 <premac.h>
21 #include <UIKit/UIKit.h>
22 #include <postmac.h>
24 #include "ios/iosinst.hxx"
25 #include "headless/svpdummies.hxx"
26 #include "generic/gendata.hxx"
27 #include "quartz/utils.h"
28 #include <vcl/layout.hxx>
29 #include <vcl/settings.hxx>
31 // Horrible hack
32 static int viewWidth = 1, viewHeight = 1;
34 class IosSalData : public SalGenericData
36 public:
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( Rectangle& rRect )
47 rRect = Rectangle( Point( 0, 0 ),
48 Size( viewWidth, viewHeight ) );
51 IosSalInstance *IosSalInstance::getInstance()
53 if (!ImplGetSVData())
54 return NULL;
55 IosSalData *pData = static_cast<IosSalData *>(ImplGetSVData()->mpSalData);
56 if (!pData)
57 return NULL;
58 return static_cast<IosSalInstance *>(pData->m_pInstance);
61 IosSalInstance::IosSalInstance( SalYieldMutex *pMutex )
62 : SvpSalInstance( pMutex )
66 IosSalInstance::~IosSalInstance()
70 class IosSalSystem : public SvpSalSystem {
71 public:
72 IosSalSystem() : SvpSalSystem() {}
73 virtual ~IosSalSystem() {}
74 virtual int ShowNativeDialog( const OUString& rTitle,
75 const OUString& rMessage,
76 const std::list< OUString >& rButtons,
77 int nDefButton );
80 SalSystem *IosSalInstance::CreateSalSystem()
82 return new IosSalSystem();
85 class IosSalFrame : public SvpSalFrame
87 public:
88 IosSalFrame( IosSalInstance *pInstance,
89 SalFrame *pParent,
90 SalFrameStyleFlags nSalFrameStyle,
91 SystemParentData *pSysParent )
92 : SvpSalFrame( pInstance, pParent, nSalFrameStyle,
93 pSysParent )
95 if (pParent == NULL && viewWidth > 1 && viewHeight > 1)
96 SetPosSize(0, 0, viewWidth, viewHeight, SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT);
99 virtual void GetWorkArea( Rectangle& rRect ) override
101 IosSalInstance::getInstance()->GetWorkArea( rRect );
104 virtual void ShowFullScreen( bool, sal_Int32 ) override
106 SetPosSize( 0, 0, viewWidth, viewHeight,
107 SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT );
110 virtual void UpdateSettings( AllSettings &rSettings ) override
112 // Clobber the UI fonts
113 vcl::Font aFont( OUString( "Helvetica" ), Size( 0, 14 ) );
115 StyleSettings aStyleSet = rSettings.GetStyleSettings();
116 aStyleSet.SetAppFont( aFont );
117 aStyleSet.SetHelpFont( aFont );
118 aStyleSet.SetMenuFont( aFont );
119 aStyleSet.SetToolFont( aFont );
120 aStyleSet.SetLabelFont( aFont );
121 aStyleSet.SetInfoFont( aFont );
122 aStyleSet.SetRadioCheckFont( aFont );
123 aStyleSet.SetPushButtonFont( aFont );
124 aStyleSet.SetFieldFont( aFont );
125 aStyleSet.SetIconFont( aFont );
126 aStyleSet.SetTabFont( aFont );
127 aStyleSet.SetGroupFont( aFont );
129 rSettings.SetStyleSettings( aStyleSet );
133 SalFrame *IosSalInstance::CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle )
135 return new IosSalFrame( this, NULL, nStyle, pParent );
138 SalFrame *IosSalInstance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle )
140 return new IosSalFrame( this, pParent, nStyle, NULL );
143 // All the interesting stuff is slaved from the IosSalInstance
144 void InitSalData() {}
145 void DeInitSalData() {}
146 void InitSalMain() {}
148 void SalAbort( const OUString& rErrorText, bool bDumpCore )
150 (void) bDumpCore;
152 NSLog(@"SalAbort: %s", OUStringToOString(rErrorText, osl_getThreadTextEncoding()).getStr() );
155 const OUString& SalGetDesktopEnvironment()
157 static OUString aEnv( "iOS" );
158 return aEnv;
161 SalData::SalData() :
162 m_pInstance( 0 ),
163 mpFontList( 0 ),
164 mxRGBSpace( CGColorSpaceCreateDeviceRGB() ),
165 mxGraySpace( CGColorSpaceCreateDeviceGray() )
169 SalData::~SalData()
173 // This is our main entry point:
174 SalInstance *CreateSalInstance()
176 IosSalInstance* pInstance = new IosSalInstance( new SalYieldMutex() );
177 new IosSalData( pInstance );
178 pInstance->AcquireYieldMutex(1);
179 return pInstance;
182 void DestroySalInstance( SalInstance *pInst )
184 pInst->ReleaseYieldMutex();
185 delete pInst;
188 int IosSalSystem::ShowNativeDialog( const OUString& rTitle,
189 const OUString& rMessage,
190 const std::list< OUString >& rButtons,
191 int nDefButton )
193 (void)rButtons;
194 (void)nDefButton;
196 NSLog(@"%@: %@", CreateNSString(rTitle), CreateNSString(rMessage));
198 return 0;
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */