1*9f62ea84SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9f62ea84SAndrew Rist * distributed with this work for additional information 6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 10*9f62ea84SAndrew Rist * 11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*9f62ea84SAndrew Rist * 13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an 15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 17*9f62ea84SAndrew Rist * specific language governing permissions and limitations 18*9f62ea84SAndrew Rist * under the License. 19*9f62ea84SAndrew Rist * 20*9f62ea84SAndrew Rist *************************************************************/ 21*9f62ea84SAndrew Rist 22*9f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_vcl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/awt/MouseEvent.hpp> 28cdf0e10cSrcweir #include <com/sun/star/awt/KeyModifier.hpp> 29cdf0e10cSrcweir #include <com/sun/star/awt/MouseButton.hpp> 30cdf0e10cSrcweir #include <tools/debug.hxx> 31cdf0e10cSrcweir #include <vcl/event.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir /** inits this vcl KeyEvent with all settings from the given awt event **/ MouseEvent(const::com::sun::star::awt::MouseEvent & rEvent)34cdf0e10cSrcweirMouseEvent::MouseEvent( const ::com::sun::star::awt::MouseEvent& rEvent ) 35cdf0e10cSrcweir : maPos( rEvent.X, rEvent.Y ) 36cdf0e10cSrcweir , mnMode( 0 ) 37cdf0e10cSrcweir , mnClicks( static_cast< sal_uInt16 >( rEvent.ClickCount ) ) 38cdf0e10cSrcweir , mnCode( 0 ) 39cdf0e10cSrcweir { 40cdf0e10cSrcweir if( rEvent.Modifiers ) 41cdf0e10cSrcweir { 42cdf0e10cSrcweir if( (rEvent.Modifiers & ::com::sun::star::awt::KeyModifier::SHIFT) != 0 ) 43cdf0e10cSrcweir mnCode |= KEY_SHIFT; 44cdf0e10cSrcweir if( (rEvent.Modifiers & ::com::sun::star::awt::KeyModifier::MOD1) != 0 ) 45cdf0e10cSrcweir mnCode |= KEY_MOD1; 46cdf0e10cSrcweir if( (rEvent.Modifiers & ::com::sun::star::awt::KeyModifier::MOD2) != 0 ) 47cdf0e10cSrcweir mnCode |= KEY_MOD2; 48cdf0e10cSrcweir if( (rEvent.Modifiers & ::com::sun::star::awt::KeyModifier::MOD3) != 0 ) 49cdf0e10cSrcweir mnCode |= KEY_MOD3; 50cdf0e10cSrcweir } 51cdf0e10cSrcweir 52cdf0e10cSrcweir if( rEvent.Buttons ) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir if( (rEvent.Buttons & ::com::sun::star::awt::MouseButton::LEFT) != 0 ) 55cdf0e10cSrcweir mnCode |= MOUSE_LEFT; 56cdf0e10cSrcweir if( (rEvent.Buttons & ::com::sun::star::awt::MouseButton::RIGHT) != 0 ) 57cdf0e10cSrcweir mnCode |= MOUSE_RIGHT; 58cdf0e10cSrcweir if( (rEvent.Buttons & ::com::sun::star::awt::MouseButton::MIDDLE) != 0 ) 59cdf0e10cSrcweir mnCode |= MOUSE_MIDDLE; 60cdf0e10cSrcweir } 61cdf0e10cSrcweir } 62cdf0e10cSrcweir 63cdf0e10cSrcweir /** fills out the given awt KeyEvent with all settings from this vcl event **/ InitMouseEvent(::com::sun::star::awt::MouseEvent & rEvent) const64cdf0e10cSrcweirvoid MouseEvent::InitMouseEvent( ::com::sun::star::awt::MouseEvent& rEvent ) const 65cdf0e10cSrcweir { 66cdf0e10cSrcweir rEvent.Modifiers = 0; 67cdf0e10cSrcweir if ( IsShift() ) 68cdf0e10cSrcweir rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::SHIFT; 69cdf0e10cSrcweir if ( IsMod1() ) 70cdf0e10cSrcweir rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD1; 71cdf0e10cSrcweir if ( IsMod2() ) 72cdf0e10cSrcweir rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD2; 73cdf0e10cSrcweir if ( IsMod3() ) 74cdf0e10cSrcweir rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD3; 75cdf0e10cSrcweir 76cdf0e10cSrcweir rEvent.Buttons = 0; 77cdf0e10cSrcweir if ( IsLeft() ) 78cdf0e10cSrcweir rEvent.Buttons |= ::com::sun::star::awt::MouseButton::LEFT; 79cdf0e10cSrcweir if ( IsRight() ) 80cdf0e10cSrcweir rEvent.Buttons |= ::com::sun::star::awt::MouseButton::RIGHT; 81cdf0e10cSrcweir if ( IsMiddle() ) 82cdf0e10cSrcweir rEvent.Buttons |= ::com::sun::star::awt::MouseButton::MIDDLE; 83cdf0e10cSrcweir 84cdf0e10cSrcweir rEvent.X = GetPosPixel().X(); 85cdf0e10cSrcweir rEvent.Y = GetPosPixel().Y(); 86cdf0e10cSrcweir rEvent.ClickCount = GetClicks(); 87cdf0e10cSrcweir rEvent.PopupTrigger = sal_False; 88cdf0e10cSrcweir } 89