1/*
2 * Copyright 1999-2009 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Jeremy Friesner
7 */
8#ifndef MetaKeyStateMap_h
9#define MetaKeyStateMap_h
10
11
12#include <List.h>
13#include <SupportDefs.h>
14
15
16class BitFieldTester;
17
18
19// This class defines a set of possible chording states (e.g. "Left only",
20// "Right only", "Both", "Either") for a meta-key (e.g. Shift), and the
21// description strings and qualifier bit-chords that go with them.
22class MetaKeyStateMap {
23public:
24
25			// Note: You MUST call SetInfo() directly after using this ctor!
26							MetaKeyStateMap();
27
28			// Creates a MetaKeyStateMap with the give name
29			// (e.g. "Shift" or "Ctrl")
30							MetaKeyStateMap(const char* keyName);
31
32
33							~MetaKeyStateMap();
34
35			// For when you have to use the default ctor
36			void			SetInfo(const char* keyName);
37
38			// (tester) becomes property of this map!
39			void			AddState(const char* desc,
40								const BitFieldTester* tester);
41
42			// Returns the name of the meta-key (e.g. "Ctrl")
43	const	char*			GetName() const;
44
45			// Returns the number of possible states contained in this
46			// MetaKeyStateMap.
47			int				GetNumStates() const;
48
49			// Returns a BitFieldTester that tests for the nth state's
50			// presence.
51	const	BitFieldTester*	GetNthStateTester(int stateNum) const;
52
53			// Returns a textual description of the nth state (e.g. "Left")
54	const	char*			GetNthStateDesc(int stateNum) const;
55
56private:
57			// e.g. "Alt" or "Ctrl"
58			char*			fKeyName;
59
60			// list of strings e.g. "Left" or "Both"
61			BList			fStateDescs;
62
63			// list of BitFieldTesters for testing bits of modifiers in state
64			BList			fStateTesters;
65};
66
67
68#endif
69
70