]> git.lyx.org Git - lyx.git/blob - src/frontends/KeySymbol.h
rename LyXKeySym into KeySymbol
[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 #include <boost/shared_ptr.hpp>
22
23
24 namespace lyx {
25
26 /**
27  * This is a base class for representing a keypress.
28  * Each frontend has to implement this to provide
29  * the functionality that LyX needs in regards to
30  * key presses.
31  */
32 class KeySymbol {
33 public:
34         KeySymbol() {}
35
36         virtual ~KeySymbol() {}
37
38         ///
39         virtual bool operator==(KeySymbol const& ks) const = 0;
40
41         /// Initialize with the name of a key. F. ex. "space" or "a"
42         virtual void init(std::string const & symbolname) = 0;
43
44         /// Is this a valid key?
45         virtual bool isOK() const = 0;
46
47         /// Is this a modifier key only?
48         virtual bool isModifier() const = 0;
49
50         /// Is this normal insertable text ? (last ditch attempt only)
51         virtual bool isText() const = 0;
52
53         /// What is the symbolic name of this key? F.ex. "Return" or "c"
54         virtual std::string getSymbolName() const = 0;
55
56         /**
57          * Return the value of the keysym into the UCS-4 encoding.
58          * This converts the KeySymbol to a 32-bit encoded character.
59          */
60         virtual char_type getUCSEncoded() const = 0;
61
62         /**
63          * Return a string describing the KeySym with modifier mod.
64          * Use the native UI format when \c forgui is true.
65          */
66         virtual docstring const print(key_modifier::state mod, bool forgui) const = 0;
67 };
68
69
70 typedef boost::shared_ptr<KeySymbol> KeySymbolPtr;
71
72
73 /**
74  * Make a KeySymbol. Used because we want to
75  * generate a toolkit-specific instance.
76  */
77 KeySymbol * createKeySymbol();
78
79
80 } // namespace lyx
81
82 #endif