1*f39251c4SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f39251c4SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f39251c4SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f39251c4SAndrew Rist * distributed with this work for additional information 6*f39251c4SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f39251c4SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f39251c4SAndrew Rist * "License"); you may not use this file except in compliance 9*f39251c4SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*f39251c4SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*f39251c4SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f39251c4SAndrew Rist * software distributed under the License is distributed on an 15*f39251c4SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f39251c4SAndrew Rist * KIND, either express or implied. See the License for the 17*f39251c4SAndrew Rist * specific language governing permissions and limitations 18*f39251c4SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*f39251c4SAndrew Rist *************************************************************/ 21*f39251c4SAndrew Rist 22*f39251c4SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include <tools/prewin.h> 25cdf0e10cSrcweir #if defined _MSC_VER 26cdf0e10cSrcweir #pragma warning(push, 1) 27cdf0e10cSrcweir #pragma warning(disable: 4917) 28cdf0e10cSrcweir #endif 29cdf0e10cSrcweir #include <windows.h> 30cdf0e10cSrcweir #include <objbase.h> 31cdf0e10cSrcweir #include <strmif.h> 32cdf0e10cSrcweir #include <control.h> 33cdf0e10cSrcweir #include <dshow.h> 34cdf0e10cSrcweir #if defined _MSC_VER 35cdf0e10cSrcweir #pragma warning(pop) 36cdf0e10cSrcweir #endif 37cdf0e10cSrcweir #include <tools/postwin.h> 38cdf0e10cSrcweir #include <com/sun/star/awt/SystemPointer.hdl> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include "window.hxx" 41cdf0e10cSrcweir #include "player.hxx" 42cdf0e10cSrcweir 43cdf0e10cSrcweir #define AVMEDIA_WIN_WINDOW_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Window_DirectX" 44cdf0e10cSrcweir #define AVMEDIA_WIN_WINDOW_SERVICENAME "com.sun.star.media.Window_DirectX" 45cdf0e10cSrcweir 46cdf0e10cSrcweir using namespace ::com::sun::star; 47cdf0e10cSrcweir 48cdf0e10cSrcweir namespace avmedia { namespace win { 49cdf0e10cSrcweir 50cdf0e10cSrcweir // ----------- 51cdf0e10cSrcweir // - statics - 52cdf0e10cSrcweir // ----------- 53cdf0e10cSrcweir 54cdf0e10cSrcweir static ::osl::Mutex& ImplGetOwnStaticMutex() 55cdf0e10cSrcweir { 56cdf0e10cSrcweir static ::osl::Mutex* pMutex = NULL; 57cdf0e10cSrcweir 58cdf0e10cSrcweir if( pMutex == NULL ) 59cdf0e10cSrcweir { 60cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 61cdf0e10cSrcweir 62cdf0e10cSrcweir if( pMutex == NULL ) 63cdf0e10cSrcweir { 64cdf0e10cSrcweir static ::osl::Mutex aMutex; 65cdf0e10cSrcweir pMutex = &aMutex; 66cdf0e10cSrcweir } 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir return *pMutex; 70cdf0e10cSrcweir } 71cdf0e10cSrcweir 72cdf0e10cSrcweir // ----------- 73cdf0e10cSrcweir // - WndProc - 74cdf0e10cSrcweir // ----------- 75cdf0e10cSrcweir 76cdf0e10cSrcweir LRESULT CALLBACK MediaPlayerWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 ) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir Window* pWindow = (Window*) ::GetWindowLong( hWnd, 0 ); 79cdf0e10cSrcweir bool bProcessed = true; 80cdf0e10cSrcweir 81cdf0e10cSrcweir if( pWindow ) 82cdf0e10cSrcweir { 83cdf0e10cSrcweir switch( nMsg ) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir case( WM_SETCURSOR ): 86cdf0e10cSrcweir pWindow->updatePointer(); 87cdf0e10cSrcweir break; 88cdf0e10cSrcweir 89cdf0e10cSrcweir case( WM_GRAPHNOTIFY ): 90cdf0e10cSrcweir pWindow->processGraphEvent(); 91cdf0e10cSrcweir break; 92cdf0e10cSrcweir 93cdf0e10cSrcweir case( WM_MOUSEMOVE ): 94cdf0e10cSrcweir case( WM_LBUTTONDOWN ): 95cdf0e10cSrcweir case( WM_MBUTTONDOWN ): 96cdf0e10cSrcweir case( WM_RBUTTONDOWN ): 97cdf0e10cSrcweir case( WM_LBUTTONUP ): 98cdf0e10cSrcweir case( WM_MBUTTONUP ): 99cdf0e10cSrcweir case( WM_RBUTTONUP ): 100cdf0e10cSrcweir { 101cdf0e10cSrcweir awt::MouseEvent aUNOEvt; 102cdf0e10cSrcweir POINT aWinPoint; 103cdf0e10cSrcweir 104cdf0e10cSrcweir if( !::GetCursorPos( &aWinPoint ) || !::ScreenToClient( hWnd, &aWinPoint ) ) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir aWinPoint.x = GET_X_LPARAM( nPar2 ); 107cdf0e10cSrcweir aWinPoint.y = GET_Y_LPARAM( nPar2 ); 108cdf0e10cSrcweir } 109cdf0e10cSrcweir aUNOEvt.Modifiers = 0; 110cdf0e10cSrcweir aUNOEvt.Buttons = 0; 111cdf0e10cSrcweir aUNOEvt.X = aWinPoint.x; 112cdf0e10cSrcweir aUNOEvt.Y = aWinPoint.y; 113cdf0e10cSrcweir aUNOEvt.PopupTrigger = false; 114cdf0e10cSrcweir 115cdf0e10cSrcweir // Modifiers 116cdf0e10cSrcweir if( nPar1 & MK_SHIFT ) 117cdf0e10cSrcweir aUNOEvt.Modifiers |= awt::KeyModifier::SHIFT; 118cdf0e10cSrcweir 119cdf0e10cSrcweir if( nPar1 & MK_CONTROL ) 120cdf0e10cSrcweir aUNOEvt.Modifiers |= awt::KeyModifier::MOD1; 121cdf0e10cSrcweir 122cdf0e10cSrcweir // Buttons 123cdf0e10cSrcweir if( WM_LBUTTONDOWN == nMsg || WM_LBUTTONUP == nMsg ) 124cdf0e10cSrcweir aUNOEvt.Buttons |= awt::MouseButton::LEFT; 125cdf0e10cSrcweir 126cdf0e10cSrcweir if( WM_MBUTTONDOWN == nMsg || WM_MBUTTONUP == nMsg ) 127cdf0e10cSrcweir aUNOEvt.Buttons |= awt::MouseButton::MIDDLE; 128cdf0e10cSrcweir 129cdf0e10cSrcweir if( WM_RBUTTONDOWN == nMsg || WM_RBUTTONUP == nMsg ) 130cdf0e10cSrcweir aUNOEvt.Buttons |= awt::MouseButton::RIGHT; 131cdf0e10cSrcweir 132cdf0e10cSrcweir // event type 133cdf0e10cSrcweir if( WM_LBUTTONDOWN == nMsg || 134cdf0e10cSrcweir WM_MBUTTONDOWN == nMsg || 135cdf0e10cSrcweir WM_RBUTTONDOWN == nMsg ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir aUNOEvt.ClickCount = 1; 138cdf0e10cSrcweir pWindow->fireMousePressedEvent( aUNOEvt ); 139cdf0e10cSrcweir } 140cdf0e10cSrcweir else if( WM_LBUTTONUP == nMsg || 141cdf0e10cSrcweir WM_MBUTTONUP == nMsg || 142cdf0e10cSrcweir WM_RBUTTONUP == nMsg ) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir aUNOEvt.ClickCount = 1; 145cdf0e10cSrcweir pWindow->fireMouseReleasedEvent( aUNOEvt ); 146cdf0e10cSrcweir } 147cdf0e10cSrcweir else if( WM_MOUSEMOVE == nMsg ) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir aUNOEvt.ClickCount = 0; 150cdf0e10cSrcweir pWindow->fireMouseMovedEvent( aUNOEvt ); 151cdf0e10cSrcweir pWindow->updatePointer(); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir } 154cdf0e10cSrcweir break; 155cdf0e10cSrcweir 156cdf0e10cSrcweir case( WM_SETFOCUS ): 157cdf0e10cSrcweir { 158cdf0e10cSrcweir const awt::FocusEvent aUNOEvt; 159cdf0e10cSrcweir pWindow->fireSetFocusEvent( aUNOEvt ); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir break; 162cdf0e10cSrcweir 163cdf0e10cSrcweir default: 164cdf0e10cSrcweir bProcessed = false; 165cdf0e10cSrcweir break; 166cdf0e10cSrcweir } 167cdf0e10cSrcweir } 168cdf0e10cSrcweir else 169cdf0e10cSrcweir bProcessed = false; 170cdf0e10cSrcweir 171cdf0e10cSrcweir return( bProcessed ? 0 : DefWindowProc( hWnd, nMsg, nPar1, nPar2 ) ); 172cdf0e10cSrcweir } 173cdf0e10cSrcweir 174cdf0e10cSrcweir // --------------- 175cdf0e10cSrcweir // - Window - 176cdf0e10cSrcweir // --------------- 177cdf0e10cSrcweir 178cdf0e10cSrcweir WNDCLASS* lcl_getWndClass() 179cdf0e10cSrcweir { 180cdf0e10cSrcweir static WNDCLASS* s_pWndClass = NULL; 181cdf0e10cSrcweir if ( !s_pWndClass ) 182cdf0e10cSrcweir { 183cdf0e10cSrcweir s_pWndClass = new WNDCLASS; 184cdf0e10cSrcweir 185cdf0e10cSrcweir memset( s_pWndClass, 0, sizeof( *s_pWndClass ) ); 186cdf0e10cSrcweir s_pWndClass->hInstance = GetModuleHandle( NULL ); 187cdf0e10cSrcweir s_pWndClass->cbWndExtra = sizeof( DWORD ); 188cdf0e10cSrcweir s_pWndClass->lpfnWndProc = MediaPlayerWndProc; 189cdf0e10cSrcweir s_pWndClass->lpszClassName = "com_sun_star_media_PlayerWnd"; 190cdf0e10cSrcweir s_pWndClass->hbrBackground = (HBRUSH) ::GetStockObject( BLACK_BRUSH ); 191cdf0e10cSrcweir s_pWndClass->hCursor = ::LoadCursor( NULL, IDC_ARROW ); 192cdf0e10cSrcweir 193cdf0e10cSrcweir ::RegisterClass( s_pWndClass ); 194cdf0e10cSrcweir } 195cdf0e10cSrcweir return s_pWndClass; 196cdf0e10cSrcweir } 197cdf0e10cSrcweir 198cdf0e10cSrcweir // ------------------------------------------------------------------------------ 199cdf0e10cSrcweir 200cdf0e10cSrcweir Window::Window( const uno::Reference< lang::XMultiServiceFactory >& rxMgr, Player& rPlayer ) : 201cdf0e10cSrcweir mxMgr( rxMgr ), 202cdf0e10cSrcweir mrPlayer( rPlayer ), 203cdf0e10cSrcweir meZoomLevel( media::ZoomLevel_NOT_AVAILABLE ), 204cdf0e10cSrcweir mnParentWnd( 0 ), 205cdf0e10cSrcweir mnFrameWnd( 0 ), 206cdf0e10cSrcweir maListeners( maMutex ), 207cdf0e10cSrcweir mnPointerType( awt::SystemPointer::ARROW ) 208cdf0e10cSrcweir { 209cdf0e10cSrcweir ::osl::MutexGuard aGuard( ImplGetOwnStaticMutex() ); 210cdf0e10cSrcweir 211cdf0e10cSrcweir lcl_getWndClass(); 212cdf0e10cSrcweir } 213cdf0e10cSrcweir 214cdf0e10cSrcweir // ------------------------------------------------------------------------------ 215cdf0e10cSrcweir 216cdf0e10cSrcweir Window::~Window() 217cdf0e10cSrcweir { 218cdf0e10cSrcweir if( mnFrameWnd ) 219cdf0e10cSrcweir ::DestroyWindow( (HWND) mnFrameWnd ); 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir // ------------------------------------------------------------------------------ 223cdf0e10cSrcweir 224cdf0e10cSrcweir void Window::ImplLayoutVideoWindow() 225cdf0e10cSrcweir { 226cdf0e10cSrcweir if( media::ZoomLevel_NOT_AVAILABLE != meZoomLevel ) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir awt::Size aPrefSize( mrPlayer.getPreferredPlayerWindowSize() ); 229cdf0e10cSrcweir awt::Rectangle aRect = getPosSize(); 230cdf0e10cSrcweir int nW = aRect.Width, nH = aRect.Height; 231cdf0e10cSrcweir int nVideoW = nW, nVideoH = nH; 232cdf0e10cSrcweir int nX = 0, nY = 0, nWidth = 0, nHeight = 0; 233cdf0e10cSrcweir bool bDone = false, bZoom = false; 234cdf0e10cSrcweir 235cdf0e10cSrcweir if( media::ZoomLevel_ORIGINAL == meZoomLevel ) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir bZoom = true; 238cdf0e10cSrcweir } 239cdf0e10cSrcweir else if( media::ZoomLevel_ZOOM_1_TO_4 == meZoomLevel ) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir aPrefSize.Width >>= 2; 242cdf0e10cSrcweir aPrefSize.Height >>= 2; 243cdf0e10cSrcweir bZoom = true; 244cdf0e10cSrcweir } 245cdf0e10cSrcweir else if( media::ZoomLevel_ZOOM_1_TO_2 == meZoomLevel ) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir aPrefSize.Width >>= 1; 248cdf0e10cSrcweir aPrefSize.Height >>= 1; 249cdf0e10cSrcweir bZoom = true; 250cdf0e10cSrcweir } 251cdf0e10cSrcweir else if( media::ZoomLevel_ZOOM_2_TO_1 == meZoomLevel ) 252cdf0e10cSrcweir { 253cdf0e10cSrcweir aPrefSize.Width <<= 1; 254cdf0e10cSrcweir aPrefSize.Height <<= 1; 255cdf0e10cSrcweir bZoom = true; 256cdf0e10cSrcweir } 257cdf0e10cSrcweir else if( media::ZoomLevel_ZOOM_4_TO_1 == meZoomLevel ) 258cdf0e10cSrcweir { 259cdf0e10cSrcweir aPrefSize.Width <<= 2; 260cdf0e10cSrcweir aPrefSize.Height <<= 2; 261cdf0e10cSrcweir bZoom = true; 262cdf0e10cSrcweir } 263cdf0e10cSrcweir else if( media::ZoomLevel_FIT_TO_WINDOW == meZoomLevel ) 264cdf0e10cSrcweir { 265cdf0e10cSrcweir nWidth = nVideoW; 266cdf0e10cSrcweir nHeight = nVideoH; 267cdf0e10cSrcweir bDone = true; 268cdf0e10cSrcweir } 269cdf0e10cSrcweir 270cdf0e10cSrcweir if( bZoom ) 271cdf0e10cSrcweir { 272cdf0e10cSrcweir if( ( aPrefSize.Width <= nVideoW ) && ( aPrefSize.Height <= nVideoH ) ) 273cdf0e10cSrcweir { 274cdf0e10cSrcweir nX = ( nVideoW - aPrefSize.Width ) >> 1; 275cdf0e10cSrcweir nY = ( nVideoH - aPrefSize.Height ) >> 1; 276cdf0e10cSrcweir nWidth = aPrefSize.Width; 277cdf0e10cSrcweir nHeight = aPrefSize.Height; 278cdf0e10cSrcweir bDone = true; 279cdf0e10cSrcweir } 280cdf0e10cSrcweir } 281cdf0e10cSrcweir 282cdf0e10cSrcweir if( !bDone ) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir if( aPrefSize.Width > 0 && aPrefSize.Height > 0 && nVideoW > 0 && nVideoH > 0 ) 285cdf0e10cSrcweir { 286cdf0e10cSrcweir double fPrefWH = (double) aPrefSize.Width / aPrefSize.Height; 287cdf0e10cSrcweir 288cdf0e10cSrcweir if( fPrefWH < ( (double) nVideoW / nVideoH ) ) 289cdf0e10cSrcweir nVideoW = (int)( nVideoH * fPrefWH ); 290cdf0e10cSrcweir else 291cdf0e10cSrcweir nVideoH = (int)( nVideoW / fPrefWH ); 292cdf0e10cSrcweir 293cdf0e10cSrcweir nX = ( nW - nVideoW ) >> 1; 294cdf0e10cSrcweir nY = ( nH - nVideoH ) >> 1; 295cdf0e10cSrcweir nWidth = nVideoW; 296cdf0e10cSrcweir nHeight = nVideoH; 297cdf0e10cSrcweir } 298cdf0e10cSrcweir else 299cdf0e10cSrcweir nX = nY = nWidth = nHeight = 0; 300cdf0e10cSrcweir } 301cdf0e10cSrcweir 302cdf0e10cSrcweir IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() ); 303cdf0e10cSrcweir 304cdf0e10cSrcweir if( pVideoWindow ) 305cdf0e10cSrcweir pVideoWindow->SetWindowPosition( nX, nY, nWidth, nHeight ); 306cdf0e10cSrcweir } 307cdf0e10cSrcweir } 308cdf0e10cSrcweir 309cdf0e10cSrcweir // ------------------------------------------------------------------------------ 310cdf0e10cSrcweir 311cdf0e10cSrcweir bool Window::create( const uno::Sequence< uno::Any >& rArguments ) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() ); 314cdf0e10cSrcweir WNDCLASS* mpWndClass = lcl_getWndClass(); 315cdf0e10cSrcweir 316cdf0e10cSrcweir 317cdf0e10cSrcweir if( !mnFrameWnd && pVideoWindow && mpWndClass ) 318cdf0e10cSrcweir { 319cdf0e10cSrcweir awt::Rectangle aRect; 320cdf0e10cSrcweir sal_IntPtr nWnd; 321cdf0e10cSrcweir 322cdf0e10cSrcweir rArguments[ 0 ] >>= nWnd; 323cdf0e10cSrcweir rArguments[ 1 ] >>= aRect; 324cdf0e10cSrcweir 325cdf0e10cSrcweir mnParentWnd = static_cast<int>(nWnd); 326cdf0e10cSrcweir 327cdf0e10cSrcweir mnFrameWnd = (int) ::CreateWindow( mpWndClass->lpszClassName, NULL, 328cdf0e10cSrcweir WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 329cdf0e10cSrcweir aRect.X, aRect.Y, aRect.Width, aRect.Height, 330cdf0e10cSrcweir (HWND) mnParentWnd, NULL, mpWndClass->hInstance, 0 ); 331cdf0e10cSrcweir 332cdf0e10cSrcweir // if the last CreateWindow failed... 333cdf0e10cSrcweir if( mnFrameWnd == 0 ) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir // try again and this time assume that mnParent is indeed a dc 336cdf0e10cSrcweir mnParentWnd = reinterpret_cast<int>(::WindowFromDC( (HDC)mnParentWnd )); 337cdf0e10cSrcweir mnFrameWnd = (int) ::CreateWindow( mpWndClass->lpszClassName, NULL, 338cdf0e10cSrcweir WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 339cdf0e10cSrcweir aRect.X, aRect.Y, aRect.Width, aRect.Height, 340cdf0e10cSrcweir (HWND)mnParentWnd , NULL, mpWndClass->hInstance, 0 ); 341cdf0e10cSrcweir } 342cdf0e10cSrcweir 343cdf0e10cSrcweir if( mnFrameWnd ) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir ::SetWindowLong( (HWND) mnFrameWnd, 0, (DWORD) this ); 346cdf0e10cSrcweir 347cdf0e10cSrcweir #ifdef DDRAW_TEST_OUTPUT 348cdf0e10cSrcweir IDirectDraw7* pDDraw; 349cdf0e10cSrcweir IDirectDrawSurface7* pDDSurface; 350cdf0e10cSrcweir IDirectDrawClipper* pDDClipper; 351cdf0e10cSrcweir 352cdf0e10cSrcweir if( DD_OK == DirectDrawCreateEx( NULL, (void**) &pDDraw, IID_IDirectDraw7, NULL ) ) 353cdf0e10cSrcweir { 354cdf0e10cSrcweir if( DD_OK == pDDraw->SetCooperativeLevel( (HWND) mnParentWnd, DDSCL_NORMAL ) ) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir DDSURFACEDESC2 aDDDesc; 357cdf0e10cSrcweir 358cdf0e10cSrcweir memset( &aDDDesc, 0, sizeof( aDDDesc ) ); 359cdf0e10cSrcweir aDDDesc.dwSize = sizeof( aDDDesc ); 360cdf0e10cSrcweir aDDDesc.dwFlags = DDSD_CAPS; 361cdf0e10cSrcweir aDDDesc.ddsCaps.dwCaps |= DDSCAPS_PRIMARYSURFACE; 362cdf0e10cSrcweir 363cdf0e10cSrcweir if( DD_OK == pDDraw->CreateSurface( &aDDDesc, &pDDSurface, NULL ) ) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir if( DD_OK == pDDraw->CreateClipper( 0, &pDDClipper, NULL ) ) 366cdf0e10cSrcweir { 367cdf0e10cSrcweir pDDClipper->SetHWnd( 0, (HWND) mnFrameWnd ); 368cdf0e10cSrcweir pDDSurface->SetClipper( pDDClipper ); 369cdf0e10cSrcweir } 370cdf0e10cSrcweir 371cdf0e10cSrcweir mrPlayer.setDDrawParams( (IDirectDraw*) pDDraw, (IDirectDrawSurface*) pDDSurface ); 372cdf0e10cSrcweir #endif 373cdf0e10cSrcweir 374cdf0e10cSrcweir pVideoWindow->put_Owner( (OAHWND) mnFrameWnd ); 375cdf0e10cSrcweir pVideoWindow->put_MessageDrain( (OAHWND) mnFrameWnd ); 376cdf0e10cSrcweir pVideoWindow->put_WindowStyle( WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN ); 377cdf0e10cSrcweir 378cdf0e10cSrcweir mrPlayer.setNotifyWnd( mnFrameWnd ); 379cdf0e10cSrcweir 380cdf0e10cSrcweir meZoomLevel = media::ZoomLevel_FIT_TO_WINDOW; 381cdf0e10cSrcweir ImplLayoutVideoWindow(); 382cdf0e10cSrcweir #ifdef DDRAW_TEST_OUTPUT 383cdf0e10cSrcweir } 384cdf0e10cSrcweir } 385cdf0e10cSrcweir } 386cdf0e10cSrcweir #endif 387cdf0e10cSrcweir } 388cdf0e10cSrcweir } 389cdf0e10cSrcweir 390cdf0e10cSrcweir return( mnFrameWnd != 0 ); 391cdf0e10cSrcweir } 392cdf0e10cSrcweir 393cdf0e10cSrcweir // ------------------------------------------------------------------------------ 394cdf0e10cSrcweir 395cdf0e10cSrcweir void Window::processGraphEvent() 396cdf0e10cSrcweir { 397cdf0e10cSrcweir mrPlayer.processEvent(); 398cdf0e10cSrcweir } 399cdf0e10cSrcweir 400cdf0e10cSrcweir // ------------------------------------------------------------------------------ 401cdf0e10cSrcweir 402cdf0e10cSrcweir void Window::updatePointer() 403cdf0e10cSrcweir { 404cdf0e10cSrcweir char* pCursorName; 405cdf0e10cSrcweir 406cdf0e10cSrcweir switch( mnPointerType ) 407cdf0e10cSrcweir { 408cdf0e10cSrcweir case( awt::SystemPointer::CROSS ): pCursorName = IDC_CROSS; break; 409cdf0e10cSrcweir //case( awt::SystemPointer::HAND ): pCursorName = IDC_HAND; break; 410cdf0e10cSrcweir case( awt::SystemPointer::MOVE ): pCursorName = IDC_SIZEALL; break; 411cdf0e10cSrcweir case( awt::SystemPointer::WAIT ): pCursorName = IDC_WAIT; break; 412cdf0e10cSrcweir 413cdf0e10cSrcweir default: 414cdf0e10cSrcweir pCursorName = IDC_ARROW; 415cdf0e10cSrcweir break; 416cdf0e10cSrcweir } 417cdf0e10cSrcweir 418cdf0e10cSrcweir ::SetCursor( ::LoadCursor( NULL, pCursorName ) ); 419cdf0e10cSrcweir } 420cdf0e10cSrcweir 421cdf0e10cSrcweir // ------------------------------------------------------------------------------ 422cdf0e10cSrcweir 423cdf0e10cSrcweir void SAL_CALL Window::update( ) 424cdf0e10cSrcweir throw (uno::RuntimeException) 425cdf0e10cSrcweir { 426cdf0e10cSrcweir ::RedrawWindow( (HWND) mnFrameWnd, NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE ); 427cdf0e10cSrcweir } 428cdf0e10cSrcweir 429cdf0e10cSrcweir // ------------------------------------------------------------------------------ 430cdf0e10cSrcweir 431cdf0e10cSrcweir sal_Bool SAL_CALL Window::setZoomLevel( media::ZoomLevel eZoomLevel ) 432cdf0e10cSrcweir throw (uno::RuntimeException) 433cdf0e10cSrcweir { 434cdf0e10cSrcweir boolean bRet = false; 435cdf0e10cSrcweir 436cdf0e10cSrcweir if( media::ZoomLevel_NOT_AVAILABLE != meZoomLevel && 437cdf0e10cSrcweir media::ZoomLevel_NOT_AVAILABLE != eZoomLevel ) 438cdf0e10cSrcweir { 439cdf0e10cSrcweir if( eZoomLevel != meZoomLevel ) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir meZoomLevel = eZoomLevel; 442cdf0e10cSrcweir ImplLayoutVideoWindow(); 443cdf0e10cSrcweir } 444cdf0e10cSrcweir 445cdf0e10cSrcweir bRet = true; 446cdf0e10cSrcweir } 447cdf0e10cSrcweir 448cdf0e10cSrcweir return bRet; 449cdf0e10cSrcweir } 450cdf0e10cSrcweir 451cdf0e10cSrcweir // ------------------------------------------------------------------------------ 452cdf0e10cSrcweir 453cdf0e10cSrcweir media::ZoomLevel SAL_CALL Window::getZoomLevel( ) 454cdf0e10cSrcweir throw (uno::RuntimeException) 455cdf0e10cSrcweir { 456cdf0e10cSrcweir return meZoomLevel; 457cdf0e10cSrcweir } 458cdf0e10cSrcweir 459cdf0e10cSrcweir // ------------------------------------------------------------------------------ 460cdf0e10cSrcweir 461cdf0e10cSrcweir void SAL_CALL Window::setPointerType( sal_Int32 nPointerType ) 462cdf0e10cSrcweir throw (uno::RuntimeException) 463cdf0e10cSrcweir { 464cdf0e10cSrcweir mnPointerType = nPointerType; 465cdf0e10cSrcweir } 466cdf0e10cSrcweir 467cdf0e10cSrcweir // ------------------------------------------------------------------------------ 468cdf0e10cSrcweir 469cdf0e10cSrcweir void SAL_CALL Window::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 ) 470cdf0e10cSrcweir throw (uno::RuntimeException) 471cdf0e10cSrcweir { 472cdf0e10cSrcweir if( mnFrameWnd ) 473cdf0e10cSrcweir { 474cdf0e10cSrcweir ::SetWindowPos( (HWND) mnFrameWnd, HWND_TOP, X, Y, Width, Height, 0 ); 475cdf0e10cSrcweir ImplLayoutVideoWindow(); 476cdf0e10cSrcweir } 477cdf0e10cSrcweir } 478cdf0e10cSrcweir 479cdf0e10cSrcweir // ------------------------------------------------------------------------------ 480cdf0e10cSrcweir 481cdf0e10cSrcweir awt::Rectangle SAL_CALL Window::getPosSize() 482cdf0e10cSrcweir throw (uno::RuntimeException) 483cdf0e10cSrcweir { 484cdf0e10cSrcweir awt::Rectangle aRet; 485cdf0e10cSrcweir 486cdf0e10cSrcweir if( mnFrameWnd ) 487cdf0e10cSrcweir { 488cdf0e10cSrcweir ::RECT aWndRect; 489cdf0e10cSrcweir 490cdf0e10cSrcweir if( ::GetClientRect( (HWND) mnFrameWnd, &aWndRect ) ) 491cdf0e10cSrcweir { 492cdf0e10cSrcweir aRet.X = aWndRect.left; 493cdf0e10cSrcweir aRet.Y = aWndRect.top; 494cdf0e10cSrcweir aRet.Width = aWndRect.right - aWndRect.left + 1; 495cdf0e10cSrcweir aRet.Height = aWndRect.bottom - aWndRect.top + 1; 496cdf0e10cSrcweir } 497cdf0e10cSrcweir } 498cdf0e10cSrcweir 499cdf0e10cSrcweir return aRet; 500cdf0e10cSrcweir } 501cdf0e10cSrcweir 502cdf0e10cSrcweir // ------------------------------------------------------------------------------ 503cdf0e10cSrcweir 504cdf0e10cSrcweir void SAL_CALL Window::setVisible( sal_Bool bVisible ) 505cdf0e10cSrcweir throw (uno::RuntimeException) 506cdf0e10cSrcweir { 507cdf0e10cSrcweir if( mnFrameWnd ) 508cdf0e10cSrcweir { 509cdf0e10cSrcweir IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() ); 510cdf0e10cSrcweir 511cdf0e10cSrcweir if( pVideoWindow ) 512cdf0e10cSrcweir pVideoWindow->put_Visible( bVisible ? OATRUE : OAFALSE ); 513cdf0e10cSrcweir 514cdf0e10cSrcweir ::ShowWindow( (HWND) mnFrameWnd, bVisible ? SW_SHOW : SW_HIDE ); 515cdf0e10cSrcweir } 516cdf0e10cSrcweir } 517cdf0e10cSrcweir 518cdf0e10cSrcweir // ------------------------------------------------------------------------------ 519cdf0e10cSrcweir 520cdf0e10cSrcweir void SAL_CALL Window::setEnable( sal_Bool bEnable ) 521cdf0e10cSrcweir throw (uno::RuntimeException) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir if( mnFrameWnd ) 524cdf0e10cSrcweir ::EnableWindow( (HWND) mnFrameWnd, bEnable ); 525cdf0e10cSrcweir } 526cdf0e10cSrcweir 527cdf0e10cSrcweir // ------------------------------------------------------------------------------ 528cdf0e10cSrcweir 529cdf0e10cSrcweir void SAL_CALL Window::setFocus( ) 530cdf0e10cSrcweir throw (uno::RuntimeException) 531cdf0e10cSrcweir { 532cdf0e10cSrcweir if( mnFrameWnd ) 533cdf0e10cSrcweir ::SetFocus( (HWND) mnFrameWnd ); 534cdf0e10cSrcweir } 535cdf0e10cSrcweir 536cdf0e10cSrcweir // ------------------------------------------------------------------------------ 537cdf0e10cSrcweir 538cdf0e10cSrcweir void SAL_CALL Window::addWindowListener( const uno::Reference< awt::XWindowListener >& xListener ) 539cdf0e10cSrcweir throw (uno::RuntimeException) 540cdf0e10cSrcweir { 541cdf0e10cSrcweir maListeners.addInterface( getCppuType( &xListener ), xListener ); 542cdf0e10cSrcweir } 543cdf0e10cSrcweir 544cdf0e10cSrcweir // ------------------------------------------------------------------------------ 545cdf0e10cSrcweir 546cdf0e10cSrcweir void SAL_CALL Window::removeWindowListener( const uno::Reference< awt::XWindowListener >& xListener ) 547cdf0e10cSrcweir throw (uno::RuntimeException) 548cdf0e10cSrcweir { 549cdf0e10cSrcweir maListeners.removeInterface( getCppuType( &xListener ), xListener ); 550cdf0e10cSrcweir } 551cdf0e10cSrcweir 552cdf0e10cSrcweir // ------------------------------------------------------------------------------ 553cdf0e10cSrcweir 554cdf0e10cSrcweir void SAL_CALL Window::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) 555cdf0e10cSrcweir throw (uno::RuntimeException) 556cdf0e10cSrcweir { 557cdf0e10cSrcweir maListeners.addInterface( getCppuType( &xListener ), xListener ); 558cdf0e10cSrcweir } 559cdf0e10cSrcweir 560cdf0e10cSrcweir // ------------------------------------------------------------------------------ 561cdf0e10cSrcweir 562cdf0e10cSrcweir void SAL_CALL Window::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) 563cdf0e10cSrcweir throw (uno::RuntimeException) 564cdf0e10cSrcweir { 565cdf0e10cSrcweir maListeners.removeInterface( getCppuType( &xListener ), xListener ); 566cdf0e10cSrcweir } 567cdf0e10cSrcweir 568cdf0e10cSrcweir // ------------------------------------------------------------------------------ 569cdf0e10cSrcweir 570cdf0e10cSrcweir void SAL_CALL Window::addKeyListener( const uno::Reference< awt::XKeyListener >& xListener ) 571cdf0e10cSrcweir throw (uno::RuntimeException) 572cdf0e10cSrcweir { 573cdf0e10cSrcweir maListeners.addInterface( getCppuType( &xListener ), xListener ); 574cdf0e10cSrcweir } 575cdf0e10cSrcweir 576cdf0e10cSrcweir // ------------------------------------------------------------------------------ 577cdf0e10cSrcweir 578cdf0e10cSrcweir void SAL_CALL Window::removeKeyListener( const uno::Reference< awt::XKeyListener >& xListener ) 579cdf0e10cSrcweir throw (uno::RuntimeException) 580cdf0e10cSrcweir { 581cdf0e10cSrcweir maListeners.removeInterface( getCppuType( &xListener ), xListener ); 582cdf0e10cSrcweir } 583cdf0e10cSrcweir 584cdf0e10cSrcweir // ------------------------------------------------------------------------------ 585cdf0e10cSrcweir 586cdf0e10cSrcweir void SAL_CALL Window::addMouseListener( const uno::Reference< awt::XMouseListener >& xListener ) 587cdf0e10cSrcweir throw (uno::RuntimeException) 588cdf0e10cSrcweir { 589cdf0e10cSrcweir maListeners.addInterface( getCppuType( &xListener ), xListener ); 590cdf0e10cSrcweir } 591cdf0e10cSrcweir 592cdf0e10cSrcweir // ------------------------------------------------------------------------------ 593cdf0e10cSrcweir 594cdf0e10cSrcweir void SAL_CALL Window::removeMouseListener( const uno::Reference< awt::XMouseListener >& xListener ) 595cdf0e10cSrcweir throw (uno::RuntimeException) 596cdf0e10cSrcweir { 597cdf0e10cSrcweir maListeners.removeInterface( getCppuType( &xListener ), xListener ); 598cdf0e10cSrcweir } 599cdf0e10cSrcweir 600cdf0e10cSrcweir // ------------------------------------------------------------------------------ 601cdf0e10cSrcweir 602cdf0e10cSrcweir void SAL_CALL Window::addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener ) 603cdf0e10cSrcweir throw (uno::RuntimeException) 604cdf0e10cSrcweir { 605cdf0e10cSrcweir maListeners.addInterface( getCppuType( &xListener ), xListener ); 606cdf0e10cSrcweir } 607cdf0e10cSrcweir 608cdf0e10cSrcweir // ------------------------------------------------------------------------------ 609cdf0e10cSrcweir 610cdf0e10cSrcweir void SAL_CALL Window::removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener ) 611cdf0e10cSrcweir throw (uno::RuntimeException) 612cdf0e10cSrcweir { 613cdf0e10cSrcweir maListeners.removeInterface( getCppuType( &xListener ), xListener ); 614cdf0e10cSrcweir } 615cdf0e10cSrcweir 616cdf0e10cSrcweir // ------------------------------------------------------------------------------ 617cdf0e10cSrcweir 618cdf0e10cSrcweir void SAL_CALL Window::addPaintListener( const uno::Reference< awt::XPaintListener >& xListener ) 619cdf0e10cSrcweir throw (uno::RuntimeException) 620cdf0e10cSrcweir { 621cdf0e10cSrcweir maListeners.addInterface( getCppuType( &xListener ), xListener ); 622cdf0e10cSrcweir } 623cdf0e10cSrcweir 624cdf0e10cSrcweir // ------------------------------------------------------------------------------ 625cdf0e10cSrcweir 626cdf0e10cSrcweir void SAL_CALL Window::removePaintListener( const uno::Reference< awt::XPaintListener >& xListener ) 627cdf0e10cSrcweir throw (uno::RuntimeException) 628cdf0e10cSrcweir { 629cdf0e10cSrcweir maListeners.removeInterface( getCppuType( &xListener ), xListener ); 630cdf0e10cSrcweir } 631cdf0e10cSrcweir 632cdf0e10cSrcweir // ------------------------------------------------------------------------------ 633cdf0e10cSrcweir 634cdf0e10cSrcweir void SAL_CALL Window::dispose( ) 635cdf0e10cSrcweir throw (uno::RuntimeException) 636cdf0e10cSrcweir { 637cdf0e10cSrcweir } 638cdf0e10cSrcweir 639cdf0e10cSrcweir // ------------------------------------------------------------------------------ 640cdf0e10cSrcweir 641cdf0e10cSrcweir void SAL_CALL Window::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) 642cdf0e10cSrcweir throw (uno::RuntimeException) 643cdf0e10cSrcweir { 644cdf0e10cSrcweir maListeners.addInterface( getCppuType( &xListener ), xListener ); 645cdf0e10cSrcweir } 646cdf0e10cSrcweir 647cdf0e10cSrcweir // ------------------------------------------------------------------------------ 648cdf0e10cSrcweir 649cdf0e10cSrcweir void SAL_CALL Window::removeEventListener( const uno::Reference< lang::XEventListener >& xListener ) 650cdf0e10cSrcweir throw (uno::RuntimeException) 651cdf0e10cSrcweir { 652cdf0e10cSrcweir maListeners.removeInterface( getCppuType( &xListener ), xListener ); 653cdf0e10cSrcweir } 654cdf0e10cSrcweir 655cdf0e10cSrcweir // ------------------------------------------------------------------------------ 656cdf0e10cSrcweir 657cdf0e10cSrcweir void Window::fireMousePressedEvent( const ::com::sun::star::awt::MouseEvent& rEvt ) 658cdf0e10cSrcweir { 659cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pContainer = maListeners.getContainer( getCppuType( (uno::Reference< awt::XMouseListener >*) 0 ) ); 660cdf0e10cSrcweir 661cdf0e10cSrcweir if( pContainer ) 662cdf0e10cSrcweir { 663cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper aIter( *pContainer ); 664cdf0e10cSrcweir 665cdf0e10cSrcweir while( aIter.hasMoreElements() ) 666cdf0e10cSrcweir uno::Reference< awt::XMouseListener >( aIter.next(), uno::UNO_QUERY )->mousePressed( rEvt ); 667cdf0e10cSrcweir } 668cdf0e10cSrcweir } 669cdf0e10cSrcweir 670cdf0e10cSrcweir // ----------------------------------------------------------------------------- 671cdf0e10cSrcweir 672cdf0e10cSrcweir void Window::fireMouseReleasedEvent( const ::com::sun::star::awt::MouseEvent& rEvt ) 673cdf0e10cSrcweir { 674cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pContainer = maListeners.getContainer( getCppuType( (uno::Reference< awt::XMouseListener >*) 0 ) ); 675cdf0e10cSrcweir 676cdf0e10cSrcweir if( pContainer ) 677cdf0e10cSrcweir { 678cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper aIter( *pContainer ); 679cdf0e10cSrcweir 680cdf0e10cSrcweir while( aIter.hasMoreElements() ) 681cdf0e10cSrcweir uno::Reference< awt::XMouseListener >( aIter.next(), uno::UNO_QUERY )->mouseReleased( rEvt ); 682cdf0e10cSrcweir } 683cdf0e10cSrcweir } 684cdf0e10cSrcweir 685cdf0e10cSrcweir // ----------------------------------------------------------------------------- 686cdf0e10cSrcweir 687cdf0e10cSrcweir void Window::fireMouseMovedEvent( const ::com::sun::star::awt::MouseEvent& rEvt ) 688cdf0e10cSrcweir { 689cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pContainer = maListeners.getContainer( getCppuType( (uno::Reference< awt::XMouseMotionListener >*) 0 ) ); 690cdf0e10cSrcweir 691cdf0e10cSrcweir if( pContainer ) 692cdf0e10cSrcweir { 693cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper aIter( *pContainer ); 694cdf0e10cSrcweir 695cdf0e10cSrcweir while( aIter.hasMoreElements() ) 696cdf0e10cSrcweir uno::Reference< awt::XMouseMotionListener >( aIter.next(), uno::UNO_QUERY )->mouseMoved( rEvt ); 697cdf0e10cSrcweir } 698cdf0e10cSrcweir } 699cdf0e10cSrcweir 700cdf0e10cSrcweir // ----------------------------------------------------------------------------- 701cdf0e10cSrcweir 702cdf0e10cSrcweir void Window::fireSetFocusEvent( const ::com::sun::star::awt::FocusEvent& rEvt ) 703cdf0e10cSrcweir { 704cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper* pContainer = maListeners.getContainer( getCppuType( (uno::Reference< awt::XFocusListener >*) 0 ) ); 705cdf0e10cSrcweir 706cdf0e10cSrcweir if( pContainer ) 707cdf0e10cSrcweir { 708cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper aIter( *pContainer ); 709cdf0e10cSrcweir 710cdf0e10cSrcweir while( aIter.hasMoreElements() ) 711cdf0e10cSrcweir uno::Reference< awt::XFocusListener >( aIter.next(), uno::UNO_QUERY )->focusGained( rEvt ); 712cdf0e10cSrcweir } 713cdf0e10cSrcweir } 714cdf0e10cSrcweir 715cdf0e10cSrcweir // ------------------------------------------------------------------------------ 716cdf0e10cSrcweir 717cdf0e10cSrcweir ::rtl::OUString SAL_CALL Window::getImplementationName( ) 718cdf0e10cSrcweir throw (uno::RuntimeException) 719cdf0e10cSrcweir { 720cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_WIN_WINDOW_IMPLEMENTATIONNAME ) ); 721cdf0e10cSrcweir } 722cdf0e10cSrcweir 723cdf0e10cSrcweir // ------------------------------------------------------------------------------ 724cdf0e10cSrcweir 725cdf0e10cSrcweir sal_Bool SAL_CALL Window::supportsService( const ::rtl::OUString& ServiceName ) 726cdf0e10cSrcweir throw (uno::RuntimeException) 727cdf0e10cSrcweir { 728cdf0e10cSrcweir return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_WIN_WINDOW_SERVICENAME ) ); 729cdf0e10cSrcweir } 730cdf0e10cSrcweir 731cdf0e10cSrcweir // ------------------------------------------------------------------------------ 732cdf0e10cSrcweir 733cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL Window::getSupportedServiceNames( ) 734cdf0e10cSrcweir throw (uno::RuntimeException) 735cdf0e10cSrcweir { 736cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aRet(1); 737cdf0e10cSrcweir aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_WIN_WINDOW_SERVICENAME ) ); 738cdf0e10cSrcweir 739cdf0e10cSrcweir return aRet; 740cdf0e10cSrcweir } 741cdf0e10cSrcweir 742cdf0e10cSrcweir } // namespace win 743cdf0e10cSrcweir } // namespace avmedia 744