]> git.lyx.org Git - lyx.git/blob - src/frontends/KeySymbol.h
more latin1..utf8 schanges. all of src/* should be utf8 now
[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 "KeyModifier.h"
16
17 #include "support/docstring.h"
18
19
20 namespace lyx {
21
22 /**
23  * This is a class representing a keypress.
24  */
25 class KeySymbol
26 {
27 public:
28         KeySymbol() : key_(0) {}
29
30         ///
31         bool operator==(KeySymbol const & ks) const;
32
33         /// Initialize with the name of a key. F. ex. "space" or "a"
34         void init(std::string const & symbolname);
35
36         /// Is this a valid key?
37         bool isOK() const;
38
39         /// Is this a modifier key only?
40         bool isModifier() const;
41
42         /// Is this normal insertable text ? (last ditch attempt only)
43         bool isText() const;
44
45         /// What is the symbolic name of this key? F.ex. "Return" or "c"
46         std::string getSymbolName() const;
47
48         /**
49          * Return the value of the keysym into the UCS-4 encoding.
50          * This converts the KeySymbol to a 32-bit encoded character.
51          */
52         char_type getUCSEncoded() const;
53
54         /**
55          * Return a string describing the KeySym with modifier mod.
56          * Use the native UI format when \c forgui is true.
57          * i.e. (translated and with special characters for Mac OS X)
58          */
59         docstring const print(KeyModifier mod, bool forgui) const;
60
61         ///
62         int key() const { return key_; }
63         ///
64         void setKey(int key) { key_ = key; }
65         ///
66         docstring text() const { return text_; }
67         ///
68         void setText(docstring const & text) { text_ = text; }
69 private:
70         /// some platform specific sym value
71         int key_;
72         /// the event string value
73         docstring text_;
74 };
75
76
77 } // namespace lyx
78
79 #endif