diff options
Diffstat (limited to 'vcl/ios/source/window')
-rw-r--r-- | vcl/ios/source/window/salframe.cxx | 1106 | ||||
-rw-r--r-- | vcl/ios/source/window/salframeview.mm | 263 | ||||
-rw-r--r-- | vcl/ios/source/window/salmenu.cxx | 62 | ||||
-rw-r--r-- | vcl/ios/source/window/salobj.cxx | 201 |
4 files changed, 0 insertions, 1632 deletions
diff --git a/vcl/ios/source/window/salframe.cxx b/vcl/ios/source/window/salframe.cxx deleted file mode 100644 index 43cc7ba24a45..000000000000 --- a/vcl/ios/source/window/salframe.cxx +++ /dev/null @@ -1,1106 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <string> - -#include "rtl/ustrbuf.hxx" - -#include "osl/file.h" - -#include "vcl/svapp.hxx" -#include "vcl/window.hxx" -#include "vcl/timer.hxx" - -#include "ios/saldata.hxx" -#include "coretext/salgdi.h" -#include "ios/salframe.h" -#include "ios/salmenu.h" -#include "ios/saltimer.h" -#include "ios/salinst.h" -#include "ios/salframeview.h" - -#include "salwtype.hxx" - -using namespace std; - -// ======================================================================= - -IosSalFrame* IosSalFrame::s_pCaptureFrame = NULL; - -// ======================================================================= - -IosSalFrame::IosSalFrame( SalFrame* pParent, sal_uLong salFrameStyle ) : - mpWindow(nil), - mpView(nil), - mpGraphics(NULL), - mpParent(NULL), - mnMinWidth(0), - mnMinHeight(0), - mnMaxWidth(0), - mnMaxHeight(0), - mbGraphics(false), - mbShown(false), - mbInitShow(true), - mbPresentation( false ), - mnStyle( salFrameStyle ), - mnStyleMask( 0 ), - mnLastEventTime( 0 ), - mnLastModifierFlags( 0 ), - mpMenu( NULL ), - mnExtStyle( 0 ), - mePointerStyle( POINTER_ARROW ), - mrClippingPath( 0 ), - mnICOptions( 0 ) -{ - maSysData.nSize = sizeof( SystemEnvData ); - - mpParent = dynamic_cast<IosSalFrame*>(pParent); - - initWindowAndView(); - - SalData* pSalData = GetSalData(); - pSalData->maFrames.push_front( this ); - pSalData->maFrameCheck.insert( this ); -} - -// ----------------------------------------------------------------------- - -IosSalFrame::~IosSalFrame() -{ - // cleanup clipping stuff - ResetClipRegion(); - - SalData* pSalData = GetSalData(); - pSalData->maFrames.remove( this ); - pSalData->maFrameCheck.erase( this ); - - DBG_ASSERT( this != s_pCaptureFrame, "capture frame destroyed" ); - if( this == s_pCaptureFrame ) - s_pCaptureFrame = NULL; - - delete mpGraphics; - - if ( mpView ) { - [mpView release]; - } - if ( mpWindow ) - [mpWindow release]; -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::initWindowAndView() -{ - // initialize mirroring parameters - // FIXME: screens changing - UIScreen * pScreen = [mpWindow screen]; - if( pScreen == nil ) - pScreen = [UIScreen mainScreen]; - maScreenRect = [pScreen applicationFrame]; - - // calculate some default geometry - CGRect aVisibleRect = [pScreen applicationFrame]; - CocoaTouchToVCL( aVisibleRect ); - - maGeometry.nX = static_cast<int>(aVisibleRect.origin.x + aVisibleRect.size.width / 10); - maGeometry.nY = static_cast<int>(aVisibleRect.origin.y + aVisibleRect.size.height / 10); - maGeometry.nWidth = static_cast<unsigned int>(aVisibleRect.size.width * 0.8); - maGeometry.nHeight = static_cast<unsigned int>(aVisibleRect.size.height * 0.8); - - // calculate style mask - if( (mnStyle & SAL_FRAME_STYLE_FLOAT) || - (mnStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) ) - ; - else if( mnStyle & SAL_FRAME_STYLE_DEFAULT ) - { - // make default window "maximized" - maGeometry.nX = static_cast<int>(aVisibleRect.origin.x); - maGeometry.nY = static_cast<int>(aVisibleRect.origin.y); - maGeometry.nWidth = static_cast<int>(aVisibleRect.size.width); - maGeometry.nHeight = static_cast<int>(aVisibleRect.size.height); - } - else - { - if( (mnStyle & SAL_FRAME_STYLE_MOVEABLE) ) - { - } - } - - mpWindow = [[SalFrameWindow alloc] initWithSalFrame: this]; - mpView = [[SalFrameView alloc] initWithSalFrame: this]; - - maSysData.pView = mpView; - - UpdateFrameGeometry(); -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::CocoaTouchToVCL( CGRect& io_rRect, bool bRelativeToScreen ) -{ - if( bRelativeToScreen ) - io_rRect.origin.y = maScreenRect.size.height - (io_rRect.origin.y+io_rRect.size.height); - else - io_rRect.origin.y = maGeometry.nHeight - (io_rRect.origin.y+io_rRect.size.height); -} - -void IosSalFrame::VCLToCocoaTouch( CGRect& io_rRect, bool bRelativeToScreen ) -{ - if( bRelativeToScreen ) - io_rRect.origin.y = maScreenRect.size.height - (io_rRect.origin.y+io_rRect.size.height); - else - io_rRect.origin.y = maGeometry.nHeight - (io_rRect.origin.y+io_rRect.size.height); -} - -void IosSalFrame::CocoaTouchToVCL( CGPoint& io_rPoint, bool bRelativeToScreen ) -{ - if( bRelativeToScreen ) - io_rPoint.y = maScreenRect.size.height - io_rPoint.y; - else - io_rPoint.y = maGeometry.nHeight - io_rPoint.y; -} - -void IosSalFrame::VCLToCocoaTouch( CGPoint& io_rPoint, bool bRelativeToScreen ) -{ - if( bRelativeToScreen ) - io_rPoint.y = maScreenRect.size.height - io_rPoint.y; - else - io_rPoint.y = maGeometry.nHeight - io_rPoint.y; -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::screenParametersChanged() -{ - UpdateFrameGeometry(); - - if( mpGraphics ) - mpGraphics->updateResolution(); - CallCallback( SALEVENT_DISPLAYCHANGED, 0 ); -} - -// ----------------------------------------------------------------------- - -SalGraphics* IosSalFrame::GetGraphics() -{ - if ( mbGraphics ) - return NULL; - - if ( !mpGraphics ) - { - mpGraphics = new QuartzSalGraphics; - mpGraphics->SetWindowGraphics( this ); - } - - mbGraphics = TRUE; - return mpGraphics; -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::ReleaseGraphics( SalGraphics *pGraphics ) -{ - (void)pGraphics; - DBG_ASSERT( pGraphics == mpGraphics, "graphics released on wrong frame" ); - mbGraphics = FALSE; -} - -// ----------------------------------------------------------------------- - -sal_Bool IosSalFrame::PostEvent( void *pData ) -{ - GetSalData()->mpFirstInstance->PostUserEvent( this, SALEVENT_USEREVENT, pData ); - return TRUE; -} - -// ----------------------------------------------------------------------- -void IosSalFrame::SetTitle(const rtl::OUString& /* rTitle */) -{ -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::SetIcon( sal_uInt16 ) -{ -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::SetRepresentedURL( const rtl::OUString& /* i_rDocURL */ ) -{ -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::initShow() -{ - mbInitShow = false; - { - Rectangle aScreenRect; - GetWorkArea( aScreenRect ); - if( mpParent ) // center relative to parent - { - // center on parent - long nNewX = mpParent->maGeometry.nX + ((long)mpParent->maGeometry.nWidth - (long)maGeometry.nWidth)/2; - if( nNewX < aScreenRect.Left() ) - nNewX = aScreenRect.Left(); - if( long(nNewX + maGeometry.nWidth) > aScreenRect.Right() ) - nNewX = aScreenRect.Right() - maGeometry.nWidth-1; - long nNewY = mpParent->maGeometry.nY + ((long)mpParent->maGeometry.nHeight - (long)maGeometry.nHeight)/2; - if( nNewY < aScreenRect.Top() ) - nNewY = aScreenRect.Top(); - if( nNewY > aScreenRect.Bottom() ) - nNewY = aScreenRect.Bottom() - maGeometry.nHeight-1; - SetPosSize( nNewX - mpParent->maGeometry.nX, - nNewY - mpParent->maGeometry.nY, - 0, 0, SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y ); - } - else if( ! (mnStyle & SAL_FRAME_STYLE_SIZEABLE) ) - { - // center on screen - long nNewX = (aScreenRect.GetWidth() - maGeometry.nWidth)/2; - long nNewY = (aScreenRect.GetHeight() - maGeometry.nHeight)/2; - SetPosSize( nNewX, nNewY, 0, 0, SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y ); - } - } -} - -void IosSalFrame::SendPaintEvent( const Rectangle* pRect ) -{ - SalPaintEvent aPaintEvt( 0, 0, maGeometry.nWidth, maGeometry.nHeight, true ); - if( pRect ) - { - aPaintEvt.mnBoundX = pRect->Left(); - aPaintEvt.mnBoundY = pRect->Top(); - aPaintEvt.mnBoundWidth = pRect->GetWidth(); - aPaintEvt.mnBoundHeight = pRect->GetHeight(); - } - - CallCallback(SALEVENT_PAINT, &aPaintEvt); -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::Show(sal_Bool bVisible, sal_Bool bNoActivate) -{ - if ( !mpWindow ) - return; - - // #i113170# may not be the main thread if called from UNO API - SalData::ensureThreadAutoreleasePool(); - - mbShown = bVisible; - if(bVisible) - { - if( mbInitShow ) - initShow(); - - CallCallback(SALEVENT_RESIZE, 0); - // trigger filling our backbuffer - SendPaintEvent(); - - if( !bNoActivate ) - [mpWindow makeKeyAndVisible]; -#if 0 // ??? - if( mpParent ) - { - /* #i92674# #i96433# we do not want an invisible parent to show up (which adding a visible - child implicitly does). However we also do not want a parentless toolbar. - - HACK: try to decide when we should not insert a child to its parent - floaters and ownerdraw windows have not yet shown up in cases where - we don't want the parent to become visible - */ - if( mpParent->mbShown || (mnStyle & (SAL_FRAME_STYLE_OWNERDRAWDECORATION | SAL_FRAME_STYLE_FLOAT) ) ) - { - [mpParent->mpWindow addChildWindow: mpWindow]; - } - } - - if( mbPresentation ) - [mpWindow makeMainWindow]; -#endif - } - else - { -#if 0 // ??? - if( mpParent && [mpWindow parentWindow] == mpParent->mpWindow ) - [mpParent->mpWindow removeChildWindow: mpWindow]; -#endif - } -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::Enable( sal_Bool ) -{ -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::SetMinClientSize( long nWidth, long nHeight ) -{ - // #i113170# may not be the main thread if called from UNO API - SalData::ensureThreadAutoreleasePool(); - - mnMinWidth = nWidth; - mnMinHeight = nHeight; - - if( mpWindow ) - { - // Always add the decoration as the dimension concerns only - // the content rectangle - nWidth += maGeometry.nLeftDecoration + maGeometry.nRightDecoration; - nHeight += maGeometry.nTopDecoration + maGeometry.nBottomDecoration; - -#if 0 // ??? - CGSize aSize = { nWidth, nHeight }; - // Size of full window (content+structure) although we only - // have the client size in arguments - [mpWindow setMinSize: aSize]; -#endif - } -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::SetMaxClientSize( long nWidth, long nHeight ) -{ - // #i113170# may not be the main thread if called from UNO API - SalData::ensureThreadAutoreleasePool(); - - mnMaxWidth = nWidth; - mnMaxHeight = nHeight; - - if( mpWindow ) - { - // Always add the decoration as the dimension concerns only - // the content rectangle - nWidth += maGeometry.nLeftDecoration + maGeometry.nRightDecoration; - nHeight += maGeometry.nTopDecoration + maGeometry.nBottomDecoration; - - // Carbon windows can't have a size greater than 32767x32767 - if (nWidth>32767) nWidth=32767; - if (nHeight>32767) nHeight=32767; - -#if 0 // ??? - CGSize aSize = { nWidth, nHeight }; - // Size of full window (content+structure) although we only - // have the client size in arguments - [mpWindow setMaxSize: aSize]; -#endif - } -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::SetClientSize( long /*nWidth*/, long /*nHeight*/ ) -{ - // #i113170# may not be the main thread if called from UNO API - SalData::ensureThreadAutoreleasePool(); - - if( mpWindow ) - { -#if 0 // ??? - CGSize aSize = { nWidth, nHeight }; - [mpWindow setContentSize: aSize]; -#endif - UpdateFrameGeometry(); - if( mbShown ) - // trigger filling our backbuffer - SendPaintEvent(); - } -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::GetClientSize( long& rWidth, long& rHeight ) -{ - if( mbShown || mbInitShow ) - { - rWidth = maGeometry.nWidth; - rHeight = maGeometry.nHeight; - } - else - { - rWidth = 0; - rHeight = 0; - } -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::SetWindowState( const SalFrameState* pState ) -{ - // ??? - - // get new geometry - UpdateFrameGeometry(); - - sal_uInt16 nEvent = 0; - if( pState->mnMask & (SAL_FRAMESTATE_MASK_X | SAL_FRAMESTATE_MASK_Y) ) - { - mbPositioned = true; - nEvent = SALEVENT_MOVE; - } - - if( pState->mnMask & (SAL_FRAMESTATE_MASK_WIDTH | SAL_FRAMESTATE_MASK_HEIGHT) ) - { - mbSized = true; - nEvent = (nEvent == SALEVENT_MOVE) ? SALEVENT_MOVERESIZE : SALEVENT_RESIZE; - } - // send event that we were moved/sized - if( nEvent ) - CallCallback( nEvent, NULL ); - - if( mbShown && mpWindow ) - { - // trigger filling our backbuffer - SendPaintEvent(); - } -} - -// ----------------------------------------------------------------------- - -sal_Bool IosSalFrame::GetWindowState( SalFrameState* pState ) -{ - if ( !mpWindow ) - return FALSE; - - // #i113170# may not be the main thread if called from UNO API - SalData::ensureThreadAutoreleasePool(); - - pState->mnMask = SAL_FRAMESTATE_MASK_X | - SAL_FRAMESTATE_MASK_Y | - SAL_FRAMESTATE_MASK_WIDTH | - SAL_FRAMESTATE_MASK_HEIGHT | - SAL_FRAMESTATE_MASK_STATE; - -#if 0 // ??? - CGRect aStateRect = [mpWindow frame]; - aStateRect = [UIWindow contentRectForFrameRect: aStateRect styleMask: mnStyleMask]; - CocoaTouchToVCL( aStateRect ); - pState->mnX = long(aStateRect.origin.x); - pState->mnY = long(aStateRect.origin.y); - pState->mnWidth = long(aStateRect.size.width); - pState->mnHeight = long(aStateRect.size.height); -#endif - pState->mnState = SAL_FRAMESTATE_MAXIMIZED; - - return TRUE; -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::SetScreenNumber(unsigned int /*nScreen*/) -{ - // ??? -} - -void IosSalFrame::SetApplicationID( const rtl::OUString &/*rApplicationID*/ ) -{ -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::ShowFullScreen( sal_Bool /*bFullScreen*/, sal_Int32 /*nDisplay*/ ) -{ - // ??? -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::StartPresentation( sal_Bool /*bStart*/ ) -{ - if ( !mpWindow ) - return; - - // ??? -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::SetAlwaysOnTop( sal_Bool ) -{ -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::ToTop(sal_uInt16 /*nFlags*/) -{ - if ( !mpWindow ) - return; - - // ??? -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::SetPointer( PointerStyle /*ePointerStyle*/ ) -{ -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::SetPointerPos( long /* nX */ , long /* nY */ ) -{ -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::Flush( void ) -{ - // ??? -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::Flush( const Rectangle& /*rRect*/ ) -{ - // ??? -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::Sync() -{ - // ??? -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::SetInputContext( SalInputContext* pContext ) -{ - if (!pContext) - { - mnICOptions = 0; - return; - } - - mnICOptions = pContext->mnOptions; - - if(!(pContext->mnOptions & SAL_INPUTCONTEXT_TEXT)) - return; -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::EndExtTextInput( sal_uInt16 ) -{ -} - -// ----------------------------------------------------------------------- - -rtl::OUString IosSalFrame::GetKeyName( sal_uInt16 nKeyCode ) -{ - static std::map< sal_uInt16, rtl::OUString > aKeyMap; - if( aKeyMap.empty() ) - { - sal_uInt16 i; - for( i = KEY_A; i <= KEY_Z; i++ ) - aKeyMap[ i ] = rtl::OUString( sal_Unicode( 'A' + (i - KEY_A) ) ); - for( i = KEY_0; i <= KEY_9; i++ ) - aKeyMap[ i ] = rtl::OUString( sal_Unicode( '0' + (i - KEY_0) ) ); - for( i = KEY_F1; i <= KEY_F26; i++ ) - { - rtl::OUStringBuffer aKey( 3 ); - aKey.append( sal_Unicode( 'F' ) ); - aKey.append( sal_Int32( i - KEY_F1 + 1 ) ); - aKeyMap[ i ] = aKey.makeStringAndClear(); - } - - aKeyMap[ KEY_DOWN ] = rtl::OUString( sal_Unicode( 0x21e3 ) ); - aKeyMap[ KEY_UP ] = rtl::OUString( sal_Unicode( 0x21e1 ) ); - aKeyMap[ KEY_LEFT ] = rtl::OUString( sal_Unicode( 0x21e0 ) ); - aKeyMap[ KEY_RIGHT ] = rtl::OUString( sal_Unicode( 0x21e2 ) ); - aKeyMap[ KEY_HOME ] = rtl::OUString( sal_Unicode( 0x2196 ) ); - aKeyMap[ KEY_END ] = rtl::OUString( sal_Unicode( 0x2198 ) ); - aKeyMap[ KEY_PAGEUP ] = rtl::OUString( sal_Unicode( 0x21de ) ); - aKeyMap[ KEY_PAGEDOWN ] = rtl::OUString( sal_Unicode( 0x21df ) ); - aKeyMap[ KEY_RETURN ] = rtl::OUString( sal_Unicode( 0x21a9 ) ); - aKeyMap[ KEY_ESCAPE ] = rtl::OUString( "esc" ); - aKeyMap[ KEY_TAB ] = rtl::OUString( sal_Unicode( 0x21e5 ) ); - aKeyMap[ KEY_BACKSPACE ]= rtl::OUString( sal_Unicode( 0x232b ) ); - aKeyMap[ KEY_SPACE ] = rtl::OUString( sal_Unicode( 0x2423 ) ); - aKeyMap[ KEY_DELETE ] = rtl::OUString( sal_Unicode( 0x2326 ) ); - aKeyMap[ KEY_ADD ] = rtl::OUString( sal_Unicode( '+' ) ); - aKeyMap[ KEY_SUBTRACT ] = rtl::OUString( sal_Unicode( '-' ) ); - aKeyMap[ KEY_DIVIDE ] = rtl::OUString( sal_Unicode( '/' ) ); - aKeyMap[ KEY_MULTIPLY ] = rtl::OUString( sal_Unicode( '*' ) ); - aKeyMap[ KEY_POINT ] = rtl::OUString( sal_Unicode( '.' ) ); - aKeyMap[ KEY_COMMA ] = rtl::OUString( sal_Unicode( ',' ) ); - aKeyMap[ KEY_LESS ] = rtl::OUString( sal_Unicode( '<' ) ); - aKeyMap[ KEY_GREATER ] = rtl::OUString( sal_Unicode( '>' ) ); - aKeyMap[ KEY_EQUAL ] = rtl::OUString( sal_Unicode( '=' ) ); - aKeyMap[ KEY_OPEN ] = rtl::OUString( sal_Unicode( 0x23cf ) ); - - /* yet unmapped KEYCODES: - aKeyMap[ KEY_INSERT ] = rtl::OUString( sal_Unicode( ) ); - aKeyMap[ KEY_CUT ] = rtl::OUString( sal_Unicode( ) ); - aKeyMap[ KEY_COPY ] = rtl::OUString( sal_Unicode( ) ); - aKeyMap[ KEY_PASTE ] = rtl::OUString( sal_Unicode( ) ); - aKeyMap[ KEY_UNDO ] = rtl::OUString( sal_Unicode( ) ); - aKeyMap[ KEY_REPEAT ] = rtl::OUString( sal_Unicode( ) ); - aKeyMap[ KEY_FIND ] = rtl::OUString( sal_Unicode( ) ); - aKeyMap[ KEY_PROPERTIES ] = rtl::OUString( sal_Unicode( ) ); - aKeyMap[ KEY_FRONT ] = rtl::OUString( sal_Unicode( ) ); - aKeyMap[ KEY_CONTEXTMENU ] = rtl::OUString( sal_Unicode( ) ); - aKeyMap[ KEY_MENU ] = rtl::OUString( sal_Unicode( ) ); - aKeyMap[ KEY_HELP ] = rtl::OUString( sal_Unicode( ) ); - aKeyMap[ KEY_HANGUL_HANJA ] = rtl::OUString( sal_Unicode( ) ); - aKeyMap[ KEY_DECIMAL ] = rtl::OUString( sal_Unicode( ) ); - aKeyMap[ KEY_TILDE ] = rtl::OUString( sal_Unicode( ) ); - aKeyMap[ KEY_QUOTELEFT ]= rtl::OUString( sal_Unicode( ) ); - */ - - } - - rtl::OUStringBuffer aResult( 16 ); - - sal_uInt16 nUnmodifiedCode = (nKeyCode & KEY_CODE); - std::map< sal_uInt16, rtl::OUString >::const_iterator it = aKeyMap.find( nUnmodifiedCode ); - if( it != aKeyMap.end() ) - { - if( (nKeyCode & KEY_SHIFT) != 0 ) - aResult.append( sal_Unicode( 0x21e7 ) ); - if( (nKeyCode & KEY_MOD1) != 0 ) - aResult.append( sal_Unicode( 0x2318 ) ); - // we do not really handle Alt (see below) - // we map it to MOD3, whichis actually Command - if( (nKeyCode & (KEY_MOD2|KEY_MOD3)) != 0 ) - aResult.append( sal_Unicode( 0x2303 ) ); - - aResult.append( it->second ); - } - - return aResult.makeStringAndClear(); -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::getResolution( long& o_rDPIX, long& o_rDPIY ) -{ - if( ! mpGraphics ) - { - GetGraphics(); - ReleaseGraphics( mpGraphics ); - } - mpGraphics->GetResolution( o_rDPIX, o_rDPIY ); -} - -void IosSalFrame::UpdateSettings( AllSettings& rSettings ) -{ - if ( !mpWindow ) - return; - - // #i113170# may not be the main thread if called from UNO API - SalData::ensureThreadAutoreleasePool(); - - StyleSettings aStyleSettings = rSettings.GetStyleSettings(); - - // Background Color - Color aBackgroundColor = Color( 0xEC, 0xEC, 0xEC ); - aStyleSettings.Set3DColors( aBackgroundColor ); - aStyleSettings.SetFaceColor( aBackgroundColor ); - Color aInactiveTabColor( aBackgroundColor ); - aInactiveTabColor.DecreaseLuminance( 32 ); - aStyleSettings.SetInactiveTabColor( aInactiveTabColor ); - - aStyleSettings.SetDialogColor( aBackgroundColor ); - aStyleSettings.SetLightBorderColor( aBackgroundColor ); - Color aShadowColor( aStyleSettings.GetShadowColor() ); - aShadowColor.IncreaseLuminance( 32 ); - aStyleSettings.SetShadowColor( aShadowColor ); - - // get the system font settings - Font aAppFont = aStyleSettings.GetAppFont(); - long nDPIX = 72, nDPIY = 72; - getResolution( nDPIX, nDPIY ); - - aStyleSettings.SetToolbarIconSize( nDPIY > 160 ? STYLE_TOOLBAR_ICONSIZE_LARGE : STYLE_TOOLBAR_ICONSIZE_SMALL ); - - aStyleSettings.SetCursorBlinkTime( 500 ); - - // no mnemonics on iOs - aStyleSettings.SetOptions( aStyleSettings.GetOptions() | STYLE_OPTION_NOMNEMONICS ); - - // images in menus false for iOS - aStyleSettings.SetPreferredUseImagesInMenus( false ); - aStyleSettings.SetHideDisabledMenuItems( sal_True ); - aStyleSettings.SetAcceleratorsInContextMenus( sal_False ); - - rSettings.SetStyleSettings( aStyleSettings ); -} - -// ----------------------------------------------------------------------- - -const SystemEnvData* IosSalFrame::GetSystemData() const -{ - return &maSysData; -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::SetPosSize(long /*nX*/, long /*nY*/, long /*nWidth*/, long /*nHeight*/, sal_uInt16 nFlags) -{ - if ( !mpWindow ) - return; - - // #i113170# may not be the main thread if called from UNO API - SalData::ensureThreadAutoreleasePool(); - - sal_uInt16 nEvent = 0; - - if (nFlags & (SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y)) - { - mbPositioned = true; - nEvent = SALEVENT_MOVE; - } - - if (nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT)) - { - mbSized = true; - nEvent = (nEvent == SALEVENT_MOVE) ? SALEVENT_MOVERESIZE : SALEVENT_RESIZE; - } - -#if 0 // ??? - CGRect aFrameRect = [mpWindow frame]; - CGRect aContentRect = [NSWindow contentRectForFrameRect: aFrameRect styleMask: mnStyleMask]; - - // position is always relative to parent frame - CGRect aParentContentRect; - - if( mpParent ) - { - if( Application::GetSettings().GetLayoutRTL() ) - { - if( (nFlags & SAL_FRAME_POSSIZE_WIDTH) != 0 ) - nX = mpParent->maGeometry.nWidth - nWidth-1 - nX; - else - nX = mpParent->maGeometry.nWidth - static_cast<long int>( aContentRect.size.width-1) - nX; - } - CGRect aParentFrameRect = [mpParent->mpWindow frame]; - aParentContentRect = [NSWindow contentRectForFrameRect: aParentFrameRect styleMask: mpParent->mnStyleMask]; - } - else - aParentContentRect = maScreenRect; // use screen if no parent - - CocoaTouchToVCL( aContentRect ); - CocoaTouchToVCL( aParentContentRect ); - - bool bPaint = false; - if( (nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT)) != 0 ) - { - if( nWidth != aContentRect.size.width || nHeight != aContentRect.size.height ) - bPaint = true; - } - - // use old window pos if no new pos requested - if( (nFlags & SAL_FRAME_POSSIZE_X) != 0 ) - aContentRect.origin.x = nX + aParentContentRect.origin.x; - if( (nFlags & SAL_FRAME_POSSIZE_Y) != 0) - aContentRect.origin.y = nY + aParentContentRect.origin.y; - - // use old size if no new size requested - if( (nFlags & SAL_FRAME_POSSIZE_WIDTH) != 0 ) - aContentRect.size.width = nWidth; - if( (nFlags & SAL_FRAME_POSSIZE_HEIGHT) != 0) - aContentRect.size.height = nHeight; - - VCLToCocoaTouch( aContentRect ); - - // do not display yet, we need to update our backbuffer - { - [mpWindow setFrame: [NSWindow frameRectForContentRect: aContentRect styleMask: mnStyleMask] display: NO]; - } - - UpdateFrameGeometry(); - - if (nEvent) - CallCallback(nEvent, NULL); - - if( mbShown && bPaint ) - { - // trigger filling our backbuffer - SendPaintEvent(); - - // now inform the system that the views need to be drawn - [mpWindow display]; - } -#endif -} - -void IosSalFrame::GetWorkArea( Rectangle& rRect ) -{ - if ( !mpWindow ) - return; - - // #i113170# may not be the main thread if called from UNO API - SalData::ensureThreadAutoreleasePool(); - - UIScreen* pScreen = [mpWindow screen]; - if( pScreen == nil ) - pScreen = [UIScreen mainScreen]; - CGRect aRect = [pScreen applicationFrame]; - CocoaTouchToVCL( aRect ); - rRect.Left() = static_cast<long>(aRect.origin.x); - rRect.Top() = static_cast<long>(aRect.origin.y); - rRect.Right() = static_cast<long>(aRect.origin.x + aRect.size.width - 1); - rRect.Bottom() = static_cast<long>(aRect.origin.y + aRect.size.height - 1); -} - -SalPointerState IosSalFrame::GetPointerState() -{ - // #i113170# may not be the main thread if called from UNO API - SalData::ensureThreadAutoreleasePool(); - - SalPointerState state; - state.mnState = 0; - - // ??? - - return state; -} - -SalFrame::SalIndicatorState IosSalFrame::GetIndicatorState() -{ - SalIndicatorState aState; - aState.mnState = 0; - return aState; -} - -void IosSalFrame::SimulateKeyPress( sal_uInt16 /*nKeyCode*/ ) -{ -} - -bool IosSalFrame::SetPluginParent( SystemParentData* ) -{ - // plugin parent may be killed unexpectedly by - // plugging process; - - //TODO: implement - return sal_False; -} - -sal_Bool IosSalFrame::MapUnicodeToKeyCode( sal_Unicode , LanguageType , KeyCode& ) -{ - // not supported yet - return FALSE; -} - -LanguageType IosSalFrame::GetInputLanguage() -{ - //TODO: implement - return LANGUAGE_DONTKNOW; -} - -void IosSalFrame::DrawMenuBar() -{ -} - -void IosSalFrame::SetMenu( SalMenu* /*pSalMenu*/ ) -{ - // #i113170# may not be the main thread if called from UNO API - SalData::ensureThreadAutoreleasePool(); - - // ??? -} - -void IosSalFrame::SetExtendedFrameStyle( SalExtStyle /*nStyle*/ ) -{ - // ??? -} - -SalFrame* IosSalFrame::GetParent() const -{ - return mpParent; -} - -void IosSalFrame::SetParent( SalFrame* pNewParent ) -{ - bool bShown = mbShown; - // remove from child list - Show( FALSE ); - mpParent = (IosSalFrame*)pNewParent; - // insert to correct parent and paint - Show( bShown ); -} - -void IosSalFrame::UpdateFrameGeometry() -{ - if ( !mpWindow ) - { - return; - } - - // keep in mind that view and window coordinates are lower left - // whereas vcl's are upper left - -#if 0 // ??? - // update screen rect - NSScreen * pScreen = [mpWindow screen]; - if( pScreen ) - { - maScreenRect = [pScreen frame]; - NSArray* pScreens = [NSScreen screens]; - if( pScreens ) - maGeometry.nDisplayScreenNumber = [pScreens indexOfObject: pScreen]; - } - - CGRect aFrameRect = [mpWindow frame]; - - CGRect aContentRect = [NSWindow contentRectForFrameRect: aFrameRect styleMask: mnStyleMask]; - - // release old track rect - [mpView removeTrackingRect: mnTrackingRectTag]; - // install the new track rect - CGRect aTrackRect = { { 0, 0 }, aContentRect.size }; - mnTrackingRectTag = [mpView addTrackingRect: aTrackRect owner: mpView userData: nil assumeInside: NO]; - - // convert to vcl convention - CocoaTouchToVCL( aFrameRect ); - CocoaTouchToVCL( aContentRect ); - - maGeometry.nX = static_cast<int>(aContentRect.origin.x); - maGeometry.nY = static_cast<int>(aContentRect.origin.y); - - maGeometry.nLeftDecoration = static_cast<unsigned int>(aContentRect.origin.x - aFrameRect.origin.x); - maGeometry.nRightDecoration = static_cast<unsigned int>((aFrameRect.origin.x + aFrameRect.size.width) - - (aContentRect.origin.x + aContentRect.size.width)); - - maGeometry.nTopDecoration = static_cast<unsigned int>(aContentRect.origin.y - aFrameRect.origin.y); - maGeometry.nBottomDecoration = static_cast<unsigned int>((aFrameRect.origin.y + aFrameRect.size.height) - - (aContentRect.origin.y + aContentRect.size.height)); - - maGeometry.nWidth = static_cast<unsigned int>(aContentRect.size.width); - maGeometry.nHeight = static_cast<unsigned int>(aContentRect.size.height); -#endif -} - -// ----------------------------------------------------------------------- - -void IosSalFrame::CaptureMouse( sal_Bool bCapture ) -{ - /* Remark: - we'll try to use a pidgin version of capture mouse - on MacOSX (neither carbon nor cocoa) there is a - CaptureMouse equivalent (in Carbon there is TrackMouseLocation - but this is useless to use since it is blocking) - - However on cocoa the active frame seems to get mouse events - also outside the window, so we'll try to forward mouse events - to the capture frame in the hope that one of our frames - gets a mouse event. - - This will break as soon as the user activates another app, but - a mouse click will normally lead to a release of the mouse anyway. - - Let's see how far we get this way. Alternatively we could use one - large overlay window like we did for the carbon implementation, - however that is resource intensive. - */ - - if( bCapture ) - s_pCaptureFrame = this; - else if( ! bCapture && s_pCaptureFrame == this ) - s_pCaptureFrame = NULL; -} - -void IosSalFrame::ResetClipRegion() -{ - if ( !mpWindow ) - { - return; - } - - // #i113170# may not be the main thread if called from UNO API - SalData::ensureThreadAutoreleasePool(); - - // release old path and indicate no clipping - CGPathRelease( mrClippingPath ); - mrClippingPath = NULL; - - if( mpWindow ) - { - [mpWindow setOpaque: YES]; - } -} - -void IosSalFrame::BeginSetClipRegion( sal_uLong nRects ) -{ - if ( !mpWindow ) - { - return; - } - - // #i113170# may not be the main thread if called from UNO API - SalData::ensureThreadAutoreleasePool(); - - // release old path - if( mrClippingPath ) - { - CGPathRelease( mrClippingPath ); - mrClippingPath = NULL; - } - - if( maClippingRects.size() > SAL_CLIPRECT_COUNT && nRects < maClippingRects.size() ) - { - std::vector<CGRect> aEmptyVec; - maClippingRects.swap( aEmptyVec ); - } - maClippingRects.clear(); - maClippingRects.reserve( nRects ); -} - -void IosSalFrame::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) -{ - // #i113170# may not be the main thread if called from UNO API - SalData::ensureThreadAutoreleasePool(); - - if( nWidth && nHeight ) - { - CGRect aRect = { { static_cast<CGFloat>(nX), static_cast<CGFloat>(nY) }, { static_cast<CGFloat>(nWidth), static_cast<CGFloat>(nHeight) } }; - VCLToCocoaTouch( aRect, false ); - maClippingRects.push_back( CGRectMake(aRect.origin.x, aRect.origin.y, aRect.size.width, aRect.size.height) ); - } -} - -void IosSalFrame::EndSetClipRegion() -{ - if ( !mpWindow ) - { - return; - } - - // #i113170# may not be the main thread if called from UNO API - SalData::ensureThreadAutoreleasePool(); - - if( ! maClippingRects.empty() ) - { - mrClippingPath = CGPathCreateMutable(); - CGPathAddRects( mrClippingPath, NULL, &maClippingRects[0], maClippingRects.size() ); - } - if( mpWindow ) - { - [mpWindow setOpaque: (mrClippingPath != NULL) ? NO : YES]; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/ios/source/window/salframeview.mm b/vcl/ios/source/window/salframeview.mm deleted file mode 100644 index 0ca3441fe814..000000000000 --- a/vcl/ios/source/window/salframeview.mm +++ /dev/null @@ -1,263 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <sal/alloca.h> -#include <sal/macros.h> - -#include "vcl/window.hxx" -#include "vcl/svapp.hxx" - -#include "ios/salinst.h" -#include "coretext/salgdi.h" -#include "ios/salframe.h" -#include "ios/salframeview.h" - -#define WHEEL_EVENT_FACTOR 1.5 - -@implementation SalFrameWindow --(id)initWithSalFrame: (IosSalFrame*)pFrame -{ - mpFrame = pFrame; -#if 0 - CGRect aRect = { { pFrame->maGeometry.nX, pFrame->maGeometry.nY }, - { pFrame->maGeometry.nWidth, pFrame->maGeometry.nHeight } }; - NSWindow* pNSWindow = [super initWithContentRect: aRect styleMask: mpFrame->getStyleMask() backing: NSBackingStoreBuffered defer: NO ]; - [pNSWindow useOptimizedDrawing: YES]; // OSX recommendation when there are no overlapping subviews within the receiver - return pNSWindow; -#endif - return nil; -} - --(IosSalFrame*)getSalFrame -{ - return mpFrame; -} - --(void)displayIfNeeded -{ - if( GetSalData() && GetSalData()->mpFirstInstance ) - { - osl::SolarMutex* pMutex = GetSalData()->mpFirstInstance->GetYieldMutex(); - if( pMutex ) - { - pMutex->acquire(); - // ??? [super displayIfNeeded]; - pMutex->release(); - } - } -} - --(BOOL)canBecomeKeyWindow -{ - if( (mpFrame->mnStyle & - ( SAL_FRAME_STYLE_FLOAT | - SAL_FRAME_STYLE_TOOLTIP | - SAL_FRAME_STYLE_INTRO - )) == 0 ) - return YES; - if( (mpFrame->mnStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) != 0 ) - return YES; - if( (mpFrame->mnStyle & SAL_FRAME_STYLE_FLOAT_FOCUSABLE) ) - return YES; - // ??? return [super canBecomeKeyWindow]; - return NO; -} - --(void)windowDidBecomeKey: (NSNotification*)pNotification -{ - (void)pNotification; - YIELD_GUARD; - - if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) - { -#if 0 - static const sal_uLong nGuessDocument = SAL_FRAME_STYLE_MOVEABLE| - SAL_FRAME_STYLE_SIZEABLE| - SAL_FRAME_STYLE_CLOSEABLE; -#endif - mpFrame->CallCallback( SALEVENT_GETFOCUS, 0 ); - mpFrame->SendPaintEvent(); // repaint controls as active - } -} - --(void)windowDidResignKey: (NSNotification*)pNotification -{ - (void)pNotification; - YIELD_GUARD; - - if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) - { - mpFrame->CallCallback(SALEVENT_LOSEFOCUS, 0); - mpFrame->SendPaintEvent(); // repaint controls as inactive - } -} - --(void)windowDidChangeScreen: (NSNotification*)pNotification -{ - (void)pNotification; - YIELD_GUARD; - - if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) - mpFrame->screenParametersChanged(); -} - --(void)windowDidMove: (NSNotification*)pNotification -{ - (void)pNotification; - YIELD_GUARD; - - if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) - { - mpFrame->UpdateFrameGeometry(); - mpFrame->CallCallback( SALEVENT_MOVE, 0 ); - } -} - --(void)windowDidResize: (NSNotification*)pNotification -{ - (void)pNotification; - YIELD_GUARD; - - if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) - { - mpFrame->UpdateFrameGeometry(); - mpFrame->CallCallback( SALEVENT_RESIZE, 0 ); - mpFrame->SendPaintEvent(); - } -} - --(void)windowDidMiniaturize: (NSNotification*)pNotification -{ - (void)pNotification; - YIELD_GUARD; - - if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) - { - mpFrame->mbShown = false; - mpFrame->UpdateFrameGeometry(); - mpFrame->CallCallback( SALEVENT_RESIZE, 0 ); - } -} - --(void)windowDidDeminiaturize: (NSNotification*)pNotification -{ - (void)pNotification; - YIELD_GUARD; - - if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) - { - mpFrame->mbShown = true; - mpFrame->UpdateFrameGeometry(); - mpFrame->CallCallback( SALEVENT_RESIZE, 0 ); - } -} - --(BOOL)windowShouldClose: (NSNotification*)pNotification -{ - (void)pNotification; - YIELD_GUARD; - - BOOL bRet = YES; - if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) - { - // #i84461# end possible input - mpFrame->CallCallback( SALEVENT_ENDEXTTEXTINPUT, 0 ); - if( IosSalFrame::isAlive( mpFrame ) ) - { - mpFrame->CallCallback( SALEVENT_CLOSE, 0 ); - bRet = NO; // application will close the window or not, AppKit shouldn't - } - } - - return bRet; -} - -@end - -@implementation SalFrameView - --(id)initWithSalFrame: (IosSalFrame*)pFrame -{ - // ??? - - (void) pFrame; - mfLastMagnifyTime = 0.0; - return self; -} - --(IosSalFrame*)getSalFrame -{ - return mpFrame; -} - --(BOOL)acceptsFirstResponder -{ - return YES; -} - --(BOOL)isOpaque -{ - return mpFrame ? (mpFrame->getClipPath() != 0 ? NO : YES) : YES; -} - -// helper class similar to a osl::SolarGuard for the SalYieldMutex -// the difference is that it only does tryToAcquire instead of aquire -// so dreaded deadlocks like #i93512# are prevented -class TryGuard -{ -public: - TryGuard() { mbGuarded = ImplSalYieldMutexTryToAcquire(); } - ~TryGuard() { if( mbGuarded ) ImplSalYieldMutexRelease(); } - bool IsGuarded() { return mbGuarded; } -private: - bool mbGuarded; -}; - --(void)drawRect: (CGRect)aRect -{ - // HOTFIX: #i93512# prevent deadlocks if any other thread already has the SalYieldMutex - TryGuard aTryGuard; - if( !aTryGuard.IsGuarded() ) - { - // NOTE: the mpFrame access below is not guarded yet! - // TODO: mpFrame et al need to be guarded by an independent mutex - QuartzSalGraphics* pGraphics = (mpFrame && IosSalFrame::isAlive(mpFrame)) ? mpFrame->mpGraphics : NULL; - if( pGraphics ) - { - pGraphics->RefreshRect( aRect ); - } - return; - } - - if( mpFrame && IosSalFrame::isAlive( mpFrame ) ) - { - if( mpFrame->mpGraphics ) - { - mpFrame->mpGraphics->UpdateWindow( aRect ); - if( mpFrame->getClipPath() ) { - // ??? [mpFrame->getWindow() invalidateShadow]; - } - } - } -} - -@end - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/ios/source/window/salmenu.cxx b/vcl/ios/source/window/salmenu.cxx deleted file mode 100644 index 50c262e25713..000000000000 --- a/vcl/ios/source/window/salmenu.cxx +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "rtl/ustrbuf.hxx" - -#include "vcl/cmdevt.hxx" -#include "vcl/floatwin.hxx" -#include "vcl/window.hxx" -#include "vcl/svapp.hxx" - -#include "ios/saldata.hxx" -#include "ios/salinst.h" -#include "ios/salmenu.h" -#include "ios/salframe.h" - -#include "svids.hrc" -#include "window.h" - -// ======================================================================= - -SalMenu* IosSalInstance::CreateMenu( sal_Bool /*bMenuBar*/, Menu* /*pVCLMenu*/ ) -{ - // ??? - return NULL; -} - -void IosSalInstance::DestroyMenu( SalMenu* pSalMenu ) -{ - delete pSalMenu; -} - -SalMenuItem* IosSalInstance::CreateMenuItem( const SalItemParams* /*pItemData*/ ) -{ - // ??? - return NULL; -} - -void IosSalInstance::DestroyMenuItem( SalMenuItem* pSalMenuItem ) -{ - delete pSalMenuItem; -} - - -// ======================================================================= - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/ios/source/window/salobj.cxx b/vcl/ios/source/window/salobj.cxx deleted file mode 100644 index 6543f4c26ed9..000000000000 --- a/vcl/ios/source/window/salobj.cxx +++ /dev/null @@ -1,201 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <string.h> - -#include "ios/saldata.hxx" -#include "ios/salobj.h" -#include "ios/salframe.h" - -// ======================================================================= - -IosSalObject::IosSalObject( IosSalFrame* pFrame ) : - mpFrame( pFrame ), - mnClipX( -1 ), - mnClipY( -1 ), - mnClipWidth( -1 ), - mnClipHeight( -1 ), - mbClip( false ), - mnX( 0 ), - mnY( 0 ), - mnWidth( 20 ), - mnHeight( 20 ) -{ - maSysData.nSize = sizeof( maSysData ); - maSysData.pView = NULL; - - CGRect aInitFrame = { { 0, 0 }, { 20, 20 } }; - maSysData.pView = [[UIView alloc] initWithFrame: aInitFrame]; -} - -// ----------------------------------------------------------------------- - -IosSalObject::~IosSalObject() -{ - if( maSysData.pView ) - { - UIView *pView = maSysData.pView; - [pView removeFromSuperview]; - [pView release]; - } -#if 0 // ??? - if( mpClipView ) - { - [mpClipView removeFromSuperview]; - [mpClipView release]; - } -#endif -} - -/* - sadly there seems to be no way to impose clipping on a child view, - especially a QTMovieView which seems to ignore the current context - completely. Also there is no real way to shape a window; on Ios a - similar effect to non-rectangular windows is achieved by using a - non-opaque window and not painting where one wants the background - to shine through. - - With respect to SalObject this leaves us to having an NSClipView - containing the child view. Even a QTMovieView respects the boundaries of - that, which gives us a clip "region" consisting of one rectangle. - This is gives us an 80% solution only, though. -*/ - -// ----------------------------------------------------------------------- - -void IosSalObject::ResetClipRegion() -{ - mbClip = false; - setClippedPosSize(); -} - -// ----------------------------------------------------------------------- - -sal_uInt16 IosSalObject::GetClipRegionType() -{ - return SAL_OBJECT_CLIP_INCLUDERECTS; -} - -// ----------------------------------------------------------------------- - -void IosSalObject::BeginSetClipRegion( sal_uLong ) -{ - mbClip = false; -} - -// ----------------------------------------------------------------------- - -void IosSalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) -{ - if( mbClip ) - { - if( nX < mnClipX ) - { - mnClipWidth += mnClipX - nX; - mnClipX = nX; - } - if( nX + nWidth > mnClipX + mnClipWidth ) - mnClipWidth = nX + nWidth - mnClipX; - if( nY < mnClipY ) - { - mnClipHeight += mnClipY - nY; - mnClipY = nY; - } - if( nY + nHeight > mnClipY + mnClipHeight ) - mnClipHeight = nY + nHeight - mnClipY; - } - else - { - mnClipX = nX; - mnClipY = nY; - mnClipWidth = nWidth; - mnClipHeight = nHeight; - mbClip = true; - } -} - -// ----------------------------------------------------------------------- - -void IosSalObject::EndSetClipRegion() -{ - setClippedPosSize(); -} - -// ----------------------------------------------------------------------- - -void IosSalObject::SetPosSize( long nX, long nY, long nWidth, long nHeight ) -{ - mnX = nX; - mnY = nY; - mnWidth = nWidth; - mnHeight = nHeight; - setClippedPosSize(); -} - -// ----------------------------------------------------------------------- - -void IosSalObject::setClippedPosSize() -{ - CGRect aViewRect = { { 0, 0 }, { static_cast<CGFloat>(mnWidth), static_cast<CGFloat>(mnHeight) } }; - if( maSysData.pView ) - { - UIView *pView = maSysData.pView; - [pView setFrame: aViewRect]; - } - - CGRect aClipViewRect = { { static_cast<CGFloat>(mnX), static_cast<CGFloat>(mnY) }, { static_cast<CGFloat>(mnWidth), static_cast<CGFloat>(mnHeight) } }; - CGPoint aClipPt = { 0, 0 }; - if( mbClip ) - { - aClipViewRect.origin.x += mnClipX; - aClipViewRect.origin.y += mnClipY; - aClipViewRect.size.width = mnClipWidth; - aClipViewRect.size.height = mnClipHeight; - aClipPt.x = mnClipX; - if( mnClipY == 0 ) - aClipPt.y = mnHeight - mnClipHeight; - } - - mpFrame->VCLToCocoaTouch( aClipViewRect, false ); -#if 0 // ??? - [mpClipView setFrame: aClipViewRect]; - - [mpClipView scrollToPoint: aClipPt]; -#endif -} - -// ----------------------------------------------------------------------- - -void IosSalObject::Show( sal_Bool /*bVisible*/ ) -{ -#if 0 // ??? - if( mpClipView ) - [mpClipView setHidden: (bVisible ? NO : YES)]; -#endif -} - -// ----------------------------------------------------------------------- - -const SystemEnvData* IosSalObject::GetSystemData() const -{ - return &maSysData; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |