]> git.lyx.org Git - lyx.git/blob - src/frontends/KeySymbol.h
set eol-style.
[lyx.git] / src / frontends / KeySymbol.h
1 // -*- C++ -*-
2 /**
3  * \file KeySymbol.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Asger and Jürgen
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef KEYSYMBOL_H
13 #define KEYSYMBOL_H
14
15 #include <string>
16
17 #include "key_state.h"
18
19 #include "support/docstring.h"
20
21
22 namespace lyx {
23
24 /**
25  * This is a class representing a keypress.
26  */
27 class KeySymbol
28 {
29 public:
30         KeySymbol() : key_(0) {}
31
32         ///
33         bool operator==(KeySymbol const & ks) const;
34
35         /// Initialize with the name of a key. F. ex. "space" or "a"
36         void init(std::string const & symbolname);
37
38         /// Is this a valid key?
39         bool isOK() const;
40
41         /// Is this a modifier key only?
42         bool isModifier() const;
43
44         /// Is this normal insertable text ? (last ditch attempt only)
45         bool isText() const;
46
47         /// What is the symbolic name of this key? F.ex. "Return" or "c"
48         std::string getSymbolName() const;
49
50         /**
51          * Return the value of the keysym into the UCS-4 encoding.
52          * This converts the KeySymbol to a 32-bit encoded character.
53          */
54         char_type getUCSEncoded() const;
55
56         /**
57          * Return a string describing the KeySym with modifier mod.
58          * Use the native UI format when \c forgui is true.
59          * i.e. (translated and with special characters for Mac OS X)
60          */
61         docstring const print(key_modifier::state mod, bool forgui) const;
62
63         ///
64         int key() const { return key_; }
65         ///
66         void setKey(int key) { key_ = key; }
67         ///
68         docstring text() const { return text_; }
69         ///
70         void setText(docstring const & text) { text_ = text; }
71 private:
72         /// some platform specific sym value
73         int key_;
74         /// the event string value
75         docstring text_;
76 };
77
78
79 } // namespace lyx
80
81 #endif