_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

Public Types | Public Member Functions | Protected Attributes | List of all members
gcn::Key Class Reference

#include <key.h>

Public Types

enum  {
  K_SPACE = ' ', K_TAB = '\t', K_ENTER = '\n', K_LEFT_ALT = 1000,
  K_RIGHT_ALT, K_LEFT_SHIFT, K_RIGHT_SHIFT, K_LEFT_CONTROL,
  K_RIGHT_CONTROL, K_LEFT_META, K_RIGHT_META, K_LEFT_SUPER,
  K_RIGHT_SUPER, K_INSERT, K_HOME, K_PAGE_UP,
  K_DELETE, K_END, K_PAGE_DOWN, K_ESCAPE,
  K_CAPS_LOCK, K_BACKSPACE, K_F1, K_F2,
  K_F3, K_F4, K_F5, K_F6,
  K_F7, K_F8, K_F9, K_F10,
  K_F11, K_F12, K_F13, K_F14,
  K_F15, K_PRINT_SCREEN, K_SCROLL_LOCK, K_PAUSE,
  K_NUM_LOCK, K_ALT_GR, K_LEFT, K_RIGHT,
  K_UP, K_DOWN
}
 

Public Member Functions

 Key ()
 
 Key (int value)
 
bool isCharacter () const
 
bool isNumber () const
 
bool isLetter () const
 
bool isShiftPressed () const
 
void setShiftPressed (bool pressed)
 
bool isControlPressed () const
 
void setControlPressed (bool pressed)
 
bool isAltPressed () const
 
void setAltPressed (bool pressed)
 
bool isMetaPressed () const
 
void setMetaPressed (bool pressed)
 
bool isNumericPad () const
 
void setNumericPad (bool numpad)
 
int getValue () const
 
void setValue (int value)
 
std::string toString () const
 

Protected Attributes

int mValue
 
bool mShiftPressed
 
bool mControlPressed
 
bool mAltPressed
 
bool mMetaPressed
 
bool mNumericPad
 

Detailed Description

Represents a key or a character.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

An enum with key values.

Enumerator
K_SPACE 
K_TAB 
K_ENTER 
K_LEFT_ALT 
K_RIGHT_ALT 
K_LEFT_SHIFT 
K_RIGHT_SHIFT 
K_LEFT_CONTROL 
K_RIGHT_CONTROL 
K_LEFT_META 
K_RIGHT_META 
K_LEFT_SUPER 
K_RIGHT_SUPER 
K_INSERT 
K_HOME 
K_PAGE_UP 
K_DELETE 
K_END 
K_PAGE_DOWN 
K_ESCAPE 
K_CAPS_LOCK 
K_BACKSPACE 
K_F1 
K_F2 
K_F3 
K_F4 
K_F5 
K_F6 
K_F7 
K_F8 
K_F9 
K_F10 
K_F11 
K_F12 
K_F13 
K_F14 
K_F15 
K_PRINT_SCREEN 
K_SCROLL_LOCK 
K_PAUSE 
K_NUM_LOCK 
K_ALT_GR 
K_LEFT 
K_RIGHT 
K_UP 
K_DOWN 

Constructor & Destructor Documentation

◆ Key() [1/2]

gcn::Key::Key ( )

Constructor.

◆ Key() [2/2]

gcn::Key::Key ( int  value)

Constructor.

Parameters
valuethe ascii or enum value for the key.

Member Function Documentation

◆ getValue()

int gcn::Key::getValue ( ) const

Gets the value of the key. If an ascii value exists it will be returned. Otherwise an enum value will be returned.

Returns
the value of the key.

◆ isAltPressed()

bool gcn::Key::isAltPressed ( ) const

Checks whether alt is pressed.

Returns
true if alt was pressed at the same time as the key.

◆ isCharacter()

bool gcn::Key::isCharacter ( ) const

Checks whether a key is a character.

Returns
true if the key is a letter, number or whitespace.

◆ isControlPressed()

bool gcn::Key::isControlPressed ( ) const

Checks whether control is pressed.

Returns
true if control was pressed at the same time as the key.

◆ isLetter()

bool gcn::Key::isLetter ( ) const

Checks whether a key is a letter.

Returns
true if the key is a letter (a-z,A-Z).

◆ isMetaPressed()

bool gcn::Key::isMetaPressed ( ) const

Checks whether meta is pressed.

Returns
true if meta was pressed at the same time as the key.

◆ isNumber()

bool gcn::Key::isNumber ( ) const

Checks whether a key is a number.

Returns
true if the key is a number (0-9).

◆ isNumericPad()

bool gcn::Key::isNumericPad ( ) const

Checks whether the key was pressed at the numeric pad.

Returns
true if key pressed at the numeric pad.

◆ isShiftPressed()

bool gcn::Key::isShiftPressed ( ) const

Checks whether shift is pressed.

Returns
true if shift was pressed at the same time as the key.

◆ setAltPressed()

void gcn::Key::setAltPressed ( bool  pressed)

Sets the alt pressed flag.

Parameters
pressedthe alt flag value.

◆ setControlPressed()

void gcn::Key::setControlPressed ( bool  pressed)

Sets the control pressed flag.

Parameters
pressedthe control flag value.

◆ setMetaPressed()

void gcn::Key::setMetaPressed ( bool  pressed)

Sets the meta pressed flag.

Parameters
pressedthe meta flag value.

◆ setNumericPad()

void gcn::Key::setNumericPad ( bool  numpad)

Sets the numeric pad flag.

Parameters
numpadthe numeric pad flag value.

◆ setShiftPressed()

void gcn::Key::setShiftPressed ( bool  pressed)

Sets the shift pressed flag.

Parameters
pressedthe shift flag value.

◆ setValue()

void gcn::Key::setValue ( int  value)

Sets the value of the key. An ascii value or an enum value.

Parameters
valuethe key value.

◆ toString()

std::string gcn::Key::toString ( ) const

Convert to a UTF8 string

Member Data Documentation

◆ mAltPressed

bool gcn::Key::mAltPressed
protected

◆ mControlPressed

bool gcn::Key::mControlPressed
protected

◆ mMetaPressed

bool gcn::Key::mMetaPressed
protected

◆ mNumericPad

bool gcn::Key::mNumericPad
protected

◆ mShiftPressed

bool gcn::Key::mShiftPressed
protected

◆ mValue

int gcn::Key::mValue
protected

The documentation for this class was generated from the following files:
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.