1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
9 * last change: $Author$ $Date$
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 ************************************************************************/
36 #include <com/sun/star/awt/SystemPointer.hdl>
38 #include "gstwindow.hxx"
39 #include "gstplayer.hxx"
41 #define AVMEDIA_GST_WINDOW_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Window_GStreamer"
42 #define AVMEDIA_GST_WINDOW_SERVICENAME "com.sun.star.media.Window_GStreamer"
44 using namespace ::com::sun::star
;
46 namespace avmedia
{ namespace gstreamer
{
52 static ::osl::Mutex
& ImplGetOwnStaticMutex()
54 static ::osl::Mutex
* pMutex
= NULL
;
58 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
62 static ::osl::Mutex aMutex
;
74 // ------------------------------------------------------------------------------
76 Window::Window( const uno::Reference
< lang::XMultiServiceFactory
>& rxMgr
, Player
& rPlayer
) :
78 maListeners( maMutex
),
79 meZoomLevel( media::ZoomLevel_NOT_AVAILABLE
),
81 mnPointerType( awt::SystemPointer::ARROW
)
83 ::osl::MutexGuard
aGuard( ImplGetOwnStaticMutex() );
87 // ------------------------------------------------------------------------------
94 // ------------------------------------------------------------------------------
96 void SAL_CALL
Window::update( )
97 throw (uno::RuntimeException
)
99 //::RedrawWindow( (HWND) mnFrameWnd, NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE );
102 // ------------------------------------------------------------------------------
104 sal_Bool SAL_CALL
Window::setZoomLevel( media::ZoomLevel eZoomLevel
)
105 throw (uno::RuntimeException
)
107 sal_Bool bRet
= false;
109 if( media::ZoomLevel_NOT_AVAILABLE
!= meZoomLevel
&&
110 media::ZoomLevel_NOT_AVAILABLE
!= eZoomLevel
)
112 if( eZoomLevel
!= meZoomLevel
)
114 meZoomLevel
= eZoomLevel
;
115 //ImplLayoutVideoWindow();
124 // ------------------------------------------------------------------------------
126 media::ZoomLevel SAL_CALL
Window::getZoomLevel( )
127 throw (uno::RuntimeException
)
132 // ------------------------------------------------------------------------------
134 void SAL_CALL
Window::setPointerType( sal_Int32 nPointerType
)
135 throw (uno::RuntimeException
)
137 mnPointerType
= nPointerType
;
141 // ------------------------------------------------------------------------------
143 void SAL_CALL
Window::setPosSize( sal_Int32 X
, sal_Int32 Y
, sal_Int32 Width
, sal_Int32 Height
, sal_Int16 Flags
)
144 throw (uno::RuntimeException
)
148 // ::SetWindowPos( (HWND) mnFrameWnd, HWND_TOP, X, Y, Width, Height, 0 );
149 // ImplLayoutVideoWindow();
153 // ------------------------------------------------------------------------------
155 awt::Rectangle SAL_CALL
Window::getPosSize()
156 throw (uno::RuntimeException
)
167 // long nX = 0, nY = 0, nWidth = 0, nHeight = 0;
169 // if( ::GetClientRect( (HWND) mnFrameWnd, &aWndRect ) )
171 // aRet.X = aWndRect.left;
172 // aRet.Y = aWndRect.top;
173 // aRet.Width = aWndRect.right - aWndRect.left + 1;
174 // aRet.Height = aWndRect.bottom - aWndRect.top + 1;
181 // ------------------------------------------------------------------------------
183 void SAL_CALL
Window::setVisible( sal_Bool bVisible
)
184 throw (uno::RuntimeException
)
188 // IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() );
190 // if( pVideoWindow )
191 // pVideoWindow->put_Visible( bVisible ? OATRUE : OAFALSE );
193 // ::ShowWindow( (HWND) mnFrameWnd, bVisible ? SW_SHOW : SW_HIDE );
197 // ------------------------------------------------------------------------------
199 void SAL_CALL
Window::setEnable( sal_Bool bEnable
)
200 throw (uno::RuntimeException
)
203 // ::EnableWindow( (HWND) mnFrameWnd, bEnable );
206 // ------------------------------------------------------------------------------
208 void SAL_CALL
Window::setFocus( )
209 throw (uno::RuntimeException
)
212 // ::SetFocus( (HWND) mnFrameWnd );
215 // ------------------------------------------------------------------------------
217 void SAL_CALL
Window::addWindowListener( const uno::Reference
< awt::XWindowListener
>& xListener
)
218 throw (uno::RuntimeException
)
220 maListeners
.addInterface( getCppuType( &xListener
), xListener
);
223 // ------------------------------------------------------------------------------
225 void SAL_CALL
Window::removeWindowListener( const uno::Reference
< awt::XWindowListener
>& xListener
)
226 throw (uno::RuntimeException
)
228 maListeners
.removeInterface( getCppuType( &xListener
), xListener
);
231 // ------------------------------------------------------------------------------
233 void SAL_CALL
Window::addFocusListener( const uno::Reference
< awt::XFocusListener
>& xListener
)
234 throw (uno::RuntimeException
)
236 maListeners
.addInterface( getCppuType( &xListener
), xListener
);
239 // ------------------------------------------------------------------------------
241 void SAL_CALL
Window::removeFocusListener( const uno::Reference
< awt::XFocusListener
>& xListener
)
242 throw (uno::RuntimeException
)
244 maListeners
.removeInterface( getCppuType( &xListener
), xListener
);
247 // ------------------------------------------------------------------------------
249 void SAL_CALL
Window::addKeyListener( const uno::Reference
< awt::XKeyListener
>& xListener
)
250 throw (uno::RuntimeException
)
252 maListeners
.addInterface( getCppuType( &xListener
), xListener
);
255 // ------------------------------------------------------------------------------
257 void SAL_CALL
Window::removeKeyListener( const uno::Reference
< awt::XKeyListener
>& xListener
)
258 throw (uno::RuntimeException
)
260 maListeners
.removeInterface( getCppuType( &xListener
), xListener
);
263 // ------------------------------------------------------------------------------
265 void SAL_CALL
Window::addMouseListener( const uno::Reference
< awt::XMouseListener
>& xListener
)
266 throw (uno::RuntimeException
)
268 maListeners
.addInterface( getCppuType( &xListener
), xListener
);
271 // ------------------------------------------------------------------------------
273 void SAL_CALL
Window::removeMouseListener( const uno::Reference
< awt::XMouseListener
>& xListener
)
274 throw (uno::RuntimeException
)
276 maListeners
.removeInterface( getCppuType( &xListener
), xListener
);
279 // ------------------------------------------------------------------------------
281 void SAL_CALL
Window::addMouseMotionListener( const uno::Reference
< awt::XMouseMotionListener
>& xListener
)
282 throw (uno::RuntimeException
)
284 maListeners
.addInterface( getCppuType( &xListener
), xListener
);
287 // ------------------------------------------------------------------------------
289 void SAL_CALL
Window::removeMouseMotionListener( const uno::Reference
< awt::XMouseMotionListener
>& xListener
)
290 throw (uno::RuntimeException
)
292 maListeners
.removeInterface( getCppuType( &xListener
), xListener
);
295 // ------------------------------------------------------------------------------
297 void SAL_CALL
Window::addPaintListener( const uno::Reference
< awt::XPaintListener
>& xListener
)
298 throw (uno::RuntimeException
)
300 maListeners
.addInterface( getCppuType( &xListener
), xListener
);
303 // ------------------------------------------------------------------------------
305 void SAL_CALL
Window::removePaintListener( const uno::Reference
< awt::XPaintListener
>& xListener
)
306 throw (uno::RuntimeException
)
308 maListeners
.removeInterface( getCppuType( &xListener
), xListener
);
313 // ------------------------------------------------------------------------------
315 void SAL_CALL
Window::dispose( )
316 throw (uno::RuntimeException
)
320 // ------------------------------------------------------------------------------
322 void SAL_CALL
Window::addEventListener( const uno::Reference
< lang::XEventListener
>& xListener
)
323 throw (uno::RuntimeException
)
325 maListeners
.addInterface( getCppuType( &xListener
), xListener
);
328 // ------------------------------------------------------------------------------
330 void SAL_CALL
Window::removeEventListener( const uno::Reference
< lang::XEventListener
>& xListener
)
331 throw (uno::RuntimeException
)
333 maListeners
.removeInterface( getCppuType( &xListener
), xListener
);
337 // ------------------------------------------------------------------------------
339 ::rtl::OUString SAL_CALL
Window::getImplementationName( )
340 throw (uno::RuntimeException
)
342 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_GST_WINDOW_IMPLEMENTATIONNAME
) );
345 // ------------------------------------------------------------------------------
347 sal_Bool SAL_CALL
Window::supportsService( const ::rtl::OUString
& ServiceName
)
348 throw (uno::RuntimeException
)
350 return ServiceName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_GST_WINDOW_SERVICENAME
) );
353 // ------------------------------------------------------------------------------
355 uno::Sequence
< ::rtl::OUString
> SAL_CALL
Window::getSupportedServiceNames( )
356 throw (uno::RuntimeException
)
358 uno::Sequence
< ::rtl::OUString
> aRet(1);
359 aRet
[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_GST_WINDOW_SERVICENAME
) );
364 } // namespace gstreamer
365 } // namespace avmedia