Gnash  0.8.10
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
gnash::DisplayObject Class Reference

DisplayObject is the base class for all DisplayList objects. More...

#include <DisplayObject.h>

Inheritance diagram for gnash::DisplayObject:
gnash::GcResource gnash::Bitmap gnash::InteractiveObject gnash::MorphShape gnash::Shape gnash::StaticText gnash::Video gnash::Button gnash::DisplayObjectContainer gnash::TextField gnash::MovieClip gnash::Movie gnash::BitmapMovie gnash::SWFMovie

List of all members.

Classes

class  MaskRenderer
 Render a dynamic mask for a specified DisplayObject. More...

Public Types

enum  BlendMode {
  BLENDMODE_UNDEFINED = 0, BLENDMODE_NORMAL = 1, BLENDMODE_LAYER, BLENDMODE_MULTIPLY,
  BLENDMODE_SCREEN, BLENDMODE_LIGHTEN, BLENDMODE_DARKEN, BLENDMODE_DIFFERENCE,
  BLENDMODE_ADD, BLENDMODE_SUBTRACT, BLENDMODE_INVERT, BLENDMODE_ALPHA,
  BLENDMODE_ERASE, BLENDMODE_OVERLAY, BLENDMODE_HARDLIGHT = 14
}
typedef std::vector< const
action_buffer * > 
BufferList
typedef std::map< event_id,
BufferList
Events

Public Member Functions

 DisplayObject (movie_root &mr, as_object *object, DisplayObject *parent)
 Construct a DisplayObject.
virtual ~DisplayObject ()
virtual as_environmentget_environment ()
 Return a reference to the variable scope of this DisplayObject.
virtual void visitNonProperties (KeyVisitor &) const
 Enumerate any non-proper properties.
DisplayObjectparent () const
 Return the parent of this DisplayObject, or NULL if the DisplayObject has no parent.
void set_parent (DisplayObject *parent)
 Set the parent of this DisplayObject.
virtual MovieClipto_movie ()
int get_depth () const
void set_depth (int d)
int getVolume () const
 Get sound volume for this DisplayObject.
void setVolume (int vol)
 Set sound volume for this DisplayObject.
int getWorldVolume () const
 Get concatenated sound volume for this DisplayObject.
virtual int getDefinitionVersion () const
 DisplayObjects can return the version of the SWF they were parsed from.
const Transformtransform () const
void setMatrix (const SWFMatrix &m, bool updateCache=false)
 Set local transform SWFMatrix for this DisplayObject.
void set_x_scale (double factor)
 Set the xscale value of current SWFMatrix.
void set_y_scale (double factor)
 Set the yscale value of current SWFMatrix.
void set_rotation (double rot)
 Set the rotation value of current SWFMatrix.
virtual void setWidth (double width)
 Set the width of this DisplayObject, modifying its SWFMatrix.
virtual void setHeight (double height)
 Set the height of this DisplayObject, modifying its SWFMatrix.
void setCxForm (const SWFCxForm &cx)
boost::uint16_t get_ratio () const
void set_ratio (boost::uint16_t r)
int get_clip_depth () const
void set_clip_depth (int d)
 See get_clip_depth()
bool isMaskLayer () const
bool isDynamicMask () const
DisplayObjectgetMask () const
 Return the DisplayObject masking this instance (if any)
void setMask (DisplayObject *mask)
void set_name (const ObjectURI &uri)
 Set DisplayObject name, initializing the original target member.
const ObjectURIget_name () const
std::auto_ptr< ExecutableCodeget_event_handler (const event_id &id) const
 Get the built-in function handlers code for the given event.
void add_event_handler (const event_id &id, const action_buffer &code)
 Set a built-in function handler for the given event.
virtual void display (Renderer &renderer, const Transform &xform)=0
 Render the DisplayObject.
virtual StaticTextgetStaticText (std::vector< const SWF::TextRecord * > &, size_t &)
 Search for StaticText objects.
virtual SWFRect getBounds () const =0
bool pointInBounds (boost::int32_t x, boost::int32_t y) const
 Return true if the given point falls in this DisplayObject's bounds.
virtual bool pointInShape (boost::int32_t x, boost::int32_t y) const =0
 Return true if the given point falls in this DisplayObject's shape.
virtual bool pointInVisibleShape (boost::int32_t x, boost::int32_t y) const
 true if the given point falls in this DisplayObject's visible shape
virtual Movieget_root () const
 Return the relative root of this DisplayObject.
virtual MovieClipgetAsRoot ()
 Return the _root ActionScript property of this DisplayObject.
virtual as_objectpathElement (const ObjectURI &uri)
bool get_accept_anim_moves () const
 Return true if PlaceObjects tag are allowed to move this DisplayObject.
bool isDynamic () const
 Was this DisplayObject dynamically created ?
void setDynamic ()
 Mark this DisplayObject as dynamically created.
void transformedByScript ()
 Call this function when the sprite has been transformed due to ActionScript code.
void set_visible (bool visible)
 Set whether this DisplayObject should be rendered.
bool visible () const
bool hasEventHandler (const event_id &id) const
 Return true if an handler for the given event is defined.
virtual InteractiveObjecttopmostMouseEntity (boost::int32_t, boost::int32_t)
 DisplayObjects are not a mouse entity by default.
virtual const DisplayObjectfindDropTarget (boost::int32_t x, boost::int32_t y, DisplayObject *dragging) const
 Point coordinates in global twips.
bool invalidated () const
 Return whether this DisplayObject has been invalidated or not.
bool childInvalidated () const
 Return whether this DisplayObject has and invalidated child or not.
virtual void update ()
 Notify a change in the DisplayObject's appearance.
void set_invalidated ()
 This function marks the DisplayObject as being modified in aspect and keeps track of current invalidated bounds the first time it's called after each call to clear_invalidated().
void set_invalidated (const char *debug_file, int debug_line)
void extend_invalidated_bounds (const InvalidatedRanges &ranges)
void set_child_invalidated ()
void clear_invalidated ()
virtual void add_invalidated_bounds (InvalidatedRanges &ranges, bool force)
 Add the DisplayObject's invalidated bounds *to* the given ranges list.
virtual void omit_display ()
virtual void construct (as_object *=0)
 Callback invoked whenever a DisplayObject is placed on stage.
bool unload ()
 Unload this instance from the stage.
virtual void getLoadedMovie (Movie *newMovie)
 Accept a loaded Movie.
bool unloaded () const
 Return true if this DisplayObject was unloaded from the stage.
virtual void destroy ()
 Mark this DisplayObject as destroyed.
bool isDestroyed () const
 Return true if this DisplayObject was destroyed.
bool boundsInClippingArea (Renderer &renderer) const
std::string getTargetPath () const
 Return full path to this object, in slash notation.
const std::string & getOrigTarget () const
std::string DSOEXPORT getTarget () const
 Return full path to this object, in dot notation.
virtual bool isSelectableTextField () const
 Return true if this DisplayObject is a selectable TextField.
bool DSOEXPORT allowHandCursor () const
 Return true if this DisplayObject allows turning the cursor into an hand shape when it happens to be the one receiving mouse events.
ObjectURI getNextUnnamedInstanceName ()
 Used to assign a name to unnamed instances.
BlendMode getBlendMode () const
void setBlendMode (BlendMode bm)
virtual bool handleFocus ()
 Set the current focus to this DisplayObject.
virtual void killFocus ()
 Some DisplayObjects require actions on losing focus.
double rotation () const
double scaleX () const
double scaleY () const
as_objectobject () const
virtual void markReachableResources () const
 Mark all reachable resources.
virtual void markOwnResources () const
 Called by markReachableResources()
boost::tribool focusRect () const
void focusRect (boost::tribool focus)

Static Public Member Functions

static as_value blendMode (const fn_call &fn)
 Getter-setter for blendMode.

Static Public Attributes

static const int lowerAccessibleBound = -16384
 See also http://www.kirupa.com/developer/actionscript/depths2.htm.
static const int upperAccessibleBound = 2130690044
static const int staticDepthOffset = lowerAccessibleBound
static const int removedDepthOffset = -32769
static const int noClipDepthValue = -1000000

Protected Member Functions

virtual bool unloadChildren ()
movie_rootstage () const
 Get the movie_root to which this DisplayObject belongs.
void saveOriginalTarget ()
const Eventsget_event_handlers () const
void set_event_handlers (const Events &copyfrom)
as_objectgetPathElementSeparator (string_table::key key)
 look for '.', 'this', '..', '_parent', '_level0' and '_root'

Protected Attributes

ObjectURI _name
 Name of this DisplayObject (if any)
DisplayObject_parent
InvalidatedRanges m_old_invalidated_ranges
 Bounds of this DisplayObject instance before first invalidation since last call to clear_invalidated().

Detailed Description

DisplayObject is the base class for all DisplayList objects.

It represents a single active element in a movie. This class does not supply any interactivity. The hierarchy of DisplayObjects in a movie provides all visual elements in a SWF. The DisplayObject hierarchy is independent of ActionScript resources, but can be controlled via AS. DisplayObjects that can be controlled through ActionScript have an associated as_object. DisplayObjects such as Shape, do not have an associated object and cannot be referenced in AS. Derived classes include InteractiveObject, StaticText, Bitmap, Video, and Shape. All DisplayObjects may be constructed during SWF parsing. In this case they are constructed using an immutable, non-copyable SWF::DefinitionTag. This tag should never be changed! Most DisplayObjects may also be constructed dynamically. In AS3, Bitmaps and Shapes can be dynamically created. Dynamically-created DisplayObjects must not have a SWF::DefinitionTag! The presence of a definition tag may be used to distinguish static from dynamic DisplayObjects, but tags are not always stored. They are not stored in most InteractiveObjects because most properties can be overridden during SWF execution.


Member Typedef Documentation

typedef std::vector<const action_buffer*> gnash::DisplayObject::BufferList

Member Enumeration Documentation

Enumerator:
BLENDMODE_UNDEFINED 
BLENDMODE_NORMAL 
BLENDMODE_LAYER 
BLENDMODE_MULTIPLY 
BLENDMODE_SCREEN 
BLENDMODE_LIGHTEN 
BLENDMODE_DARKEN 
BLENDMODE_DIFFERENCE 
BLENDMODE_ADD 
BLENDMODE_SUBTRACT 
BLENDMODE_INVERT 
BLENDMODE_ALPHA 
BLENDMODE_ERASE 
BLENDMODE_OVERLAY 
BLENDMODE_HARDLIGHT 

Constructor & Destructor Documentation

gnash::DisplayObject::DisplayObject ( movie_root mr,
as_object object,
DisplayObject parent 
)

Construct a DisplayObject.

Parameters:
mrThe movie_root containing the DisplayObject hierarchy. All DisplayObjects may need movie_root resources.
objectAn object to be associated with this DisplayObject. If this is non-null, the DisplayObject will be referenceable in ActionScript. Referenceable DisplayObjects may access AS resources through their associated object.
parentThe parent of the new DisplayObject. This may be null.

References assert, m_old_invalidated_ranges, gnash::geometry::SnappingRanges2d::isNull(), and gnash::as_object::setDisplayObject().

virtual gnash::DisplayObject::~DisplayObject ( ) [inline, virtual]

Member Function Documentation

void gnash::DisplayObject::add_event_handler ( const event_id id,
const action_buffer code 
)

Set a built-in function handler for the given event.

Mark the DisplayObject as having mouse or Key event handlers if this is the case.

NOTE: this function is only for registering statically-defined event handlers, which are the ones attached to a DisplayObject with a PlaceObject2. It's the DisplayObject's responsibility to properly invoke any user-defined event handler, which are the ones attached to a DisplayObject with ActionScript code.

Parameters:
idThe event triggering the handler.
codeAn action buffer to execute when given event is triggered. The buffer is externally owned (not copied), make sure it is kept alive for the whole lifetime of this DisplayObject.

Referenced by set_event_handlers(), and gnash::MovieClip::add_display_object().

void gnash::DisplayObject::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.

Reimplemented in gnash::MovieClip, gnash::TextField, gnash::InteractiveObject, gnash::Button, gnash::Video, and gnash::Bitmap.

References gnash::geometry::SnappingRanges2d::add(), m_old_invalidated_ranges, visible(), gnash::SWFRect::expand_to_transformed_rect(), gnash::getWorldMatrix(), getBounds(), and gnash::SWFRect::getRange().

Referenced by gnash::Button::add_invalidated_bounds(), gnash::DisplayList::replaceDisplayObject(), gnash::DisplayList::add_invalidated_bounds(), and set_invalidated().

bool gnash::DisplayObject::allowHandCursor ( ) const

Return true if this DisplayObject allows turning the cursor into an hand shape when it happens to be the one receiving mouse events.

Whether to use a hand cursor when the mouse is over this DisplayObject.

This depends on the useHandCursor AS property, but: 1. Only AS-referenceable objects may use a hand cursor (TODO: check Video). 2. Only objects with a release event may use a hand cursor. CANNOT CONFIRM THE ABOVE, SEE ButtonEventsTest.swf in misc-ming.all 3. The default value (if the property is not defined) is true.

References gnash::getObject(), gnash::as_object::get_member(), gnash::NSV::PROP_USEHANDCURSOR, gnash::toBool(), and gnash::getVM().

Referenced by gnash::Gui::notifyMouseMove().

as_value gnash::DisplayObject::blendMode ( const fn_call fn) [static]

Getter-setter for blendMode.

If the blend mode is undefined, it doesn't return a string.

The extra static cast is required to keep OpenBSD happy.

References LOG_ONCE, _, gnash::fn_call::nargs, getBlendMode(), BLENDMODE_UNDEFINED, gnash::fn_call::arg(), gnash::as_value::is_undefined(), setBlendMode(), BLENDMODE_NORMAL, gnash::as_value::is_number(), gnash::toNumber(), gnash::getVM(), BLENDMODE_HARDLIGHT, gnash::as_value::to_string(), and gnash::key::_1.

Referenced by gnash::registerMovieClipNative().

bool gnash::DisplayObject::boundsInClippingArea ( Renderer renderer) const

Returns true when the DisplayObject bounds intersect with the current rendering clipping area.

There is no need to do any rendering for this DisplayObject when this function returns false because the renderer will not change any pixels in the area where this DisplayObject is placed.

References getBounds(), gnash::getWorldMatrix(), gnash::SWFMatrix::transform(), gnash::Renderer::bounds_in_clipping_area(), and gnash::SWFRect::getRange().

Referenced by gnash::DisplayList::display().

bool gnash::DisplayObject::childInvalidated ( ) const [inline]

Return whether this DisplayObject has and invalidated child or not.

Referenced by gnash::MovieClip::omit_display(), and gnash::MovieClip::add_invalidated_bounds().

void gnash::DisplayObject::clear_invalidated ( ) [inline]

Clear invalidated flag and reset m_old_invalidated_bounds to null.

It is very important that each DisplayObject with any m_XXXX_invalidated flag set calls clear_invalidated() during the rendering of one frame. Basically this means each call to display() must match a call to clear_invalidated. This includes no-op display() calls, i.e. when the DisplayObject is outside of the screen. The DisplayList must still call clear_invalidated() even if display() is not necessary.

Not doing so will result in a stale invalidated flag which in turn will prevent the parent to be informed when this DisplayObject (or a child) is invalidated again (see set_invalidated() recursion).

References m_old_invalidated_ranges, and gnash::geometry::SnappingRanges2d::setNull().

Referenced by gnash::Bitmap::display(), gnash::Button::display(), omit_display(), gnash::MorphShape::display(), gnash::movie_root::display(), gnash::MovieClip::display(), gnash::MovieClip::omit_display(), gnash::Shape::display(), gnash::StaticText::display(), gnash::TextField::display(), and gnash::Video::display().

virtual void gnash::DisplayObject::construct ( as_object = 0) [inline, virtual]

Callback invoked whenever a DisplayObject is placed on stage.

This function must be called when the DisplayObject is placed on stage for the first time.

The DisplayObject version of this call sets the original target of the DisplayObject, for soft references to work. If you override the method remember to call saveOriginalTarget() as the first thing.

This handles all ActionScript construction and initialization events.

Reimplemented in gnash::MovieClip, gnash::Button, gnash::SWFMovie, gnash::Bitmap, and gnash::Video.

References saveOriginalTarget().

Referenced by gnash::Button::set_current_state(), gnash::Button::construct(), gnash::MovieClip::addDisplayListObject(), gnash::MovieClip::attachCharacter(), gnash::MovieClip::add_display_object(), and gnash::MovieClip::replace_display_object().

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

Mark this DisplayObject as destroyed.

A DisplayObject should be destroyed when is removed from the display list and is not more needed for names (target) resolutions. Sprites are needed for names resolution whenever themselves or a contained object has an onUnload event handler defined, in which case we want the event handler to find the 'this' variable w/out attempting to rebind it.

Note: this function can safely release most memory associated with the DisplayObject as it will not be needed anymore.

we may destory a DisplayObject that's not unloaded. (we don't have chance to unload it in current model, see new_child_in_unload_test.c) We don't destroy ourself twice, right ?

Reimplemented in gnash::MovieClip, and gnash::Button.

References gnash::as_object::clearProperties(), and assert.

Referenced by gnash::Button::set_current_state(), gnash::Button::destroy(), gnash::DisplayList::placeDisplayObject(), gnash::DisplayList::replaceDisplayObject(), gnash::DisplayList::removeDisplayObject(), gnash::DisplayList::unload(), gnash::DisplayList::destroy(), and gnash::DisplayList::mergeDisplayList().

virtual void gnash::DisplayObject::display ( Renderer renderer,
const Transform xform 
) [pure virtual]
void gnash::DisplayObject::extend_invalidated_bounds ( const InvalidatedRanges ranges)

Calls set_invalidated() and extends old_invalidated_ranges to the given value so that also this area gets re-rendered (used when replacing DisplayObjects).

References set_invalidated(), m_old_invalidated_ranges, and gnash::geometry::SnappingRanges2d::add().

Referenced by gnash::DisplayList::placeDisplayObject(), and gnash::DisplayList::replaceDisplayObject().

virtual const DisplayObject* gnash::DisplayObject::findDropTarget ( boost::int32_t  x,
boost::int32_t  y,
DisplayObject dragging 
) const [inline, virtual]

Point coordinates in global twips.

Find highest depth DisplayObject whose shape contains the given point and is not the DisplayObject being dragged or any of its childs.

Reimplemented in gnash::MovieClip.

References visible(), and pointInVisibleShape().

boost::tribool gnash::DisplayObject::focusRect ( ) const [inline]
void gnash::DisplayObject::focusRect ( boost::tribool  focus) [inline]
bool gnash::DisplayObject::get_accept_anim_moves ( ) const [inline]

Return true if PlaceObjects tag are allowed to move this DisplayObject.

Once a DisplayObject has been transformed by ActionScript, further transformation trought non-action SWF constrol tags is not allowed.

See scriptTransformed()

Referenced by gnash::DisplayList::moveDisplayObject(), and gnash::DisplayList::mergeDisplayList().

int gnash::DisplayObject::get_clip_depth ( ) const [inline]

Returns the clipping depth (if any) of this DisplayObject. The parameter tells us to use the DisplayObject as a mask for all the objects contained in the display list from _depth to m_clipping_depth inclusive.

The value returned by get_clip_depth() is only valid when isMaskLayer() returns true!

Referenced by gnash::DisplayList::display(), gnash::DisplayList::add_invalidated_bounds(), gnash::MovieClip::duplicateMovieClip(), and gnash::MovieClip::getLoadedMovie().

int gnash::DisplayObject::get_depth ( ) const [inline]
virtual as_environment& gnash::DisplayObject::get_environment ( ) [inline, virtual]

Return a reference to the variable scope of this DisplayObject.

Reimplemented in gnash::MovieClip.

References assert, _parent, and get_environment().

Referenced by gnash::Button::mouseEvent(), and get_environment().

std::auto_ptr< ExecutableCode > gnash::DisplayObject::get_event_handler ( const event_id id) const

Get the built-in function handlers code for the given event.

NOTE: this function is only for getting statically-defined event handlers, which are the ones attached to a DisplayObject with a PlaceObject2. It's the DisplayObject's responsibility to properly fetch any user-defined event handler, which are the ones attached to a DisplayObject with ActionScript code.

Referenced by gnash::Button::mouseEvent(), and gnash::MovieClip::notifyEvent().

const Events& gnash::DisplayObject::get_event_handlers ( ) const [inline, protected]
const ObjectURI& gnash::DisplayObject::get_name ( ) const [inline]
boost::uint16_t gnash::DisplayObject::get_ratio ( ) const [inline]
virtual Movie* gnash::DisplayObject::get_root ( ) const [inline, virtual]

Return the relative root of this DisplayObject.

The "relative" is the Movie created by the same SWF definition that contained the definition of this DisplayObject.

The default implementation is to invoke get_root against this DisplayObject's parent.

Reimplemented in gnash::MovieClip.

References parent(), and get_root().

Referenced by getAsRoot(), get_root(), gnash::sprite_definition::createDisplayObject(), and gnash::TextField::getDefinitionVersion().

MovieClip * gnash::DisplayObject::getAsRoot ( ) [virtual]

Return the _root ActionScript property of this DisplayObject.

By default calls get_root(). The resulting MovieClip may be passed to actionscript methods, so it is not const. As the override in MovieClip may return this, the method cannot be const either.

Reimplemented in gnash::MovieClip.

References get_root().

Referenced by gnash::findObject(), gnash::getDisplayObjectProperty(), gnash::Function2::call(), and gnash::MovieClip::getAsRoot().

BlendMode gnash::DisplayObject::getBlendMode ( ) const [inline]

Referenced by blendMode().

virtual SWFRect gnash::DisplayObject::getBounds ( ) const [pure virtual]
virtual int gnash::DisplayObject::getDefinitionVersion ( ) const [inline, virtual]

DisplayObjects can return the version of the SWF they were parsed from.

Reimplemented in gnash::MovieClip, and gnash::TextField.

void gnash::DisplayObject::getLoadedMovie ( Movie newMovie) [virtual]

