Public Member Functions | Static Public Member Functions | Protected Member Functions

wit::Application Class Reference

#include <wit/application.h>

List of all members.

Public Member Functions

 Application (int features=AllFeatures)
virtual ~Application ()
Consoleconsole () const
int features () const
void * framebuffer () const
int screenWidth () const
int screenHeight () const
void setAutoHomeMenu (bool on)
bool autoHomeMenu () const
bool isHomeMenuVisible () const
virtual void showHomeMenu ()
virtual void hideHomeMenu ()
void reboot ()
void shutdown (ShutdownMode mode=Shutdown_Auto)
void returnToMenu ()
void quit ()
void run ()
virtual void postEvent (Event *event)
void pushFocus (EventHandler *handler, int controllerID=-1)
EventHandlercurrentFocus (int controllerID=-1) const
EventHandlerpopFocus (int controllerID=-1)
void removeFromFocusStack (EventHandler *handler, int controllerID=-1)
void installEventFilter (EventHandler *handler)
void removeEventFilter (EventHandler *handler)
void scheduleTimer (int frames, EventHandler *handler, void *data)
bool abortGxOnReset () const
void setAbortGxOnReset (bool on)

Static Public Member Functions

static Applicationinstance ()

Protected Member Functions

virtual void resetButtonPressed ()
virtual void powerButtonPressed (int controllerID)
virtual void homeMenuEvent (Event *event)
void setHomeMenuVisible (bool on)

Detailed Description

The Application class is the central component of the WIT toolkit. Application is responsible for initializing the Wii hardware and providing the main event loop, where all events from the other sources are processed and dispatched.

The main areas of interest are:

Additionally, Application provides two ways to preview and modify all events that are dispatched:

Overriding postEvent() has less overhead and is guaranteed to give you the earliest access possible to each event, but a program can only use a single subclass of Application whereas multiple event filters can be installed. See the documentation for these functions for more information.

Focus Stacks

For event dispatching, WIT has the concept of focus stacks. Each controller has its own parallel focus stack. Whenever a non-pointer event is dispatched, it is first sent to all installed event filters and then it is sent to each object on that controller's focus stack, starting from the most recently added, until an object consumes the event.

In addition to each controller's individual stack, objects can be added to the global focus stack. When an object is added to the global focus stack, it takes precedence over all objects currently on individual focus stacks, but other objects subsequently pushed onto one of these individual stacks will take precedence over the object on the global stack.

The concept may be better illustrated graphically:

1
13
Global
2
234

In such a situation, events generated by controllers 1 and 3 would be first dispatched to the objects on top of their respective stacks, but events generated by controllers 2 and 4 would be first dispatched to the object on the global stack. If the object on the global stack were removed, the current focus would not change for controllers 1 and 3, but controllers 2 and 4 would each return to dispatching events to their current stacks.

Definition at line 13 of file application.h.


Constructor & Destructor Documentation

wit::Application::Application ( int  features = AllFeatures )

Creates a WIT application with the requested features.

Definition at line 126 of file application.cpp.

wit::Application::~Application (  ) [virtual]

Destroys the WIT application.

Definition at line 225 of file application.cpp.


Member Function Documentation

bool wit::Application::abortGxOnReset (  ) const

Returns true if the current GX operation will be aborted on reset.

See also:
setAbortGxOnReset()

Definition at line 961 of file application.cpp.

bool wit::Application::autoHomeMenu (  ) const

Returns true if the Home button on any controller will open the Home menu automatically.

See also:
setAutoHomeMenu
showHomeMenu

Definition at line 335 of file application.cpp.

Console * wit::Application::console (  ) const

Returns a pointer to the console, if it is enabled. If the console is disabled, this function returns 0.

Definition at line 276 of file application.cpp.

EventHandler * wit::Application::currentFocus ( int  controllerID = -1 ) const

Returns the object currently on top of the focus stack for the specified controller.

Passing -1 to controllerID (the default) will return the topmost object that has the global focus, that is, that will accept events from any controller.

