• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

Button.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
00003 //   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" // GNASH_USE_GC
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 
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         // See dox in DisplayObject.h
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         // Override to append button DisplayObjects info, see dox in DisplayObject.h
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 }       // end namespace gnash
00206 
00207 
00208 #endif // GNASH_BUTTON_H
00209 
00210 
00211 // Local Variables:
00212 // mode: C++
00213 // c-basic-offset: 8 
00214 // tab-width: 8
00215 // indent-tabs-mode: t
00216 // End:

Generated on Thu Sep 30 2010 14:34:56 for Gnash by  doxygen 1.7.1