xref: /haiku/src/preferences/keymap/Keymap.h (revision 1345706a9ff6ad0dc041339a02d4259998b0765d)
1 /*
2  * Copyright 2004-2010 Haiku Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Jérôme Duval
7  *		Axel Dörfler, axeld@pinc-software.de.
8  */
9 #ifndef KEYMAP_H
10 #define KEYMAP_H
11 
12 
13 #include <Keymap.h>
14 
15 #include <Entry.h>
16 #include <Messenger.h>
17 #include <String.h>
18 
19 
20 enum dead_key_index {
21 	kDeadKeyAcute = 1,
22 	kDeadKeyGrave,
23 	kDeadKeyCircumflex,
24 	kDeadKeyDiaeresis,
25 	kDeadKeyTilde
26 };
27 
28 
29 class Keymap : public BKeymap {
30 public:
31 							Keymap();
32 							~Keymap();
33 
34 			void			SetTarget(BMessenger target,
35 								BMessage* modificationMessage);
36 
37 			status_t		Load(entry_ref& ref);
38 			status_t		Save(entry_ref& ref);
39 
40 			void			DumpKeymap();
41 
42 			status_t		SetModifier(uint32 keyCode, uint32 modifier);
43 
44 			void			SetDeadKeyEnabled(uint32 keyCode, uint32 modifiers,
45 								bool enabled);
46 			void			GetDeadKeyTrigger(dead_key_index deadKeyIndex,
47 								BString& outTrigger);
48 			void			SetDeadKeyTrigger(dead_key_index deadKeyIndex,
49 								const BString& trigger);
50 
51 			status_t		Use();
52 
53 			void			SetKey(uint32 keyCode, uint32 modifiers,
54 								int8 deadKey, const char* bytes,
55 								int32 numBytes = -1);
56 
57 			void			SetName(const char* name);
58 
59 			const key_map&	Map() const { return fKeys; }
60 			key_map&		Map() { return fKeys; }
61 
62 			Keymap&			operator=(const Keymap& other);
63 
64 private:
65 			bool			_SetChars(int32 offset, const char* bytes,
66 								int32 numBytes);
67 
68 private:
69 			char			fName[B_FILE_NAME_LENGTH];
70 
71 			BMessenger		fTarget;
72 			BMessage*		fModificationMessage;
73 };
74 
75 
76 #endif	// KEYMAP_H
77