1 /* 2 * Copyright 1999-2009 Jeremy Friesner 3 * Copyright 2009 Haiku, Inc. All rights reserved. 4 * Distributed under the terms of the MIT License. 5 * 6 * Authors: 7 * Jeremy Friesner 8 */ 9 #ifndef META_KEY_STATE_MAP_H 10 #define META_KEY_STATE_MAP_H 11 12 13 #include <List.h> 14 #include <SupportDefs.h> 15 16 17 class BitFieldTester; 18 19 20 // This class defines a set of possible chording states (e.g. "Left only", 21 // "Right only", "Both", "Either") for a meta-key (e.g. Shift), and the 22 // description strings and qualifier bit-chords that go with them. 23 class MetaKeyStateMap { 24 public: 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 56 private: 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 // META_KEY_STATE_MAP_H 69