MoSync 3.3
MAUtil::GLMoblet Class Reference

OpenGL|ES fullscreen moblet. More...

#include <MAUtil/GLMoblet.h>

Inheritance diagram for MAUtil::GLMoblet:
MAUtil::Moblet MAUtil::Environment MAUtil::KeyListener MAUtil::PointerListener MAUtil::CloseListener MAUtil::CustomEventListener

List of all members.

Public Types

enum  ApiVersion { GL1 = 1, GL2 = 2 }

Public Member Functions

 GLMoblet (int apiVersions)
virtual void init ()=0
virtual void draw ()=0
void startDrawing ()
void stopDrawing ()
bool isDrawing () const
ApiVersion getApiVersion () const
float getActualFramesPerSecond () const
void setPreferredFramesPerSecond (float fps)
virtual void keyPressEvent (int keyCode, int nativeCode)
virtual void keyPressEvent (int keyCode)
virtual void keyReleaseEvent (int keyCode, int nativeCode)
virtual void keyReleaseEvent (int keyCode)
virtual void pointerPressEvent (MAPoint2d p)
virtual void pointerMoveEvent (MAPoint2d p)
virtual void pointerReleaseEvent (MAPoint2d p)
virtual void multitouchPressEvent (MAPoint2d p, int touchId)
virtual void multitouchMoveEvent (MAPoint2d p, int touchId)
virtual void multitouchReleaseEvent (MAPoint2d p, int touchId)
virtual void closeEvent () __attribute__((noreturn))
virtual void customEvent (const MAEvent &event)
void exit ()
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)
void addCustomEventListener (CustomEventListener *cl)
void removeCustomEventListener (CustomEventListener *cl)
void addTextBoxListener (TextBoxListener *tl)
void removeTextBoxListener (TextBoxListener *tl)
void addSensorListener (SensorListener *tl)
void removeSensorListener (SensorListener *tl)
void addOrientationListener (OrientationListener *ol)
void removeOrientationListener (OrientationListener *ol)
void addCameraListener (CameraListener *camListener)
void removeCameraListener (CameraListener *camListener)
PLATFORM_TYPE getCurrentPlatform ()
void addMediaExportListener (MediaExportListener *meListener)
void removeMediaExportListener (MediaExportListener *meListener)
virtual void charEvent (uint character)

Static Public Member Functions

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

Protected Member Functions

void fireFocusGainedEvent ()
void fireFocusLostEvent ()
void fireKeyPressEvent (int keyCode, int nativeCode)
void fireKeyReleaseEvent (int keyCode, int nativeCode)
void fireCharEvent (uint character)
void firePointerPressEvent (MAPoint2d p)
void firePointerMoveEvent (MAPoint2d p)
void firePointerReleaseEvent (MAPoint2d p)
void fireMultitouchPressEvent (MAPoint2d p, int touchId)
void fireMultitouchMoveEvent (MAPoint2d p, int touchId)
void fireMultitouchReleaseEvent (MAPoint2d p, int touchId)
void fireBluetoothEvent (int state)
void fireCustomEventListeners (const MAEvent &e)
void fireTextBoxListeners (int result, int textLength)
void fireSensorListeners (MASensor a)
void fireConnEvent (const MAConnEventData &data)
void fireCloseEvent ()
void fireOrientationChangedEvent (int screenOrientation)
void fireOrientationWillChangeEvent ()
void fireCameraEvent (const MAEvent &cameraEvent)
void fireMediaExportEvent (const MAEvent &mediaExportEvent)
void runIdleListeners ()

Protected Attributes

bool mRun
ListenerSet< KeyListenermKeyListeners
ListenerSet< PointerListenermPointerListeners
BluetoothListenermBtListener
Vector< CloseListener * > mCloseListeners
ListenerSet< ConnListenermConnListeners
ListenerSet< IdleListenermIdleListeners
ListenerSet< TimerEventInstancemTimerEvents
ListenerSet< FocusListenermFocusListeners
ListenerSet< CustomEventListenermCustomEventListeners
ListenerSet< TextBoxListenermTextBoxListeners
ListenerSet< SensorListenermSensorListeners
ListenerSet< OrientationListenermOrientationListeners
ListenerSet< CameraListenermCameraListeners
ListenerSet< MediaExportListenermMediaExportListeners
PLATFORM_TYPE mCurrentPlatform

Friends

class GLMobletListener

Detailed Description

OpenGL|ES fullscreen moblet.


Member Enumeration Documentation

Enum of the different OpenGL|ES versions that may be supported on the system.

Enumerator:
GL1 
GL2 

Constructor & Destructor Documentation

MAUtil::GLMoblet::GLMoblet ( int  apiVersions)

Constructor for the GLMoblet.

Parameters:
apiVersionA mask of the api versions supported by the application. The latest api version that is available on the system will be initialized. If none of the api versions are available, the system sends a panic.

Member Function Documentation

virtual void MAUtil::GLMoblet::init ( ) [pure virtual]

This function will be called when the OpenGL|ES fullscreen window is initialized and the context is bound. Override it to do initialization for the application. No OpenGL|ES calls may be used until this function has been invoked by the system. startDrawing is automatically executed after this function has been invoked. Use getApiVersion to check which version has been initialized.

virtual void MAUtil::GLMoblet::draw ( ) [pure virtual]

This function will be invoked continuously after startDrawing has been invoked. Override it to do the application drawing. When the execution returns it automatically flips the screen.

Use this function to enable drawing, i.e. set the system to start calling 'draw' continuously. This function is called automatically if the application focus is gained.

Use this function to disable drawing, i.e. set the system to stop calling 'draw' continuously. This function is called automatically if the application focus is lost.

Use this function to ask the system whether it has drawing enabled or disabled.

Returns the api version the GLMoblet was initialized to. Use this to choose code paths if you want to support both OpenGL|ES 1.1 and 2.0

Get the current frames per second. Will take some time since drawing has started to become stable. Will be 0 if isDrawing equals to false.

Sets the amount of calls to 'draw' per second. This is the optimal amount of frames per second. If 'draw' do complex drawing it might get invoked less times per second. Default is as fast as possible.

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

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

Reimplemented from MAUtil::KeyListener.

Reimplemented in Wormhole::WebAppMoblet.

virtual void MAUtil::KeyListener::keyPressEvent ( int  keyCode) [inline, virtual, inherited]
virtual void MAUtil::Moblet::keyReleaseEvent ( int  keyCode,
int  nativeCode 
) [inline, virtual, inherited]

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

Reimplemented from MAUtil::KeyListener.

virtual void MAUtil::KeyListener::keyReleaseEvent ( int  keyCode) [inline, virtual, inherited]
virtual void MAUtil::Moblet::pointerPressEvent ( MAPoint2d  p) [inline, virtual, inherited]

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

Implements MAUtil::PointerListener.

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

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

Implements MAUtil::PointerListener.

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

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

Implements MAUtil::PointerListener.

virtual void MAUtil::Moblet::multitouchPressEvent ( MAPoint2d  p,
int  touchId 
) [inline, virtual, inherited]

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

Reimplemented from MAUtil::PointerListener.

virtual void MAUtil::Moblet::multitouchMoveEvent ( MAPoint2d  p,
int  touchId 
) [inline, virtual, inherited]

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

Reimplemented from MAUtil::PointerListener.

virtual void MAUtil::Moblet::multitouchReleaseEvent ( MAPoint2d  p,
int  touchId 
) [inline, virtual, inherited]

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

Reimplemented from MAUtil::PointerListener.

virtual void MAUtil::Moblet::closeEvent ( ) [virtual, inherited]

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, inherited]

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

Implements MAUtil::CustomEventListener.

static void MAUtil::Moblet::run ( Moblet moblet) [static, inherited]

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, inherited]

Shuts down the running application.

void MAUtil::Moblet::exit ( ) [inherited]

Stops the running moblet.

Referenced by MAUtil::Moblet::~Moblet().

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

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

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

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

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.

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

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

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

Sets the Bluetooth listener. Any previously set listener is replaced.

Parameters:
btlThe listener.

Removes the Bluetooth listener, if any.

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.

Removes the listener for a connection, if any.

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

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:
tlThe TimerListener to use.
periodThe timer's average period, in milliseconds.
numTimesThe 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.

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

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

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

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

void MAUtil::Environment::addCameraListener ( CameraListener camListener) [inherited]
void MAUtil::Environment::removeCameraListener ( CameraListener camListener) [inherited]

Retrieves the current platform.

Adds listener for media export events.

Removes media export events listener.

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::fireCharEvent ( uint  character) [protected, inherited]

Calls charEvent() of all registered KeyListeners with the specified character.

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::fireMultitouchPressEvent ( MAPoint2d  p,
int  touchId 
) [protected, inherited]

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

void MAUtil::Environment::fireMultitouchMoveEvent ( MAPoint2d  p,
int  touchId 
) [protected, inherited]

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

void MAUtil::Environment::fireMultitouchReleaseEvent ( MAPoint2d  p,
int  touchId 
) [protected, inherited]

Calls multitouchReleaseEvent() 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::fireCustomEventListeners ( const MAEvent e) [protected, inherited]

Calls the registered custom event listeners, if any.

void MAUtil::Environment::fireTextBoxListeners ( int  result,
int  textLength 
) [protected, inherited]

Calls the registered text box listeners, if any.

void MAUtil::Environment::fireSensorListeners ( MASensor  a) [protected, inherited]

Calls the registered sensor listeners, 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::fireOrientationChangedEvent ( int  screenOrientation) [protected, inherited]

Calls orientationChanged() of all registered orientation listeners.

void MAUtil::Environment::fireOrientationWillChangeEvent ( ) [protected, inherited]

Calls orientationWillChange() of all registered orientation listeners.

void MAUtil::Environment::fireCameraEvent ( const MAEvent cameraEvent) [protected, inherited]

Calls cameraEvent() of all registered camera listeners.

void MAUtil::Environment::fireMediaExportEvent ( const MAEvent mediaExportEvent) [protected, inherited]

Calls specific method of all media export listeners. The method called depends on the media export operation.

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

Calls all registered IdleListeners once each.

virtual void MAUtil::KeyListener::charEvent ( uint  character) [virtual, inherited]
Parameters:
characterA Unicode character.

Reimplemented in MAUtil::CharInput.


Friends And Related Function Documentation

friend class GLMobletListener [friend]

Member Data Documentation

bool MAUtil::Moblet::mRun [protected, inherited]

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.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines