1*0d63794cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*0d63794cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*0d63794cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*0d63794cSAndrew Rist * distributed with this work for additional information
6*0d63794cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*0d63794cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*0d63794cSAndrew Rist * "License"); you may not use this file except in compliance
9*0d63794cSAndrew Rist * with the License. You may obtain a copy of the License at
10*0d63794cSAndrew Rist *
11*0d63794cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*0d63794cSAndrew Rist *
13*0d63794cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*0d63794cSAndrew Rist * software distributed under the License is distributed on an
15*0d63794cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*0d63794cSAndrew Rist * KIND, either express or implied. See the License for the
17*0d63794cSAndrew Rist * specific language governing permissions and limitations
18*0d63794cSAndrew Rist * under the License.
19*0d63794cSAndrew Rist *
20*0d63794cSAndrew Rist *************************************************************/
21*0d63794cSAndrew Rist
22*0d63794cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef _SV_KEYCODE_HXX
25cdf0e10cSrcweir #define _SV_KEYCODE_HXX
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <tools/string.hxx>
28cdf0e10cSrcweir #include <vcl/sv.h>
29cdf0e10cSrcweir #include <vcl/dllapi.h>
30cdf0e10cSrcweir #include <tools/resid.hxx>
31cdf0e10cSrcweir #include <vcl/keycodes.hxx>
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include <vcl/vclenum.hxx>
34cdf0e10cSrcweir
35cdf0e10cSrcweir class Window;
36cdf0e10cSrcweir
37cdf0e10cSrcweir // -------------
38cdf0e10cSrcweir // - Key-Types -
39cdf0e10cSrcweir // -------------
40cdf0e10cSrcweir
41cdf0e10cSrcweir // Logische KeyFunktionen
42cdf0e10cSrcweir /*
43cdf0e10cSrcweir #ifndef ENUM_KEYFUNCTYPE_DECLARED
44cdf0e10cSrcweir #define ENUM_KEYFUNCTYPE_DECLARED
45cdf0e10cSrcweir enum KeyFuncType { KEYFUNC_DONTKNOW, KEYFUNC_NEW, KEYFUNC_OPEN,
46cdf0e10cSrcweir KEYFUNC_SAVE, KEYFUNC_SAVEAS, KEYFUNC_PRINT,
47cdf0e10cSrcweir KEYFUNC_CLOSE, KEYFUNC_QUIT,
48cdf0e10cSrcweir KEYFUNC_CUT, KEYFUNC_COPY, KEYFUNC_PASTE, KEYFUNC_UNDO,
49cdf0e10cSrcweir KEYFUNC_REDO, KEYFUNC_DELETE, KEYFUNC_REPEAT,
50cdf0e10cSrcweir KEYFUNC_FIND, KEYFUNC_FINDBACKWARD, KEYFUNC_PROPERTIES,
51cdf0e10cSrcweir KEYFUNC_FRONT };
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir */
54cdf0e10cSrcweir // -----------
55cdf0e10cSrcweir // - KeyCode -
56cdf0e10cSrcweir // -----------
57cdf0e10cSrcweir
58cdf0e10cSrcweir class VCL_DLLPUBLIC KeyCode
59cdf0e10cSrcweir {
60cdf0e10cSrcweir private:
61cdf0e10cSrcweir sal_uInt16 nCode;
62cdf0e10cSrcweir KeyFuncType eFunc;
63cdf0e10cSrcweir
64cdf0e10cSrcweir public:
KeyCode()65cdf0e10cSrcweir KeyCode() { nCode = 0; eFunc = KEYFUNC_DONTKNOW; }
66cdf0e10cSrcweir KeyCode( const ResId& rResId );
KeyCode(sal_uInt16 nKey,sal_uInt16 nModifier=0)67cdf0e10cSrcweir KeyCode( sal_uInt16 nKey, sal_uInt16 nModifier = 0 )
68cdf0e10cSrcweir { nCode = nKey | nModifier; eFunc = KEYFUNC_DONTKNOW; }
69cdf0e10cSrcweir KeyCode( sal_uInt16 nKey, sal_Bool bShift, sal_Bool bMod1, sal_Bool bMod2, sal_Bool bMod3 );
70cdf0e10cSrcweir KeyCode( KeyFuncType eFunction );
71cdf0e10cSrcweir
GetFullCode() const72cdf0e10cSrcweir sal_uInt16 GetFullCode() const { return nCode; }
GetFullKeyCode() const73cdf0e10cSrcweir sal_uInt16 GetFullKeyCode() const { return (nCode) ; }
GetFullFunction() const74cdf0e10cSrcweir KeyFuncType GetFullFunction() const { return eFunc; }
75cdf0e10cSrcweir sal_Bool IsDefinedKeyCodeEqual( const KeyCode& rKeyCode ) const;
76cdf0e10cSrcweir
GetCode() const77cdf0e10cSrcweir sal_uInt16 GetCode() const
78cdf0e10cSrcweir { return (nCode & KEY_CODE); }
79cdf0e10cSrcweir
GetModifier() const80cdf0e10cSrcweir sal_uInt16 GetModifier() const
81cdf0e10cSrcweir { return (nCode & KEY_MODTYPE); }
GetAllModifier() const82cdf0e10cSrcweir sal_uInt16 GetAllModifier() const
83cdf0e10cSrcweir { return (nCode & KEY_ALLMODTYPE); }
IsShift() const84cdf0e10cSrcweir sal_Bool IsShift() const
85cdf0e10cSrcweir { return ((nCode & KEY_SHIFT) != 0); }
IsMod1() const86cdf0e10cSrcweir sal_Bool IsMod1() const
87cdf0e10cSrcweir { return ((nCode & KEY_MOD1) != 0); }
IsMod2() const88cdf0e10cSrcweir sal_Bool IsMod2() const
89cdf0e10cSrcweir { return ((nCode & KEY_MOD2) != 0); }
IsMod3() const90cdf0e10cSrcweir sal_Bool IsMod3() const
91cdf0e10cSrcweir { return ((nCode & KEY_MOD3) != 0); }
GetGroup() const92cdf0e10cSrcweir sal_uInt16 GetGroup() const
93cdf0e10cSrcweir { return (nCode & KEYGROUP_TYPE); }
94cdf0e10cSrcweir
95cdf0e10cSrcweir XubString GetName( Window* pWindow = NULL ) const;
96cdf0e10cSrcweir XubString GetSymbolName( const XubString& rFontName, Window* pWindow = NULL ) const;
97cdf0e10cSrcweir
IsFunction() const98cdf0e10cSrcweir sal_Bool IsFunction() const
99cdf0e10cSrcweir { return ((eFunc != KEYFUNC_DONTKNOW) ? sal_True : sal_False); }
100cdf0e10cSrcweir
101cdf0e10cSrcweir KeyFuncType GetFunction() const;
102cdf0e10cSrcweir
103cdf0e10cSrcweir KeyCode& operator = ( const KeyCode& rKeyCode );
104cdf0e10cSrcweir sal_Bool operator ==( const KeyCode& rKeyCode ) const;
105cdf0e10cSrcweir sal_Bool operator !=( const KeyCode& rKeyCode ) const;
106cdf0e10cSrcweir };
107cdf0e10cSrcweir
KeyCode(sal_uInt16 nKey,sal_Bool bShift,sal_Bool bMod1,sal_Bool bMod2,sal_Bool bMod3)108cdf0e10cSrcweir inline KeyCode::KeyCode( sal_uInt16 nKey, sal_Bool bShift, sal_Bool bMod1, sal_Bool bMod2, sal_Bool bMod3 )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir nCode = nKey;
111cdf0e10cSrcweir if( bShift )
112cdf0e10cSrcweir nCode |= KEY_SHIFT;
113cdf0e10cSrcweir if( bMod1 )
114cdf0e10cSrcweir nCode |= KEY_MOD1;
115cdf0e10cSrcweir if( bMod2 )
116cdf0e10cSrcweir nCode |= KEY_MOD2;
117cdf0e10cSrcweir if( bMod3 )
118cdf0e10cSrcweir nCode |= KEY_MOD3;
119cdf0e10cSrcweir eFunc = KEYFUNC_DONTKNOW;
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
operator ==(const KeyCode & rKeyCode) const122cdf0e10cSrcweir inline sal_Bool KeyCode::operator ==( const KeyCode& rKeyCode ) const
123cdf0e10cSrcweir {
124cdf0e10cSrcweir if ( (eFunc == KEYFUNC_DONTKNOW) && (rKeyCode.eFunc == KEYFUNC_DONTKNOW) )
125cdf0e10cSrcweir return (nCode == rKeyCode.nCode);
126cdf0e10cSrcweir else
127cdf0e10cSrcweir return (GetFunction() == rKeyCode.GetFunction());
128cdf0e10cSrcweir }
129cdf0e10cSrcweir
operator !=(const KeyCode & rKeyCode) const130cdf0e10cSrcweir inline sal_Bool KeyCode::operator !=( const KeyCode& rKeyCode ) const
131cdf0e10cSrcweir {
132cdf0e10cSrcweir if ( (eFunc == KEYFUNC_DONTKNOW) && (rKeyCode.eFunc == KEYFUNC_DONTKNOW) )
133cdf0e10cSrcweir return (nCode != rKeyCode.nCode);
134cdf0e10cSrcweir else
135cdf0e10cSrcweir return (GetFunction() != rKeyCode.GetFunction());
136cdf0e10cSrcweir }
137cdf0e10cSrcweir
IsDefinedKeyCodeEqual(const KeyCode & rKeyCode) const138cdf0e10cSrcweir inline sal_Bool KeyCode::IsDefinedKeyCodeEqual( const KeyCode& rKeyCode ) const
139cdf0e10cSrcweir {
140cdf0e10cSrcweir if ( (eFunc == KEYFUNC_DONTKNOW) && (rKeyCode.eFunc == KEYFUNC_DONTKNOW) )
141cdf0e10cSrcweir return (GetFullKeyCode() == rKeyCode.GetFullKeyCode());
142cdf0e10cSrcweir return (GetFunction() == rKeyCode.GetFunction());
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
operator =(const KeyCode & rKeyCode)145cdf0e10cSrcweir inline KeyCode& KeyCode::operator = ( const KeyCode& rKeyCode )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir nCode = rKeyCode.nCode;
148cdf0e10cSrcweir eFunc = rKeyCode.eFunc;
149cdf0e10cSrcweir
150cdf0e10cSrcweir return *this;
151cdf0e10cSrcweir }
152cdf0e10cSrcweir
153cdf0e10cSrcweir #endif // _SV_KEYCODE_HXX
154