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 "quartz/salgdi.h"
26 #include "headless/svpdata.hxx"
27 #include "headless/svpdummies.hxx"
28 #include "quartz/utils.h"
29 #include <vcl/layout.hxx>
30 #include <vcl/settings.hxx>
32 // Totally wrong of course but doesn't seem to harm much in the iOS app.
33 static int viewWidth
= 1, viewHeight
= 1;
35 void IosSalInstance::GetWorkArea( tools::Rectangle
& rRect
)
37 rRect
= tools::Rectangle( Point( 0, 0 ),
38 Size( viewWidth
, viewHeight
) );
41 IosSalInstance
*IosSalInstance::getInstance()
45 return static_cast<IosSalInstance
*>(GetSalInstance());
48 IosSalInstance::IosSalInstance( std::unique_ptr
<SalYieldMutex
> pMutex
)
49 : SvpSalInstance( std::move(pMutex
) )
53 IosSalInstance::~IosSalInstance()
57 class IosSalSystem
: public SvpSalSystem
{
59 IosSalSystem() : SvpSalSystem() {}
60 virtual ~IosSalSystem() {}
61 virtual int ShowNativeDialog( const OUString
& rTitle
,
62 const OUString
& rMessage
,
63 const std::vector
< OUString
>& rButtons
);
66 SalSystem
*IosSalInstance::CreateSalSystem()
68 return new IosSalSystem();
71 class IosSalFrame
: public SvpSalFrame
74 IosSalFrame( IosSalInstance
*pInstance
,
76 SalFrameStyleFlags nSalFrameStyle
)
77 : SvpSalFrame( pInstance
, pParent
, nSalFrameStyle
)
79 if (pParent
== NULL
&& viewWidth
> 1 && viewHeight
> 1)
80 SetPosSize(0, 0, viewWidth
, viewHeight
, SAL_FRAME_POSSIZE_WIDTH
| SAL_FRAME_POSSIZE_HEIGHT
);
83 virtual void GetWorkArea( tools::Rectangle
& rRect
) override
85 IosSalInstance::getInstance()->GetWorkArea( rRect
);
88 virtual void ShowFullScreen( bool, sal_Int32
) override
90 SetPosSize( 0, 0, viewWidth
, viewHeight
,
91 SAL_FRAME_POSSIZE_WIDTH
| SAL_FRAME_POSSIZE_HEIGHT
);
94 virtual void UpdateSettings( AllSettings
&rSettings
) override
96 // Clobber the UI fonts
97 vcl::Font
aFont( "Helvetica", Size( 0, 10 ) );
99 StyleSettings aStyleSet
= rSettings
.GetStyleSettings();
100 aStyleSet
.SetAppFont( aFont
);
101 aStyleSet
.SetHelpFont( aFont
);
102 aStyleSet
.SetMenuFont( aFont
);
103 aStyleSet
.SetToolFont( aFont
);
104 aStyleSet
.SetLabelFont( aFont
);
105 aStyleSet
.SetRadioCheckFont( aFont
);
106 aStyleSet
.SetPushButtonFont( aFont
);
107 aStyleSet
.SetFieldFont( aFont
);
108 aStyleSet
.SetIconFont( aFont
);
109 aStyleSet
.SetTabFont( aFont
);
110 aStyleSet
.SetGroupFont( aFont
);
112 Color
aBackgroundColor( 0xff, 0xff, 0xff );
113 aStyleSet
.BatchSetBackgrounds( aBackgroundColor
, false );
114 aStyleSet
.SetMenuColor( aBackgroundColor
);
115 aStyleSet
.SetMenuBarColor( aBackgroundColor
);
116 aStyleSet
.SetDialogColor( aBackgroundColor
);
118 rSettings
.SetStyleSettings( aStyleSet
);
122 SalFrame
*IosSalInstance::CreateChildFrame( SystemParentData
* pParent
, SalFrameStyleFlags nStyle
)
125 return new IosSalFrame( this, NULL
, nStyle
);
128 SalFrame
*IosSalInstance::CreateFrame( SalFrame
* pParent
, SalFrameStyleFlags nStyle
)
130 return new IosSalFrame( this, pParent
, nStyle
);
134 mxRGBSpace( CGColorSpaceCreateDeviceRGB() ),
135 mxGraySpace( CGColorSpaceCreateDeviceGray() )
142 CGColorSpaceRelease(mxRGBSpace
);
143 CGColorSpaceRelease(mxGraySpace
);
146 extern "C" SalInstance
*create_SalInstance()
148 IosSalInstance
* pInstance
= new IosSalInstance( std::make_unique
<SvpSalYieldMutex
>() );
153 int IosSalSystem::ShowNativeDialog( const OUString
& rTitle
,
154 const OUString
& rMessage
,
155 const std::vector
< OUString
>& rButtons
)
159 NSLog(@
"%@: %@", CreateNSString(rTitle
), CreateNSString(rMessage
));
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */