Gnash  0.8.11dev
InteractiveObject.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
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.
9 //
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.
14 //
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
18 
19 #ifndef GNASH_INTERACTIVE_DISPLAY_OBJECT_H
20 #define GNASH_INTERACTIVE_DISPLAY_OBJECT_H
21 
22 #include <vector>
23 #include <cassert>
24 
25 #include "DisplayObject.h" // for inheritance
26 #include "log.h"
27 #include "as_object.h" // for getRoot()
28 
29 namespace gnash {
30  class StaticText;
31  namespace SWF {
32  class TextRecord;
33  }
34 }
35 
36 namespace gnash {
37 
39 //
42 //
45 {
46 
47 public:
48 
50  :
52  {
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.
56  assert(object);
57  }
58 
59  virtual ~InteractiveObject() {}
60 
62  virtual void display(Renderer& renderer, const Transform& xform) = 0;
63 
65  //
68  virtual bool mouseEnabled() const = 0;
69 
71  virtual bool trackAsMenu() {
72  return false;
73  }
74 
76  //
79  virtual StaticText* getStaticText(std::vector<const SWF::TextRecord*>&,
80  size_t&) {
81  return nullptr;
82  }
83 
85  //
89  virtual SWFRect getBounds() const = 0;
90 
94  //
115  virtual InteractiveObject* topmostMouseEntity(std::int32_t /*x*/,
116  std::int32_t /*y*/) = 0;
117 
119  //
122  virtual void mouseEvent(const event_id& id) = 0;
123 
125  //
132  virtual bool pointInShape(std::int32_t x, std::int32_t y) const
133  {
134  log_error("Character %s did not override pointInShape() - "
135  "using pointInBounds() instead", typeid(*this).name());
136  return pointInBounds(x, y);
137  }
138 
139  void add_invalidated_bounds(InvalidatedRanges& ranges, bool force) = 0;
140 
141 };
142 
143 
144 } // namespace gnash
145 
146 
147 #endif
148 
149 
150 // Local Variables:
151 // mode: C++
152 // indent-tabs-mode: t
153 // End:
gnash::geometry::SnappingRanges2d< std::int32_t >
gnash::as_object
The base class for all ActionScript objects.
Definition: as_object.h:162
as_object.h
gnash::InteractiveObject::add_invalidated_bounds
void add_invalidated_bounds(InvalidatedRanges &ranges, bool force)=0
Add the DisplayObject's invalidated bounds to the given ranges list.
y
std::int32_t y
Definition: BitmapData_as.cpp:435
gnash::DisplayObject::pointInBounds
bool pointInBounds(std::int32_t x, std::int32_t y) const
Return true if the given point falls in this DisplayObject's bounds.
Definition: DisplayObject.h:488
gnash::DisplayObject::object
as_object * object() const
Definition: DisplayObject.h:931
gnash::InteractiveObject::mouseEvent
virtual void mouseEvent(const event_id &id)=0
Called whenever a mouse event affects this InteractiveObject.
gnash::InteractiveObject::getBounds
virtual SWFRect getBounds() const =0
Returns local, untransformed bounds of this DisplayObject in TWIPS.
gnash::event_id
A class to identify 'static' SWF events (system events).
Definition: event_id.h:53
gnash::InteractiveObject::topmostMouseEntity
virtual InteractiveObject * topmostMouseEntity(std::int32_t, std::int32_t)=0
Return the topmost entity covering the given point and enabled to receive mouse events.
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::InteractiveObject::getStaticText
virtual StaticText * getStaticText(std::vector< const SWF::TextRecord * > &, size_t &)
Allow extraction of static text.
Definition: InteractiveObject.h:79
gnash::Renderer
Base class for render handlers.
Definition: Renderer.h:189
gnash::InteractiveObject::pointInShape
virtual bool pointInShape(std::int32_t x, std::int32_t y) const
Return true if the given point falls in this DisplayObject's shape.
Definition: InteractiveObject.h:132
gnash::InteractiveObject::mouseEnabled
virtual bool mouseEnabled() const =0
Whether the DisplayObject can handle a mouse event.
gnash::log_error
void log_error(StringType msg, Args... args)
Definition: log.h:283
gnash::InteractiveObject::~InteractiveObject
virtual ~InteractiveObject()
Definition: InteractiveObject.h:59
gnash::InteractiveObject
The base class for interactive objects.
Definition: InteractiveObject.h:45
gnash::SWFRect
Rectangle class, see swf defined rectangle record.
Definition: SWFRect.h:45
gnash::StaticText
Static text fields, SWF-defined with read-only text.
Definition: StaticText.h:44
DisplayObject.h
log.h
gnash::DisplayObject::parent
DisplayObject * parent() const
Return the parent of this DisplayObject, or NULL if the DisplayObject has no parent.
Definition: DisplayObject.h:252
gnash::getRoot
movie_root & getRoot(const as_environment &env)
Definition: as_environment.cpp:645
gnash::InteractiveObject::InteractiveObject
InteractiveObject(as_object *object, DisplayObject *parent)
Definition: InteractiveObject.h:49
gnash::InteractiveObject::trackAsMenu
virtual bool trackAsMenu()
ActionScript property of Buttons and MovieClips altering mouse handling.
Definition: InteractiveObject.h:71
gnash::InteractiveObject::display
virtual void display(Renderer &renderer, const Transform &xform)=0
Render this InteractiveObject.
gnash::DisplayObject
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:169
gnash::Transform
The Transform class expresses a stage in a cumulative transformation.
Definition: Transform.h:34
gnash::key::SWF
@ SWF
Definition: GnashKey.h:331
x
std::int32_t x
Definition: BitmapData_as.cpp:434
InteractiveObject.h