]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiKeySymbol.h
a88314cf916850814ac2a7733200c4f5fc7772ca
[lyx.git] / src / frontends / qt4 / GuiKeySymbol.h
1 // -*- C++ -*-
2 /**
3  * \file GuiKeySymbol.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  * \author John Levon
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef QLYXKEYSYM_H
14 #define QLYXKEYSYM_H
15
16 #include "frontends/KeySymbol.h"
17
18 #include <QString>
19 #include <QKeyEvent>
20
21
22 class QKeyEvent;
23
24 namespace lyx {
25
26 /**
27  * Qt-specific key press.
28  *
29  * This is some really sick stuff.
30  */
31 class GuiKeySymbol : public KeySymbol {
32 public:
33         GuiKeySymbol();
34
35         virtual ~GuiKeySymbol() {}
36
37         /// .
38         /// inlined out because of profiling results under linux when
39         /// opening a document.
40         inline bool operator==(KeySymbol const& ks) const;
41
42         /// delayed constructor
43         void set(QKeyEvent * ev);
44
45         /// set from a LyX symbolic name
46         virtual void init(std::string const & symbolname);
47
48         /// Is this a valid key?
49         virtual bool isOK() const;
50
51         /// Is this a modifier key only?
52         virtual bool isModifier() const;
53
54         /// return the LyX symbolic name
55         virtual std::string getSymbolName() const;
56
57         /// Is this normal insertable text ? (last ditch attempt only)
58         virtual bool isText() const;
59
60         /**
61          * Return the value of the keysym into the UCS-4 encoding.
62          * This converts the KeySymbol to a 32-bit encoded character.
63          */
64         virtual char_type getUCSEncoded() const;
65
66         /**
67          * Return a human-readable version of a key+modifier pair.
68          * This will be the GUI version (translated and with special
69          * characters for Mac OS X) when \c forgui is true.
70          */
71         virtual docstring const print(key_modifier::state mod, bool forgui) const;
72
73         ///
74         int key() const { return key_; }
75
76 private:
77         /// the Qt sym value
78         int key_;
79         /// the event string value
80         QString text_;
81 };
82
83 /// return the LyX key state from Qt's
84 key_modifier::state q_key_state(Qt::KeyboardModifiers state);
85
86 } // namespace lyx
87
88 #endif // QLYXKEYSYM_H