Accept a loaded Movie.

Reimplemented in gnash::MovieClip.

References LOG_ONCE, _, gnash::typeName(), and UNUSED.

DisplayObject* gnash::DisplayObject::getMask ( ) const [inline]

Return the DisplayObject masking this instance (if any)

References assert.

Referenced by gnash::MovieClip::pointInVisibleShape(), and gnash::MovieClip::pointInHitableShape().

ObjectURI gnash::DisplayObject::getNextUnnamedInstanceName ( )
const std::string& gnash::DisplayObject::getOrigTarget ( ) const [inline]

Return original target path to this object, in dot notation as of at construction time. This is needed to properly dereference dangling soft-references See testcase misc-swfc.all/soft_reference_test1.sc

as_object* gnash::DisplayObject::getPathElementSeparator ( string_table::key  key) [protected]

look for '.', 'this', '..', '_parent', '_level0' and '_root'

NOTE: case insensitive up to SWF6, sensitive from SWF7 up

virtual StaticText* gnash::DisplayObject::getStaticText ( std::vector< const SWF::TextRecord * > &  ,
size_t &   
) [inline, virtual]

Search for StaticText objects.

If this is a StaticText object and contains SWF::TextRecords, these are written to the passed parameter. @ return 0 if this object is not a StaticText or contains no text.

Reimplemented in gnash::InteractiveObject, and gnash::StaticText.

std::string gnash::DisplayObject::getTarget ( ) const
std::string gnash::DisplayObject::getTargetPath ( ) const
int gnash::DisplayObject::getVolume ( ) const [inline]

Get sound volume for this DisplayObject.

Referenced by getWorldVolume().

int gnash::DisplayObject::getWorldVolume ( ) const

Get concatenated sound volume for this DisplayObject.

NOTE: the concatenated volume does NOT include global volume settings, which is the one controlled by Sound instances created passing null, undefined or no argument to constructor.

References volume, _parent, and getVolume().