See also:
pushFocus(), popFocus(), removeFromFocusStack()

Definition at line 828 of file application.cpp.

int wit::Application::features (  ) const

Returns a bitmask of the enabled features.

See also:
wit::ApplicationFeatures

Definition at line 285 of file application.cpp.

void * wit::Application::framebuffer (  ) const

Returns a pointer to the framebuffer.

Definition at line 293 of file application.cpp.

void wit::Application::hideHomeMenu (  ) [virtual]

Hides the Home menu, if it's visible.

Subclass implementations should invoke setHomeMenuVisible(false) to ensure event handling is properly restored.

See also:
showHomeMenu

Definition at line 372 of file application.cpp.

void wit::Application::homeMenuEvent ( Event event ) [protected, virtual]

Processes events triggered while the Home menu is visible.

See showHomeMenu for information on customizing Home menu behavior.

See also:
postEvent
showHomeMenu

Definition at line 385 of file application.cpp.

void wit::Application::installEventFilter ( EventHandler handler )

Adds a new event filter to the front of the filter chain.

See also:
removeEventFilter(), postEvent()

Definition at line 903 of file application.cpp.

Application * wit::Application::instance (  ) [static]

Returns a pointer to the running WIT application.

As a convenience, the global function witApp() is also provided.

Definition at line 267 of file application.cpp.

bool wit::Application::isHomeMenuVisible (  ) const

Returns true if the Home menu is currently visible.

See also:
showHomeMenu
hideHomeMenu

Definition at line 409 of file application.cpp.

EventHandler * wit::Application::popFocus ( int  controllerID = -1 )

Removes and returns the object on top of the focus stack.

Passing -1 to controllerID (the default) will remove the topmost object from the global focus stack, leaving the per-controller focus stacks unchanged.

See also:
pushFocus(), currentFocus(), removeFromFocusStack()

Definition at line 848 of file application.cpp.

void wit::Application::postEvent ( Event event ) [virtual]

Handles an event, dispatching it to the appropriate object(s).

When an event is posted, Application takes ownership of the event object passed to postEvent() and will delete the event object after it has been dispatched. Use operator new to create event objects.

To customize event dispatching, subclass Application and override this function. If you only need to preview all incoming events before they are dispatched to the object with the focus, use installEventFilter() instead.

Events are first sent to each event filter, in the opposite order they were installed, unless a filter returns true to cancel propagation.

After the event filters have been given an opportunity to preview the event, non-pointer events are dispatched to the object with the focus (see currentFocus()). If the object does not consume the event by returning true, it will be dispatched to the next object on the focus stack. Pointer events are dispatched to the topmost Hotspot object claiming the associated region of the screen. If multiple Hotspot objects with the same z-index claim the same region, the last Hotspot to be created receives the event.

See also:
wit::EventHandler::event()

Definition at line 752 of file application.cpp.

void wit::Application::powerButtonPressed ( int  controllerID ) [protected, virtual]

Invoked when the power button on the Wii console or on a Wii Remote is pressed.

controllerID indicates the ID of the Wii Remote that triggered the callback, or -1 if the power button on the console was pressed.

Override this function in a subclass to change the behavior of the power button. The default behavior invokes shutdown().

See also:
resetButtonPressed()

Definition at line 1006 of file application.cpp.

void wit::Application::pushFocus ( EventHandler handler,
int  controllerID = -1 
)

Adds an object to the top of the focus stack for the specified controller.

Passing -1 to controllerID (the default) will add the object to the global focus stack, that is, it will receive events for all controllers unless another object is pushed above it onto a controller's specific stack.

See also:
currentFocus(), popFocus(), removeFromFocusStack()

Definition at line 811 of file application.cpp.

void wit::Application::quit (  )

Signals the main event loop to stop running.

Definition at line 454 of file application.cpp.

void wit::Application::reboot (  )

Reboots the Wii hardware.

Definition at line 417 of file application.cpp.

