Update ooo320-m1
[ooovba.git] / vcl / source / window / mouseevent.cxx
blob7e675e4fc7c9b12c5db2a5bad631fba25b7c7f7f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: mouseevent.cxx,v $
10 * $Revision: 1.3 $
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 )
43 , mnMode( 0 )
44 , mnClicks( static_cast< USHORT >( rEvent.ClickCount ) )
45 , mnCode( 0 )
47 if( rEvent.Modifiers )
49 if( (rEvent.Modifiers & ::com::sun::star::awt::KeyModifier::SHIFT) != 0 )
50 mnCode |= KEY_SHIFT;
51 if( (rEvent.Modifiers & ::com::sun::star::awt::KeyModifier::MOD1) != 0 )
52 mnCode |= KEY_MOD1;
53 if( (rEvent.Modifiers & ::com::sun::star::awt::KeyModifier::MOD2) != 0 )
54 mnCode |= KEY_MOD2;
55 if( (rEvent.Modifiers & ::com::sun::star::awt::KeyModifier::MOD3) != 0 )
56 mnCode |= KEY_MOD3;
59 if( rEvent.Buttons )
61 if( (rEvent.Buttons & ::com::sun::star::awt::MouseButton::LEFT) != 0 )
62 mnCode |= MOUSE_LEFT;
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
73 rEvent.Modifiers = 0;
74 if ( IsShift() )
75 rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::SHIFT;
76 if ( IsMod1() )
77 rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD1;
78 if ( IsMod2() )
79 rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD2;
80 if ( IsMod3() )
81 rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD3;
83 rEvent.Buttons = 0;
84 if ( IsLeft() )
85 rEvent.Buttons |= ::com::sun::star::awt::MouseButton::LEFT;
86 if ( IsRight() )
87 rEvent.Buttons |= ::com::sun::star::awt::MouseButton::RIGHT;
88 if ( IsMiddle() )
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;