25#include <com/sun/star/awt/SystemPointer.hpp>
40 Window* pWindow =
reinterpret_cast<Window*
>(GetWindowLongPtrW( hWnd, 0 ));
41 bool bProcessed =
true;
62 PostMessage(pWindow->
getParentWnd(), nMsg, nPar1, nPar2);
67 const awt::FocusEvent aUNOEvt;
80 return( bProcessed ? 0 : DefWindowProcW( hWnd, nMsg, nPar1, nPar2 ) );
85 WNDCLASSW* s_pWndClass =
new WNDCLASSW;
87 memset( s_pWndClass, 0,
sizeof( *s_pWndClass ) );
88 s_pWndClass->hInstance = GetModuleHandleW(
nullptr );
89 s_pWndClass->cbWndExtra =
sizeof( DWORD_PTR );
91 s_pWndClass->lpszClassName = L
"com_sun_star_media_PlayerWnd";
92 s_pWndClass->hbrBackground =
static_cast<HBRUSH
>(::GetStockObject(
BLACK_BRUSH ));
93 s_pWndClass->hCursor = ::LoadCursor(
nullptr, IDC_ARROW );
95 RegisterClassW( s_pWndClass );
101 meZoomLevel( media::ZoomLevel_NOT_AVAILABLE ),
103 mnFrameWnd( nullptr ),
104 mnParentWnd( nullptr ),
105 mnPointerType( awt::SystemPointer::
ARROW )
117 if( media::ZoomLevel_NOT_AVAILABLE !=
meZoomLevel )
121 int nW = aRect.Width, nH = aRect.Height;
122 int nVideoW = nW, nVideoH = nH;
123 int nX = 0, nY = 0, nWidth = 0, nHeight = 0;
124 bool bDone =
false, bZoom =
false;
130 else if( media::ZoomLevel_ZOOM_1_TO_4 ==
meZoomLevel )
132 aPrefSize.Width >>= 2;
133 aPrefSize.Height >>= 2;
136 else if( media::ZoomLevel_ZOOM_1_TO_2 ==
meZoomLevel )
138 aPrefSize.Width >>= 1;
139 aPrefSize.Height >>= 1;
142 else if( media::ZoomLevel_ZOOM_2_TO_1 ==
meZoomLevel )
144 aPrefSize.Width <<= 1;
145 aPrefSize.Height <<= 1;
148 else if( media::ZoomLevel_ZOOM_4_TO_1 ==
meZoomLevel )
150 aPrefSize.Width <<= 2;
151 aPrefSize.Height <<= 2;
154 else if( media::ZoomLevel_FIT_TO_WINDOW ==
meZoomLevel )
163 if( ( aPrefSize.Width <= nVideoW ) && ( aPrefSize.Height <= nVideoH ) )
165 nX = ( nVideoW - aPrefSize.Width ) >> 1;
166 nY = ( nVideoH - aPrefSize.Height ) >> 1;
167 nWidth = aPrefSize.Width;
168 nHeight = aPrefSize.Height;
175 if( aPrefSize.Width > 0 && aPrefSize.Height > 0 && nVideoW > 0 && nVideoH > 0 )
177 double fPrefWH =
static_cast<double>(aPrefSize.Width) / aPrefSize.Height;
179 if( fPrefWH < (
static_cast<double>(nVideoW) / nVideoH ) )
180 nVideoW =
static_cast<int>( nVideoH * fPrefWH );
182 nVideoH =
static_cast<int>( nVideoW / fPrefWH );
184 nX = ( nW - nVideoW ) >> 1;
185 nY = ( nH - nVideoH ) >> 1;
190 nX = nY = nWidth = nHeight = 0;
196 pVideoWindow->SetWindowPosition( nX, nY, nWidth, nHeight );
205 if( !
mnFrameWnd && pVideoWindow && mpWndClass )
207 awt::Rectangle aRect;
210 rArguments[ 0 ] >>= nWnd;
211 rArguments[ 1 ] >>= aRect;
215 mnFrameWnd = CreateWindowW( mpWndClass->lpszClassName,
nullptr,
216 WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
217 aRect.X, aRect.Y, aRect.Width, aRect.Height,
218 mnParentWnd,
nullptr, mpWndClass->hInstance,
nullptr );
222 SetWindowLongPtrW(
mnFrameWnd, 0,
reinterpret_cast<LONG_PTR
>(
this) );
224 pVideoWindow->put_Owner(
reinterpret_cast<OAHWND
>(
mnFrameWnd) );
225 pVideoWindow->put_MessageDrain(
reinterpret_cast<OAHWND
>(
mnFrameWnd) );
226 pVideoWindow->put_WindowStyle( WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN );
249 case awt::SystemPointer::CROSS: pCursorName = IDC_CROSS;
break;
250 case awt::SystemPointer::MOVE: pCursorName = IDC_SIZEALL;
break;
251 case awt::SystemPointer::WAIT: pCursorName = IDC_WAIT;
break;
254 pCursorName = IDC_ARROW;
258 SetCursor( LoadCursor(
nullptr, pCursorName ) );
263 ::RedrawWindow(
mnFrameWnd,
nullptr,
nullptr, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE );
270 if( media::ZoomLevel_NOT_AVAILABLE !=
meZoomLevel &&
271 media::ZoomLevel_NOT_AVAILABLE != eZoomLevel )
295void SAL_CALL
Window::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 )
312 if( ::GetClientRect(
mnFrameWnd, &aWndRect ) )
314 aRet.X = aWndRect.left;
315 aRet.Y = aWndRect.top;
316 aRet.Width = aWndRect.right - aWndRect.left + 1;
317 aRet.Height = aWndRect.bottom - aWndRect.top + 1;
331 pVideoWindow->put_Visible(
bVisible ? OATRUE : OAFALSE );
sal_Int32 addInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
void notifyEach(std::unique_lock< std::mutex > &rGuard, void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event) const
sal_Int32 removeInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr OUStringLiteral AVMEDIA_WIN_WINDOW_SERVICENAME
constexpr OUStringLiteral AVMEDIA_WIN_WINDOW_IMPLEMENTATIONNAME