MAUtil::Moblet Class Reference

#include <MAUtil/Moblet.h>

Inheritance diagram for MAUtil::Moblet:

MAUtil::Environment MAUtil::KeyListener MAUtil::PointerListener MAUtil::CloseListener List of all members.

Detailed Description

A C++ event manager, a base class for applications.

A Moblet manages the application main loop for you. To use Moblet: inherit it, construct an instance and call Moblet::run().

You'll probably want to implement your own keyPressEvent() and keyReleaseEvent().

Code that isn't supposed to be executed in response to an event should be placed in a TimerListener or IdleListener that's registered with the Moblet.


Public Member Functions

virtual void keyPressEvent (int keyCode, int nativeCode)
virtual void keyReleaseEvent (int keyCode, int nativeCode)
virtual void pointerPressEvent (MAPoint2d p)
virtual void pointerMoveEvent (MAPoint2d p)
virtual void pointerReleaseEvent (MAPoint2d p)
virtual void closeEvent () __attribute__((noreturn))
virtual void customEvent (const MAEvent &event)
void addFocusListener (FocusListener *kl)
void removeFocusListener (FocusListener *kl)
bool isFocusListener (FocusListener *kl)
void addKeyListener (KeyListener *kl)
void removeKeyListener (KeyListener *kl)
bool isKeyListener (KeyListener *kl)
void addPointerListener (PointerListener *pl)
void removePointerListener (PointerListener *pl)
bool isPointerListener (PointerListener *pl)
void setBluetoothListener (BluetoothListener *btl)
void removeBluetoothListener ()
void setConnListener (MAHandle conn, ConnListener *cl)
void removeConnListener (MAHandle conn)
void addCloseListener (CloseListener *cl)
void removeCloseListener (CloseListener *cl)
virtual void addIdleListener (IdleListener *il)
virtual void removeIdleListener (IdleListener *il)
void addTimer (TimerListener *tl, int period, int numTimes)
void removeTimer (TimerListener *tl)
virtual void keyPressEvent (int keyCode)
virtual void keyReleaseEvent (int keyCode)

Static Public Member Functions

static void run (Moblet *moblet)
static void close () __attribute__((noreturn))
static EnvironmentgetEnvironment ()

Protected Member Functions

 Moblet ()
void fireFocusGainedEvent ()
void fireFocusLostEvent ()
void fireKeyPressEvent (int keyCode, int nativeCode)
void fireKeyReleaseEvent (int keyCode, int nativeCode)
void firePointerPressEvent (MAPoint2d p)
void firePointerMoveEvent (MAPoint2d p)
void firePointerReleaseEvent (MAPoint2d p)
void fireBluetoothEvent (int state)
void fireConnEvent (const MAConnEventData &data)
void fireCloseEvent ()
void runIdleListeners ()

Protected Attributes

bool mRun
ListenerSet< KeyListenermKeyListeners
ListenerSet< PointerListenermPointerListeners
BluetoothListenermBtListener
Vector< CloseListener * > mCloseListeners
ListenerSet< ConnListenermConnListeners
ListenerSet< IdleListenermIdleListeners
ListenerSet< TimerEventInstance > mTimerEvents
ListenerSet< FocusListenermFocusListeners


Constructor & Destructor Documentation

MAUtil::Moblet::Moblet  )  [protected]
 

Moblet's constructor is protected, forcing you to inherit the class. Causes a panic if another Moblet already exists. There can be only one.


Member Function Documentation

virtual void MAUtil::Moblet::keyPressEvent int  keyCode,
int  nativeCode
[inline, virtual]
 

This function is called with a MAK_ code when a key is pressed.

Reimplemented from MAUtil::KeyListener.

virtual void MAUtil::Moblet::keyReleaseEvent int  keyCode,
int  nativeCode
[inline, virtual]
 

This function is called with a MAK_ code when a key is released.

Reimplemented from MAUtil::KeyListener.

virtual void MAUtil::Moblet::pointerPressEvent MAPoint2d  p  )  [inline, virtual]
 

This function is called with a coordinate when a pointer is pressed.

Implements MAUtil::PointerListener.

virtual void MAUtil::Moblet::pointerMoveEvent MAPoint2d  p  )  [inline, virtual]
 

This function is called with a coordinate when a pointer is moved.

Implements MAUtil::PointerListener.

virtual void MAUtil::Moblet::pointerReleaseEvent MAPoint2d  p  )  [inline, virtual]
 

This function is called with a coordinate when a pointer is released.

Implements MAUtil::PointerListener.

virtual void MAUtil::Moblet::closeEvent  )  [virtual]
 

This function is called when the Close event is recieved. The default implementation just calls close().

Implements MAUtil::CloseListener.

virtual void MAUtil::Moblet::customEvent const MAEvent event  )  [inline, virtual]
 

This function is called when an event that Moblet doesn't recognize is recieved.

static void MAUtil::Moblet::run Moblet moblet  )  [static]
 

Runs a Moblet. This function only returns if someone sets Moblet::mRun to false. Example: Moblet::run(new MyMoblet());

static void MAUtil::Moblet::close  )  [static]
 

Shuts down the running application.

void MAUtil::Environment::addFocusListener FocusListener kl  )  [inherited]
 

Adds the specified listener to the end of the list, unless it is already in the list.

void MAUtil::Environment::removeFocusListener FocusListener kl  )  [inherited]
 

Removes the specified listener from the list, if it's in it.

bool MAUtil::Environment::isFocusListener FocusListener kl  )  [inherited]
 

Queries whether the specified listener is in the list of key listeners.

void MAUtil::Environment::addKeyListener KeyListener kl  )  [inherited]
 

Adds the specified listener to the end of the list, unless it is already in the list.

void MAUtil::Environment::removeKeyListener KeyListener kl  )  [inherited]
 

Removes the specified listener from the list, if it's in it.

bool MAUtil::Environment::isKeyListener KeyListener kl  )  [inherited]
 

Queries whether the specified listener is in the list of key listeners.

void MAUtil::Environment::addPointerListener PointerListener pl  )  [inherited]
 

Adds the specified listener to the end of the list, unless it is already in the list.

void MAUtil::Environment::removePointerListener PointerListener pl  )  [inherited]
 

Removes the specified listener from the list, if it's in it.

bool MAUtil::Environment::isPointerListener PointerListener pl  )  [inherited]
 

Queries whether the specified listener is in the list of key listeners.

void MAUtil::Environment::setBluetoothListener BluetoothListener btl  )  [inherited]
 

Sets the Bluetooth Discovery listener. Causes a panic if there is already a listener set.

Parameters:
btl The listener, or NULL, to remove the set listener, if any.

void MAUtil::Environment::removeBluetoothListener  )  [inherited]
 

Removes the set Bluetooth Discovery listener. Causes a panic if there is no listener set.

void MAUtil::Environment::setConnListener MAHandle  conn,
ConnListener cl
[inherited]
 

Sets the listener for a connection. Only one listener per connection is allowed, but the same ConnListener can be used with several connections.

void MAUtil::Environment::removeConnListener MAHandle  conn  )  [inherited]
 

Removes the listener for a connection, if any.

void MAUtil::Environment::addCloseListener CloseListener cl  )  [inherited]
 

Adds a listener for the Close event. Adds the specified listener to the end of the list, unless it is already in the list.

void MAUtil::Environment::removeCloseListener CloseListener cl  )  [inherited]
 

Removes a listener for the Close event. Removes the specified listener from the list, if it's in it. Must not be called from within closeEvent().

virtual void MAUtil::Environment::addIdleListener IdleListener il  )  [virtual, inherited]
 

Adds the specified IdleListener to the end of the list, unless it is already in the list.

IdleListeners are run again and again while they are registered. Take care, as constant processor usage will drain battery power quickly.

virtual void MAUtil::Environment::removeIdleListener IdleListener il  )  [virtual, inherited]
 

Removes the specified IdleListener from the list, if it's in it.

void MAUtil::Environment::addTimer TimerListener tl,
int  period,
int  numTimes
[inherited]
 

Adds a timer. This causes the runTimerEvent() function of the specified TimerListener to be called a number of times, at a fixed rate. The timer is then removed automatically.

You can only have one timer per listener, so if a timer with the specified listener is already active, it is overwritten.

Parameters:
tl The TimerListener to use.
period The timer's average period, in milliseconds.
numTimes The number of periods that should pass before the timer is removed. May be zero or negative. If so, the timer is never removed automatically.

void MAUtil::Environment::removeTimer TimerListener tl  )  [inherited]
 

Removes the timer associated with the specified listener, if any.

static Environment& MAUtil::Environment::getEnvironment  )  [static, inherited]
 

Returns a reference to the Environment. Causes a panic if no Environment exists.

void MAUtil::Environment::fireFocusGainedEvent  )  [protected, inherited]
 

Calls focusGained() of all registered FocusListeners.

void MAUtil::Environment::fireFocusLostEvent  )  [protected, inherited]
 

Calls focusLost() of all registered FocusListeners.

void MAUtil::Environment::fireKeyPressEvent int  keyCode,
int  nativeCode
[protected, inherited]
 

Calls keyPressEvent() of all registered KeyListeners with the specified keyCode.

void MAUtil::Environment::fireKeyReleaseEvent int  keyCode,
int  nativeCode
[protected, inherited]
 

Calls keyReleaseEvent() of all registered KeyListeners with the specified keyCode.

void MAUtil::Environment::firePointerPressEvent MAPoint2d  p  )  [protected, inherited]
 

Calls pointerPressEvent() of all registered PointerListeners with the specified keyCode.

void MAUtil::Environment::firePointerMoveEvent MAPoint2d  p  )  [protected, inherited]
 

Calls pointerMoveEvent() of all registered PointerListeners with the specified keyCode.

void MAUtil::Environment::firePointerReleaseEvent MAPoint2d  p  )  [protected, inherited]
 

Calls pointerReleaseEvent() of all registered PointerListeners with the specified keyCode.

void MAUtil::Environment::fireBluetoothEvent int  state  )  [protected, inherited]
 

Calls the registered BluetoothListener, if any.

void MAUtil::Environment::fireConnEvent const MAConnEventData data  )  [protected, inherited]
 

Calls the registered ConnListener, if any, for the MAHandle specified by data.

void MAUtil::Environment::fireCloseEvent  )  [protected, inherited]
 

Calls all registered CloseListeners.

void MAUtil::Environment::runIdleListeners  )  [protected, inherited]
 

Calls all registered IdleListeners once each.

virtual void MAUtil::KeyListener::keyPressEvent int  keyCode  )  [inline, virtual, inherited]
 

virtual void MAUtil::KeyListener::keyReleaseEvent int  keyCode  )  [inline, virtual, inherited]
 


Member Data Documentation

bool MAUtil::Moblet::mRun [protected]
 

Controls the continued execution of the Moblet's event loop. Setting it to 'false' will cause Moblet::run() to return upon completing its current iteration.

ListenerSet<KeyListener> MAUtil::Environment::mKeyListeners [protected, inherited]
 

ListenerSet<PointerListener> MAUtil::Environment::mPointerListeners [protected, inherited]
 

BluetoothListener* MAUtil::Environment::mBtListener [protected, inherited]
 

Vector<CloseListener*> MAUtil::Environment::mCloseListeners [protected, inherited]
 

ListenerSet<ConnListener> MAUtil::Environment::mConnListeners [protected, inherited]
 

ListenerSet<IdleListener> MAUtil::Environment::mIdleListeners [protected, inherited]
 

ListenerSet<TimerEventInstance> MAUtil::Environment::mTimerEvents [protected, inherited]
 

ListenerSet<FocusListener> MAUtil::Environment::mFocusListeners [protected, inherited]
 


Generated on Sat Feb 13 00:15:40 2010 for MoSync 2 beta 1 by  doxygen 1.4.6-NO