1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "mediaevent_impl.hxx"
21 #include "mediawindow_impl.hxx"
22 #include <osl/mutex.hxx>
23 #include <vcl/svapp.hxx>
24 #include <vcl/event.hxx>
26 using namespace ::com::sun::star
;
28 /* Definition of MediaWindowImpl class */
30 namespace avmedia
{ namespace priv
{
31 // ---------------------------
32 // - MediaEventListenersImpl -
33 // ---------------------------
35 MediaEventListenersImpl::MediaEventListenersImpl( Window
& rEventWindow
) :
36 mpNotifyWindow( &rEventWindow
)
40 // ---------------------------------------------------------------------
42 MediaEventListenersImpl::~MediaEventListenersImpl()
46 // ---------------------------------------------------------------------
48 void MediaEventListenersImpl::cleanUp()
50 Application::RemoveMouseAndKeyEvents( reinterpret_cast< ::Window
* >( mpNotifyWindow
) );
51 mpNotifyWindow
= NULL
;
54 // ---------------------------------------------------------------------
56 void SAL_CALL
MediaEventListenersImpl::disposing( const ::com::sun::star::lang::EventObject
& /* Source */ )
57 throw (::com::sun::star::uno::RuntimeException
)
61 // ---------------------------------------------------------------------
63 void SAL_CALL
MediaEventListenersImpl::keyPressed( const ::com::sun::star::awt::KeyEvent
& e
)
64 throw (::com::sun::star::uno::RuntimeException
)
66 const ::osl::MutexGuard
aGuard( maMutex
);
67 const SolarMutexGuard aAppGuard
;
71 KeyCode
aVCLKeyCode( e
.KeyCode
,
72 ( ( e
.Modifiers
& 1 ) ? KEY_SHIFT
: 0 ) |
73 ( ( e
.Modifiers
& 2 ) ? KEY_MOD1
: 0 ) |
74 ( ( e
.Modifiers
& 4 ) ? KEY_MOD2
: 0 ) );
75 KeyEvent
aVCLKeyEvt( e
.KeyChar
, aVCLKeyCode
);
77 Application::PostKeyEvent( VCLEVENT_WINDOW_KEYINPUT
, reinterpret_cast< ::Window
* >( mpNotifyWindow
), &aVCLKeyEvt
);
81 // ---------------------------------------------------------------------
83 void SAL_CALL
MediaEventListenersImpl::keyReleased( const ::com::sun::star::awt::KeyEvent
& e
)
84 throw (::com::sun::star::uno::RuntimeException
)
86 const ::osl::MutexGuard
aGuard( maMutex
);
87 const SolarMutexGuard aAppGuard
;
91 KeyCode
aVCLKeyCode( e
.KeyCode
,
92 ( ( e
.Modifiers
& 1 ) ? KEY_SHIFT
: 0 ) |
93 ( ( e
.Modifiers
& 2 ) ? KEY_MOD1
: 0 ) |
94 ( ( e
.Modifiers
& 4 ) ? KEY_MOD2
: 0 ) );
95 KeyEvent
aVCLKeyEvt( e
.KeyChar
, aVCLKeyCode
);
96 Application::PostKeyEvent( VCLEVENT_WINDOW_KEYUP
, reinterpret_cast< ::Window
* >( mpNotifyWindow
), &aVCLKeyEvt
);
100 // ---------------------------------------------------------------------
102 void SAL_CALL
MediaEventListenersImpl::mousePressed( const ::com::sun::star::awt::MouseEvent
& e
)
103 throw (::com::sun::star::uno::RuntimeException
)
105 const ::osl::MutexGuard
aGuard( maMutex
);
106 const SolarMutexGuard aAppGuard
;
110 MouseEvent
aVCLMouseEvt( Point( e
.X
, e
.Y
),
111 sal::static_int_cast
< sal_uInt16
>(e
.ClickCount
),
113 ( ( e
.Buttons
& 1 ) ? MOUSE_LEFT
: 0 ) |
114 ( ( e
.Buttons
& 2 ) ? MOUSE_RIGHT
: 0 ) |
115 ( ( e
.Buttons
& 4 ) ? MOUSE_MIDDLE
: 0 ),
117 Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONDOWN
, reinterpret_cast< ::Window
* >( mpNotifyWindow
), &aVCLMouseEvt
);
121 // ----------------------------------------------gvd-----------------------
123 void SAL_CALL
MediaEventListenersImpl::mouseReleased( const ::com::sun::star::awt::MouseEvent
& e
)
124 throw (::com::sun::star::uno::RuntimeException
)
126 const ::osl::MutexGuard
aGuard( maMutex
);
127 const SolarMutexGuard aAppGuard
;
131 MouseEvent
aVCLMouseEvt( Point( e
.X
, e
.Y
),
132 sal::static_int_cast
< sal_uInt16
>(e
.ClickCount
),
134 ( ( e
.Buttons
& 1 ) ? MOUSE_LEFT
: 0 ) |
135 ( ( e
.Buttons
& 2 ) ? MOUSE_RIGHT
: 0 ) |
136 ( ( e
.Buttons
& 4 ) ? MOUSE_MIDDLE
: 0 ),
138 Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONUP
, reinterpret_cast< ::Window
* >( mpNotifyWindow
), &aVCLMouseEvt
);
142 // ---------------------------------------------------------------------
144 void SAL_CALL
MediaEventListenersImpl::mouseEntered( const ::com::sun::star::awt::MouseEvent
& /* e */ )
145 throw (::com::sun::star::uno::RuntimeException
)
147 const ::osl::MutexGuard
aGuard( maMutex
);
148 const SolarMutexGuard aAppGuard
;
155 // ---------------------------------------------------------------------
157 void SAL_CALL
MediaEventListenersImpl::mouseExited( const ::com::sun::star::awt::MouseEvent
& /* e */ )
158 throw (::com::sun::star::uno::RuntimeException
)
160 const ::osl::MutexGuard
aGuard( maMutex
);
161 const SolarMutexGuard aAppGuard
;
168 // ---------------------------------------------------------------------
170 void SAL_CALL
MediaEventListenersImpl::mouseDragged( const ::com::sun::star::awt::MouseEvent
& e
)
171 throw (::com::sun::star::uno::RuntimeException
)
173 const ::osl::MutexGuard
aGuard( maMutex
);
174 const SolarMutexGuard aAppGuard
;
178 MouseEvent
aVCLMouseEvt( Point( e
.X
, e
.Y
), 0, 0, e
.Buttons
, e
.Modifiers
);
179 Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE
, reinterpret_cast< ::Window
* >( mpNotifyWindow
), &aVCLMouseEvt
);
183 // ---------------------------------------------------------------------
185 void SAL_CALL
MediaEventListenersImpl::mouseMoved( const ::com::sun::star::awt::MouseEvent
& e
)
186 throw (::com::sun::star::uno::RuntimeException
)
188 const ::osl::MutexGuard
aGuard( maMutex
);
189 const SolarMutexGuard aAppGuard
;
193 MouseEvent
aVCLMouseEvt( Point( e
.X
, e
.Y
), 0, 0, e
.Buttons
, e
.Modifiers
);
194 Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE
, reinterpret_cast< ::Window
* >( mpNotifyWindow
), &aVCLMouseEvt
);
198 // ---------------------------------------------------------------------
200 void SAL_CALL
MediaEventListenersImpl::focusGained( const ::com::sun::star::awt::FocusEvent
& /* e */ )
201 throw (::com::sun::star::uno::RuntimeException
)
205 // ---------------------------------------------------------------------
207 void SAL_CALL
MediaEventListenersImpl::focusLost( const ::com::sun::star::awt::FocusEvent
& /* e */ )
208 throw (::com::sun::star::uno::RuntimeException
)
213 } // namespace avemdia
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */