2002-06-18 15:44:30 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
/**
|
2007-04-27 08:43:38 +00:00
|
|
|
|
* \file KeySymbol.h
|
2002-09-05 15:14:23 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-06-18 15:44:30 +00:00
|
|
|
|
*
|
2003-09-07 01:45:40 +00:00
|
|
|
|
* \author Asger and J<EFBFBD>rgen
|
2002-09-05 14:10:50 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-06-18 15:44:30 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2007-04-27 08:43:38 +00:00
|
|
|
|
#ifndef KEYSYMBOL_H
|
|
|
|
|
#define KEYSYMBOL_H
|
2002-06-18 15:44:30 +00:00
|
|
|
|
|
2007-10-02 21:51:54 +00:00
|
|
|
|
#include "KeyModifier.h"
|
2004-03-26 15:12:35 +00:00
|
|
|
|
|
2006-12-13 14:13:01 +00:00
|
|
|
|
#include "support/docstring.h"
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
/**
|
2007-09-17 18:41:03 +00:00
|
|
|
|
* This is a class representing a keypress.
|
2002-06-18 15:44:30 +00:00
|
|
|
|
*/
|
2007-09-17 18:41:03 +00:00
|
|
|
|
class KeySymbol
|
|
|
|
|
{
|
2002-06-18 15:44:30 +00:00
|
|
|
|
public:
|
2007-09-17 18:41:03 +00:00
|
|
|
|
KeySymbol() : key_(0) {}
|
2002-06-18 15:44:30 +00:00
|
|
|
|
|
2007-01-08 11:01:26 +00:00
|
|
|
|
///
|
2007-09-17 18:41:03 +00:00
|
|
|
|
bool operator==(KeySymbol const & ks) const;
|
2007-01-08 11:01:26 +00:00
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
/// Initialize with the name of a key. F. ex. "space" or "a"
|
2007-09-17 18:41:03 +00:00
|
|
|
|
void init(std::string const & symbolname);
|
2002-06-18 15:44:30 +00:00
|
|
|
|
|
|
|
|
|
/// Is this a valid key?
|
2007-09-17 18:41:03 +00:00
|
|
|
|
bool isOK() const;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
|
|
|
|
|
/// Is this a modifier key only?
|
2007-09-17 18:41:03 +00:00
|
|
|
|
bool isModifier() const;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
|
2002-12-12 13:46:06 +00:00
|
|
|
|
/// Is this normal insertable text ? (last ditch attempt only)
|
2007-09-17 18:41:03 +00:00
|
|
|
|
bool isText() const;
|
2003-02-25 13:17:01 +00:00
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
/// What is the symbolic name of this key? F.ex. "Return" or "c"
|
2007-09-17 18:41:03 +00:00
|
|
|
|
std::string getSymbolName() const;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2006-08-13 22:54:59 +00:00
|
|
|
|
* Return the value of the keysym into the UCS-4 encoding.
|
2007-04-27 08:43:38 +00:00
|
|
|
|
* This converts the KeySymbol to a 32-bit encoded character.
|
2002-06-18 15:44:30 +00:00
|
|
|
|
*/
|
2007-09-17 18:41:03 +00:00
|
|
|
|
char_type getUCSEncoded() const;
|
2004-03-26 15:12:35 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return a string describing the KeySym with modifier mod.
|
2007-01-04 17:10:24 +00:00
|
|
|
|
* Use the native UI format when \c forgui is true.
|
2007-09-17 18:41:03 +00:00
|
|
|
|
* i.e. (translated and with special characters for Mac OS X)
|
2004-03-26 15:12:35 +00:00
|
|
|
|
*/
|
2007-10-02 21:51:54 +00:00
|
|
|
|
docstring const print(KeyModifier mod, bool forgui) const;
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2007-09-17 18:41:03 +00:00
|
|
|
|
///
|
|
|
|
|
int key() const { return key_; }
|
|
|
|
|
///
|
|
|
|
|
void setKey(int key) { key_ = key; }
|
|
|
|
|
///
|
|
|
|
|
docstring text() const { return text_; }
|
|
|
|
|
///
|
|
|
|
|
void setText(docstring const & text) { text_ = text; }
|
|
|
|
|
private:
|
|
|
|
|
/// some platform specific sym value
|
|
|
|
|
int key_;
|
|
|
|
|
/// the event string value
|
|
|
|
|
docstring text_;
|
|
|
|
|
};
|
2006-04-13 12:18:42 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
#endif
|