Gnash  0.8.10
DragState.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00003 //   Free Software 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 #ifndef GNASH_DRAG_STATE_H
00020 #define GNASH_DRAG_STATE_H
00021 
00022 #include <boost/optional.hpp>
00023 
00024 #include "SWFRect.h"
00025 #include "DisplayObject.h"
00026 
00027 // Forward declarations
00028 namespace gnash {
00029     class DisplayObject;
00030 }
00031 
00032 namespace gnash {
00033 
00035 class DragState
00036 {
00037 public:
00038 
00039     DragState(DisplayObject* d, bool lock)
00040         :
00041         _displayObject(d),
00042         _lock_centered(lock)
00043     {
00044     }
00045 
00046     bool isLockCentered() const {
00047         return _lock_centered;
00048     }
00049 
00054     void setOffset(boost::int32_t x, boost::int32_t y) {
00055         _xoffset = x;
00056         _yoffset = y;
00057     }
00058 
00059     boost::int32_t xOffset() const { return _xoffset; }
00060     boost::int32_t yOffset() const { return _yoffset; }
00061 
00062     bool hasBounds() const {
00063         return (_bounds);
00064     }
00065 
00069     //
00077     const SWFRect& getBounds() const { return *_bounds; }
00078 
00082     //
00086     void setBounds(const SWFRect& bounds) {
00087         _bounds = bounds;
00088     }
00089 
00091     DisplayObject* getCharacter() const {
00092         return _displayObject;
00093     }
00094 
00096     void reset() {
00097         _displayObject = 0;
00098         _bounds.reset();
00099         _lock_centered = false;
00100     }
00101 
00103     void markReachableResources() const {
00104         if (_displayObject) _displayObject->setReachable();
00105     }
00106 
00107 private:
00108 
00111     boost::optional<SWFRect> _bounds;
00112 
00113     DisplayObject* _displayObject;
00114 
00115     bool _lock_centered;
00116 
00121     boost::int32_t _xoffset;
00122     boost::int32_t _yoffset;
00123 
00124 };
00125 
00126 
00127 } // namespace gnash
00128 
00129 #endif // GNASH_DRAG_STATE_H