2002-06-19 05:20:29 +00:00
|
|
|
/**
|
|
|
|
* \file QLyXKeySym.C
|
2002-09-24 13:57:09 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-06-19 05:20:29 +00:00
|
|
|
*
|
|
|
|
* \author Asger and Juergen
|
2002-10-20 01:48:28 +00:00
|
|
|
* \author John Levon
|
2002-09-24 13:57:09 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2002-06-19 05:20:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "QLyXKeySym.h"
|
|
|
|
#include "qlkey.h"
|
2002-07-30 00:53:57 +00:00
|
|
|
#include "debug.h"
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-08-25 05:41:42 +00:00
|
|
|
#include <qevent.h>
|
2002-09-04 09:46:08 +00:00
|
|
|
|
|
|
|
using std::endl;
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-06-19 05:20:29 +00:00
|
|
|
QLyXKeySym::QLyXKeySym()
|
2002-08-25 05:41:42 +00:00
|
|
|
: LyXKeySym(), key_(0)
|
2002-06-19 05:20:29 +00:00
|
|
|
{
|
|
|
|
}
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
|
|
|
2002-08-25 05:41:42 +00:00
|
|
|
void QLyXKeySym::set(QKeyEvent * ev)
|
2002-06-19 05:20:29 +00:00
|
|
|
{
|
2002-08-25 05:41:42 +00:00
|
|
|
key_ = ev->key();
|
2002-10-20 01:48:28 +00:00
|
|
|
text_ = ev->text();
|
2002-06-19 05:20:29 +00:00
|
|
|
}
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-06-19 05:20:29 +00:00
|
|
|
|
|
|
|
void QLyXKeySym::init(string const & symbolname)
|
|
|
|
{
|
|
|
|
key_ = string_to_qkey(symbolname);
|
2002-08-25 05:41:42 +00:00
|
|
|
text_ = symbolname.c_str();
|
|
|
|
lyxerr[Debug::KEY] << "Init key to " << key_ << ", " << text_ << endl;
|
2002-06-19 05:20:29 +00:00
|
|
|
}
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-06-19 05:20:29 +00:00
|
|
|
bool QLyXKeySym::isOK() const
|
|
|
|
{
|
2002-08-25 05:41:42 +00:00
|
|
|
return ! key_ == 0;
|
2002-06-19 05:20:29 +00:00
|
|
|
}
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-06-19 05:20:29 +00:00
|
|
|
|
|
|
|
bool QLyXKeySym::isModifier() const
|
|
|
|
{
|
|
|
|
return q_is_modifier(key_);
|
|
|
|
}
|
|
|
|
|
2002-08-25 05:41:42 +00:00
|
|
|
|
2002-06-19 05:20:29 +00:00
|
|
|
string QLyXKeySym::getSymbolName() const
|
|
|
|
{
|
2002-08-25 05:41:42 +00:00
|
|
|
string sym(qkey_to_string(key_));
|
|
|
|
|
|
|
|
if (sym.empty()) {
|
|
|
|
lyxerr[Debug::KEY] << "sym empty in getSymbolName()" << endl;
|
2002-08-25 06:45:16 +00:00
|
|
|
sym = text_.latin1();
|
2002-08-25 05:41:42 +00:00
|
|
|
}
|
|
|
|
lyxerr[Debug::KEY] << "getSymbolName() -> " << sym << endl;
|
|
|
|
return sym;
|
2002-06-19 05:20:29 +00:00
|
|
|
}
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-06-19 05:20:29 +00:00
|
|
|
char QLyXKeySym::getISOEncoded() const
|
|
|
|
{
|
2002-08-25 05:41:42 +00:00
|
|
|
lyxerr[Debug::KEY] << "getISO returning " << text_.latin1()[0] << endl;
|
2002-10-20 01:48:28 +00:00
|
|
|
return text_.latin1()[0];
|
2002-06-19 05:20:29 +00:00
|
|
|
}
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
|
|
bool operator==(LyXKeySym const & k1, LyXKeySym const & k2)
|
2002-06-19 05:20:29 +00:00
|
|
|
{
|
2002-10-20 01:48:28 +00:00
|
|
|
// note we ignore text_ here (non-strict ==), because
|
|
|
|
// text_ is not filled out by keymap initialisation
|
|
|
|
|
|
|
|
return static_cast<QLyXKeySym const &>(k1).key()
|
|
|
|
== static_cast<QLyXKeySym const &>(k2).key();
|
|
|
|
|
2002-06-19 05:20:29 +00:00
|
|
|
}
|