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 SAL_WNODEPRECATED_DECLARATIONS_PUSH //TODO: 10.9
30 namespace avmedia { namespace quicktime {
32 static ::osl::Mutex& ImplGetOwnStaticMutex()
34 static ::osl::Mutex* pMutex = NULL;
38 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
42 static ::osl::Mutex aMutex;
50 Window::Window( const uno::Reference< lang::XMultiServiceFactory >& i_rxMgr, Player& i_rPlayer, NSView* i_pParentView ) :
52 maListeners( maMutex ),
53 meZoomLevel( media::ZoomLevel_NOT_AVAILABLE ),
54 mrPlayer( i_rPlayer ),
55 mnPointerType( awt::SystemPointer::ARROW ),
56 mpParentView( i_pParentView ),
60 ::osl::MutexGuard aGuard( ImplGetOwnStaticMutex() );
62 if( mpParentView ) // sanity check
65 NSRect aViewRect = [mpParentView frame];
66 aViewRect.origin.x = aViewRect.origin.y = 0;
67 mpMovieView = [[QTMovieView alloc] initWithFrame: aViewRect];
68 [mpMovieView setMovie: mrPlayer.getMovie() ];
69 [mpMovieView setControllerVisible: NO];
70 [mpMovieView setPreservesAspectRatio: YES];
71 [mpMovieView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
72 [mpParentView addSubview: mpMovieView];
73 [mpParentView setAutoresizesSubviews: YES];
76 OSL_TRACE ("Window::Window");
83 [mpMovieView removeFromSuperview];
84 [mpMovieView setMovie:nil];
85 [mpMovieView release];
92 void SAL_CALL Window::update( )
93 throw (uno::RuntimeException)
98 sal_Bool SAL_CALL Window::setZoomLevel( media::ZoomLevel )
99 throw (uno::RuntimeException)
104 media::ZoomLevel SAL_CALL Window::getZoomLevel( )
105 throw (uno::RuntimeException)
110 void SAL_CALL Window::setPointerType( sal_Int32 nPointerType )
111 throw (uno::RuntimeException)
113 mnPointerType = nPointerType;
118 void SAL_CALL Window::setPosSize( sal_Int32 , sal_Int32 , sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags )
119 throw (uno::RuntimeException)
121 if( mpParentView && mpMovieView )
123 NSRect aRect = [mpMovieView frame];
124 if( (Flags & awt::PosSize::WIDTH) )
125 aRect.size.width = Width;
126 if( (Flags & awt::PosSize::HEIGHT) )
127 aRect.size.height = Height;
131 awt::Rectangle SAL_CALL Window::getPosSize()
132 throw (uno::RuntimeException)
136 NSRect aRect = [mpMovieView frame];
138 aRet.Width = aRect.size.width;
139 aRet.Height = aRect.size.height;
144 void SAL_CALL Window::setVisible( sal_Bool )
145 throw (uno::RuntimeException)
147 OSL_TRACE ("Window::setVisible");
151 void SAL_CALL Window::setEnable( sal_Bool )
152 throw (uno::RuntimeException)
157 void SAL_CALL Window::setFocus( )
158 throw (uno::RuntimeException)
160 OSL_TRACE ("Window::setFocus");
163 void SAL_CALL Window::addWindowListener( const uno::Reference< awt::XWindowListener >& xListener )
164 throw (uno::RuntimeException)
166 maListeners.addInterface( cppu::UnoType<decltype(xListener)>::get(), xListener );
169 void SAL_CALL Window::removeWindowListener( const uno::Reference< awt::XWindowListener >& xListener )
170 throw (uno::RuntimeException)
172 maListeners.removeInterface( cppu::UnoType<decltype(xListener)>::get(), xListener );
175 void SAL_CALL Window::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener )
176 throw (uno::RuntimeException)
178 maListeners.addInterface( cppu::UnoType<decltype(xListener)>::get(), xListener );
181 void SAL_CALL Window::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener )
182 throw (uno::RuntimeException)
184 maListeners.removeInterface( cppu::UnoType<decltype(xListener)>::get(), xListener );
187 void SAL_CALL Window::addKeyListener( const uno::Reference< awt::XKeyListener >& xListener )
188 throw (uno::RuntimeException)
190 maListeners.addInterface( cppu::UnoType<decltype(xListener)>::get(), xListener );
193 void SAL_CALL Window::removeKeyListener( const uno::Reference< awt::XKeyListener >& xListener )
194 throw (uno::RuntimeException)
196 maListeners.removeInterface( cppu::UnoType<decltype(xListener)>::get(), xListener );
199 void SAL_CALL Window::addMouseListener( const uno::Reference< awt::XMouseListener >& xListener )
200 throw (uno::RuntimeException)
202 maListeners.addInterface( cppu::UnoType<decltype(xListener)>::get(), xListener );
205 void SAL_CALL Window::removeMouseListener( const uno::Reference< awt::XMouseListener >& xListener )
206 throw (uno::RuntimeException)
208 maListeners.removeInterface( cppu::UnoType<decltype(xListener)>::get(), xListener );
211 void SAL_CALL Window::addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener )
212 throw (uno::RuntimeException)
214 maListeners.addInterface( cppu::UnoType<decltype(xListener)>::get(), xListener );
217 void SAL_CALL Window::removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener )
218 throw (uno::RuntimeException)
220 maListeners.removeInterface( cppu::UnoType<decltype(xListener)>::get(), xListener );
223 void SAL_CALL Window::addPaintListener( const uno::Reference< awt::XPaintListener >& xListener )
224 throw (uno::RuntimeException)
226 maListeners.addInterface( cppu::UnoType<decltype(xListener)>::get(), xListener );
229 void SAL_CALL Window::removePaintListener( const uno::Reference< awt::XPaintListener >& xListener )
230 throw (uno::RuntimeException)
232 maListeners.removeInterface( cppu::UnoType<decltype(xListener)>::get(), xListener );
237 void SAL_CALL Window::dispose( )
238 throw (uno::RuntimeException)
242 void SAL_CALL Window::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
243 throw (uno::RuntimeException)
245 maListeners.addInterface( cppu::UnoType<decltype(xListener)>::get(), xListener );
248 void SAL_CALL Window::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
249 throw (uno::RuntimeException)
251 maListeners.removeInterface( cppu::UnoType<decltype(xListener)>::get(), xListener );
256 ::rtl::OUString SAL_CALL Window::getImplementationName( )
257 throw (uno::RuntimeException)
259 return ::rtl::OUString( AVMEDIA_QUICKTIME_WINDOW_IMPLEMENTATIONNAME );
262 sal_Bool SAL_CALL Window::supportsService( const ::rtl::OUString& ServiceName )
263 throw (uno::RuntimeException)
265 return ( ServiceName == AVMEDIA_QUICKTIME_WINDOW_SERVICENAME );
268 uno::Sequence< ::rtl::OUString > SAL_CALL Window::getSupportedServiceNames( )
269 throw (uno::RuntimeException)
271 uno::Sequence< ::rtl::OUString > aRet(1);
272 aRet[0] = AVMEDIA_QUICKTIME_WINDOW_SERVICENAME;
277 } // namespace quicktime
278 } // namespace avmedia
280 SAL_WNODEPRECATED_DECLARATIONS_POP
282 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */