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: mouseevent.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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #include <com/sun/star/awt/MouseEvent.hpp>
35 #include <com/sun/star/awt/KeyModifier.hpp>
36 #include <com/sun/star/awt/MouseButton.hpp>
37 #include <tools/debug.hxx>
38 #include <vcl/event.hxx>
40 /** inits this vcl KeyEvent with all settings from the given awt event **/
41 MouseEvent::MouseEvent( const ::com::sun::star::awt::MouseEvent
& rEvent
)
42 : maPos( rEvent
.X
, rEvent
.Y
)
44 , mnClicks( static_cast< USHORT
>( rEvent
.ClickCount
) )
47 if( rEvent
.Modifiers
)
49 if( (rEvent
.Modifiers
& ::com::sun::star::awt::KeyModifier::SHIFT
) != 0 )
51 if( (rEvent
.Modifiers
& ::com::sun::star::awt::KeyModifier::MOD1
) != 0 )
53 if( (rEvent
.Modifiers
& ::com::sun::star::awt::KeyModifier::MOD2
) != 0 )
55 if( (rEvent
.Modifiers
& ::com::sun::star::awt::KeyModifier::MOD3
) != 0 )
61 if( (rEvent
.Buttons
& ::com::sun::star::awt::MouseButton::LEFT
) != 0 )
63 if( (rEvent
.Buttons
& ::com::sun::star::awt::MouseButton::RIGHT
) != 0 )
64 mnCode
|= MOUSE_RIGHT
;
65 if( (rEvent
.Buttons
& ::com::sun::star::awt::MouseButton::MIDDLE
) != 0 )
66 mnCode
|= MOUSE_MIDDLE
;
70 /** fills out the given awt KeyEvent with all settings from this vcl event **/
71 void MouseEvent::InitMouseEvent( ::com::sun::star::awt::MouseEvent
& rEvent
) const
75 rEvent
.Modifiers
|= ::com::sun::star::awt::KeyModifier::SHIFT
;
77 rEvent
.Modifiers
|= ::com::sun::star::awt::KeyModifier::MOD1
;
79 rEvent
.Modifiers
|= ::com::sun::star::awt::KeyModifier::MOD2
;
81 rEvent
.Modifiers
|= ::com::sun::star::awt::KeyModifier::MOD3
;
85 rEvent
.Buttons
|= ::com::sun::star::awt::MouseButton::LEFT
;
87 rEvent
.Buttons
|= ::com::sun::star::awt::MouseButton::RIGHT
;
89 rEvent
.Buttons
|= ::com::sun::star::awt::MouseButton::MIDDLE
;
91 rEvent
.X
= GetPosPixel().X();
92 rEvent
.Y
= GetPosPixel().Y();
93 rEvent
.ClickCount
= GetClicks();
94 rEvent
.PopupTrigger
= sal_False
;