1 #pragma once
2 
3 #include "ieventmanager.h"
4 
5 #include "Event.h"
6 
7 #include <iostream>
8 
9 /* greebo: An Accelerator consists of a key/modifier combination plus a connected Event object.
10  *
11  * Use the match() method to test if the accelerator matches a certain key/modifier combination.
12  * Use the connectCommand() method to assign a command to this accelerator.
13  * Use the keyUp()/keyDown() methods to trigger the keyup/keydown command callbacks.
14  */
15 
16 class Accelerator :
17 	public IAccelerator
18 {
19 	// The internally stored key/modifier combination
20 	unsigned int _key;
21 	unsigned int _modifiers;
22 
23 	// The connected event
24 	IEvent* _event;
25 
26 public:
27 	// Constructor with no arguments
28 	Accelerator();
29 
30 	// Construct an accelerator with just the key/modifier combination
31 	Accelerator(const unsigned int& key, const unsigned int& modifiers);
32 
33 	// Construct an accelerator out of the key/modifier plus a command
34 	Accelerator(const unsigned int& key, const unsigned int& modifiers, IEvent* event);
35 
36 	// Returns true if the key/modifier combination matches this accelerator
37 	bool match(const unsigned int& key, const unsigned int& modifiers) const;
38 
39 	// Returns true if the event is attached to this Accelerator
40 	bool match(const IEvent* event) const;
41 
42 	// Reads out the interal key/modifier combination of this Accelerator
43 	unsigned int getKey() const;
44 	unsigned int getModifiers() const;
45 
46 	// Make the accelerator use this key/modifier
47 	void setKey(const unsigned int& key);
48 	void setModifiers(const unsigned int& modifiers);
49 
50 	// Connect this modifier to the specified command
51 	void connectEvent(IEvent* event);
52 
53 	// Retrieve the contained event pointer
54 	IEvent* getEvent();
55 
56 	// Call the connected event keyup/keydown callbacks
57 	void keyUp();
58 	void keyDown();
59 
60 }; // class Accelerator
61