virtual bool gnash::DisplayObject::handleFocus ( ) [inline, 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.

Reimplemented in gnash::MovieClip, and gnash::Button.

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

bool gnash::DisplayObject::hasEventHandler ( const event_id id) const

Return true if an handler for the given event is defined.

NOTE that we look for both clip-defined and user-defined handlers, which is likely error prone since we're doing this in a non-virtual function. Main use for this method is for being called by ::unload() to verify an Unload handler is available.

References gnash::as_object::findProperty().

Referenced by gnash::MovieClip::mouseEnabled(), and gnash::MovieClip::unloadChildren().

bool gnash::DisplayObject::invalidated ( ) const [inline]
bool gnash::DisplayObject::isDestroyed ( ) const [inline]
bool gnash::DisplayObject::isDynamic ( ) const [inline]

Was this DisplayObject dynamically created ?

"Dynamically created" means created trough ActionScript.

NOTE, With current code:

  • Characters created by means of a loadMovie are NOT set as dynamic (should check if they should)
  • Characters created by attachMovie ARE dynamic
  • Characters created by duplicateMovieClip ARE dynamic
  • Characters created by createEmptyMovieClip ARE dynamic
  • Characters created by new Video ARE dynamic
  • Characters created by createTextField ARE dynamic

Referenced by gnash::DisplayList::mergeDisplayList(), gnash::MovieClip::notifyEvent(), gnash::MovieClip::construct(), gnash::MovieClip::get_bytes_total(), and gnash::MovieClip::get_bytes_loaded().

bool gnash::DisplayObject::isDynamicMask ( ) const [inline]

Returns true when the DisplayObject (and its childs) is used as a mask for another DisplayObject. isDynamicMask() does not return true when one of its parents is a mask and the DisplayObject itself is not.

NOTE: there's no way to obtain the maskee from a dynamic mask

See also isMaskLayer() and isMask()

Referenced by gnash::DisplayList::display(), pointInVisibleShape(), gnash::MovieClip::pointInVisibleShape(), and gnash::MovieClip::pointInHitableShape().

bool gnash::DisplayObject::isMaskLayer ( ) const [inline]

Returns true when the DisplayObject (and its childs) is used as a mask for other DisplayObjects at higher depth (up to get_clip_depth). isMaskLayer() does not return true when one of its parents is a mask and the DisplayObject itself is not.

See also isDynamicMask() and isMask()

References noClipDepthValue.

Referenced by gnash::DisplayList::display(), gnash::DisplayList::add_invalidated_bounds(), and pointInVisibleShape().

virtual bool gnash::DisplayObject::isSelectableTextField ( ) const [inline, virtual]

Return true if this DisplayObject is a selectable TextField.

This method is used by Gui to set up an appropriate cursor for input textfields.

Reimplemented in gnash::TextField.

Referenced by gnash::Gui::notifyMouseMove().

virtual void gnash::DisplayObject::killFocus ( ) [inline, virtual]

Some DisplayObjects require actions on losing focus.

Default is a no-op. TextField implements this function.

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

virtual void gnash::DisplayObject::markOwnResources ( ) const [inline, virtual]

Called by markReachableResources()

DisplayObjects should mark their own resources in this function.

Reimplemented in gnash::MovieClip, gnash::Button, and gnash::Video.

Referenced by markReachableResources().

void gnash::DisplayObject::markReachableResources ( ) const [virtual]

Mark all reachable resources.

Try not to override this function in derived classes. This always marks the base class's resources and calls markOwnResources() to take care of any further GC resources.

Reimplemented from gnash::GcResource.

References markOwnResources(), gnash::GcResource::setReachable(), and _parent.

as_object* gnash::DisplayObject::object ( ) const [inline]
virtual void gnash::DisplayObject::omit_display ( ) [inline, virtual]

Called instead of display() when the DisplayObject is not visible on stage. Used to clear the invalidated flags.

Reimplemented in gnash::MovieClip.

References clear_invalidated().

Referenced by gnash::DisplayList::display(), and gnash::DisplayList::omit_display().

DisplayObject* gnash::DisplayObject::parent ( ) const [inline]
as_object * gnash::DisplayObject::pathElement ( const ObjectURI uri) [virtual]

Find the object which is one degree removed from us, given the relative pathname.

If the pathname is "..", then return our parent. If the pathname is ".", then return ourself. If the pathname is "_level0" or "_root", then return the root movie.

Otherwise, the name should refer to one our our named DisplayObjects, so we return it.

NOTE: In ActionScript 2.0, top level names (like "_root" and "_level0") are CASE SENSITIVE. Character names in a display list are CASE SENSITIVE. Member names are CASE INSENSITIVE. Gah.

In ActionScript 1.0, everything seems to be CASE INSENSITIVE.

Reimplemented in gnash::MovieClip.

References gnash::getObject(), gnash::getName(), stage(), gnash::movie_root::getVM(), gnash::VM::getStringTable(), gnash::string_table::find(), parent(), gnash::caseless(), and gnash::NSV::PROP_THIS.

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

bool gnash::DisplayObject::pointInBounds ( boost::int32_t  x,
boost::int32_t  y 
) const [inline]

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

Parameters:
xPoint x coordinate in world space
yPoint y coordinate in world space
Returns:
Whether (x, y) is within the DisplayObject's bounds. This ignores _root's transform.

References getBounds(), gnash::getWorldMatrix(), gnash::SWFMatrix::transform(), and gnash::SWFRect::point_test().

Referenced by gnash::Bitmap::pointInShape(), gnash::InteractiveObject::pointInShape(), gnash::StaticText::pointInShape(), and gnash::Video::pointInShape().

virtual bool gnash::DisplayObject::pointInShape ( boost::int32_t  x,
boost::int32_t  y 
) const [pure virtual]

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

Parameters:
xPoint x coordinate in world space
yPoint y coordinate in world space
Returns:
Whether (x, y) is within the DisplayObject's bounds.

Implemented in gnash::TextField, gnash::MovieClip, gnash::InteractiveObject, gnash::Button, gnash::StaticText, gnash::Bitmap, gnash::Shape, gnash::MorphShape, and gnash::Video.

Referenced by gnash::Button::pointInShape(), pointInVisibleShape(), gnash::MovieClip::pointInVisibleShape(), and gnash::MovieClip::pointInHitableShape().

virtual bool gnash::DisplayObject::pointInVisibleShape ( boost::int32_t  x,
boost::int32_t  y 
) const [inline, virtual]

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

Point coordinates are in world TWIPS

The default implementation returns false if the DisplayObject is not visible, calling pointInShape() otherwise.

Note that this is good for simple DisplayObjects but needs to be overridden for DisplayObjects with childs. When a DisplayObject has childs it must take into account the case in which some childs are visible and some are not.

Reimplemented in gnash::MovieClip.

References visible(), isDynamicMask(), isMaskLayer(), and pointInShape().

Referenced by findDropTarget().

double gnash::DisplayObject::rotation ( ) const [inline]

Referenced by setWidth(), setHeight(), and set_rotation().

void gnash::DisplayObject::saveOriginalTarget ( ) [inline, protected]

Register currently computable target as the "original" one. This will be used by soft references (as_value) and should be called as soon as the stagePlacementCallback is invoked.

References getTarget().

Referenced by gnash::Button::construct(), construct(), gnash::MovieClip::construct(), gnash::SWFMovie::construct(), and gnash::Video::construct().

double gnash::DisplayObject::scaleX ( ) const [inline]

Referenced by set_rotation().

double gnash::DisplayObject::scaleY ( ) const [inline]
void gnash::DisplayObject::set_child_invalidated ( )

Called by a child to signalize it has changed visibily. The difference to set_invalidated() is that *this* DisplayObject does not need to redraw itself completely. This function will recursively inform all its parents of the change.

References _parent, and set_child_invalidated().

Referenced by set_invalidated(), and set_child_invalidated().

void gnash::DisplayObject::set_clip_depth ( int  d) [inline]
void gnash::DisplayObject::set_depth ( int  d) [inline]
void gnash::DisplayObject::set_event_handlers ( const Events copyfrom) [protected]
void gnash::DisplayObject::set_invalidated ( )

This function marks the DisplayObject as being modified in aspect and keeps track of current invalidated bounds the first time it's called after each call to clear_invalidated().

Call this function *before* any change in this DisplayObject that modifies its rendering. This information will be used to detect visual changes that need to be redrawn.

It is *important* to call this function *before* the change rather then after as it will also take care of updating the previously invalidated bounds (m_old_invalidated_bounds)

Calling this function multiple time is a no-op, unless clear_invalidated() is called in between.

NOTE: Marking a DisplayObject as invalidated automatically marks its parent as being invalidated.

See also:
Detection of updated regions

Referenced by gnash::Bitmap::construct(), gnash::Bitmap::update(), gnash::Button::set_current_state(), gnash::DisplayList::placeDisplayObject(), gnash::DisplayList::replaceDisplayObject(), gnash::DisplayList::swapDepths(), gnash::DisplayList::insertDisplayObject(), gnash::DisplayList::mergeDisplayList(), extend_invalidated_bounds(), set_visible(), setMatrix(), setMask(), setCxForm(), set_ratio(), update(), gnash::movie_root::setLevel(), gnash::movie_root::swapLevels(), gnash::MovieClip::addDisplayListObject(), gnash::MovieClip::remove_display_object(), gnash::MovieClip::graphics(), gnash::SWF::RemoveObjectTag::executeState(), gnash::TextField::keyInput(), gnash::TextField::setFont(), gnash::TextField::setDrawBorder(), gnash::TextField::setBorderColor(), gnash::TextField::setDrawBackground(), gnash::TextField::setBackgroundColor(), gnash::TextField::setTextColor(), gnash::TextField::setEmbedFonts(), gnash::TextField::setWordWrap(), gnash::TextField::setLeading(), gnash::TextField::setUnderlined(), gnash::TextField::setTabStops(), gnash::TextField::setURL(), gnash::TextField::setTarget(), gnash::TextField::setDisplay(), gnash::TextField::setAlignment(), gnash::TextField::setIndent(), gnash::TextField::setBlockIndent(), gnash::TextField::setRightMargin(), gnash::TextField::setLeftMargin(), gnash::TextField::setFontHeight(), gnash::TextField::setAutoSize(), and gnash::Video::clear().

void gnash::DisplayObject::set_invalidated ( const char *  debug_file,
int  debug_line 
)
void gnash::DisplayObject::set_name ( const ObjectURI uri) [inline]
void gnash::DisplayObject::set_parent ( DisplayObject parent) [inline]

Set the parent of this DisplayObject.

In AS3, DisplayObjects may be created before being attached to a parent. In AS2, this is only used for external movies

References _parent, and parent().

Referenced by gnash::MovieClip::getLoadedMovie().

void gnash::DisplayObject::set_ratio ( boost::uint16_t  r) [inline]
void gnash::DisplayObject::set_rotation ( double  rot)

Set the rotation value of current SWFMatrix.

Set the real and cached rotation.

This is used when setting _rotation See rotation_getset

Parameters:
rotrotation in degrees. will be trimmed to the -180 .. 180 range, can be passed outside it.

Cached scale values are not updated.

References rotation(), gnash::key::m, gnash::getMatrix(), gnash::SWFMatrix::set_rotation(), gnash::SWFMatrix::set_x_scale(), scaleX(), setMatrix(), and transformedByScript().

void gnash::DisplayObject::set_visible ( bool  visible)

Set whether this DisplayObject should be rendered.

TODO: handle all visible getter/setters in DisplayObject, not in subclasses, and drop this / make it private.

References set_invalidated(), assert, stage(), gnash::movie_root::getFocus(), gnash::movie_root::setFocus(), and visible().

void gnash::DisplayObject::set_x_scale ( double  scale_percent)

Set the xscale value of current SWFMatrix.

Set the real and cached x scale.

This is used when setting _xscale. See xscale_getset.

Parameters:
factorscale factor, in percent

Cached rotation and y scale are not updated.

References gnash::key::m, gnash::getMatrix(), gnash::SWFMatrix::set_x_scale(), setMatrix(), and transformedByScript().

void gnash::DisplayObject::set_y_scale ( double  scale_percent)

Set the yscale value of current SWFMatrix.

Set the real and cached y scale.

This is used when setting _yscale See yscale_getset.

Parameters:
factorscale factor, in percent

Cached rotation and x scale are not updated.

References gnash::key::m, gnash::getMatrix(), gnash::SWFMatrix::set_y_scale(), setMatrix(), and transformedByScript().

void gnash::DisplayObject::setBlendMode ( BlendMode  bm) [inline]
void gnash::DisplayObject::setCxForm ( const SWFCxForm cx) [inline]
void gnash::DisplayObject::setDynamic ( ) [inline]

Mark this DisplayObject as dynamically created.

Referenced by gnash::MovieClip::duplicateMovieClip().

void gnash::DisplayObject::setHeight ( double  height) [virtual]

Set the height of this DisplayObject, modifying its SWFMatrix.

This is used when setting _height

Parameters:
hnew height, in TWIPS.

Reimplemented in gnash::TextField.

References getBounds(), gnash::SWFRect::height(), assert, rotation(), gnash::key::m, gnash::getMatrix(), gnash::SWFMatrix::get_x_scale(), gnash::SWFMatrix::set_scale_rotation(), and setMatrix().

Referenced by gnash::setHeight().

void gnash::DisplayObject::setMask ( DisplayObject mask)

Register a DisplayObject as a mask for this instance.

Parameters:
maskThe DisplayObject to use as a mask, possibly NULL. A reference to us will be registered with the mask, if not null, so it'll know it's a mask for us, and would stop being a mask for anything else.

Register as as masked by the mask

References set_invalidated(), setMask(), set_clip_depth(), and noClipDepthValue.

Referenced by unload(), and setMask().

void gnash::DisplayObject::setMatrix ( const SWFMatrix m,
bool  updateCache = false 
)
void gnash::DisplayObject::setVolume ( int  vol) [inline]

Set sound volume for this DisplayObject.

void gnash::DisplayObject::setWidth ( double  width) [virtual]

Set the width of this DisplayObject, modifying its SWFMatrix.

This is used when setting _width

Parameters:
wnew width, in TWIPS. TextField does this differently (caches not updated).

Reimplemented in gnash::TextField.

References getBounds(), gnash::SWFRect::width(), assert, rotation(), gnash::key::m, gnash::getMatrix(), gnash::SWFMatrix::get_y_scale(), gnash::SWFMatrix::set_scale_rotation(), and setMatrix().

movie_root& gnash::DisplayObject::stage ( ) const [inline, protected]
virtual MovieClip* gnash::DisplayObject::to_movie ( ) [inline, virtual]
virtual InteractiveObject* gnash::DisplayObject::topmostMouseEntity ( boost::int32_t  ,
boost::int32_t   
) [inline, virtual]

DisplayObjects are not a mouse entity by default.

Override this function for InteractiveObjects.

Reimplemented in gnash::MovieClip, gnash::TextField, gnash::InteractiveObject, and gnash::Button.

Referenced by gnash::Button::topmostMouseEntity().

const Transform& gnash::DisplayObject::transform ( ) const [inline]
void gnash::DisplayObject::transformedByScript ( ) [inline]

Call this function when the sprite has been transformed due to ActionScript code.

This information will be used while executing PlaceObject tags in that ActionScript-transformed DisplayObjects won't be allowed to be moved.

TODO: make protected

Referenced by gnash::DisplayList::swapDepths(), set_x_scale(), set_rotation(), and set_y_scale().

bool gnash::DisplayObject::unload ( )

Unload this instance from the stage.

This function must be called when the DisplayObject is removed from the stage. It will take care of properly calling unload against any child DisplayObjects and queuing the 'UNLOAD' event handler.

Returns:
true if any onUnload event handler was defined by either this or any child DisplayObjects, false otherwise.

References unloadChildren(), and setMask().

Referenced by gnash::Button::set_current_state(), gnash::Button::unloadChildren(), gnash::DisplayList::placeDisplayObject(), gnash::DisplayList::replaceDisplayObject(), gnash::DisplayList::removeDisplayObject(), gnash::DisplayList::unload(), gnash::DisplayList::mergeDisplayList(), and gnash::movie_root::dropLevel().

virtual bool gnash::DisplayObject::unloadChildren ( ) [inline, protected, virtual]

Reimplemented in gnash::MovieClip, and gnash::Button.

Referenced by unload().

bool gnash::DisplayObject::unloaded ( ) const [inline]
virtual void gnash::DisplayObject::update ( ) [inline, virtual]

Notify a change in the DisplayObject's appearance.

Reimplemented in gnash::Bitmap.

References set_invalidated().

Referenced by gnash::BitmapData_as::updateObjects().

bool gnash::DisplayObject::visible ( ) const [inline]
virtual void gnash::DisplayObject::visitNonProperties ( KeyVisitor ) const [inline, virtual]

Enumerate any non-proper properties.

This function allows enumeration of properties that are derived from the DisplayObject type, e.g. DisplayList members.

The default implementation adds nothing

Reimplemented in gnash::MovieClip.

Referenced by gnash::as_object::visitKeys().


Member Data Documentation

Name of this DisplayObject (if any)

Referenced by set_name(), and get_name().

const int gnash::DisplayObject::lowerAccessibleBound = -16384 [static]

See also http://www.kirupa.com/developer/actionscript/depths2.htm.

The lowest placeable and accessible depth for a DisplayObject. Macromedia Flash help says: depth starts at -16383 (0x3FFF)

See: http://www.senocular.com/flash/tutorials/depths/?page=2 The only way to exceed these bounds is with createEmptyMoveClip(), which can be placed at any depth within +/- 2**31.

Bounds of this DisplayObject instance before first invalidation since last call to clear_invalidated().

This stores the bounds of the DisplayObject before it has been changed, ie. the position when set_invalidated() is being called. While drawing, both the old and the new bounds are updated (rendered). When moving a DisplayObject A to B then both the position A needs to be re-rendered (to reveal the backgrond) and the position B needs to be re-rendered (to show the DisplayObject in its new position). The bounds may be identical or overlap, but SnappingRanges takes care of that.

Will be set by set_invalidated() and used by get_invalidated_bounds().

Referenced by gnash::Bitmap::add_invalidated_bounds(), gnash::Button::add_invalidated_bounds(), DisplayObject(), set_invalidated(), add_invalidated_bounds(), extend_invalidated_bounds(), clear_invalidated(), gnash::MovieClip::add_invalidated_bounds(), gnash::TextField::add_invalidated_bounds(), and gnash::Video::add_invalidated_bounds().

const int gnash::DisplayObject::noClipDepthValue = -1000000 [static]

This value is used for m_clip_depth when the DisplayObject is not a layer mask. Depths below -16384 are illegal, so this value should not collide with real depths.

Referenced by setMask(), and isMaskLayer().

const int gnash::DisplayObject::removedDepthOffset = -32769 [static]

This is the offset at which DisplayObject's depth is shifted when a DisplayObject is removed from stage but an onUnload event handler is defined.

Example: a DisplayObject at depth 60 gets moved to depth -32829 (-32769-60) when unloaded and an onUnload event handler is defined for it or any of its childs.

So, to recap: 1: -32769 to -16385 are removed 2: -16384 to 0 are statics 3: Max depth for a PlaceObject call is 16384 (which becomes 0 in the statics) (all of the above correct?)

Referenced by gnash::Button::set_current_state().

This is the amount added to displaylist tag defined depths. DisplayObjects placed by tags (vs. DisplayObjects instantiated by ActionScript) always have negative depths by effect of this offset.

Referenced by gnash::BitmapMovie::BitmapMovie(), gnash::SWF::ButtonRecord::instantiate(), gnash::DisplayList::swapDepths(), getTargetPath(), getTarget(), gnash::movie_root::setLevel(), gnash::movie_root::swapLevels(), gnash::movie_root::replaceLevel(), gnash::movie_root::getLevel(), and gnash::MovieClip::getLoadedMovie().

const int gnash::DisplayObject::upperAccessibleBound = 2130690044 [static]

This is the maximum depth a MovieClip DisplayObject can be placed at (attachMovie). Kirupa (see above) says 2130690045, but this seems not to be included in the range.


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