Wt::SDLEvent Class Reference

#include <sdlevent.h>

Inheritance diagram for Wt::SDLEvent:

Inheritance graph
[legend]
Collaboration diagram for Wt::SDLEvent:

Collaboration graph
[legend]
List of all members.

Public Types

typedef void(*) SDLEventHandler (const SDL_Event *event)

Public Member Functions

SDLEventHandleroperator[] (int event_type)
 register event handler
const SDLEventHandleroperator[] (int event_type) const
 get current handler

Static Public Member Functions

static void push (SDL_Event *event)
 pushes an SDL event to SDL stack
static void handle (const SDL_Event *event)
 handle the event
static void wait ()
 handle all events so far
static DERIVED * instance ()
template<class GRANDCHILD>
static DERIVED * instance ()
 instantiates the pointer compatible child of DERIVED aka grandchild
static DERIVED * existingInstance ()
static void init ()
static void quit ()

Static Public Attributes

static const Member None = SDL_NOEVENT
static const Member Active = SDL_ACTIVEEVENT
static const Member KeyDown = SDL_KEYDOWN
static const Member KeyUp = SDL_KEYUP
static const Member MouseMotion = SDL_MOUSEMOTION
static const Member MouseButtonDown = SDL_MOUSEBUTTONDOWN
static const Member MouseButtonUp = SDL_MOUSEBUTTONUP
static const Member JoyAxisMotion = SDL_JOYAXISMOTION
static const Member JoyBallMotion = SDL_JOYBALLMOTION
static const Member JoyHatMotion = SDL_JOYHATMOTION
static const Member JoyButtonDown = SDL_JOYBUTTONDOWN
static const Member JoyButtonUp = SDL_JOYBUTTONUP
static const Member Quit = SDL_QUIT
static const Member SysWM = SDL_SYSWMEVENT
static const Member VideoResize = SDL_VIDEORESIZE
static const Member VideoExpose = SDL_VIDEOEXPOSE
static const Member Time = SDL_USEREVENT
static const Member Audio
static const Member Net
static const Member User = SDL_USEREVENT + 3
static const Member NumEvents = SDL_NUMEVENTS
 we can't exceed this

Protected Member Functions

 SDLEvent ()
 ~SDLEvent ()

Static Protected Member Functions

static DERIVED * load ()
 try to load the instance

Static Protected Attributes

static DERIVED * instance_ = 0

Static Private Attributes

static std::vector< SDLEventHandlerhandlers

Friends

class Singleton< SDLEvent >

Detailed Description

Definition at line 33 of file sdlevent.h.


Member Typedef Documentation

typedef void(*) Wt::SDLEvent::SDLEventHandler(const SDL_Event *event)

Definition at line 61 of file sdlevent.h.


Constructor & Destructor Documentation

Wt::SDLEvent::SDLEvent (  )  [protected]

Definition at line 55 of file sdlevent.cpp.

References FE_Init(), handlers, and NumEvents.

00056         : Singleton<SDLEvent>(this) {
00057     handlers.resize(NumEvents, 0);
00058     // initialize fast events
00059     FE_Init();
00060 }

Here is the call graph for this function:

Wt::SDLEvent::~SDLEvent (  )  [protected]

Definition at line 62 of file sdlevent.cpp.

References FE_Quit().

00062                     {
00063     FE_Quit();
00064 }

Here is the call graph for this function:


Member Function Documentation

template<class DERIVED>
static DERIVED* Wt::Singleton< DERIVED >::existingInstance (  )  [inline, static, inherited]

Definition at line 36 of file singleton.h.

Referenced by Wt::Application::exit(), Wt::Application::postEvent(), Wt::Application::sendEvent(), and Wt::Application::sendPostedEvents().

00036                                        {
00037         return instance_;
00038     }

void Wt::SDLEvent::handle ( const SDL_Event *  event  )  [static]

handle the event

Definition at line 70 of file sdlevent.cpp.

References handlers, User, and Warn.

Referenced by wait().

00070                                             {
00071     //trace("sdlevent", "Incoming SDL_Event type: %d\n", event->type);
00072     assert(event->type <= User);
00073     if (handlers[event->type]) {
00074         handlers[event->type](event);
00075     } else {
00076         Warn("Unhandled event %d\n", event->type);
00077     }
00078 }

template<class DERIVED>
static void Wt::Singleton< DERIVED >::init (  )  [inline, static, inherited]

Note:
cannot fail

Reimplemented in Wt::Application.

Definition at line 49 of file singleton.h.

Referenced by Wt::Application::Application().

00049                        {
00050         if (!instance()) {
00051             assert(0);
00052         }
00053     }

template<class DERIVED>
template<class GRANDCHILD>
static DERIVED* Wt::Singleton< DERIVED >::instance (  )  [inline, static, inherited]

instantiates the pointer compatible child of DERIVED aka grandchild

it is handy in driver like situations

Definition at line 43 of file singleton.h.

00043                                {
00044         return (instance_) ? instance_ : GRANDCHILD::load();
00045     }

template<class DERIVED>
static DERIVED* Wt::Singleton< DERIVED >::instance (  )  [inline, static, inherited]

Definition at line 32 of file singleton.h.

Referenced by Wt::Audio::Audio(), Wt::Sound::available(), Wt::SDLMixer::Chunk::channel(), Wt::NullAudio::Chunk::channel(), Wt::SDLSurface::defaultDepth(), Wt::SDLInput::EventInfo::EventInfo(), Wt::Dialog::exec(), Wt::Widget::grabKeyboard(), Wt::Widget::grabMouse(), Wt::Audio::handleAudioEvent(), Wt::SDLInput::handleKeyEvent(), Wt::Singleton< Wt::Audio >::init(), Wt::SDLTimer::init(), Wt::Sound::isAvailable(), Wt::Widget::keyboardGrabber(), Wt::Audio::load(), Wt::Widget::mouseGrabber(), Wt::SDLMixer::onChannelFinish(), Wt::Audio::onChannelFinish(), Wt::Sound::play(), Wt::Singleton< Wt::Audio >::quit(), Wt::Widget::releaseKeyboard(), Wt::Widget::releaseMouse(), Wt::SDLInput::SDLInput(), Wt::SDLMixer::setMusicVolume(), Wt::SDLMixer::Channel::setVolume(), and Wt::SDLMixer::Chunk::setVolume().

00032                                {
00033         return (instance_) ? instance_ : DERIVED::load();
00034     }

template<class DERIVED>
static DERIVED* Wt::Singleton< DERIVED >::load (  )  [inline, static, protected, inherited]

try to load the instance

if it fails return NULL if it succeeds must return the newly created object

Reimplemented in Wt::Audio, Wt::NullAudio, and Wt::SDLMixer.

Definition at line 86 of file singleton.h.

00086                            {
00087         instance_ = new DERIVED;
00088         return  instance_;
00089     }

const SDLEvent::SDLEventHandler & Wt::SDLEvent::operator[] ( int  event_type  )  const

get current handler

Definition at line 90 of file sdlevent.cpp.

References handlers.

00090                                                                         {
00091     return handlers[event_type];
00092 }

SDLEvent::SDLEventHandler & Wt::SDLEvent::operator[] ( int  event_type  ) 

register event handler

Definition at line 87 of file sdlevent.cpp.

References handlers.

00087                                                             {
00088     return handlers[event_type];
00089 }

void Wt::SDLEvent::push ( SDL_Event *  event  )  [static]

pushes an SDL event to SDL stack

Definition at line 66 of file sdlevent.cpp.

References FE_PushEvent().

Referenced by Wt::Audio::onChannelFinish(), Wt::Audio::onMusicFinish(), and Wt::timer_callback().

00066                                     {
00067     FE_PushEvent(event);
00068 }

Here is the call graph for this function:

template<class DERIVED>
static void Wt::Singleton< DERIVED >::quit (  )  [inline, static, inherited]

Reimplemented in Wt::Application.

Definition at line 55 of file singleton.h.

Referenced by Wt::Application::~Application().

00055                        {
00056         delete instance();
00057     }

void Wt::SDLEvent::wait (  )  [static]

handle all events so far

Definition at line 81 of file sdlevent.cpp.

References FE_WaitEvent(), and handle().

Referenced by Wt::Application::processEvents().

00081                     {
00082     SDL_Event event;
00083     FE_WaitEvent(&event);
00084     handle(&event);
00085 }

Here is the call graph for this function:


Friends And Related Function Documentation

friend class Singleton< SDLEvent > [friend]

Definition at line 35 of file sdlevent.h.


Member Data Documentation

const SDLEvent::Member Wt::SDLEvent::Active = SDL_ACTIVEEVENT [static]

Definition at line 38 of file sdlevent.h.

Referenced by Wt::SDLInput::SDLInput().

const SDLEvent::Member Wt::SDLEvent::Audio [static]

Definition at line 54 of file sdlevent.h.

Referenced by Wt::Audio::Audio(), Wt::Audio::onChannelFinish(), and Wt::Audio::onMusicFinish().

std::vector< SDLEvent::SDLEventHandler > Wt::SDLEvent::handlers [static, private]

Definition at line 79 of file sdlevent.h.

Referenced by handle(), operator[](), and SDLEvent().

template<class DERIVED>
DERIVED * Wt::Singleton< DERIVED >::instance_ = 0 [static, protected, inherited]

Definition at line 91 of file singleton.h.

Referenced by Wt::Singleton< Wt::Audio >::existingInstance(), Wt::Singleton< Wt::Audio >::instance(), Wt::Singleton< Wt::Audio >::load(), Wt::SDLDisplay::load(), Wt::Audio::load(), Wt::Singleton< Wt::Audio >::Singleton(), and Wt::Singleton< Wt::Audio >::~Singleton().

const SDLEvent::Member Wt::SDLEvent::JoyAxisMotion = SDL_JOYAXISMOTION [static]

Definition at line 44 of file sdlevent.h.

const SDLEvent::Member Wt::SDLEvent::JoyBallMotion = SDL_JOYBALLMOTION [static]

Definition at line 45 of file sdlevent.h.

const SDLEvent::Member Wt::SDLEvent::JoyButtonDown = SDL_JOYBUTTONDOWN [static]

Definition at line 47 of file sdlevent.h.

const SDLEvent::Member Wt::SDLEvent::JoyButtonUp = SDL_JOYBUTTONUP [static]

Definition at line 48 of file sdlevent.h.

const SDLEvent::Member Wt::SDLEvent::JoyHatMotion = SDL_JOYHATMOTION [static]

Definition at line 46 of file sdlevent.h.

const SDLEvent::Member Wt::SDLEvent::KeyDown = SDL_KEYDOWN [static]

Definition at line 39 of file sdlevent.h.

Referenced by Wt::SDLInput::SDLInput().

const SDLEvent::Member Wt::SDLEvent::KeyUp = SDL_KEYUP [static]

Definition at line 40 of file sdlevent.h.

Referenced by Wt::SDLInput::SDLInput().

const SDLEvent::Member Wt::SDLEvent::MouseButtonDown = SDL_MOUSEBUTTONDOWN [static]

Definition at line 42 of file sdlevent.h.

Referenced by Wt::SDLInput::SDLInput().

const SDLEvent::Member Wt::SDLEvent::MouseButtonUp = SDL_MOUSEBUTTONUP [static]

Definition at line 43 of file sdlevent.h.

Referenced by Wt::SDLInput::SDLInput().

const SDLEvent::Member Wt::SDLEvent::MouseMotion = SDL_MOUSEMOTION [static]

Definition at line 41 of file sdlevent.h.

Referenced by Wt::SDLInput::SDLInput().

const SDLEvent::Member Wt::SDLEvent::Net [static]

Definition at line 55 of file sdlevent.h.

const SDLEvent::Member Wt::SDLEvent::None = SDL_NOEVENT [static]

Definition at line 37 of file sdlevent.h.

const SDLEvent::Member Wt::SDLEvent::NumEvents = SDL_NUMEVENTS [static]

we can't exceed this

Definition at line 57 of file sdlevent.h.

Referenced by SDLEvent().

const SDLEvent::Member Wt::SDLEvent::Quit = SDL_QUIT [static]

Definition at line 49 of file sdlevent.h.

Referenced by Wt::SDLInput::SDLInput().

const SDLEvent::Member Wt::SDLEvent::SysWM = SDL_SYSWMEVENT [static]

Definition at line 50 of file sdlevent.h.

Referenced by Wt::SDLInput::SDLInput().

const SDLEvent::Member Wt::SDLEvent::Time = SDL_USEREVENT [static]

Definition at line 53 of file sdlevent.h.

Referenced by Wt::SDLTimer::init(), and Wt::timer_callback().

const SDLEvent::Member Wt::SDLEvent::User = SDL_USEREVENT + 3 [static]

Definition at line 56 of file sdlevent.h.

Referenced by handle().

const SDLEvent::Member Wt::SDLEvent::VideoExpose = SDL_VIDEOEXPOSE [static]

Definition at line 52 of file sdlevent.h.

Referenced by Wt::SDLInput::SDLInput().

const SDLEvent::Member Wt::SDLEvent::VideoResize = SDL_VIDEORESIZE [static]

Definition at line 51 of file sdlevent.h.

Referenced by Wt::SDLInput::SDLInput().


The documentation for this class was generated from the following files:

Generated Fri Jul 28 19:32:23 2006.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.