void wit::Application::removeEventFilter ( EventHandler handler )

Removes an event filter from the filter chain.

See also:
installEventFilter()

Definition at line 917 of file application.cpp.

void wit::Application::removeFromFocusStack ( EventHandler handler,
int  controllerID = -1 
)

Removes the specified object from the focus stack for the specified controller.

Passing -1 to controllerID (the default) removes the object from all focus stacks.

See also:
pushFocus(), currentFocus(), popFocus()

Definition at line 877 of file application.cpp.

void wit::Application::resetButtonPressed (  ) [protected, virtual]

Invoked when the reset button on the Wii console is pressed.

Override this function in a subclass to change the behavior of the reset button. The default behavior invokes reboot().

See also:
powerButtonPressed()

Definition at line 990 of file application.cpp.

void wit::Application::returnToMenu (  )

Terminates the running application immediately and returns to the Wii Menu.

Definition at line 445 of file application.cpp.

void wit::Application::run (  )

Starts running the main event loop. This function will not return until quit() is called.

run() will typically be the last statement in your main() function. The application will return to the loader after main() exits if the Wii was not shut down using reboot(), shutdown(), or returnToMenu().

Definition at line 611 of file application.cpp.

void wit::Application::scheduleTimer ( int  frames,
EventHandler handler,
void *  data 
)

Schedules a timer to trigger in frames frames.

When the timer elapses, handler's EventHandler::timerTriggered(void*) will be invoked with data as a parameter.

See also:
EventHandler::timerTriggered

Definition at line 944 of file application.cpp.

int wit::Application::screenHeight (  ) const

Returns the height of the screen, in pixels.

Definition at line 309 of file application.cpp.

int wit::Application::screenWidth (  ) const

Returns the width of the screen, in pixels.

Definition at line 301 of file application.cpp.

void wit::Application::setAbortGxOnReset ( bool  on )

Sets whether or not the current GX operation will be aborted on reset.

When this property is enabled, pressing the power or reset button will cancel pending GX operations before invoking powerButtonPressed() or resetButtonPressed(). This is useful if the GX subsystem has become hung, for instance, due to a bug.

This property is enabled by default.

See also:
abortGxOnReset()

Definition at line 977 of file application.cpp.

void wit::Application::setAutoHomeMenu ( bool  on )

Controls the default behavior of the Home button. If false (the default), the Home button is dispatched to event handlers and focus stacks like any other button. If true, pressing any Home button will invoke showHomeMenu.

See also:
autoHomeMenu
showHomeMenu

Definition at line 323 of file application.cpp.

void wit::Application::setHomeMenuVisible ( bool  on ) [protected]

Updates the internal state to properly manage dispatching events while the Home menu is visible.

See also:
showHomeMenu
hideHomeMenu

Definition at line 397 of file application.cpp.

void wit::Application::showHomeMenu (  ) [virtual]

Shows the Home menu.

While the Home menu is visible, all input events are directed to Application::homeMenuEvent(Event*) and timer dispatching is paused.

Subclasses of Application may override this function, hideHomeMenu, and homeMenuEvent to customize the home menu; alternatively, programs may simply elect not to use the built-in Home menu functionality and bind the Home buttons directly. Subclass implementations should invoke setHomeMenuVisible(true) to ensure event handling is properly initialized.

See also:
hideHomeMenu
isHomeMenuVisible
autoHomeMenu
setAutoHomeMenu
homeMenuEvent

Definition at line 359 of file application.cpp.

void wit::Application::shutdown ( ShutdownMode  mode = Shutdown_Auto )

Shuts down the Wii hardware.

If invoked with Shutdown_Idle, the Wii will enter idle mode, with WiiConnect24 disabled (red LED).
If invoked with Shutdown_Standby, the Wii will enter standby mode, with WiiConnect24 enabled (yellow LED).
If invoked with Shutdown_Auto (the default), the Wii will select the mode based on its system settings.

See also:
wit::ShutdownMode

Definition at line 431 of file application.cpp.


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