OpenASIP 2.2
Loading...
Searching...
No Matches
KeyboardShortcut.hh
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file KeyboardShortcut.hh
26 *
27 * Declaration of KeyboardShortcut class.
28 *
29 * @author Lasse Laasonen 2003 (lasse.laasonen-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#ifndef TTA_KEYBOARD_SHORTCUT_HH
34#define TTA_KEYBOARD_SHORTCUT_HH
35
36#include <string>
37
38#include "Serializable.hh"
39#include "Exception.hh"
40
41/**
42 * This class stores the keyboard buttons used in a keyboard
43 * shortcut.
44 *
45 * It contains also the name of the action performed by the
46 * key combination. This class implements the Serializable interface
47 * because keyboard shortcuts are serialized into the configuration
48 * file.
49 */
51public:
52 /// ObjectState name for keyboard shortcut.
53 static const std::string OSNAME_KEYBOARD_SHORTCUT;
54 /// ObjectState attribute key for action name.
55 static const std::string OSKEY_ACTION;
56 /// ObjectState attribute key for function key number.
57 static const std::string OSKEY_FKEY;
58 /// ObjectState attribute key for ctrl key.
59 static const std::string OSKEY_CTRL;
60 /// ObjectState attribute key for alt key.
61 static const std::string OSKEY_ALT;
62 /// ObjectState attribute key for normal letter or number key.
63 static const std::string OSKEY_KEY;
64
66 const std::string& action,
67 int fKey,
68 bool ctrl,
69 bool alt,
70 char key);
71 KeyboardShortcut(const ObjectState* state);
73 virtual ~KeyboardShortcut();
74
75 std::string action() const;
76 int fKey() const;
77 bool ctrl() const;
78 bool alt() const;
79 char key() const;
80
81 void setFKey(int fKey);
82 void setCtrl(bool ctrl);
83 void setAlt(bool alt);
84 void setKey(char key);
85
86 bool equals(const KeyboardShortcut& sc) const;
87
88 void loadState(const ObjectState* state);
89 ObjectState* saveState() const;
90
91private:
92 /// Name of the action which is performed by the key combination.
93 std::string action_;
94 /// Number of the function key if it is used, 0 otherwise
95 int fKey_;
96 /// True if Ctrl button is used in the key combination.
97 bool ctrl_;
98 /// True if Alt button is used in the key combination.
99 bool alt_;
100 /**
101 * ASCII character of the button used in the key combination, if the
102 * key is not used the value is a NUL character (ASCII 0).
103 */
104 char key_;
105
106 /// Assigment forbidden.
108};
109
110#endif
bool equals(const KeyboardShortcut &sc) const
bool alt_
True if Alt button is used in the key combination.
static const std::string OSKEY_KEY
ObjectState attribute key for normal letter or number key.
KeyboardShortcut & operator=(const KeyboardShortcut)
Assigment forbidden.
bool ctrl_
True if Ctrl button is used in the key combination.
static const std::string OSKEY_ALT
ObjectState attribute key for alt key.
int fKey_
Number of the function key if it is used, 0 otherwise.
void loadState(const ObjectState *state)
void setFKey(int fKey)
std::string action() const
static const std::string OSKEY_FKEY
ObjectState attribute key for function key number.
void setAlt(bool alt)
void setCtrl(bool ctrl)
static const std::string OSKEY_ACTION
ObjectState attribute key for action name.
static const std::string OSKEY_CTRL
ObjectState attribute key for ctrl key.
ObjectState * saveState() const
std::string action_
Name of the action which is performed by the key combination.
void setKey(char key)
static const std::string OSNAME_KEYBOARD_SHORTCUT
ObjectState name for keyboard shortcut.