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/KeyEvent.hpp>
28cdf0e10cSrcweir #include <com/sun/star/awt/KeyModifier.hpp>
29cdf0e10cSrcweir #include <tools/debug.hxx>
30cdf0e10cSrcweir #include <vcl/event.hxx>
31cdf0e10cSrcweir
KeyEvent(const KeyEvent & rKeyEvent)32cdf0e10cSrcweir KeyEvent::KeyEvent (const KeyEvent& rKeyEvent) :
33cdf0e10cSrcweir maKeyCode (rKeyEvent.maKeyCode),
34cdf0e10cSrcweir mnRepeat (rKeyEvent.mnRepeat),
35cdf0e10cSrcweir mnCharCode(rKeyEvent.mnCharCode)
36cdf0e10cSrcweir {}
37cdf0e10cSrcweir
38cdf0e10cSrcweir /** inits this vcl KeyEvent with all settings from the given awt event **/
KeyEvent(const::com::sun::star::awt::KeyEvent & rEvent)39cdf0e10cSrcweir KeyEvent::KeyEvent( const ::com::sun::star::awt::KeyEvent& rEvent )
40cdf0e10cSrcweir {
41cdf0e10cSrcweir maKeyCode = KeyCode(
42cdf0e10cSrcweir rEvent.KeyCode,
43cdf0e10cSrcweir (rEvent.Modifiers & ::com::sun::star::awt::KeyModifier::SHIFT) != 0,
44cdf0e10cSrcweir (rEvent.Modifiers & ::com::sun::star::awt::KeyModifier::MOD1) != 0,
45cdf0e10cSrcweir (rEvent.Modifiers & ::com::sun::star::awt::KeyModifier::MOD2) != 0,
46cdf0e10cSrcweir (rEvent.Modifiers & ::com::sun::star::awt::KeyModifier::MOD3) != 0);
47cdf0e10cSrcweir mnRepeat = 0;
48cdf0e10cSrcweir mnCharCode = rEvent.KeyChar;
49cdf0e10cSrcweir }
50cdf0e10cSrcweir
51cdf0e10cSrcweir /** fills out the given awt KeyEvent with all settings from this vcl event **/
InitKeyEvent(::com::sun::star::awt::KeyEvent & rEvent) const52cdf0e10cSrcweir void KeyEvent::InitKeyEvent( ::com::sun::star::awt::KeyEvent& rEvent ) const
53cdf0e10cSrcweir {
54cdf0e10cSrcweir rEvent.Modifiers = 0;
55cdf0e10cSrcweir if( GetKeyCode().IsShift() )
56cdf0e10cSrcweir rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::SHIFT;
57cdf0e10cSrcweir if( GetKeyCode().IsMod1() )
58cdf0e10cSrcweir rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD1;
59cdf0e10cSrcweir if( GetKeyCode().IsMod2() )
60cdf0e10cSrcweir rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD2;
61cdf0e10cSrcweir if( GetKeyCode().IsMod3() )
62cdf0e10cSrcweir rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD3;
63cdf0e10cSrcweir
64cdf0e10cSrcweir rEvent.KeyCode = GetKeyCode().GetCode();
65cdf0e10cSrcweir rEvent.KeyChar = GetCharCode();
66cdf0e10cSrcweir rEvent.KeyFunc = sal::static_int_cast< sal_Int16 >(GetKeyCode().GetFunction());
67cdf0e10cSrcweir }
68cdf0e10cSrcweir
LogicalTextDirectionality(TextDirectionality eMode) const69cdf0e10cSrcweir KeyEvent KeyEvent::LogicalTextDirectionality (TextDirectionality eMode) const
70cdf0e10cSrcweir {
71cdf0e10cSrcweir KeyEvent aClone(*this);
72cdf0e10cSrcweir
73cdf0e10cSrcweir sal_uInt16 nCode = maKeyCode.GetCode();
74cdf0e10cSrcweir sal_uInt16 nMod = maKeyCode.GetAllModifier();
75cdf0e10cSrcweir
76cdf0e10cSrcweir switch (eMode)
77cdf0e10cSrcweir {
78cdf0e10cSrcweir case TextDirectionality_RightToLeft_TopToBottom:
79cdf0e10cSrcweir switch (nCode)
80cdf0e10cSrcweir {
81cdf0e10cSrcweir case KEY_LEFT: aClone.maKeyCode = KeyCode(KEY_RIGHT, nMod); break;
82cdf0e10cSrcweir case KEY_RIGHT: aClone.maKeyCode = KeyCode(KEY_LEFT, nMod); break;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir break;
85cdf0e10cSrcweir
86cdf0e10cSrcweir case TextDirectionality_TopToBottom_RightToLeft:
87cdf0e10cSrcweir switch (nCode)
88cdf0e10cSrcweir {
89cdf0e10cSrcweir case KEY_DOWN: aClone.maKeyCode = KeyCode(KEY_RIGHT, nMod); break;
90cdf0e10cSrcweir case KEY_UP: aClone.maKeyCode = KeyCode(KEY_LEFT, nMod); break;
91cdf0e10cSrcweir case KEY_LEFT: aClone.maKeyCode = KeyCode(KEY_DOWN, nMod); break;
92cdf0e10cSrcweir case KEY_RIGHT: aClone.maKeyCode = KeyCode(KEY_UP, nMod); break;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir break;
95cdf0e10cSrcweir
96cdf0e10cSrcweir case TextDirectionality_LeftToRight_TopToBottom:
97cdf0e10cSrcweir /* do nothing */
98cdf0e10cSrcweir break;
99cdf0e10cSrcweir }
100cdf0e10cSrcweir
101cdf0e10cSrcweir return aClone;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
104cdf0e10cSrcweir
105cdf0e10cSrcweir // -------------------------------------------------------
106cdf0e10cSrcweir
GetMousePosPixel() const107cdf0e10cSrcweir const Point& HelpEvent::GetMousePosPixel() const
108cdf0e10cSrcweir {
109cdf0e10cSrcweir //DBG_ASSERT( !mbKeyboardActivated, "Keyboard help has no mouse position !");
110cdf0e10cSrcweir return maPos;
111cdf0e10cSrcweir }
112cdf0e10cSrcweir
113