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 <boost/intrusive_ptr.hpp>
00027 #include <vector>
00028 #include <set>
00029
00030 #include "InteractiveObject.h"
00031 #include "GnashKey.h"
00032
00033
00034 namespace gnash {
00035 namespace SWF {
00036 class DefineButtonTag;
00037 }
00038 }
00039
00040 namespace gnash {
00041
00043 class Button : public InteractiveObject
00044 {
00045 public:
00046
00047 typedef std::vector<DisplayObject*> DisplayObjects;
00048 typedef std::vector<const DisplayObject*> ConstDisplayObjects;
00049
00051 typedef std::set<int> ActiveRecords;
00052
00053 enum mouse_flags
00054 {
00055 FLAG_IDLE = 0,
00056 FLAG_OVER = 1,
00057 FLAG_DOWN = 2,
00058 OVER_DOWN = FLAG_OVER | FLAG_DOWN,
00059
00060
00061 OVER_UP = FLAG_OVER,
00062 OUT_DOWN = FLAG_DOWN
00063 };
00064
00065 enum MouseState
00066 {
00067 MOUSESTATE_UP = 0,
00068 MOUSESTATE_DOWN,
00069 MOUSESTATE_OVER,
00070 MOUSESTATE_HIT
00071 };
00072
00074
00076 Button(as_object* object, const SWF::DefineButtonTag* def,
00077 DisplayObject* parent);
00078
00079 ~Button();
00080
00081 bool mouseEnabled() const { return true; }
00082
00083 virtual bool trackAsMenu();
00084
00086 void keyPress(key::code c);
00087
00089 virtual void display(Renderer& renderer, const Transform& xform);
00090
00091 void set_current_state(MouseState new_state);
00092
00094
00096 virtual InteractiveObject* topmostMouseEntity(boost::int32_t x,
00097 boost::int32_t y);
00098
00100 virtual void mouseEvent(const event_id& event);
00101
00103 virtual bool handleFocus();
00104
00105 void add_invalidated_bounds(InvalidatedRanges& ranges, bool force);
00106
00107 virtual SWFRect getBounds() const;
00108
00109
00110 bool pointInShape(boost::int32_t x, boost::int32_t y) const;
00111
00112 bool isEnabled();
00113
00115 void destroy();
00116
00118
00120
00123 virtual void construct(as_object* init = 0);
00124
00125 #ifdef USE_SWFTREE
00126
00127 virtual InfoTree::iterator getMovieInfo(InfoTree& tr,
00128 InfoTree::iterator it);
00129 #endif
00130
00131 protected:
00132
00134 virtual bool unloadChildren();
00135
00137
00143 void markOwnResources() const;
00144
00145 private:
00146
00148
00154 void getActiveCharacters(DisplayObjects& list, bool includeUnloaded=false);
00155
00157
00162 void getActiveCharacters(ConstDisplayObjects& list) const;
00163
00166
00173 void get_active_records(ActiveRecords& list, MouseState state);
00174
00176 virtual int getDefinitionVersion() const;
00177
00178 MouseState _mouseState;
00179
00180 const boost::intrusive_ptr<const SWF::DefineButtonTag> _def;
00181
00182 DisplayObjects _stateCharacters;
00183
00184 DisplayObjects _hitCharacters;
00185
00186 };
00187
00188 std::ostream& operator<<(std::ostream& o, const Button::MouseState& st);
00189
00191 void button_class_init(as_object& global, const ObjectURI& uri);
00192
00193 void registerButtonNative(as_object& global);
00194
00195 }
00196
00197
00198 #endif // GNASH_BUTTON_H
00199
00200
00201
00202
00203
00204
00205
00206