Gnash 0.8.9

DragState.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
00003 //   2011 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 "SWFRect.h"
00023 #include "DisplayObject.h"
00024 
00025 // Forward declarations
00026 namespace gnash {
00027     class DisplayObject;
00028 }
00029 
00030 namespace gnash {
00031 
00033 class DragState
00034 {
00035 public:
00036 
00037     DragState(DisplayObject* d)
00038         :
00039         _hasbounds(false),
00040         _bounds(),
00041         _displayObject(d),
00042         _lock_centered(false)
00043     {
00044     }
00045 
00046     bool isLockCentered() const {
00047         return _lock_centered;
00048     }
00049 
00050     void setLockCentered(bool lock) {
00051         _lock_centered = lock;
00052     }
00053 
00058     void setOffset(boost::int32_t x, boost::int32_t y) {
00059         _xoffset = x;
00060         _yoffset = y;
00061     }
00062 
00063     boost::int32_t xOffset() const { return _xoffset; }
00064     boost::int32_t yOffset() const { return _yoffset; }
00065 
00066     bool hasBounds() const {
00067         return _hasbounds;
00068     }
00069 
00073     //
00081     const SWFRect& getBounds() const { return _bounds; }
00082 
00086     //
00090     void setBounds(const SWFRect& bounds) {
00091         _bounds = bounds;
00092         _hasbounds = true;
00093     }
00094 
00096     DisplayObject* getCharacter() const {
00097         return _displayObject;
00098     }
00099 
00101     void reset() {
00102         _displayObject = 0;
00103         _hasbounds = false;
00104         _bounds.set_null();
00105         _lock_centered = false;
00106     }
00107 
00109     void markReachableResources() const {
00110         if (_displayObject) _displayObject->setReachable();
00111     }
00112 
00113 private:
00114 
00115     bool _hasbounds;
00116 
00119     SWFRect _bounds;
00120 
00121     DisplayObject* _displayObject;
00122 
00123     bool _lock_centered;
00124 
00129     boost::int32_t _xoffset;
00130     boost::int32_t _yoffset;
00131 
00132 };
00133 
00134 
00135 } // namespace gnash
00136 
00137 #endif // GNASH_DRAG_STATE_H