cwidget  0.5.17
Public Member Functions | List of all members
cwidget::config::keybindings Class Reference

Stores the keys bound to various functions. More...

#include <keybindings.h>

Public Member Functions

 keybindings (keybindings *_parent=NULL)
 Create a new key-binding scope. More...
 
std::wstring keyname (const std::string &tag)
 
std::wstring readable_keyname (const std::string &tag)
 
keybinding get (std::string tag)
 Retrieve the binding of the given function. More...
 
void set (std::string tag, keybinding strokes)
 Modify a binding in this scope. More...
 
void set (std::string tag, const key &stroke)
 Modify a binding in this scope. More...
 
bool key_matches (const key &k, std::string tag)
 Test whether a key is bound to a function. More...
 

Detailed Description

Stores the keys bound to various functions.

Functions are simply arbitrary strings chosen by the user of this class. For instance, "QuitProgram" might be the function that quits the program.

Each keybindings object represents a scope in which bindings can be defined. Scopes are arranged hierarchically, and the bindings defined in child scopes override the bindings defined in parent scopes.

Constructor & Destructor Documentation

◆ keybindings()

cwidget::config::keybindings::keybindings ( keybindings _parent = NULL)
inline

Create a new key-binding scope.

Parameters
_parentThe parent of this scope, if any, or NULL for no parent.

References cwidget::config::keyname(), and cwidget::config::readable_keyname().

Member Function Documentation

◆ get()

keybinding cwidget::config::keybindings::get ( std::string  tag)
inline

Retrieve the binding of the given function.

◆ key_matches()

bool cwidget::config::keybindings::key_matches ( const key k,
std::string  tag 
)

Test whether a key is bound to a function.

Parameters
kThe key to test.
tagThe function to test against.
Returns
true if k is bound to tag in this scope.

References KEY_CTRL, and cwidget::config::parse_key().

Referenced by cwidget::widgets::text_layout::handle_key(), cwidget::widgets::menubar::handle_key(), cwidget::widgets::menu::handle_key(), and cwidget::toplevel::post_event().

◆ keyname()

wstring cwidget::config::keybindings::keyname ( const std::string &  tag)
Returns
the first binding of the given function, in a format that can be passed to parse_key().
Parameters
tagThe function whose keystroke is to be returned.

◆ readable_keyname()

wstring cwidget::config::keybindings::readable_keyname ( const std::string &  tag)
Returns
a human-readable string describing the keystroke bound to the given function.
Parameters
tagThe name of the function whose keystroke is to be returned.

Referenced by cwidget::widgets::menu::paint(), and cwidget::widgets::menu::width_request().

◆ set() [1/2]

void cwidget::config::keybindings::set ( std::string  tag,
keybinding  strokes 
)

Modify a binding in this scope.

Parameters
tagThe name of the function to be bound.
strokesThe keystrokes to bind to the function.

This routine throws away any previous bindings for the given function and replaces them with the bindings stored in strokes.

Referenced by cwidget::toplevel::init().

◆ set() [2/2]

void cwidget::config::keybindings::set ( std::string  tag,
const key stroke 
)
inline

Modify a binding in this scope.

Parameters
tagThe name of the function to be bound.
strokeA keystroke to bind to the function.

This routine throws away any previous bindings for the given function and replaces them with stroke.

References cwidget::config::global_bindings, cwidget::config::keyname(), and cwidget::config::readable_keyname().


The documentation for this class was generated from the following files: