Public Member Functions | Static Public Member Functions

wit::Widget Class Reference

#include <wit/widget.h>

List of all members.

Public Member Functions

 Widget ()
bool autoFocus () const
void setAutoFocus (bool on)
bool hasPointer (int controllerID=-1) const
virtual void focusEvent (PointerEvent *event)
virtual bool pointerEvent (PointerEvent *event)
virtual bool pointerLeaveEvent (PointerLeaveEvent *event)
virtual bool event (Event *event)
virtual bool joystickEvent (JoystickEvent *event)
virtual bool analogEvent (AnalogEvent *event)
virtual bool motionEvent (MotionEvent *event)
virtual bool buttonPressEvent (ButtonEvent *event)
virtual bool buttonReleaseEvent (ButtonEvent *event)
virtual void timerTriggered (void *data)
bool isEnabled () const
void setEnabled (bool on)
Rect boundingBox () const
bool boundingBoxContains (float x, float y)
Polygon region () const
void setRegion (const Rect &rect)
void setRegion (const Polygon &polygon)
bool contains (float x, float y)
void setEventHandler (EventHandler *handler)
EventHandlereventHandler () const
int zIndex () const
void setZIndex (int z)
virtual void render ()=0
virtual void waitForRendering ()
float scale () const
void setScale (float mag)
float translateX () const
float translateY () const
void setTranslation (float x, float y)
void drawPoint (const Point &p, const GXColor &color)
void drawPoint (float x, float y, const GXColor &color)
void drawLine (const Point &p1, const Point &p2, const GXColor &color)
void drawLine (float x1, float y1, float x2, float y2, const GXColor &color)
void drawRect (const Rect &rect, const GXColor &color)
void fillRect (const Rect &rect, const GXColor &color)
void drawPoints (const Polygon &poly, const GXColor &color)
void drawPolygon (const Polygon &poly, const GXColor &color)
void fillPolygon (const Polygon &poly, const GXColor &color)

Static Public Member Functions

static std::auto_ptr< HotspotListfindAtPoint (float x, float y)

Detailed Description

The Widget class provides an event-sensitive region on the screen that can be drawn upon.

Unlike most desktop-style interface toolkits, the Widget class is not the base class for all interface objects; rather, it is a convenience class combining EventHandler, Hotspot, and Renderer in a single object. Its primary use is for implementing buttons and button-like objects through its auto-focus feature, which allows the widget to accept events (such as button events) while the Wii Remote is pointed at it.

For interface elements that do not need to accept events, use Renderer alone. For interface elements that do not need to accept pointer events, inherit both Renderer and EventHandler. To receive all pointer events, regardless of screen position, inherit from EventHandler and use Application::installEventFilter().

Definition at line 14 of file widget.h.


Constructor & Destructor Documentation

wit::Widget::Widget (  )

Constructs a new Widget object.

Definition at line 29 of file widget.cpp.


Member Function Documentation

bool wit::EventHandler::analogEvent ( AnalogEvent event ) [virtual, inherited]

Processes an analog button event.

The default behavior returns false.

See also:
event()

Definition at line 90 of file eventhandler.cpp.

bool wit::Widget::autoFocus (  ) const

Returns true if the widget is set to auto-focus.

See also:
setAutoFocus()

Definition at line 42 of file widget.cpp.

Rect wit::Hotspot::boundingBox (  ) const [inherited]

Returns the axis-aligned bounding box of the hotspot.

This bounding box is the smallest rectangle parallel to the sides of the screen that contains the entire region.

Definition at line 83 of file hotspot.cpp.

bool wit::Hotspot::boundingBoxContains ( float  x,
float  y 
) [inherited]

Returns true if the specified point is contained within the hotspot's bounding box.

This operation is significantly faster than contains() for non-rectangular regions.

See also:
boundingBox()

Definition at line 135 of file hotspot.cpp.

bool wit::EventHandler::buttonPressEvent ( ButtonEvent event ) [virtual, inherited]

Processes a non-analog button press event.

The default behavior returns false.

See also:
event()

Definition at line 142 of file eventhandler.cpp.

bool wit::EventHandler::buttonReleaseEvent ( ButtonEvent event ) [virtual, inherited]

Processes a non-analog button release event.

The default behavior returns false.

See also:
event()

Definition at line 155 of file eventhandler.cpp.

bool wit::Hotspot::contains ( float  x,
float  y 
) [inherited]

Returns true if the specified point is contained within the hotspot's region.

See also:
region()

Definition at line 146 of file hotspot.cpp.

