Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

KeyBinder Class Reference

Inheritance diagram for KeyBinder:

Inheritance graph
[legend]
Collaboration diagram for KeyBinder:

Collaboration graph
[legend]

Detailed Description

Key binder.

Definition at line 14 of file KeyBinder.h.

Public Member Functions

 ~KeyBinder ()
void addStroke (const KeyStroke &stroke, BaseMsg *msg)
 Bind keystroke.
void removeStroke (const KeyStroke &stroke)
void keyDown (const SDL_keysym &keysym) const
 Handle keydown event, find keystroke and send message.


Constructor & Destructor Documentation

KeyBinder::~KeyBinder  ) 
 

Definition at line 18 of file KeyBinder.cpp.

00019 {
00020     t_strokes::iterator end = m_strokes.end();
00021     for (t_strokes::iterator i = m_strokes.begin(); i != end; ++i) {
00022         delete i->second;
00023     }
00024 }


Member Function Documentation

void KeyBinder::addStroke const KeyStroke stroke,
BaseMsg msg
 

Bind keystroke.

Parameters:
stroke keystroke
msg message to raise, will be deleted
Exceptions:
LogicException when keystroke is occupied

Definition at line 33 of file KeyBinder.cpp.

00034 {
00035     std::pair<t_strokes::iterator,bool> status =
00036         m_strokes.insert(
00037                 std::pair<KeyStroke,BaseMsg*>(stroke, msg));
00038     if (!status.second) {
00039         throw LogicException(ExInfo("keystroke is occupied")
00040                 .addInfo("keystroke", stroke.toString()));
00041     }
00042     else {
00043         LOG_DEBUG(ExInfo("binding keystroke")
00044                 .addInfo("keystroke", stroke.toString())
00045                 .addInfo("msg", msg->toString()));
00046     }
00047 }

void KeyBinder::keyDown const SDL_keysym &  keysym  )  const
 

Handle keydown event, find keystroke and send message.

Definition at line 68 of file KeyBinder.cpp.

00069 {
00070     KeyStroke stroke(keysym);
00071     t_strokes::const_iterator it = m_strokes.find(stroke);
00072     if (m_strokes.end() != it) {
00073         it->second->sendClone();
00074     }
00075 }

void KeyBinder::removeStroke const KeyStroke stroke  ) 
 

Definition at line 50 of file KeyBinder.cpp.

00051 {
00052     t_strokes::iterator it = m_strokes.find(stroke);
00053     if (m_strokes.end() != it) {
00054         delete it->second;
00055         m_strokes.erase(it);
00056     }
00057     else {
00058         LOG_WARNING(ExInfo("keystroke does not exist")
00059                 .addInfo("keystroke", stroke.toString()));
00060     }
00061 }


The documentation for this class was generated from the following files:
Generated on Wed Jun 1 09:55:28 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2