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
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
#include <string>
|
2002-06-18 15:44:30 +00:00
|
|
|
|
|
2004-03-26 15:12:35 +00:00
|
|
|
|
#include "key_state.h"
|
|
|
|
|
|
2006-12-13 14:13:01 +00:00
|
|
|
|
#include "support/docstring.h"
|
|
|
|
|
|
2006-04-13 12:18:42 +00:00
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* This is a base class for representing a keypress.
|
|
|
|
|
* Each frontend has to implement this to provide
|
|
|
|
|
* the functionality that LyX needs in regards to
|
|
|
|
|
* key presses.
|
|
|
|
|
*/
|
2007-04-27 08:43:38 +00:00
|
|
|
|
class KeySymbol {
|
2002-06-18 15:44:30 +00:00
|
|
|
|
public:
|
2007-04-27 08:43:38 +00:00
|
|
|
|
KeySymbol() {}
|
2002-06-18 15:44:30 +00:00
|
|
|
|
|
2007-04-27 08:43:38 +00:00
|
|
|
|
virtual ~KeySymbol() {}
|
2002-06-18 15:44:30 +00:00
|
|
|
|
|
2007-01-08 11:01:26 +00:00
|
|
|
|
///
|
2007-04-27 08:43:38 +00:00
|
|
|
|
virtual bool operator==(KeySymbol const& ks) const = 0;
|
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"
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual void init(std::string const & symbolname) = 0;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
|
|
|
|
|
/// Is this a valid key?
|
|
|
|
|
virtual bool isOK() const = 0;
|
|
|
|
|
|
|
|
|
|
/// Is this a modifier key only?
|
|
|
|
|
virtual bool isModifier() const = 0;
|
|
|
|
|
|
2002-12-12 13:46:06 +00:00
|
|
|
|
/// Is this normal insertable text ? (last ditch attempt only)
|
2006-08-13 22:54:59 +00:00
|
|
|
|
virtual bool isText() const = 0;
|
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"
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string getSymbolName() const = 0;
|
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-01-24 14:01:34 +00:00
|
|
|
|
virtual char_type getUCSEncoded() const = 0;
|
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.
|
2004-03-26 15:12:35 +00:00
|
|
|
|
*/
|
2007-01-04 17:10:24 +00:00
|
|
|
|
virtual docstring const print(key_modifier::state mod, bool forgui) const = 0;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
};
|
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2007-04-27 08:43:38 +00:00
|
|
|
|
typedef boost::shared_ptr<KeySymbol> KeySymbolPtr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Make a KeySymbol. Used because we want to
|
|
|
|
|
* generate a toolkit-specific instance.
|
|
|
|
|
*/
|
|
|
|
|
KeySymbol * createKeySymbol();
|
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
|