]> git.lyx.org Git - lyx.git/blob - src/frontends/KeySymbol.h
Increase hint verbosity, otherwise difficult to understand.
[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         /// Initialize with some platform specific sym value
37         void init(int key);
38
39         /// Is this a valid key?
40         bool isOK() const;
41
42         /// Is this a modifier key only?
43         bool isModifier() const;
44
45         /// Is this normal insertable text ? (last ditch attempt only)
46         bool isText() const;
47
48         /// What is the symbolic name of this key? F.ex. "Return" or "c"
49         std::string getSymbolName() const;
50
51         /**
52          * Return the value of the keysym into the UCS-4 encoding.
53          * This converts the KeySymbol to a 32-bit encoded character.
54          */
55         char_type getUCSEncoded() const;
56
57         /**
58          * Return a string describing the KeySym with modifier mod.
59          * Use the native UI format when \c forgui is true.
60          * i.e. (translated and with special characters for Mac OS X)
61          */
62         docstring const print(KeyModifier mod, bool forgui, bool untranslated = false) const;
63
64         ///
65         int key() const { return key_; }
66         ///
67         void setKey(int key) { key_ = key; }
68         ///
69         docstring text() const { return text_; }
70         ///
71         void setText(docstring const & text) { text_ = text; }
72 private:
73         /// some platform specific sym value
74         int key_;
75         /// the event string value
76         docstring text_;
77 };
78
79
80 } // namespace lyx
81
82 #endif