1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: mediaevent_impl.cxx,v $
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 "mediaevent_impl.hxx"
32 #include "mediawindow_impl.hxx"
33 #include <osl/mutex.hxx>
34 #include <vos/mutex.hxx>
35 #include <vcl/svapp.hxx>
36 #include <vcl/event.hxx>
38 using namespace ::com::sun::star
;
40 /* Definition of MediaWindowImpl class */
42 namespace avmedia
{ namespace priv
{
43 // ---------------------------
44 // - MediaEventListenersImpl -
45 // ---------------------------
47 MediaEventListenersImpl::MediaEventListenersImpl( Window
& rEventWindow
) :
48 mpNotifyWindow( &rEventWindow
)
52 // ---------------------------------------------------------------------
54 MediaEventListenersImpl::~MediaEventListenersImpl()
58 // ---------------------------------------------------------------------
60 void MediaEventListenersImpl::cleanUp()
62 Application::RemoveMouseAndKeyEvents( reinterpret_cast< ::Window
* >( mpNotifyWindow
) );
63 mpNotifyWindow
= NULL
;
66 // ---------------------------------------------------------------------
68 void SAL_CALL
MediaEventListenersImpl::disposing( const ::com::sun::star::lang::EventObject
& /* Source */ )
69 throw (::com::sun::star::uno::RuntimeException
)
73 // ---------------------------------------------------------------------
75 void SAL_CALL
MediaEventListenersImpl::keyPressed( const ::com::sun::star::awt::KeyEvent
& e
)
76 throw (::com::sun::star::uno::RuntimeException
)
78 const ::osl::MutexGuard
aGuard( maMutex
);
79 const ::vos::OGuard
aAppGuard( Application::GetSolarMutex() );
83 KeyCode
aVCLKeyCode( e
.KeyCode
,
84 ( ( e
.Modifiers
& 1 ) ? KEY_SHIFT
: 0 ) |
85 ( ( e
.Modifiers
& 2 ) ? KEY_MOD1
: 0 ) |
86 ( ( e
.Modifiers
& 4 ) ? KEY_MOD2
: 0 ) );
87 KeyEvent
aVCLKeyEvt( e
.KeyChar
, aVCLKeyCode
);
89 Application::PostKeyEvent( VCLEVENT_WINDOW_KEYINPUT
, reinterpret_cast< ::Window
* >( mpNotifyWindow
), &aVCLKeyEvt
);
93 // ---------------------------------------------------------------------
95 void SAL_CALL
MediaEventListenersImpl::keyReleased( const ::com::sun::star::awt::KeyEvent
& e
)
96 throw (::com::sun::star::uno::RuntimeException
)
98 const ::osl::MutexGuard
aGuard( maMutex
);
99 const ::vos::OGuard
aAppGuard( Application::GetSolarMutex() );
103 KeyCode
aVCLKeyCode( e
.KeyCode
,
104 ( ( e
.Modifiers
& 1 ) ? KEY_SHIFT
: 0 ) |
105 ( ( e
.Modifiers
& 2 ) ? KEY_MOD1
: 0 ) |
106 ( ( e
.Modifiers
& 4 ) ? KEY_MOD2
: 0 ) );
107 KeyEvent
aVCLKeyEvt( e
.KeyChar
, aVCLKeyCode
);
108 Application::PostKeyEvent( VCLEVENT_WINDOW_KEYUP
, reinterpret_cast< ::Window
* >( mpNotifyWindow
), &aVCLKeyEvt
);
112 // ---------------------------------------------------------------------
114 void SAL_CALL
MediaEventListenersImpl::mousePressed( const ::com::sun::star::awt::MouseEvent
& e
)
115 throw (::com::sun::star::uno::RuntimeException
)
117 const ::osl::MutexGuard
aGuard( maMutex
);
118 const ::vos::OGuard
aAppGuard( Application::GetSolarMutex() );
122 MouseEvent
aVCLMouseEvt( Point( e
.X
, e
.Y
),
123 sal::static_int_cast
< USHORT
>(e
.ClickCount
),
125 ( ( e
.Buttons
& 1 ) ? MOUSE_LEFT
: 0 ) |
126 ( ( e
.Buttons
& 2 ) ? MOUSE_RIGHT
: 0 ) |
127 ( ( e
.Buttons
& 4 ) ? MOUSE_MIDDLE
: 0 ),
129 Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONDOWN
, reinterpret_cast< ::Window
* >( mpNotifyWindow
), &aVCLMouseEvt
);
133 // ----------------------------------------------gvd-----------------------
135 void SAL_CALL
MediaEventListenersImpl::mouseReleased( const ::com::sun::star::awt::MouseEvent
& e
)
136 throw (::com::sun::star::uno::RuntimeException
)
138 const ::osl::MutexGuard
aGuard( maMutex
);
139 const ::vos::OGuard
aAppGuard( Application::GetSolarMutex() );
143 MouseEvent
aVCLMouseEvt( Point( e
.X
, e
.Y
),
144 sal::static_int_cast
< USHORT
>(e
.ClickCount
),
146 ( ( e
.Buttons
& 1 ) ? MOUSE_LEFT
: 0 ) |
147 ( ( e
.Buttons
& 2 ) ? MOUSE_RIGHT
: 0 ) |
148 ( ( e
.Buttons
& 4 ) ? MOUSE_MIDDLE
: 0 ),
150 Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONUP
, reinterpret_cast< ::Window
* >( mpNotifyWindow
), &aVCLMouseEvt
);
154 // ---------------------------------------------------------------------
156 void SAL_CALL
MediaEventListenersImpl::mouseEntered( const ::com::sun::star::awt::MouseEvent
& /* e */ )
157 throw (::com::sun::star::uno::RuntimeException
)
159 const ::osl::MutexGuard
aGuard( maMutex
);
160 const ::vos::OGuard
aAppGuard( Application::GetSolarMutex() );
167 // ---------------------------------------------------------------------
169 void SAL_CALL
MediaEventListenersImpl::mouseExited( const ::com::sun::star::awt::MouseEvent
& /* e */ )
170 throw (::com::sun::star::uno::RuntimeException
)
172 const ::osl::MutexGuard
aGuard( maMutex
);
173 const ::vos::OGuard
aAppGuard( Application::GetSolarMutex() );
180 // ---------------------------------------------------------------------
182 void SAL_CALL
MediaEventListenersImpl::mouseDragged( const ::com::sun::star::awt::MouseEvent
& e
)
183 throw (::com::sun::star::uno::RuntimeException
)
185 const ::osl::MutexGuard
aGuard( maMutex
);
186 const ::vos::OGuard
aAppGuard( Application::GetSolarMutex() );
190 MouseEvent
aVCLMouseEvt( Point( e
.X
, e
.Y
), 0, 0, e
.Buttons
, e
.Modifiers
);
191 Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE
, reinterpret_cast< ::Window
* >( mpNotifyWindow
), &aVCLMouseEvt
);
195 // ---------------------------------------------------------------------
197 void SAL_CALL
MediaEventListenersImpl::mouseMoved( const ::com::sun::star::awt::MouseEvent
& e
)
198 throw (::com::sun::star::uno::RuntimeException
)
200 const ::osl::MutexGuard
aGuard( maMutex
);
201 const ::vos::OGuard
aAppGuard( Application::GetSolarMutex() );
205 MouseEvent
aVCLMouseEvt( Point( e
.X
, e
.Y
), 0, 0, e
.Buttons
, e
.Modifiers
);
206 Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE
, reinterpret_cast< ::Window
* >( mpNotifyWindow
), &aVCLMouseEvt
);
210 // ---------------------------------------------------------------------
212 void SAL_CALL
MediaEventListenersImpl::focusGained( const ::com::sun::star::awt::FocusEvent
& /* e */ )
213 throw (::com::sun::star::uno::RuntimeException
)
217 // ---------------------------------------------------------------------
219 void SAL_CALL
MediaEventListenersImpl::focusLost( const ::com::sun::star::awt::FocusEvent
& /* e */ )
220 throw (::com::sun::star::uno::RuntimeException
)
225 } // namespace avemdia