Gnash 0.8.9
|
00001 // 00002 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 00003 // 2011 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 00020 // SWF buttons. Mouse-sensitive update/display, actions, etc. 00021 00022 00023 #ifndef GNASH_BUTTON_H 00024 #define GNASH_BUTTON_H 00025 00026 #include "smart_ptr.h" 00027 #include "InteractiveObject.h" // for inheritance 00028 00029 #include <boost/intrusive_ptr.hpp> 00030 #include <vector> 00031 #include <set> 00032 00033 // Forward declarations. 00034 namespace gnash { 00035 namespace SWF { 00036 class DefineButtonTag; 00037 } 00038 } 00039 00040 namespace gnash { 00041 // 00042 // Button 00043 // 00044 00045 class Button : public InteractiveObject 00046 { 00047 public: 00048 00049 typedef std::vector<DisplayObject*> DisplayObjects; 00050 typedef std::vector<const DisplayObject*> ConstDisplayObjects; 00051 00053 typedef std::set<int> ActiveRecords; 00054 00055 enum mouse_flags 00056 { 00057 FLAG_IDLE = 0, 00058 FLAG_OVER = 1, 00059 FLAG_DOWN = 2, 00060 OVER_DOWN = FLAG_OVER | FLAG_DOWN, 00061 00062 // aliases 00063 OVER_UP = FLAG_OVER, 00064 OUT_DOWN = FLAG_DOWN 00065 }; 00066 00067 enum MouseState 00068 { 00069 MOUSESTATE_UP = 0, 00070 MOUSESTATE_DOWN, 00071 MOUSESTATE_OVER, 00072 MOUSESTATE_HIT 00073 }; 00074 00076 // 00078 Button(as_object* object, const SWF::DefineButtonTag* def, 00079 DisplayObject* parent); 00080 00081 ~Button(); 00082 00083 static const char* mouseStateName(MouseState s); 00084 00085 bool mouseEnabled() const { return true; } 00086 00087 virtual bool trackAsMenu(); 00088 00089 // called from keypress listener only 00090 void notifyEvent(const event_id& id); 00091 00093 virtual void display(Renderer& renderer, const Transform& xform); 00094 00095 void set_current_state(MouseState new_state); 00096 00100 // 00103 virtual InteractiveObject* topmostMouseEntity(boost::int32_t x, 00104 boost::int32_t y); 00105 00106 virtual void mouseEvent(const event_id& event); 00107 00108 virtual bool handleFocus(); 00109 00110 void add_invalidated_bounds(InvalidatedRanges& ranges, bool force); 00111 00112 virtual SWFRect getBounds() const; 00113 00114 // See dox in DisplayObject.h 00115 bool pointInShape(boost::int32_t x, boost::int32_t y) const; 00116 00117 bool isEnabled(); 00118 00120 void destroy(); 00121 00123 // 00126 // 00129 virtual void construct(as_object* init = 0); 00130 00131 #ifdef USE_SWFTREE 00132 // Override to append button DisplayObjects info, see dox in DisplayObject.h 00133 virtual InfoTree::iterator getMovieInfo(InfoTree& tr, 00134 InfoTree::iterator it); 00135 #endif 00136 00137 protected: 00138 00140 virtual bool unloadChildren(); 00141 00143 // 00149 void markOwnResources() const; 00150 00151 private: 00152 00154 // 00163 void getActiveCharacters(DisplayObjects& list, bool includeUnloaded=false); 00164 00166 // 00171 void getActiveCharacters(ConstDisplayObjects& list) const; 00172 00175 // 00182 void get_active_records(ActiveRecords& list, MouseState state); 00183 00185 virtual int getDefinitionVersion() const; 00186 00187 MouseState _mouseState; 00188 00189 const boost::intrusive_ptr<const SWF::DefineButtonTag> _def; 00190 00191 DisplayObjects _stateCharacters; 00192 00193 DisplayObjects _hitCharacters; 00194 00195 00196 }; 00197 00198 00200 void button_class_init(as_object& global, const ObjectURI& uri); 00201 00202 void registerButtonNative(as_object& global); 00203 00204 } // end namespace gnash 00205 00206 00207 #endif // GNASH_BUTTON_H 00208 00209 00210 // Local Variables: 00211 // mode: C++ 00212 // c-basic-offset: 8 00213 // tab-width: 8 00214 // indent-tabs-mode: t 00215 // End: