64 #ifndef GNASH_MOVIE_ROOT_H
65 #define GNASH_MOVIE_ROOT_H
77 #include <boost/array.hpp>
78 #include <boost/ptr_container/ptr_deque.hpp>
79 #include <boost/noncopyable.hpp>
80 #include <boost/any.hpp>
81 #include <boost/optional.hpp>
107 #ifndef GNASH_PARANOIA_LEVEL
108 # define GNASH_PARANOIA_LEVEL 1
113 class ExecutableCode;
162 void setReachable()
const;
164 boost::shared_ptr<IOChannel> _stream;
170 typedef std::bitset<key::KEYCOUNT>
Keys;
197 MovieClip* getLevel(
unsigned int num)
const;
205 void setLevel(
unsigned int num,
Movie* movie);
216 void replaceLevel(
unsigned int num,
Movie* external_movie);
232 void swapLevels(
MovieClip* sp,
int depth);
243 void dropLevel(
int depth);
252 void setDimensions(
size_t w,
size_t h);
255 size_t getStageWidth()
const;
258 size_t getStageHeight()
const;
270 DSOEXPORT bool mouseMoved(boost::int32_t
x, boost::int32_t
y);
296 std::pair<boost::int32_t, boost::int32_t> mousePosition()
const;
322 boost::uint32_t addIntervalTimer(std::auto_ptr<Timer> timer);
340 void addLoadableObject(
as_object* obj, std::auto_ptr<IOChannel> str);
349 bool clearIntervalTimer(boost::uint32_t
x);
351 void set_background_color(
const rgba&
color);
353 void set_background_alpha(
float alpha);
372 int timeToNextFrame()
const;
391 return ++_unnamedInstance;
395 void registerButton(
Button* listener);
398 void removeButton(
Button* listener);
441 bool testInvariant()
const;
446 DISPLAYSTATE_FULLSCREEN
494 void setStageAlignment(
short s);
498 void setAllowScriptAccess(AllowScriptAccessMode mode);
501 AllowScriptAccessMode getAllowScriptAccess();
503 typedef std::pair<StageHorizontalAlign, StageVerticalAlign>
StageAlign;
511 bool getShowMenuState()
const;
515 void setShowMenuState(
bool state);
524 std::string getStageAlignMode()
const;
530 void setStageDisplayState(
const DisplayState ds);
549 typedef boost::array<boost::ptr_deque<ExecutableCode>, PRIORITY_SIZE>
553 void pushAction(std::auto_ptr<ExecutableCode>
code,
size_t lvl);
568 void markReachableResources()
const;
581 #if GNASH_PARANOIA_LEVEL > 1
582 assert(std::find(_liveChars.begin(), _liveChars.end(), ch) ==
585 _liveChars.push_front(ch);
602 void disableScripts();
615 void flushHigherPriorityActionQueues();
617 DisplayObject* findCharacterByTarget(
const std::string& tgtstr)
const;
636 void loadMovie(
const std::string&
url,
const std::string& target,
640 _movieLoader.loadMovie(url, target, data, method, handler);
656 void getURL(
const std::string& urlstr,
const std::string& target,
661 return _lastKeyEvent;
665 return _unreleasedKeys;
717 _fsCommandHandler = handler;
721 DSOEXPORT void handleFsCommand(
const std::string& cmd,
722 const std::string& arg)
const;
731 _interfaceHandler = handler;
765 void setScriptLimits(boost::uint16_t recursion, boost::uint16_t timeout);
770 return _recursionLimit;
775 boost::uint16_t getTimeoutLimit()
const
777 return _timeoutLimit;
781 typedef tree<std::pair<std::string, std::string> > InfoTree;
782 void getMovieInfo(InfoTree& tr, InfoTree::iterator it);
783 void getCharacterTree(InfoTree& tr, InfoTree::iterator it);
789 void addExternalCallback(
const std::string& name,
as_object* callback);
793 std::string callExternalCallback(
const std::string &name,
794 const std::vector<as_value>& args);
796 std::string callExternalJavascript(
const std::string &name,
797 const std::vector<as_value>& args);
805 void removeQueuedConstructor(
MovieClip* target);
815 bool queryInterface(
const std::string& what)
const;
828 void setStreamBlock(
int id,
int block);
836 void stopStream(
int id);
863 void setRootMovie(
Movie* movie);
866 bool notify_mouse_listeners(
const event_id& event);
871 bool fire_mouse_event();
877 void executeAdvanceCallbacks();
880 void executeTimers();
883 void cleanupAndCollect();
901 boost::int32_t
y)
const;
905 void cleanupDisplayList();
908 void advanceLiveChars();
913 void setInvalidated() { _invalidated =
true; }
919 void clearInvalidated() { _invalidated =
false; }
929 bool isInvalidated() {
return _invalidated; }
935 size_t minPopulatedPriorityQueue()
const;
940 size_t processActionQueue(
size_t lvl);
942 bool processingActions()
const {
943 return (_processingActionLevel < PRIORITY_SIZE);
946 const DisplayObject* findDropTarget(boost::int32_t
x, boost::int32_t
y,
947 DisplayObject* dragging)
const;
949 void handleActionLimitHit(
const std::string& ref);
951 typedef std::list<Button*> ButtonListeners;
952 ButtonListeners _buttonListeners;
956 const RunResources& _runResources;
963 HostInterface* _interfaceHandler;
966 FsCallback* _fsCommandHandler;
974 typedef std::list<MovieClip*> LiveChars;
977 LiveChars _liveChars;
979 ActionQueue _actionQueue;
982 void processActionQueue();
988 rgba m_background_color;
989 bool m_background_color_set;
991 boost::int32_t _mouseX;
992 boost::int32_t _mouseY;
994 MouseButtonState _mouseButtonState;
997 typedef std::set<ActiveRelay*> ObjectCallbacks;
998 ObjectCallbacks _objectCallbacks;
1000 LoadCallbacks _loadCallbacks;
1002 typedef std::map<boost::uint32_t, boost::shared_ptr<Timer> > TimerMap;
1004 TimerMap _intervalTimers;
1006 size_t _lastTimerId;
1009 Keys _unreleasedKeys;
1014 DisplayObject* _currentFocus;
1017 boost::optional<DragState> _dragState;
1019 typedef std::map<int, MovieClip*> Levels;
1028 typedef std::map<const SWF::DefinitionTag*, as_function*> RegisteredClasses;
1029 RegisteredClasses _registeredClasses;
1041 bool _disableScripts;
1042 int _processingActionLevel;
1057 std::bitset<4u> _alignMode;
1059 AllowScriptAccessMode _allowScriptAccess;
1065 ScaleMode _scaleMode;
1068 DisplayState _displayState;
1071 boost::uint16_t _recursionLimit;
1074 boost::uint16_t _timeoutLimit;
1077 size_t _movieAdvancementDelay;
1080 size_t _lastMovieAdvancement;
1083 size_t _unnamedInstance;
1085 MovieLoader _movieLoader;
1087 struct SoundStream {
1088 SoundStream(
int i,
int b) : id(i), block(b) {}
1093 boost::optional<SoundStream> _timelineSound;
1105 bool isLevelTarget(
int version,
const std::string& name,
unsigned int& levelno);
1109 template<
typename T>
1113 if (!_interfaceHandler) {
1114 log_error(
"Hosting application registered no callback for "
1115 "messages, can't call %s(%s)");
1120 return boost::any_cast<
T>(_interfaceHandler->
call(e));
1122 catch (
const boost::bad_any_cast&) {
1123 log_error(
_(
"Unexpected type from host interface when requesting "
1131 #endif // GNASH_MOVIE_ROOT_H