display key binding in native UI style

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8532 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2004-03-26 15:12:35 +00:00
parent c158a7987b
commit 500fa5f591
14 changed files with 75 additions and 6 deletions

View File

@ -1,3 +1,10 @@
2004-03-26 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* kbsequence.C (print): adjust
* kbmap.C (printKeySym): rename and change signature
(printKey): use LyXKeySym::print()
2004-03-26 Martin Vermeer <martin.vermeer@hut.fi>
* undo.C: add using std::advance to compile for stlport

View File

@ -14,6 +14,8 @@
#include <string>
#include "key_state.h"
/**
* This is a base class for representing a keypress.
* Each frontend has to implement this to provide
@ -47,6 +49,12 @@ public:
* This relies on user to use the right encoding.
*/
virtual char getISOEncoded(std::string const & encoding) const = 0;
/**
* Return a string describing the KeySym with modifier mod.
* This should use the native UI format when applicable
*/
virtual std::string const print(key_modifier::state mod) const = 0;
};

View File

@ -1,3 +1,8 @@
2004-03-26 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* GLyXKeySym.C (print): new method; print a keysym using
kb_keymap::printKeySym (should use some native gtk method instead)
2004-03-24 Angus Leeming <leeming@lyx.org>
* GMenubar.C (submenuDisabled, onSubMenuActivate): compile fixes

View File

@ -14,6 +14,8 @@
#include <gdk/gdkkeysyms.h>
#include "GLyXKeySym.h"
#include "kbmap.h"
using std::string;
@ -92,6 +94,12 @@ char GLyXKeySym::getISOEncoded(string const & /*encoding*/) const
}
string const GLyXKeySym::print(key_modifier::state mod) const
{
return kb_keymap::printKeySym(*this, mod);
}
bool operator==(LyXKeySym const & k1, LyXKeySym const & k2)
{
return static_cast<GLyXKeySym const &>(k1).getKeyval()

View File

@ -27,6 +27,7 @@ public:
virtual bool isModifier() const;
virtual std::string getSymbolName() const;
virtual char getISOEncoded(std::string const & encoding) const;
virtual std::string const print(key_modifier::state mod) const;
private:
unsigned int keyval_;
};

View File

@ -1,3 +1,7 @@
2004-03-25 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* QLyXKeySym.C (print): new method; print a KeySym using Qt syntax
2004-03-17 Angus Leeming <leeming@lyx.org>
* Dialogs2.C, lyx_gui.C: remove mention of the forks dialog.

View File

@ -16,6 +16,7 @@
#include "qlkey.h"
#include "qt_helpers.h"
#include <qaccel.h>
#include <qevent.h>
#include <qtextcodec.h>
@ -167,6 +168,22 @@ char QLyXKeySym::getISOEncoded(string const & encoding) const
}
string const QLyXKeySym::print(key_modifier::state mod) const
{
int tmpkey = key_;
if (mod & key_modifier::shift)
tmpkey += Qt::SHIFT;
if (mod & key_modifier::ctrl)
tmpkey += Qt::CTRL;
if (mod & key_modifier::alt)
tmpkey += Qt::ALT;
return fromqstr(QAccel::keyToString(tmpkey));
}
bool QLyXKeySym::isText() const
{
if (text_.isEmpty()) {

View File

@ -54,6 +54,10 @@ public:
* This relies on user to use the right encoding.
*/
virtual char getISOEncoded(std::string const & encoding) const;
///
virtual std::string const print(key_modifier::state mod) const;
///
int key() const {
return key_;

View File

@ -1,3 +1,8 @@
2004-03-26 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* XLyXKeySym.C (print): new method; print a keysym using
kb_keymap::printKeySym.
2004-03-17 Angus Leeming <leeming@lyx.org>
* Dialogs2.C, FormForks.[Ch], Makefile.am:

View File

@ -13,6 +13,7 @@
#include "XLyXKeySym.h"
#include "debug.h"
#include "kbmap.h"
#include <X11/keysym.h>
@ -100,6 +101,12 @@ char XLyXKeySym::getISOEncoded(string const &) const
}
string const XLyXKeySym::print(key_modifier::state mod) const
{
return kb_keymap::printKeySym(*this, mod);
}
bool operator==(LyXKeySym const & k1, LyXKeySym const & k2)
{
return static_cast<XLyXKeySym const &>(k1).keysym()

View File

@ -44,6 +44,9 @@ public:
*/
virtual char getISOEncoded(std::string const & encoding) const;
///
virtual std::string const print(key_modifier::state mod) const;
///
unsigned int keysym() const {
return keysym_;

View File

@ -30,12 +30,12 @@ using std::endl;
using std::string;
string const kb_keymap::printKeysym(LyXKeySymPtr key,
string const kb_keymap::printKeySym(LyXKeySym const & key,
key_modifier::state mod)
{
string buf;
string const s = key->getSymbolName();
string const s = key.getSymbolName();
if (mod & key_modifier::shift)
buf += "S-";
@ -51,7 +51,7 @@ string const kb_keymap::printKeysym(LyXKeySymPtr key,
string const kb_keymap::printKey(kb_key const & key) const
{
return printKeysym(key.code, key.mod.first);
return key.code->print(key.mod.first);
}

View File

@ -64,8 +64,8 @@ public:
* @param key the key as a keysym
* @param mod the modifiers
*/
static std::string const printKeysym(LyXKeySymPtr key,
key_modifier::state mod);
static std::string const printKeySym(LyXKeySym const & key,
key_modifier::state mod);
typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;

View File

@ -137,7 +137,7 @@ string const kb_sequence::print() const
KeySequence::size_type i, length = sequence.size();
for (i = 0; i < length; ++i) {
buf += kb_keymap::printKeysym(sequence[i], modifiers[i].first);
buf += kb_keymap::printKeySym(*sequence[i], modifiers[i].first);
// append a blank
if (i + 1 < length) {