The Battle for Wesnoth  1.15.1+dev
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
hotkey::hotkey_keyboard Class Reference

This class is responsible for handling keys, not modifiers. More...

#include <hotkey_item.hpp>

Inheritance diagram for hotkey::hotkey_keyboard:
Inheritance graph

Public Member Functions

 hotkey_keyboard ()
 Initialise new instance of this class that has no key associated with is. More...
 
void set_keycode (SDL_Keycode keycode)
 Set the keycode associated with this class. More...
 
void set_text (const std::string &text)
 
virtual bool valid () const
 Checks whether this hotkey has been set to a sensible value. More...
 
- Public Member Functions inherited from hotkey::hotkey_base
 hotkey_base ()
 Initialises a new empty hotkey that will be disabled. More...
 
void set_command (const std::string &command)
 
void set_mods (unsigned int mods)
 Set keyboard modifiers. More...
 
const std::string & get_command () const
 Returns the string name of the HOTKEY_COMMAND. More...
 
const std::string get_description () const
 Returns the translated description. More...
 
virtual bool hidden () const
 This controls whether the item should appear in the hotkey preferences. More...
 
bool is_default () const
 This indicates whether a hotkey is from the default config or if it's from the user preferences. More...
 
void unset_default ()
 Used to indicate that a hotkey is overridden and should be treated as a user-set hotkey. More...
 
bool is_disabled () const
 
void disable ()
 
void enable ()
 
void clear ()
 Unbind this hotkey by linking it to the null-command. More...
 
bool null () const
 Returns whether this hotkey points to the null-command. More...
 
bool active () const
 
void save (config &cfg) const
 Save the hotkey into the configuration object. More...
 
const std::string get_name () const
 Return "name" of hotkey. More...
 
bool matches (const SDL_Event &event) const
 Used to evaluate whether: More...
 
virtual bool bindings_equal (hotkey_ptr other)
 Checks whether the hotkey bindings and scope are equal. More...
 
virtual ~hotkey_base ()
 

Protected Member Functions

virtual void save_helper (config &cfg) const
 
virtual const std::string get_name_helper () const
 This is invoked by hotkey_base::get_name and must be implemented by subclasses. More...
 
virtual bool matches_helper (const SDL_Event &event) const
 This is invoked by hotkey_base::matches as a helper for the concrete classes. More...
 
virtual bool bindings_equal_helper (hotkey_ptr other) const
 This is invoked by hotkey_base::bindings_equal as a helper for the concrete classes. More...
 

Protected Attributes

SDL_Keycode keycode_
 
std::string text_
 
- Protected Attributes inherited from hotkey::hotkey_base
std::string command_
 The command that should be executed, or "null". More...
 
bool is_default_
 is_default_ is true if the hot-key is part of the default hot-key list defined in data/core/hotkeys.cfg. More...
 
bool is_disabled_
 
unsigned int mod_
 

Detailed Description

This class is responsible for handling keys, not modifiers.

Definition at line 236 of file hotkey_item.hpp.

Constructor & Destructor Documentation

◆ hotkey_keyboard()

hotkey::hotkey_keyboard::hotkey_keyboard ( )
inline

Initialise new instance of this class that has no key associated with is.

Definition at line 242 of file hotkey_item.hpp.

Member Function Documentation

◆ bindings_equal_helper()

bool hotkey::hotkey_keyboard::bindings_equal_helper ( hotkey_ptr  other) const
protectedvirtual

This is invoked by hotkey_base::bindings_equal as a helper for the concrete classes.

Implementing classes should only check their parts of the hotkey.

Parameters
otherThe other hotkey the check against. Not guaranteed to be the same subclass.
Returns
true if they match, false otherwise.

Implements hotkey::hotkey_base.

Definition at line 355 of file hotkey_item.cpp.

References text_.

◆ get_name_helper()

const std::string hotkey::hotkey_keyboard::get_name_helper ( ) const
protectedvirtual

This is invoked by hotkey_base::get_name and must be implemented by subclasses.

Keyboard modifiers are handled in this class, other hotkeys in the respective classes

Implements hotkey::hotkey_base.

Definition at line 298 of file hotkey_item.cpp.

◆ matches_helper()

bool hotkey::hotkey_keyboard::matches_helper ( const SDL_Event &  event) const
protectedvirtual

This is invoked by hotkey_base::matches as a helper for the concrete classes.

Implementing classes should only check their parts of the hotkey.

Parameters
eventThe SDL_Event being generated.
Returns
true if they match, false otherwise.

Implements hotkey::hotkey_base.

Definition at line 303 of file hotkey_item.cpp.

References hotkey::hotkey_base::get_command(), hotkey::get_hotkey_command(), CKey::is_uncomposable(), hotkey::hotkey_base::mod_, hotkey::sdl_get_mods(), utf8::size(), and hotkey::hotkey_command::toggle.

◆ save_helper()

void hotkey::hotkey_keyboard::save_helper ( config cfg) const
protectedvirtual

Implements hotkey::hotkey_base.

Definition at line 337 of file hotkey_item.cpp.

◆ set_keycode()

void hotkey::hotkey_keyboard::set_keycode ( SDL_Keycode  keycode)
inline

Set the keycode associated with this class.

Parameters
keycodeThe SDL_Keycode that this hotkey should be associated with

Definition at line 249 of file hotkey_item.hpp.

◆ set_text()

void hotkey::hotkey_keyboard::set_text ( const std::string &  text)
inline

Definition at line 254 of file hotkey_item.hpp.

◆ valid()

virtual bool hotkey::hotkey_keyboard::valid ( ) const
inlinevirtual

Checks whether this hotkey has been set to a sensible value.

@ return true if it is a known key

Implements hotkey::hotkey_base.

Definition at line 264 of file hotkey_item.hpp.

Member Data Documentation

◆ keycode_

SDL_Keycode hotkey::hotkey_keyboard::keycode_
protected

Definition at line 270 of file hotkey_item.hpp.

◆ text_

std::string hotkey::hotkey_keyboard::text_
protected

Definition at line 271 of file hotkey_item.hpp.

Referenced by bindings_equal_helper().


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