Gnash  0.8.10
Public Types | Public Member Functions | Protected Member Functions
gnash::Button Class Reference

Button implements Flash buttons. More...

#include <Button.h>

Inheritance diagram for gnash::Button:
gnash::InteractiveObject gnash::DisplayObject gnash::GcResource

List of all members.

Public Types

enum  mouse_flags {
  FLAG_IDLE = 0, FLAG_OVER = 1, FLAG_DOWN = 2, OVER_DOWN = FLAG_OVER | FLAG_DOWN,
  OVER_UP = FLAG_OVER, OUT_DOWN = FLAG_DOWN
}
enum  MouseState { MOUSESTATE_UP = 0, MOUSESTATE_DOWN, MOUSESTATE_OVER, MOUSESTATE_HIT }
typedef std::vector
< DisplayObject * > 
DisplayObjects
typedef std::vector< const
DisplayObject * > 
ConstDisplayObjects
typedef std::set< int > ActiveRecords
 A container for holding the id of active button records.

Public Member Functions

 Button (as_object *object, const SWF::DefineButtonTag *def, DisplayObject *parent)
 Construct a Button.
 ~Button ()
bool mouseEnabled () const
 Whether the DisplayObject can handle a mouse event.
virtual bool trackAsMenu ()
 ActionScript property of Buttons and MovieClips altering mouse handling.
void keyPress (key::code c)
 Handle a key press associated with a button event.
virtual void display (Renderer &renderer, const Transform &xform)
 Render this Button.
void set_current_state (MouseState new_state)
virtual InteractiveObjecttopmostMouseEntity (boost::int32_t x, boost::int32_t y)
 Return the topmost entity that the given point covers. NULL if none.
virtual void mouseEvent (const event_id &event)
 Called whenever a mouse event affects this Button.
virtual bool handleFocus ()
 Called when the Button is in focus.
void add_invalidated_bounds (InvalidatedRanges &ranges, bool force)
 Add the DisplayObject's invalidated bounds *to* the given ranges list.
virtual SWFRect getBounds () const
 Returns local, untransformed bounds of this DisplayObject in TWIPS.
bool pointInShape (boost::int32_t x, boost::int32_t y) const
 Return true if the given point falls in this DisplayObject's shape.
bool isEnabled ()
void destroy ()
 Properly destroy contained DisplayObjects.
virtual void construct (as_object *init=0)
 Do ActionScript construction of the Button.

Protected Member Functions

virtual bool unloadChildren ()
 Properly unload contained DisplayObjects.
void markOwnResources () const
 Mark reachable resources (for the GC)

Detailed Description

Button implements Flash buttons.


Member Typedef Documentation

typedef std::set<int> gnash::Button::ActiveRecords

A container for holding the id of active button records.


Member Enumeration Documentation

Enumerator:
FLAG_IDLE 
FLAG_OVER 
FLAG_DOWN 
OVER_DOWN 
OVER_UP 
OUT_DOWN 
Enumerator:
MOUSESTATE_UP 
MOUSESTATE_DOWN 
MOUSESTATE_OVER 
MOUSESTATE_HIT 

Constructor & Destructor Documentation

gnash::Button::Button ( as_object object,
const SWF::DefineButtonTag def,
DisplayObject parent 
)

Construct a Button.

A button should always have an associated object.

References assert.

gnash::Button::~Button ( )

Member Function Documentation

void gnash::Button::add_invalidated_bounds ( InvalidatedRanges ranges,
bool  force 
) [virtual]

Add the DisplayObject's invalidated bounds *to* the given ranges list.

NOTE that this method should include the bounds that it covered the last time clear_invalidated() was called, as those need to be rerendered as well (to clear the region previously occupied by this DisplayObject).

That's why it returns the *union* of old_invalidated_ranges and the current bounds. The function is also used internally by set_invalidated() to update m_old_invalidated_ranges itself (you may notice some kind of circular reference), but that's no problem since old_invalidated_ranges is NULL during that call.

It is used to determine what area needs to be re-rendered. The coordinates are world coordinates (in TWIPS). Only instances with _invalidated flag set are checked unless force is set.

Implements gnash::InteractiveObject.

References gnash::DisplayObject::visible(), gnash::geometry::SnappingRanges2d::add(), gnash::DisplayObject::m_old_invalidated_ranges, gnash::renderer::opengl::for_each(), gnash::DisplayObject::add_invalidated_bounds(), gnash::key::_1, and gnash::DisplayObject::invalidated().

void gnash::Button::construct ( as_object init = 0) [virtual]

Do ActionScript construction of the Button.

Construct all button state DisplayObjects.

Parameters:
initAn init object, which can be passed when constructing Buttons with attachMovie, but is never used.

Reimplemented from gnash::DisplayObject.

References IF_VERBOSE_ASCODING_ERRORS, _, gnash::DisplayObject::saveOriginalTarget(), MOUSESTATE_HIT, gnash::key::e, gnash::key::i, gnash::key::SWF, gnash::SWF::ButtonRecord::instantiate(), MOUSESTATE_UP, gnash::DisplayObject::construct(), gnash::DisplayObject::stage(), and gnash::movie_root::registerButton().

void gnash::Button::destroy ( ) [virtual]
void gnash::Button::display ( Renderer renderer,
const Transform xform 
) [virtual]
SWFRect gnash::Button::getBounds ( ) const [virtual]

Returns local, untransformed bounds of this DisplayObject in TWIPS.

Container DisplayObjects (sprite and buttons) return the composite bounds of all their children, appropriately transformed with their local SWFMatrix.

Implements gnash::InteractiveObject.

References gnash::key::e, gnash::key::i, gnash::DisplayObject::getBounds(), gnash::key::m, gnash::getMatrix(), and gnash::SWFRect::expand_to_transformed_rect().

bool gnash::Button::handleFocus ( ) [virtual]

Called when the Button is in focus.

Nothing to do, but can receive focus.

Reimplemented from gnash::DisplayObject.

bool gnash::Button::isEnabled ( )
void gnash::Button::keyPress ( key::code  c)

Handle a key press associated with a button event.

References gnash::DisplayObject::unloaded(), gnash::DisplayObject::stage(), and gnash::event_id::KEY_PRESS.

void gnash::Button::markOwnResources ( ) const [protected, virtual]

Mark reachable resources (for the GC)

These are:

  • this char's definition (_def)
  • the vector of state DisplayObjects (_stateCharacters)
  • the vector of hit DisplayObjects (_hitCharacters)

Reimplemented from gnash::DisplayObject.

References gnash::key::e, gnash::key::i, gnash::GcResource::setReachable(), and gnash::renderer::opengl::for_each().

bool gnash::Button::mouseEnabled ( ) const [inline, virtual]

Whether the DisplayObject can handle a mouse event.

Returns:
true if the DisplayObject can handle mouse events

Implements gnash::InteractiveObject.

void gnash::Button::mouseEvent ( const event_id event) [virtual]
bool gnash::Button::pointInShape ( boost::int32_t  x,
boost::int32_t  y 
) const [virtual]

Return true if the given point falls in this DisplayObject's shape.

Point coordinates are in world TWIPS

The default implementation warns about a missing override and invokes pointInBounds().

Reimplemented from gnash::InteractiveObject.

References gnash::key::e, gnash::key::i, and gnash::DisplayObject::pointInShape().

void gnash::Button::set_current_state ( MouseState  new_state)
InteractiveObject * gnash::Button::topmostMouseEntity ( boost::int32_t  x,
boost::int32_t  y 
) [virtual]
bool gnash::Button::trackAsMenu ( ) [virtual]

ActionScript property of Buttons and MovieClips altering mouse handling.

Reimplemented from gnash::InteractiveObject.

References gnash::getObject(), assert, gnash::getVM(), gnash::getURI(), gnash::as_object::get_member(), and gnash::toBool().

bool gnash::Button::unloadChildren ( ) [protected, virtual]

Properly unload contained DisplayObjects.

Reimplemented from gnash::DisplayObject.

References gnash::key::e, gnash::key::i, gnash::DisplayObject::unloaded(), and gnash::DisplayObject::unload().


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