Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef GNASH_BUTTON_H
00024 #define GNASH_BUTTON_H
00025
00026 #include "smart_ptr.h"
00027 #include "InteractiveObject.h"
00028
00029 #include <boost/intrusive_ptr.hpp>
00030 #include <vector>
00031 #include <set>
00032
00033
00034 namespace gnash {
00035 namespace SWF {
00036 class DefineButtonTag;
00037 }
00038 }
00039
00040 namespace gnash {
00041
00042
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
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
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
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
00133 virtual InfoTree::iterator getMovieInfo(InfoTree& tr,
00134 InfoTree::iterator it);
00135 #endif
00136
00137 protected:
00138
00140 virtual bool unloadChildren();
00141
00142 #ifdef GNASH_USE_GC
00143
00144
00150 void markOwnResources() const;
00151 #endif // GNASH_USE_GC
00152
00153 private:
00154
00156
00165 void getActiveCharacters(DisplayObjects& list, bool includeUnloaded=false);
00166
00168
00173 void getActiveCharacters(ConstDisplayObjects& list) const;
00174
00177
00184 void get_active_records(ActiveRecords& list, MouseState state);
00185
00187 virtual int getDefinitionVersion() const;
00188
00189 MouseState _mouseState;
00190
00191 const boost::intrusive_ptr<const SWF::DefineButtonTag> _def;
00192
00193 DisplayObjects _stateCharacters;
00194
00195 DisplayObjects _hitCharacters;
00196
00197
00198 };
00199
00200
00202 void button_class_init(as_object& global, const ObjectURI& uri);
00203
00204 void registerButtonNative(as_object& global);
00205
00206 }
00207
00208
00209 #endif // GNASH_BUTTON_H
00210
00211
00212
00213
00214
00215
00216
00217