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