Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

Key Class Reference

#include <Key.h>

Inheritance diagram for Key:

MenuItem List of all members.

Public Member Functions

 Key (const string &label, const string &name, Font *font, SDLKey defaultValue=SDLK_SPACE)
void load (ifstream &file)
void save (ofstream &file)
void draw (float x, float y, float zoom)
Type getType ()
float getWidth (float zoom)
float getHeight (float zoom)
string & getName ()
bool isPressed ()
bool keyPress ()
void handleGameKeyboardEvent (SDL_Event *event)
bool handleKeyEvent (SDL_Event *event)

Detailed Description

A class for configuring keyboard control and handling the keyboard input.

Definition at line 13 of file Key.h.


Constructor & Destructor Documentation

Key::Key const string &  label,
const string &  name,
Font font,
SDLKey  defaultValue = SDLK_SPACE
 

Constructor

lable is the name the user can see on screen.

name is the name of the TextEntry in the config file.

font is the Font to use when rendering.

defaultValue is the SDLKey to use when no configration is loaded.

Definition at line 6 of file Key.cpp.


Member Function Documentation

void Key::draw float  x,
float  y,
float  zoom
[virtual]
 

Draws the MenuItem at x,y with a zoom factor of zoom (2 equals double size).

The MenuItem may decide not to apply the scale or to only support some zoom steps, always check getWidth and getHeight if you need the excact size.

Implements MenuItem.

Definition at line 38 of file Key.cpp.

float Key::getHeight float  zoom  )  [virtual]
 

Returns the height of this MenuItem at zoom factor zoom, must be excact

Implements MenuItem.

Definition at line 48 of file Key.cpp.

string & Key::getName  )  [virtual]
 

Returns the name of the MenuItem used when save is called.

The name may not contain a =.

Implements MenuItem.

Definition at line 266 of file Key.cpp.

Type Key::getType  )  [inline, virtual]
 

Returns the Type of this control.

Implements MenuItem.

Definition at line 34 of file Key.h.

float Key::getWidth float  zoom  )  [virtual]
 

Returns the width of this MenuItem at zoom factor zoom, must be excact

Implements MenuItem.

Definition at line 43 of file Key.cpp.

void Key::handleGameKeyboardEvent SDL_Event *  event  ) 
 

Call this in your event loop with the events to make the key register the keyboard events (Otherwise isPressed and keyPress won't work)

Definition at line 283 of file Key.cpp.

bool Key::handleKeyEvent SDL_Event *  event  )  [virtual]
 

Called when a key press/release event occurs, return true if the MenuItem has handled the event.

If true is returned the event handling will stop.

Implements MenuItem.

Definition at line 295 of file Key.cpp.

bool Key::isPressed  ) 
 

Returns true if the key is currently pressed.

Definition at line 271 of file Key.cpp.

bool Key::keyPress  ) 
 

Returns true if the key has been pressed since the last time keyPress has been called.

Definition at line 276 of file Key.cpp.

void Key::load ifstream &  file  )  [virtual]
 

Reads the configuration for the MenuItem from any position within the file

Hint: Use findLoadPosition to find you entry in the file

Reimplemented from MenuItem.

Definition at line 22 of file Key.cpp.

void Key::save ofstream &  file  )  [virtual]
 

Saves the MenuItem at the current position in the file.

Entrys must look like "name=value\n".

Reimplemented from MenuItem.

Definition at line 33 of file Key.cpp.


The documentation for this class was generated from the following files:
Generated on Wed Sep 1 14:46:57 2004 by doxygen 1.3.7