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