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
00092 void display(Renderer& renderer);
00093
00094 void set_current_state(MouseState new_state);
00095
00099
00102 virtual InteractiveObject* topmostMouseEntity(boost::int32_t x,
00103 boost::int32_t y);
00104
00105 virtual void mouseEvent(const event_id& event);
00106
00107 virtual bool handleFocus();
00108
00109 void add_invalidated_bounds(InvalidatedRanges& ranges, bool force);
00110
00111 virtual SWFRect getBounds() const;
00112
00113
00114 bool pointInShape(boost::int32_t x, boost::int32_t y) const;
00115
00116 bool isEnabled();
00117
00119 void destroy();
00120
00122
00125
00128 virtual void construct(as_object* init = 0);
00129
00130 #ifdef USE_SWFTREE
00131
00132 virtual InfoTree::iterator getMovieInfo(InfoTree& tr,
00133 InfoTree::iterator it);
00134 #endif
00135
00136 protected:
00137
00139 virtual bool unloadChildren();
00140
00141 #ifdef GNASH_USE_GC
00142
00143
00149 void markOwnResources() const;
00150 #endif // GNASH_USE_GC
00151
00152 private:
00153
00155
00164 void getActiveCharacters(DisplayObjects& list, bool includeUnloaded=false);
00165
00167
00172 void getActiveCharacters(ConstDisplayObjects& list) const;
00173
00176
00183 void get_active_records(ActiveRecords& list, MouseState state);
00184
00186 virtual int getDefinitionVersion() const;
00187
00188 MouseState _mouseState;
00189
00190 const boost::intrusive_ptr<const SWF::DefineButtonTag> _def;
00191
00192 DisplayObjects _stateCharacters;
00193
00194 DisplayObjects _hitCharacters;
00195
00196
00197 };
00198
00199
00201 void button_class_init(as_object& global, const ObjectURI& uri);
00202
00203 void registerButtonNative(as_object& global);
00204
00205 }
00206
00207
00208 #endif // GNASH_BUTTON_H
00209
00210
00211
00212
00213
00214
00215
00216