update dev300-m58
[ooovba.git] / avmedia / source / quicktime / window.cxx
blob9fff6d77ff5e0b7d09d56c1c586f3c2aa661805d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: window.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <com/sun/star/awt/SystemPointer.hpp>
32 #include <com/sun/star/awt/PosSize.hpp>
34 #include "window.hxx"
35 #include "player.hxx"
37 using namespace ::com::sun::star;
39 namespace avmedia { namespace quicktime {
41 // -----------
42 // - statics -
43 // -----------
45 static ::osl::Mutex& ImplGetOwnStaticMutex()
47 static ::osl::Mutex* pMutex = NULL;
49 if( pMutex == NULL )
51 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
53 if( pMutex == NULL )
55 static ::osl::Mutex aMutex;
56 pMutex = &aMutex;
60 return *pMutex;
63 // ---------------
64 // - Window -
65 // ---------------
67 // ------------------------------------------------------------------------------
69 Window::Window( const uno::Reference< lang::XMultiServiceFactory >& i_rxMgr, Player& i_rPlayer, NSView* i_pParentView ) :
70 mxMgr( i_rxMgr ),
71 maListeners( maMutex ),
72 meZoomLevel( media::ZoomLevel_NOT_AVAILABLE ),
73 mrPlayer( i_rPlayer ),
74 mnPointerType( awt::SystemPointer::ARROW ),
75 mpParentView( i_pParentView ),
76 mpMovieView( nil )
79 ::osl::MutexGuard aGuard( ImplGetOwnStaticMutex() );
82 if( mpParentView ) // sanity check
85 NSRect aViewRect = [mpParentView frame];
86 aViewRect.origin.x = aViewRect.origin.y = 0;
87 mpMovieView = [[QTMovieView alloc] initWithFrame: aViewRect];
88 [mpMovieView setMovie: mrPlayer.getMovie() ];
89 [mpMovieView setControllerVisible: NO];
90 [mpMovieView setPreservesAspectRatio: YES];
91 [mpMovieView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
92 [mpParentView addSubview: mpMovieView];
93 [mpParentView setAutoresizesSubviews: YES];
96 OSL_TRACE ("Window::Window");
99 // ------------------------------------------------------------------------------
101 Window::~Window()
103 if( mpMovieView )
105 [mpMovieView removeFromSuperview];
106 [mpMovieView setMovie:nil];
107 [mpMovieView release];
108 mpMovieView = nil;
112 bool Window::create( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
114 return true;
117 // XPlayerWindow
118 // ------------------------------------------------------------------------------
120 void SAL_CALL Window::update( )
121 throw (uno::RuntimeException)
126 // ------------------------------------------------------------------------------
128 sal_Bool SAL_CALL Window::setZoomLevel( media::ZoomLevel eZoomLevel )
129 throw (uno::RuntimeException)
131 return false;
134 // ------------------------------------------------------------------------------
136 media::ZoomLevel SAL_CALL Window::getZoomLevel( )
137 throw (uno::RuntimeException)
139 return meZoomLevel;
142 // ------------------------------------------------------------------------------
144 void SAL_CALL Window::setPointerType( sal_Int32 nPointerType )
145 throw (uno::RuntimeException)
147 mnPointerType = nPointerType;
150 // XWindow
151 // ------------------------------------------------------------------------------
153 void SAL_CALL Window::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags )
154 throw (uno::RuntimeException)
156 if( mpParentView && mpMovieView )
158 NSRect aRect = [mpMovieView frame];
159 if( (Flags & awt::PosSize::WIDTH) )
160 aRect.size.width = Width;
161 if( (Flags & awt::PosSize::HEIGHT) )
162 aRect.size.height = Height;
166 // ------------------------------------------------------------------------------
168 awt::Rectangle SAL_CALL Window::getPosSize()
169 throw (uno::RuntimeException)
171 awt::Rectangle aRet;
173 NSRect aRect = [mpMovieView frame];
174 aRet.X = aRet.Y = 0;
175 aRet.Width = aRect.size.width;
176 aRet.Height = aRect.size.height;
178 return aRet;
181 // ------------------------------------------------------------------------------
183 void SAL_CALL Window::setVisible( sal_Bool bVisible )
184 throw (uno::RuntimeException)
186 OSL_TRACE ("Window::setVisible");
190 // ------------------------------------------------------------------------------
192 void SAL_CALL Window::setEnable( sal_Bool bEnable )
193 throw (uno::RuntimeException)
198 // ------------------------------------------------------------------------------
200 void SAL_CALL Window::setFocus( )
201 throw (uno::RuntimeException)
203 OSL_TRACE ("Window::setFocus");
206 // ------------------------------------------------------------------------------
208 void SAL_CALL Window::addWindowListener( const uno::Reference< awt::XWindowListener >& xListener )
209 throw (uno::RuntimeException)
211 maListeners.addInterface( getCppuType( &xListener ), xListener );
214 // ------------------------------------------------------------------------------
216 void SAL_CALL Window::removeWindowListener( const uno::Reference< awt::XWindowListener >& xListener )
217 throw (uno::RuntimeException)
219 maListeners.removeInterface( getCppuType( &xListener ), xListener );
222 // ------------------------------------------------------------------------------
224 void SAL_CALL Window::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener )
225 throw (uno::RuntimeException)
227 maListeners.addInterface( getCppuType( &xListener ), xListener );
230 // ------------------------------------------------------------------------------
232 void SAL_CALL Window::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener )
233 throw (uno::RuntimeException)
235 maListeners.removeInterface( getCppuType( &xListener ), xListener );
238 // ------------------------------------------------------------------------------
240 void SAL_CALL Window::addKeyListener( const uno::Reference< awt::XKeyListener >& xListener )
241 throw (uno::RuntimeException)
243 maListeners.addInterface( getCppuType( &xListener ), xListener );
246 // ------------------------------------------------------------------------------
248 void SAL_CALL Window::removeKeyListener( const uno::Reference< awt::XKeyListener >& xListener )
249 throw (uno::RuntimeException)
251 maListeners.removeInterface( getCppuType( &xListener ), xListener );
254 // ------------------------------------------------------------------------------
256 void SAL_CALL Window::addMouseListener( const uno::Reference< awt::XMouseListener >& xListener )
257 throw (uno::RuntimeException)
259 maListeners.addInterface( getCppuType( &xListener ), xListener );
262 // ------------------------------------------------------------------------------
264 void SAL_CALL Window::removeMouseListener( const uno::Reference< awt::XMouseListener >& xListener )
265 throw (uno::RuntimeException)
267 maListeners.removeInterface( getCppuType( &xListener ), xListener );
270 // ------------------------------------------------------------------------------
272 void SAL_CALL Window::addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener )
273 throw (uno::RuntimeException)
275 maListeners.addInterface( getCppuType( &xListener ), xListener );
278 // ------------------------------------------------------------------------------
280 void SAL_CALL Window::removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener )
281 throw (uno::RuntimeException)
283 maListeners.removeInterface( getCppuType( &xListener ), xListener );
286 // ------------------------------------------------------------------------------
288 void SAL_CALL Window::addPaintListener( const uno::Reference< awt::XPaintListener >& xListener )
289 throw (uno::RuntimeException)
291 maListeners.addInterface( getCppuType( &xListener ), xListener );
294 // ------------------------------------------------------------------------------
296 void SAL_CALL Window::removePaintListener( const uno::Reference< awt::XPaintListener >& xListener )
297 throw (uno::RuntimeException)
299 maListeners.removeInterface( getCppuType( &xListener ), xListener );
303 // XComponent
304 // ------------------------------------------------------------------------------
306 void SAL_CALL Window::dispose( )
307 throw (uno::RuntimeException)
311 // ------------------------------------------------------------------------------
313 void SAL_CALL Window::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
314 throw (uno::RuntimeException)
316 maListeners.addInterface( getCppuType( &xListener ), xListener );
319 // ------------------------------------------------------------------------------
321 void SAL_CALL Window::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
322 throw (uno::RuntimeException)
324 maListeners.removeInterface( getCppuType( &xListener ), xListener );
327 // XServiceInfo
328 // ------------------------------------------------------------------------------
330 ::rtl::OUString SAL_CALL Window::getImplementationName( )
331 throw (uno::RuntimeException)
333 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_QUICKTIME_WINDOW_IMPLEMENTATIONNAME ) );
336 // ------------------------------------------------------------------------------
338 sal_Bool SAL_CALL Window::supportsService( const ::rtl::OUString& ServiceName )
339 throw (uno::RuntimeException)
341 return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_QUICKTIME_WINDOW_SERVICENAME ) );
344 // ------------------------------------------------------------------------------
346 uno::Sequence< ::rtl::OUString > SAL_CALL Window::getSupportedServiceNames( )
347 throw (uno::RuntimeException)
349 uno::Sequence< ::rtl::OUString > aRet(1);
350 aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_QUICKTIME_WINDOW_SERVICENAME ) );
352 return aRet;
355 } // namespace quicktime
356 } // namespace avmedia