OpenASIP  2.0
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  */
51 public:
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 
91 private:
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
KeyboardShortcut::ctrl_
bool ctrl_
True if Ctrl button is used in the key combination.
Definition: KeyboardShortcut.hh:97
KeyboardShortcut::OSKEY_KEY
static const std::string OSKEY_KEY
ObjectState attribute key for normal letter or number key.
Definition: KeyboardShortcut.hh:63
KeyboardShortcut::OSKEY_ACTION
static const std::string OSKEY_ACTION
ObjectState attribute key for action name.
Definition: KeyboardShortcut.hh:55
KeyboardShortcut::OSNAME_KEYBOARD_SHORTCUT
static const std::string OSNAME_KEYBOARD_SHORTCUT
ObjectState name for keyboard shortcut.
Definition: KeyboardShortcut.hh:53
Exception.hh
KeyboardShortcut::key_
char key_
Definition: KeyboardShortcut.hh:104
Serializable
Definition: Serializable.hh:44
KeyboardShortcut::loadState
void loadState(const ObjectState *state)
Definition: KeyboardShortcut.cc:268
KeyboardShortcut::setKey
void setKey(char key)
Definition: KeyboardShortcut.cc:222
ObjectState
Definition: ObjectState.hh:59
KeyboardShortcut::operator=
KeyboardShortcut & operator=(const KeyboardShortcut)
Assigment forbidden.
KeyboardShortcut::key
char key() const
Definition: KeyboardShortcut.cc:190
KeyboardShortcut::~KeyboardShortcut
virtual ~KeyboardShortcut()
Definition: KeyboardShortcut.cc:127
KeyboardShortcut::OSKEY_ALT
static const std::string OSKEY_ALT
ObjectState attribute key for alt key.
Definition: KeyboardShortcut.hh:61
KeyboardShortcut::action_
std::string action_
Name of the action which is performed by the key combination.
Definition: KeyboardShortcut.hh:93
KeyboardShortcut::equals
bool equals(const KeyboardShortcut &sc) const
Definition: KeyboardShortcut.cc:250
KeyboardShortcut::action
std::string action() const
Definition: KeyboardShortcut.cc:137
KeyboardShortcut::OSKEY_CTRL
static const std::string OSKEY_CTRL
ObjectState attribute key for ctrl key.
Definition: KeyboardShortcut.hh:59
KeyboardShortcut::KeyboardShortcut
KeyboardShortcut(const std::string &action, int fKey, bool ctrl, bool alt, char key)
Definition: KeyboardShortcut.cc:60
KeyboardShortcut::setFKey
void setFKey(int fKey)
Definition: KeyboardShortcut.cc:233
KeyboardShortcut::fKey_
int fKey_
Number of the function key if it is used, 0 otherwise.
Definition: KeyboardShortcut.hh:95
Serializable.hh
KeyboardShortcut
Definition: KeyboardShortcut.hh:50
KeyboardShortcut::fKey
int fKey() const
Definition: KeyboardShortcut.cc:149
KeyboardShortcut::OSKEY_FKEY
static const std::string OSKEY_FKEY
ObjectState attribute key for function key number.
Definition: KeyboardShortcut.hh:57
KeyboardShortcut::alt_
bool alt_
True if Alt button is used in the key combination.
Definition: KeyboardShortcut.hh:99
KeyboardShortcut::saveState
ObjectState * saveState() const
Definition: KeyboardShortcut.cc:310
KeyboardShortcut::setAlt
void setAlt(bool alt)
Definition: KeyboardShortcut.cc:212
KeyboardShortcut::setCtrl
void setCtrl(bool ctrl)
Definition: KeyboardShortcut.cc:201
KeyboardShortcut::ctrl
bool ctrl() const
Definition: KeyboardShortcut.cc:165
KeyboardShortcut::alt
bool alt() const
Definition: KeyboardShortcut.cc:177