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:
Inheritance graph
[legend]
Collaboration diagram for gnash::DisplayObject:
Collaboration graph
[legend]

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 enumerateNonProperties (as_environment &) 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)
int get_ratio () const
void set_ratio (int 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 (string_table::key name)
 Set DisplayObject name, initializing the original target member.
string_table::key get_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 (string_table::key key)
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
virtual void notifyEvent (const event_id &)
 Notify clip events (and also user-defined ones).
void queueEvent (const event_id &id, int lvl)
 Queue event in the global action queue.
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.
string_table::key 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().

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

string_table::key _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:
mr The movie_root containing the DisplayObject hierarchy. All DisplayObjects may need movie_root resources.
object An 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.
parent The parent of the new DisplayObject. This may be null.

References gnash::geometry::SnappingRanges2d< T >::isNull(), m_old_invalidated_ranges, 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:
id The event triggering the handler.
code An 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().

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::Bitmap, gnash::Button, gnash::InteractiveObject, gnash::MovieClip, gnash::TextField, gnash::Video, and gnash::DummyCharacter.

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

Referenced by gnash::DisplayList::add_invalidated_bounds(), gnash::Button::add_invalidated_bounds(), gnash::DisplayList::replaceDisplayObject(), 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. 3. The default value (if the property is not defined) is true.

References gnash::getObject(), hasEventHandler(), gnash::NSV::PROP_USEHANDCURSOR, gnash::event_id::RELEASE, and gnash::as_value::to_bool().

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 _, gnash::key::_1, gnash::fn_call::arg(), BLENDMODE_HARDLIGHT, BLENDMODE_NORMAL, BLENDMODE_UNDEFINED, getBlendMode(), gnash::as_value::is_number(), gnash::as_value::is_undefined(), LOG_ONCE, gnash::fn_call::nargs, setBlendMode(), gnash::as_value::to_number(), and gnash::as_value::to_string().

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 gnash::Renderer::bounds_in_clipping_area(), getBounds(), gnash::SWFRect::getRange(), gnash::getWorldMatrix(), and gnash::SWFMatrix::transform().

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::constructAsScriptObject().

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< T >::setNull().

Referenced by gnash::MovieClip::add_display_object(), gnash::TextField::display(), gnash::StaticText::display(), gnash::Button::display(), and omit_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::Bitmap, gnash::Button, gnash::MovieClip, gnash::SWFMovie, and gnash::Video.

References saveOriginalTarget().

Referenced by gnash::Button::construct(), and gnash::Button::set_current_state().

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::Button, and gnash::MovieClip.

References gnash::as_object::clearProperties().

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

virtual void gnash::DisplayObject::display ( Renderer renderer,
const Transform xform 
) [pure virtual]
virtual void gnash::DisplayObject::enumerateNonProperties ( as_environment  )  const [inline, virtual]

Enumerate any non-proper properties.

This function is called by enumerateProperties(as_environment&) to allow for enumeration of properties that are derived from the DisplayObject type, e.g. DisplayList members.

The default implementation adds nothing

Reimplemented in gnash::MovieClip.

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 gnash::geometry::SnappingRanges2d< T >::add(), m_old_invalidated_ranges, and set_invalidated().

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 pointInVisibleShape(), and visible().

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::mergeDisplayList(), and gnash::DisplayList::moveDisplayObject().

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::add_invalidated_bounds(), and gnash::DisplayList::display().

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.

TODO: make const/return const& ?

Reimplemented in gnash::MovieClip.

References _parent, and get_environment().

Referenced by 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().

const Events& gnash::DisplayObject::get_event_handlers (  )  const [inline, protected]
string_table::key gnash::DisplayObject::get_name (  )  const [inline]
int 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 get_root(), and parent().

Referenced by get_root(), getAsRoot(), 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::Function2::call().

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).

string_table::key 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

Return full path to this object, in slash notation.

e.g. "/sprite1/sprite2/ourSprite"

References gnash::Path::empty(), get_depth(), get_name(), gnash::getObject(), gnash::movie_root::getRootMovie(), gnash::getStringTable(), parent(), stage(), staticDepthOffset, and gnash::string_table::value().

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 _parent, getVolume(), and volume.

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::Button, and gnash::MovieClip.

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::get_member(), and gnash::as_value::to_function().

Referenced by allowHandCursor(), and unload().

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::MovieClip::get_bytes_loaded(), gnash::MovieClip::get_bytes_total(), and gnash::DisplayList::mergeDisplayList().

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(), and pointInVisibleShape().

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::add_invalidated_bounds(), gnash::DisplayList::display(), 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::getEntityUnderPointer().

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

Called by markReachableResources().

DisplayObjects should mark their own resources in this function.

Reimplemented in gnash::Button, gnash::MovieClip, 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 _parent, markOwnResources(), and gnash::GcResource::setReachable().

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

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

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

Referenced by gnash::QueuedEvent::execute(), and gnash::InteractiveObject::mouseEvent().

as_object * gnash::DisplayObject::object (  )  const
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 ( string_table::key  key  )  [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::caseless(), gnash::equal(), gnash::string_table::find(), gnash::getObject(), gnash::VM::getStringTable(), gnash::movie_root::getVM(), parent(), gnash::NSV::PROP_THIS, and stage().

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:
x Point x coordinate in world space
y Point 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::SWFRect::point_test(), and gnash::SWFMatrix::transform().

Referenced by gnash::Bitmap::display(), gnash::Video::pointInShape(), and gnash::InteractiveObject::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:
x Point x coordinate in world space
y Point y coordinate in world space
Returns:
Whether (x, y) is within the DisplayObject's bounds.

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

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

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 isDynamicMask(), isMaskLayer(), pointInShape(), and visible().

Referenced by findDropTarget().

void gnash::DisplayObject::queueEvent ( const event_id id,
int  lvl 
)

Queue event in the global action queue.

notifyEvent(id) will be called by execution of the queued action

References gnash::movie_root::pushAction(), and stage().

Referenced by unload().

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

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

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::SWFMovie::construct(), construct(), and gnash::Button::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_child_invalidated(), and set_invalidated().

void gnash::DisplayObject::set_clip_depth ( int  d  )  [inline]

See get_clip_depth().

Referenced by setMask().

void gnash::DisplayObject::set_depth ( int  d  )  [inline]
void gnash::DisplayObject::set_event_handlers ( const Events copyfrom  )  [protected]
void gnash::DisplayObject::set_invalidated ( const char *  debug_file,
int  debug_line 
)
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::DisplayList::addDisplayObject(), gnash::SWF::RemoveObjectTag::executeState(), extend_invalidated_bounds(), gnash::MovieClip::graphics(), gnash::DisplayList::insertDisplayObject(), gnash::TextField::notifyEvent(), gnash::DisplayList::placeDisplayObject(), gnash::DisplayList::replaceDisplayObject(), gnash::Button::set_current_state(), set_ratio(), set_visible(), gnash::TextField::setAlignment(), gnash::TextField::setAutoSize(), gnash::TextField::setBackgroundColor(), gnash::TextField::setBlockIndent(), gnash::TextField::setBorderColor(), setCxForm(), gnash::TextField::setDisplay(), gnash::TextField::setDrawBackground(), gnash::TextField::setDrawBorder(), gnash::TextField::setEmbedFonts(), gnash::TextField::setFont(), gnash::TextField::setFontHeight(), gnash::TextField::setIndent(), gnash::TextField::setLeading(), gnash::TextField::setLeftMargin(), setMask(), setMatrix(), gnash::TextField::setRightMargin(), gnash::TextField::setTabStops(), gnash::TextField::setTarget(), gnash::TextField::setTextColor(), gnash::TextField::setUnderlined(), gnash::TextField::setURL(), gnash::TextField::setWordWrap(), gnash::DisplayList::swapDepths(), and update().

void gnash::DisplayObject::set_name ( string_table::key  name  )  [inline]

Set DisplayObject name, initializing the original target member.

References _name.

Referenced by gnash::SWF::ButtonRecord::instantiate().

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.

Referenced by gnash::DisplayObjectContainer::addChild(), gnash::DisplayObjectContainer::addChildAt(), gnash::DisplayObjectContainer::removeChild(), and gnash::DisplayObjectContainer::removeChildAt().

void gnash::DisplayObject::set_ratio ( int  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:
rot rotation in degrees. will be trimmed to the -180 .. 180 range, can be passed outside it.

Cached scale values are not updated.

References gnash::getMatrix(), gnash::key::m, rotation(), scaleX(), gnash::SWFMatrix::set_rotation(), gnash::SWFMatrix::set_x_scale(), 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 gnash::movie_root::getFocus(), gnash::getRoot(), set_invalidated(), and gnash::movie_root::setFocus().

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:
factor scale factor, in percent

Cached rotation and y scale are not updated.

References gnash::getMatrix(), gnash::key::m, 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:
factor scale factor, in percent

Cached rotation and x scale are not updated.

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

void gnash::DisplayObject::setBlendMode ( BlendMode  bm  )  [inline]

Referenced by blendMode().

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

Mark this DisplayObject as dynamically created.

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

Set the height of this DisplayObject, modifying its SWFMatrix.

This is used when setting _height

Parameters:
h new height, in TWIPS.

Reimplemented in gnash::TextField.

References gnash::SWFMatrix::get_x_scale(), getBounds(), gnash::getMatrix(), gnash::SWFRect::height(), gnash::key::m, rotation(), 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:
mask The 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 noClipDepthValue, set_clip_depth(), set_invalidated(), and setMask().

Referenced by setMask(), and unload().

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:
w new width, in TWIPS. TextField does this differently (caches not updated).

Reimplemented in gnash::TextField.

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

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::Button, gnash::InteractiveObject, gnash::MovieClip, gnash::TextField, and gnash::DummyCharacter.

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 set_rotation(), set_x_scale(), set_y_scale(), and gnash::DisplayList::swapDepths().

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 hasEventHandler(), gnash::movie_root::PRIORITY_DOACTION, queueEvent(), gnash::movie_root::removeQueuedConstructor(), setMask(), stage(), gnash::event_id::UNLOAD, and unloadChildren().

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

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

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

Referenced by unload().

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

Notify a change in the DisplayObject's appearance.

Reimplemented in gnash::Bitmap.

References set_invalidated().

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

Member Data Documentation

Name of this DisplayObject (if any).

Referenced by get_name(), and set_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::TextField::add_invalidated_bounds(), add_invalidated_bounds(), gnash::Button::add_invalidated_bounds(), clear_invalidated(), gnash::MovieClip::constructAsScriptObject(), DisplayObject(), extend_invalidated_bounds(), set_invalidated(), and gnash::Video::setStream().

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 isMaskLayer(), and setMask().

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(), getTarget(), getTargetPath(), gnash::SWF::ButtonRecord::instantiate(), main(), gnash::DisplayList::mergeDisplayList(), gnash::SWF::RemoveObjectTag::read(), gnash::DisplayList::swapDepths(), and testAll().

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: