2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef GNASH_INTERACTIVE_DISPLAY_OBJECT_H
20 #define GNASH_INTERACTIVE_DISPLAY_OBJECT_H
22 #include "DisplayObject.h" // for inheritance
24 #include "as_object.h" // for getRoot()
38 /// The base class for interactive objects.
40 /// Objects of type InteractiveObject can receive focus, mouse events,
41 /// and key events for user interaction.
43 /// Derived classes include TextField, Button, and MovieClip.
44 class InteractiveObject
: public DisplayObject
49 InteractiveObject(as_object
* object
, DisplayObject
* parent
)
51 DisplayObject(getRoot(*object
), object
, parent
)
53 // It's a bit too late for this assertion as we've already
54 // deferenced it. All InteractiveObjects are AS-referenceable,
55 // so they must have an object.
59 virtual ~InteractiveObject() {}
61 /// Render this InteractiveObject
62 virtual void display(Renderer
& renderer
, const Transform
& xform
) = 0;
64 /// Whether the DisplayObject can handle a mouse event.
66 /// @return true if the DisplayObject can handle mouse
68 virtual bool mouseEnabled() const = 0;
70 /// ActionScript property of Buttons and MovieClips altering mouse handling
71 virtual bool trackAsMenu() {
75 /// Allow extraction of static text.
77 /// Default returns 0, implemented only for DefineText though
79 virtual StaticText
* getStaticText(std::vector
<const SWF::TextRecord
*>&,
84 /// Returns local, untransformed bounds of this DisplayObject in TWIPS
86 /// Container DisplayObjects (sprite and buttons) return the composite
87 /// bounds of all their children, appropriately transformed with
88 /// their local SWFMatrix.
89 virtual SWFRect
getBounds() const = 0;
92 /// Return the topmost entity covering the given point
93 /// and enabled to receive mouse events.
95 /// Return NULL if no "active" entity is found under the pointer.
97 /// Coordinates of the point are given in parent's coordinate space.
98 /// This means that in order to convert the point to the local coordinate
99 /// space you need to apply an inverse transformation using this
100 /// DisplayObject SWFMatrix. Example:
103 /// getMatrix().transform_by_inverse(p);
104 /// -- p is now in local coordinates
106 /// Don't blame me for this mess, I'm just trying to document the existing
107 /// functions ... --strk
110 /// X ordinate of the pointer, in parent's coordinate space.
113 /// Y ordinate of the pointer, in parent's coordiante space.
115 virtual InteractiveObject
* topmostMouseEntity(boost::int32_t /*x*/,
116 boost::int32_t /*y*/) = 0;
118 virtual void mouseEvent(const event_id
& id
)
123 /// Return true if the given point falls in this DisplayObject's shape
125 /// Point coordinates are in world TWIPS
127 /// The default implementation warns about a missing
128 /// override and invokes pointInBounds().
131 virtual bool pointInShape(boost::int32_t x
, boost::int32_t y
) const
133 log_error("Character %s did not override pointInShape() - "
134 "using pointInBounds() instead", typeid(*this).name());
135 return pointInBounds(x
, y
);
138 void add_invalidated_bounds(InvalidatedRanges
& ranges
, bool force
) = 0;
151 // indent-tabs-mode: t