1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_KEYCOD_HXX
21 #define INCLUDED_VCL_KEYCOD_HXX
23 #include <rtl/ustring.hxx>
24 #include <tools/resid.hxx>
25 #include <vcl/dllapi.h>
26 #include <vcl/keycodes.hxx>
27 #include <vcl/vclenum.hxx>
31 class VCL_DLLPUBLIC KeyCode
38 KeyCode() { nCode
= 0; eFunc
= KEYFUNC_DONTKNOW
; }
39 KeyCode( const ResId
& rResId
);
40 KeyCode( sal_uInt16 nKey
, sal_uInt16 nModifier
= 0 )
41 { nCode
= nKey
| nModifier
; eFunc
= KEYFUNC_DONTKNOW
; }
42 KeyCode( sal_uInt16 nKey
, bool bShift
, bool bMod1
, bool bMod2
, bool bMod3
);
43 KeyCode( KeyFuncType eFunction
);
45 sal_uInt16
GetFullCode() const { return nCode
; }
46 KeyFuncType
GetFullFunction() const { return eFunc
; }
47 bool IsDefinedKeyCodeEqual( const KeyCode
& rKeyCode
) const;
49 sal_uInt16
GetCode() const
50 { return (nCode
& KEY_CODE
); }
52 sal_uInt16
GetModifier() const
53 { return (nCode
& KEY_MODTYPE
); }
54 sal_uInt16
GetAllModifier() const
55 { return (nCode
& KEY_ALLMODTYPE
); }
57 { return ((nCode
& KEY_SHIFT
) != 0); }
59 { return ((nCode
& KEY_MOD1
) != 0); }
61 { return ((nCode
& KEY_MOD2
) != 0); }
63 { return ((nCode
& KEY_MOD3
) != 0); }
64 sal_uInt16
GetGroup() const
65 { return (nCode
& KEYGROUP_TYPE
); }
67 OUString
GetName( Window
* pWindow
= NULL
) const;
69 bool IsFunction() const
70 { return (eFunc
!= KEYFUNC_DONTKNOW
); }
72 KeyFuncType
GetFunction() const;
74 KeyCode
& operator = ( const KeyCode
& rKeyCode
);
75 bool operator ==( const KeyCode
& rKeyCode
) const;
76 bool operator !=( const KeyCode
& rKeyCode
) const;
79 inline KeyCode::KeyCode( sal_uInt16 nKey
, bool bShift
, bool bMod1
, bool bMod2
, bool bMod3
)
90 eFunc
= KEYFUNC_DONTKNOW
;
93 inline bool KeyCode::operator ==( const KeyCode
& rKeyCode
) const
95 if ( (eFunc
== KEYFUNC_DONTKNOW
) && (rKeyCode
.eFunc
== KEYFUNC_DONTKNOW
) )
96 return (nCode
== rKeyCode
.nCode
);
98 return (GetFunction() == rKeyCode
.GetFunction());
101 inline bool KeyCode::operator !=( const KeyCode
& rKeyCode
) const
103 if ( (eFunc
== KEYFUNC_DONTKNOW
) && (rKeyCode
.eFunc
== KEYFUNC_DONTKNOW
) )
104 return (nCode
!= rKeyCode
.nCode
);
106 return (GetFunction() != rKeyCode
.GetFunction());
109 inline bool KeyCode::IsDefinedKeyCodeEqual( const KeyCode
& rKeyCode
) const
111 if ( (eFunc
== KEYFUNC_DONTKNOW
) && (rKeyCode
.eFunc
== KEYFUNC_DONTKNOW
) )
112 return (GetFullCode() == rKeyCode
.GetFullCode());
113 return (GetFunction() == rKeyCode
.GetFunction());
116 inline KeyCode
& KeyCode::operator = ( const KeyCode
& rKeyCode
)
118 nCode
= rKeyCode
.nCode
;
119 eFunc
= rKeyCode
.eFunc
;
124 #endif // INCLUDED_VCL_KEYCOD_HXX
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */