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 .
20 #include <com/sun/star/awt/SystemPointer.hpp>
21 #include <com/sun/star/awt/PosSize.hpp>
26 using namespace ::com::sun::star;
28 namespace avmedia { namespace quicktime {
30 static ::osl::Mutex& ImplGetOwnStaticMutex()
32 static ::osl::Mutex* pMutex = NULL;
36 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
40 static ::osl::Mutex aMutex;
48 Window::Window( const uno::Reference< lang::XMultiServiceFactory >& i_rxMgr, Player& i_rPlayer, NSView* i_pParentView ) :
50 maListeners( maMutex ),
51 meZoomLevel( media::ZoomLevel_NOT_AVAILABLE ),
52 mrPlayer( i_rPlayer ),
53 mnPointerType( awt::SystemPointer::ARROW ),
54 mpParentView( i_pParentView ),
58 ::osl::MutexGuard aGuard( ImplGetOwnStaticMutex() );
60 if( mpParentView ) // sanity check
63 NSRect aViewRect = [mpParentView frame];
64 aViewRect.origin.x = aViewRect.origin.y = 0;
65 mpMovieView = [[QTMovieView alloc] initWithFrame: aViewRect];
66 [mpMovieView setMovie: mrPlayer.getMovie() ];
67 [mpMovieView setControllerVisible: NO];
68 [mpMovieView setPreservesAspectRatio: YES];
69 [mpMovieView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
70 [mpParentView addSubview: mpMovieView];
71 [mpParentView setAutoresizesSubviews: YES];
74 OSL_TRACE ("Window::Window");
81 [mpMovieView removeFromSuperview];
82 [mpMovieView setMovie:nil];
83 [mpMovieView release];
88 bool Window::create( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& )
95 void SAL_CALL Window::update( )
96 throw (uno::RuntimeException)
101 sal_Bool SAL_CALL Window::setZoomLevel( media::ZoomLevel )
102 throw (uno::RuntimeException)
107 media::ZoomLevel SAL_CALL Window::getZoomLevel( )
108 throw (uno::RuntimeException)
113 void SAL_CALL Window::setPointerType( sal_Int32 nPointerType )
114 throw (uno::RuntimeException)
116 mnPointerType = nPointerType;
121 void SAL_CALL Window::setPosSize( sal_Int32 , sal_Int32 , sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags )
122 throw (uno::RuntimeException)
124 if( mpParentView && mpMovieView )
126 NSRect aRect = [mpMovieView frame];
127 if( (Flags & awt::PosSize::WIDTH) )
128 aRect.size.width = Width;
129 if( (Flags & awt::PosSize::HEIGHT) )
130 aRect.size.height = Height;
134 awt::Rectangle SAL_CALL Window::getPosSize()
135 throw (uno::RuntimeException)
139 NSRect aRect = [mpMovieView frame];
141 aRet.Width = aRect.size.width;
142 aRet.Height = aRect.size.height;
147 void SAL_CALL Window::setVisible( sal_Bool )
148 throw (uno::RuntimeException)
150 OSL_TRACE ("Window::setVisible");
154 void SAL_CALL Window::setEnable( sal_Bool )
155 throw (uno::RuntimeException)
160 void SAL_CALL Window::setFocus( )
161 throw (uno::RuntimeException)
163 OSL_TRACE ("Window::setFocus");
166 void SAL_CALL Window::addWindowListener( const uno::Reference< awt::XWindowListener >& xListener )
167 throw (uno::RuntimeException)
169 maListeners.addInterface( getCppuType( &xListener ), xListener );
172 void SAL_CALL Window::removeWindowListener( const uno::Reference< awt::XWindowListener >& xListener )
173 throw (uno::RuntimeException)
175 maListeners.removeInterface( getCppuType( &xListener ), xListener );
178 void SAL_CALL Window::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener )
179 throw (uno::RuntimeException)
181 maListeners.addInterface( getCppuType( &xListener ), xListener );
184 void SAL_CALL Window::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener )
185 throw (uno::RuntimeException)
187 maListeners.removeInterface( getCppuType( &xListener ), xListener );
190 void SAL_CALL Window::addKeyListener( const uno::Reference< awt::XKeyListener >& xListener )
191 throw (uno::RuntimeException)
193 maListeners.addInterface( getCppuType( &xListener ), xListener );
196 void SAL_CALL Window::removeKeyListener( const uno::Reference< awt::XKeyListener >& xListener )
197 throw (uno::RuntimeException)
199 maListeners.removeInterface( getCppuType( &xListener ), xListener );
202 void SAL_CALL Window::addMouseListener( const uno::Reference< awt::XMouseListener >& xListener )
203 throw (uno::RuntimeException)
205 maListeners.addInterface( getCppuType( &xListener ), xListener );
208 void SAL_CALL Window::removeMouseListener( const uno::Reference< awt::XMouseListener >& xListener )
209 throw (uno::RuntimeException)
211 maListeners.removeInterface( getCppuType( &xListener ), xListener );
214 void SAL_CALL Window::addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener )
215 throw (uno::RuntimeException)
217 maListeners.addInterface( getCppuType( &xListener ), xListener );
220 void SAL_CALL Window::removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener )
221 throw (uno::RuntimeException)
223 maListeners.removeInterface( getCppuType( &xListener ), xListener );
226 void SAL_CALL Window::addPaintListener( const uno::Reference< awt::XPaintListener >& xListener )
227 throw (uno::RuntimeException)
229 maListeners.addInterface( getCppuType( &xListener ), xListener );
232 void SAL_CALL Window::removePaintListener( const uno::Reference< awt::XPaintListener >& xListener )
233 throw (uno::RuntimeException)
235 maListeners.removeInterface( getCppuType( &xListener ), xListener );
240 void SAL_CALL Window::dispose( )
241 throw (uno::RuntimeException)
245 void SAL_CALL Window::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
246 throw (uno::RuntimeException)
248 maListeners.addInterface( getCppuType( &xListener ), xListener );
251 void SAL_CALL Window::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
252 throw (uno::RuntimeException)
254 maListeners.removeInterface( getCppuType( &xListener ), xListener );
259 ::rtl::OUString SAL_CALL Window::getImplementationName( )
260 throw (uno::RuntimeException)
262 return ::rtl::OUString( AVMEDIA_QUICKTIME_WINDOW_IMPLEMENTATIONNAME );
265 sal_Bool SAL_CALL Window::supportsService( const ::rtl::OUString& ServiceName )
266 throw (uno::RuntimeException)
268 return ( ServiceName == AVMEDIA_QUICKTIME_WINDOW_SERVICENAME );
271 uno::Sequence< ::rtl::OUString > SAL_CALL Window::getSupportedServiceNames( )
272 throw (uno::RuntimeException)
274 uno::Sequence< ::rtl::OUString > aRet(1);
275 aRet[0] = ::rtl::OUString( AVMEDIA_QUICKTIME_WINDOW_SERVICENAME );
280 } // namespace quicktime
281 } // namespace avmedia
283 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */