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

gnash::Button Class Reference

#include <Button.h>

Inheritance diagram for gnash::Button:
Inheritance graph
[legend]
Collaboration diagram for gnash::Button:
Collaboration graph
[legend]

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 notifyEvent (const event_id &id)
 Notify clip events (and also user-defined ones).
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)
virtual bool handleFocus ()
 Set the current focus to this DisplayObject.
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.

Static Public Member Functions

static const char * mouseStateName (MouseState s)

Protected Member Functions

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

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 gnash::movie_root::add_key_listener(), and gnash::DisplayObject::stage().

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::key::_1, gnash::geometry::SnappingRanges2d< T >::add(), gnash::DisplayObject::add_invalidated_bounds(), gnash::for_each(), gnash::DisplayObject::invalidated(), gnash::DisplayObject::m_old_invalidated_ranges, and gnash::DisplayObject::visible().

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

Do ActionScript construction of the Button.

(1) Register this button instance as a live DisplayObject (2) Construct all button state DisplayObjects.

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

Reimplemented from gnash::DisplayObject.

References gnash::DisplayObject::construct(), IF_VERBOSE_ASCODING_ERRORS, gnash::SWF::ButtonRecord::instantiate(), MOUSESTATE_HIT, MOUSESTATE_UP, and gnash::DisplayObject::saveOriginalTarget().

void gnash::Button::destroy (  )  [virtual]

Properly destroy contained DisplayObjects.

Reimplemented from gnash::DisplayObject.

References gnash::DisplayObject::destroy(), and gnash::DisplayObject::isDestroyed().

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::SWFRect::expand_to_transformed_rect(), gnash::DisplayObject::getBounds(), gnash::getMatrix(), and gnash::key::m.

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

Set the current focus to this DisplayObject.

Returns:
false if the DisplayObject cannot receive focus, true if it can (and does). Button, Textfield and MovieClip can receive focus. In SWF6 and above, MovieClip can only receive focus if the focusEnabled property evaluates to true.

Nothing to do, but can receive focus.

Reimplemented from gnash::DisplayObject.

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

Mark reachabe 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::for_each(), and gnash::GcResource::setReachable().

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]
const char * gnash::Button::mouseStateName ( MouseState  s  )  [static]
void gnash::Button::notifyEvent ( const event_id  )  [virtual]

Notify clip events (and also user-defined ones).

Reimplemented from gnash::DisplayObject.

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

Referenced by gnash::movie_root::mouseClick().

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::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::string_table::find(), gnash::getObject(), gnash::getStringTable(), and gnash::as_value::to_bool().

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

Properly unload contained DisplayObjects.

Reimplemented from gnash::DisplayObject.

References gnash::DisplayObject::unload(), and gnash::DisplayObject::unloaded().


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