3 * Copyright 2002 the LyX Team
4 * Read the file COPYING
6 * \author Asger and Juergen
12 #pragma implementation
15 #include "XLyXKeySym.h"
20 #include <X11/keysym.h>
24 XLyXKeySym::XLyXKeySym()
25 : LyXKeySym(), keysym(NoSymbol)
30 void XLyXKeySym::initFromKeySym(KeySym ks)
36 void XLyXKeySym::init(string const & symbolname)
38 keysym = XStringToKeysym(symbolname.c_str());
39 if (keysym == NoSymbol) {
41 << "XLyXKeySym.C: No such keysym: "
42 << symbolname << endl;
47 bool XLyXKeySym::isOK() const
49 return keysym != NoSymbol;
53 bool XLyXKeySym::isModifier() const
55 // Can we be sure that this will work for all X Window
56 // implementations? (Lgb)
57 // Perhaps all of them should be explictly mentioned?
58 return ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
59 || keysym == XK_Mode_switch || keysym == 0x0);
63 string XLyXKeySym::getSymbolName() const
65 char * name = XKeysymToString(keysym);
66 return name ? name : string();
70 char XLyXKeySym::getISOEncoded() const
72 if (keysym == NoSymbol) {
76 unsigned int c = keysym;
78 switch (c & 0x0000FF00) {
80 case 0x00000000: break;
91 // latin 8 byte 3 = 18 (0x12)
93 // latin 9 byte 3 = 19 (0x13)
104 bool XLyXKeySym::operator==(LyXKeySym const & k) const
106 // This is dangerous! Ideally, we should use dynamic_cast instead,
107 // but on the other hand, we are sure that we will always get
108 // the right type, because we decide at compile time which
109 // frontend we use. (Asger)
110 return keysym == static_cast<XLyXKeySym const &>(k).keysym;