Gnash  0.8.10
InteractiveObject.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00003 //   Free Software Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 #ifndef GNASH_INTERACTIVE_DISPLAY_OBJECT_H
00020 #define GNASH_INTERACTIVE_DISPLAY_OBJECT_H
00021 
00022 #include "DisplayObject.h" // for inheritance
00023 #include "log.h"
00024 #include "as_object.h" // for getRoot()
00025 
00026 #include <vector>
00027 #include <cassert>
00028 
00029 namespace gnash {
00030     class StaticText;
00031     namespace SWF {
00032         class TextRecord;
00033     }
00034 }
00035 
00036 namespace gnash {
00037 
00039 //
00042 //
00044 class InteractiveObject : public DisplayObject
00045 {
00046 
00047 public:
00048 
00049         InteractiveObject(as_object* object, DisplayObject* parent)
00050                 :
00051                 DisplayObject(getRoot(*object), object, parent)
00052         {
00053         // It's a bit too late for this assertion as we've already
00054         // deferenced it. All InteractiveObjects are AS-referenceable,
00055         // so they must have an object.
00056         assert(object);
00057         }
00058 
00059     virtual ~InteractiveObject() {}
00060 
00062         virtual void display(Renderer& renderer, const Transform& xform) = 0;
00063 
00065     //
00068         virtual bool mouseEnabled() const = 0;
00069 
00071     virtual bool trackAsMenu() {
00072         return false;
00073     }
00074 
00076     //
00079     virtual StaticText* getStaticText(std::vector<const SWF::TextRecord*>&,
00080             size_t&) {
00081         return 0;
00082     }
00083 
00085     //
00089     virtual SWFRect getBounds() const = 0;
00090 
00094     //
00115     virtual InteractiveObject* topmostMouseEntity(boost::int32_t /*x*/,
00116             boost::int32_t /*y*/) = 0;
00117 
00119     //
00122     virtual void mouseEvent(const event_id& id) = 0;
00123 
00125     //
00132     virtual bool pointInShape(boost::int32_t x, boost::int32_t y) const
00133     {
00134         log_error("Character %s did not override pointInShape() - "
00135                 "using pointInBounds() instead", typeid(*this).name());
00136         return pointInBounds(x, y);
00137     }
00138 
00139         void add_invalidated_bounds(InvalidatedRanges& ranges, bool force) = 0;
00140 
00141 };
00142 
00143 
00144 } // namespace gnash
00145 
00146 
00147 #endif 
00148 
00149 
00150 // Local Variables:
00151 // mode: C++
00152 // indent-tabs-mode: t
00153 // End: