Interface Class Reference

OO interface for event handling using different OS abstraction layers. More...

#include <Interface.h>

Inheritance diagram for Interface:

Inheritance graph
[legend]
Collaboration diagram for Interface:

Collaboration graph
[legend]
List of all members.

Public Types

 LEFT_BUTTON = 1
 MIDDLE_BUTTON = 1 << 1
 RIGHT_BUTTON = 1 << 2
 FOURTH_BUTTON = 1 << 3
 FIFTH_BUTTON = 1 << 4
enum  MouseButtonType {
  LEFT_BUTTON = 1, MIDDLE_BUTTON = 1 << 1, RIGHT_BUTTON = 1 << 2, FOURTH_BUTTON = 1 << 3,
  FIFTH_BUTTON = 1 << 4
}
 Mouse buttons that can be detected. More...

Public Member Functions

virtual ~Interface ()
 Empty destructor.
virtual int start ()=0
 Enter the main loop of the interface.
virtual void flush ()=0
 Make all drawings visible on-screen (i.e. flush any buffers).
virtual void repaint ()=0
 Mark the scene as needing repainting.
virtual void setIdleCallback (void(*func)(void))=0
 Set the idle callback function.
virtual void setPaintCallback (void(*func)(void))=0
 Set the paint callback function.
virtual void setKeyboardCallback (void(*func)(int key, int x, int y, bool special, bool down, unsigned int modifiers))=0
 Set the keyboard callback function.
virtual void addTimerCallback (void(*func)(int value), int time_ms, int val=0)=0
 Add a timer callback.
virtual void setMouseEventCallback (void(*func)(int x, int y, MouseButtonType button, bool down))=0
 Set the mouse clicked callback function.
virtual void setMouseMotionCallback (void(*func)(int x, int y))=0
 Set the mouse motion callback function.
virtual void setRawEventCallback (void(*func)(void *event))=0
 Set the raw event callback function.
virtual void setWindowSize (int width, int height)=0
 Change the size of the current window.
virtual void setFullScreen (bool fullScreen)=0
 Set the fullscreen mode.
virtual bool getFullScreen (void)=0
 Check if the application is currently in fullscreen or windowed mode.
virtual int getTime ()=0
 Get a timestamp that is incremented with one every ms.
virtual int getWindowWidth ()=0
 Get width of current window.
virtual int getWindowHeight ()=0
 Get height of current window.
virtual const char * name ()
 Return the name of this interface type.

Static Public Member Functions

static InterfaceGetSharedInstance ()
 Return a pointer to the singleton object representing the applications interface.
static int Init (Interface *iface, int argc, const char *argv[], int width, int height)
 Initialize the singleton object with a specific instance of an Interface.
static void Exit ()
 Clean up the singleton object.

Protected Member Functions

virtual int init (int argc, const char *argv[], int width, int height)=0

Static Private Attributes

static InterfacesharedInstance

Detailed Description

OO interface for event handling using different OS abstraction layers.


Member Enumeration Documentation

enum Interface::MouseButtonType

Mouse buttons that can be detected.

Enumerator:
LEFT_BUTTON 
MIDDLE_BUTTON 
RIGHT_BUTTON 
FOURTH_BUTTON 
FIFTH_BUTTON 


Constructor & Destructor Documentation

virtual Interface::~Interface (  )  [inline, virtual]

Empty destructor.


Member Function Documentation

virtual void Interface::addTimerCallback ( void(*)(int value)  func,
int  time_ms,
int  val = 0 
) [pure virtual]

Add a timer callback.

Parameters:
func a function to call when the timer expires, NULL for none.
time_ms The time in ms until the timer fires.
val An optional value to pass to the timer function.
Note:
The timer is not repeated.

Implemented in GLUTInterface, and SDLInterface.

static void Interface::Exit (  )  [static]

Clean up the singleton object.

virtual void Interface::flush (  )  [pure virtual]

Make all drawings visible on-screen (i.e. flush any buffers).

Implemented in GLUTInterface, and SDLInterface.

virtual bool Interface::getFullScreen ( void   )  [pure virtual]

Check if the application is currently in fullscreen or windowed mode.

Returns:
true if application is in fullscreen mode, false if in windowed mode.

Implemented in SDLInterface.

static Interface* Interface::GetSharedInstance (  )  [inline, static]

Return a pointer to the singleton object representing the applications interface.

virtual int Interface::getTime (  )  [pure virtual]

Get a timestamp that is incremented with one every ms.

The time at which getTime returns 0 is undefined.

Implemented in GLUTInterface, and SDLInterface.

virtual int Interface::getWindowHeight (  )  [pure virtual]

Get height of current window.

Implemented in GLUTInterface, and SDLInterface.

virtual int Interface::getWindowWidth (  )  [pure virtual]

Get width of current window.

Implemented in GLUTInterface, and SDLInterface.

virtual int Interface::init ( int  argc,
const char *  argv[],
int  width,
int  height 
) [protected, pure virtual]

Implemented in GLUTInterface, and SDLInterface.

static int Interface::Init ( Interface iface,
int  argc,
const char *  argv[],
int  width,
int  height 
) [static]

Initialize the singleton object with a specific instance of an Interface.

Parameters:
iface A specific instance of an Interface.
argc number of strings in argv
argv interesting argument strings for the interface initialization
width Create a default window with this width
height Create a default window with this height

virtual const char* Interface::name (  )  [inline, virtual]

Return the name of this interface type.

Reimplemented in GLUTInterface, and SDLInterface.

virtual void Interface::repaint (  )  [pure virtual]

Mark the scene as needing repainting.

Implemented in GLUTInterface, and SDLInterface.

virtual void Interface::setFullScreen ( bool  fullScreen  )  [pure virtual]

Set the fullscreen mode.

Parameters:
fullScreen If true switch to full screen mode, if false switch to window mode.

Implemented in GLUTInterface, and SDLInterface.

virtual void Interface::setIdleCallback ( void(*)(void)  func  )  [pure virtual]

Set the idle callback function.

Parameters:
func a function to call when no other events are pending, NULL for none.

Implemented in GLUTInterface, and SDLInterface.

virtual void Interface::setKeyboardCallback ( void(*)(int key, int x, int y, bool special, bool down, unsigned int modifiers)  func  )  [pure virtual]

Set the keyboard callback function.

Parameters:
func a function to call when a keyboard event is detected, NULL for none.

Implemented in SDLInterface.

virtual void Interface::setMouseEventCallback ( void(*)(int x, int y, MouseButtonType button, bool down)  func  )  [pure virtual]

Set the mouse clicked callback function.

Parameters:
func a function to call when any mouse button is clicked, NULL for none.

virtual void Interface::setMouseMotionCallback ( void(*)(int x, int y)  func  )  [pure virtual]

Set the mouse motion callback function.

Parameters:
func a function to call when mouse moves, NULL for none.

Implemented in GLUTInterface, and SDLInterface.

virtual void Interface::setPaintCallback ( void(*)(void)  func  )  [pure virtual]

Set the paint callback function.

Parameters:
func a function to call to draw the scene, NULL for none.

Implemented in GLUTInterface, and SDLInterface.

virtual void Interface::setRawEventCallback ( void(*)(void *event)  func  )  [pure virtual]

Set the raw event callback function.

Parameters:
func a function to call for each new event, NULL for none.

Implemented in SDLInterface.

virtual void Interface::setWindowSize ( int  width,
int  height 
) [pure virtual]

Change the size of the current window.

Implemented in GLUTInterface, and SDLInterface.

virtual int Interface::start (  )  [pure virtual]

Enter the main loop of the interface.

Implemented in GLUTInterface, and SDLInterface.


Member Data Documentation

Interface* Interface::sharedInstance [static, private]


The documentation for this class was generated from the following file:
Generated on Sun Mar 11 15:33:26 2007 for MetalWarriors by  doxygen 1.4.7