void wit::Renderer::drawLine ( const Point p1,
const Point p2,
const GXColor &  color 
) [inherited]

Draws a line on the screen in the selected color.

This is an overloaded member function provided for convenience.

Definition at line 216 of file renderer.cpp.

void wit::Renderer::drawLine ( float  x1,
float  y1,
float  x2,
float  y2,
const GXColor &  color 
) [inherited]

Draws a line on the screen in the selected color.

Definition at line 199 of file renderer.cpp.

void wit::Renderer::drawPoint ( const Point p,
const GXColor &  color 
) [inherited]

Draws a point on the screen in the selected color.

This is an overloaded member function provided for convenience.

Definition at line 191 of file renderer.cpp.

void wit::Renderer::drawPoint ( float  x,
float  y,
const GXColor &  color 
) [inherited]

Draws a point on the screen in the selected color.

Definition at line 176 of file renderer.cpp.

void wit::Renderer::drawPoints ( const Polygon poly,
const GXColor &  color 
) [inherited]

Draws a series of points on the screen in the specified color.

Definition at line 264 of file renderer.cpp.

void wit::Renderer::drawPolygon ( const Polygon poly,
const GXColor &  color 
) [inherited]

Draws a polygon on the screen in the specified color.

Definition at line 282 of file renderer.cpp.

void wit::Renderer::drawRect ( const Rect rect,
const GXColor &  color 
) [inherited]

Draws a rectangle on the screen in the specified color.

Definition at line 224 of file renderer.cpp.

bool wit::EventHandler::event ( Event event ) [virtual, inherited]

Processes an event.

Return true from event() or one of the other event-handling functions to consume the event, that is, to prevent the event from propagating to the next object in the event chain or focus stack.

For non-user event types, the default behavior invokes the appropriate specialized event-handling function (which themselves by default do nothing but return false); for user event types, the default behavior returns false.

Definition at line 47 of file eventhandler.cpp.

EventHandler * wit::Hotspot::eventHandler (  ) const [inherited]

Sets the event handler that will receive pointer events generated when the Wii Remote enters the hotspot's region.

See also:
setEventHandler()

Definition at line 171 of file hotspot.cpp.

void wit::Renderer::fillPolygon ( const Polygon poly,
const GXColor &  color 
) [inherited]

Draws a polygon on the screen and fills it with the specified color.

Note that this function will only accurately fill convex polygons whose points are specified in clockwise order.

Definition at line 305 of file renderer.cpp.

void wit::Renderer::fillRect ( const Rect rect,
const GXColor &  color 
) [inherited]

Draws a rectangle on the screen and fills it with the specified color.

Definition at line 245 of file renderer.cpp.

std::auto_ptr< HotspotList > wit::Hotspot::findAtPoint ( float  x,
float  y 
) [static, inherited]

Returns a list of all hotspots that contain the specified point.

Definition at line 204 of file hotspot.cpp.

void wit::Widget::focusEvent ( PointerEvent event ) [virtual]

Notifies the widget that it has gained the focus via auto-focus.

Note that this is not a real event handler; that is, it is not dispatched via event() and event filters on Application will not receive it. The event object passed to focusEvent() is the PointerEvent that caused the focus to be gained.

Definition at line 98 of file widget.cpp.

bool wit::Widget::hasPointer ( int  controllerID = -1 ) const

Returns true if the specified Wii Remote is currently pointing at the widget.

Passing -1 as the controllerID (the default) will return true if any Wii Remotes are currently pointing at the widget.

Definition at line 67 of file widget.cpp.

bool wit::Hotspot::isEnabled (  ) const [inherited]

Returns true if the hotspot is enabled.

See also:
setEnabled()

Definition at line 59 of file hotspot.cpp.

bool wit::EventHandler::joystickEvent ( JoystickEvent event ) [virtual, inherited]

Processes a joystick event.

The default behavior returns false.

See also:
event()

Definition at line 77 of file eventhandler.cpp.

bool wit::EventHandler::motionEvent ( MotionEvent event ) [virtual, inherited]

Processes a motion sensor event.

The default behavior returns false.

See also:
event()

Definition at line 103 of file eventhandler.cpp.

bool wit::Widget::pointerEvent ( PointerEvent event ) [virtual]

Processes a pointer event.

If autoFocus() is enabled, the default behavior captures the focus, invokes focusEvent(), and returns true. If autoFocus() is disabled, the default behavior simply returns true.

Reimplemented from wit::EventHandler.

Definition at line 80 of file widget.cpp.

bool wit::Widget::pointerLeaveEvent ( PointerLeaveEvent event ) [virtual]

Processes a pointer leave event.

The default implementation relinquishes the focus if autoFocus() is enabled and returns true.

Reimplemented from wit::EventHandler.

Definition at line 110 of file widget.cpp.

Polygon wit::Hotspot::region (  ) const [inherited]

Returns the region of the hotspot.

See also:
setRegion()

Definition at line 93 of file hotspot.cpp.

void wit::Renderer::render (  ) [pure virtual, inherited]

Implement this function to perform whatever steps are necessary to draw the Renderer's content on the screen.

To render in another thread, you may use this function to signal a rendering thread to begin processing, or you may ignore this function and use waitForRendered() to control the event loop when rendering is complete.

float wit::Renderer::scale (  ) const [inherited]

Returns the current scaling factor applied to the convenience functions for this renderer object.

See also:
setScale()

Definition at line 123 of file renderer.cpp.

void wit::Widget::setAutoFocus ( bool  on )

Enables or disables the auto-focus feature.

When auto-focus is enabled (the default), pointing the Wii Remote at the widget's hotspot (see region()) pushes the widget onto that controller's focus stack and moving the pointer away from the hotspot removes it from that stack.

See also:
autoFocus()

Definition at line 56 of file widget.cpp.

void wit::Hotspot::setEnabled ( bool  on ) [inherited]

Sets whether or not the hotspot is enabled.

Hotspots will only be used for dispatching pointer events if they are enabled, non-empty (see region()), and have an event handler set (see eventHandler()).

See also:
isEnabled()

Definition at line 72 of file hotspot.cpp.

void wit::Hotspot::setEventHandler ( EventHandler handler ) [inherited]

Sets the event handler that will receive pointer events generated when the Wii Remote enters the hotspot's region.

See also:
eventHandler()

Definition at line 160 of file hotspot.cpp.

void wit::Hotspot::setRegion ( const Polygon polygon ) [inherited]

Sets the region of the hotspot to the specified polygon.

Definition at line 120 of file hotspot.cpp.

void wit::Hotspot::setRegion ( const Rect rect ) [inherited]

Sets the region of the hotspot to the specified rectangle.

Rectangular hotspot regions should be created using this overload, not by passing a rectangular polygon to the other overload, because it enables performance optimizations that cannot be done with arbitrary polygons.

Definition at line 106 of file hotspot.cpp.

void wit::Renderer::setScale ( float  mag ) [inherited]

Sets the scaling factor applied to the convenience functions for this renderer object.

The default value of 1.0 performs no scaling.

See also:
scale()

Definition at line 135 of file renderer.cpp.

void wit::Renderer::setTranslation ( float  x,
float  y 
) [inherited]

Sets the translation applied to the convenience functions for this renderer object.

The default value of 0.0 for both horizontal and vertical translations performs no translation.

See also:
translateX(), translateY()

Definition at line 167 of file renderer.cpp.

void wit::Hotspot::setZIndex ( int  z ) [inherited]

Sets the Z-index of the hotspot.

If more than one hotspot lays claim to some portion of the screen, the hotspot with the greatest Z-index will receive the event. If multiple hotspots have the same Z-index, an arbitrarily selected hotspot will receive the event.

See also:
setZIndex()

Definition at line 196 of file hotspot.cpp.

void wit::EventHandler::timerTriggered ( void *  data ) [virtual, inherited]

Invoked when a timer requested using Application::scheduleTimer() expires. data is the user data pointer passed to scheduleTimer().

The default behavior does nothing.

See also:
Application::scheduleTimer()

Definition at line 169 of file eventhandler.cpp.

float wit::Renderer::translateX (  ) const [inherited]

Returns the horizontal translation applied to the convenience functions for this renderer object.

See also:
setTranslation()

Definition at line 145 of file renderer.cpp.

float wit::Renderer::translateY (  ) const [inherited]

Returns the vertical translation applied to the convenience functions for this renderer object.

See also:
setTranslation()

Definition at line 155 of file renderer.cpp.

void wit::Renderer::waitForRendering (  ) [virtual, inherited]

If you are performing rendering in another thread, implement this function to block the main event loop until the rendering is complete.

The default implementation does nothing.

Definition at line 85 of file renderer.cpp.

int wit::Hotspot::zIndex (  ) const [inherited]

Returns the Z-index of the hotspot.

See also:
setZIndex()

Definition at line 181 of file hotspot.cpp.


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