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  :
51  DisplayObject(getRoot(*object), object, parent)
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:
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:168
virtual bool trackAsMenu()
ActionScript property of Buttons and MovieClips altering mouse handling.
Definition: InteractiveObject.h:71
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
virtual ~InteractiveObject()
Definition: InteractiveObject.h:59
virtual StaticText * getStaticText(std::vector< const SWF::TextRecord *> &, size_t &)
Allow extraction of static text.
Definition: InteractiveObject.h:79
The base class for all ActionScript objects.
Definition: as_object.h:161
Base class for render handlers.
Definition: Renderer.h:188
void log_error(StringType msg, Args... args)
Definition: log.h:283
std::int32_t x
Definition: BitmapData_as.cpp:434
The base class for interactive objects.
Definition: InteractiveObject.h:44
std::int32_t y
Definition: BitmapData_as.cpp:435
Static text fields, SWF-defined with read-only text.
Definition: StaticText.h:43
Rectangle class, see swf defined rectangle record.
Definition: SWFRect.h:44
virtual bool pointInShape(std::int32_t x, std::int32_t y) const
Return true if the given point falls in this DisplayObject&#39;s shape.
Definition: InteractiveObject.h:132
A class to identify &#39;static&#39; SWF events (system events).
Definition: event_id.h:52
Definition: GnashKey.h:331
The Transform class expresses a stage in a cumulative transformation.
Definition: Transform.h:33
InteractiveObject(as_object *object, DisplayObject *parent)
Definition: InteractiveObject.h:49
movie_root & getRoot(const as_environment &env)
Definition: as_environment.cpp:645