Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / vcl / ios / iosinst.cxx
blobb2b090834d87d181e0aa19dd5ebb34b7f01f7e8d
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 "unx/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( tools::Rectangle& rRect )
47 rRect = tools::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 : 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 )
132 pParent = NULL;
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 )
148 (void) bDumpCore;
150 NSLog(@"SalAbort: %s", OUStringToOString(rErrorText, osl_getThreadTextEncoding()).getStr() );
153 const OUString& SalGetDesktopEnvironment()
155 static OUString aEnv( "iOS" );
156 return aEnv;
159 SalData::SalData() :
160 m_pInstance( 0 ),
161 mpFontList( 0 ),
162 mxRGBSpace( CGColorSpaceCreateDeviceRGB() ),
163 mxGraySpace( CGColorSpaceCreateDeviceGray() )
167 SalData::~SalData()
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);
177 return pInstance;
180 void DestroySalInstance( SalInstance *pInst )
182 pInst->ReleaseYieldMutex();
183 delete pInst;
186 int IosSalSystem::ShowNativeDialog( const OUString& rTitle,
187 const OUString& rMessage,
188 const std::list< OUString >& rButtons,
189 int nDefButton )
191 (void)rButtons;
192 (void)nDefButton;
194 NSLog(@"%@: %@", CreateNSString(rTitle), CreateNSString(rMessage));
196 return 0;
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */