GG

Cursor.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /* GG is a GUI for SDL and OpenGL.
00003    Copyright (C) 2007 T. Zachary Laine
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public License
00007    as published by the Free Software Foundation; either version 2.1
00008    of the License, or (at your option) any later version.
00009    
00010    This library 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 GNU
00013    Lesser General Public License for more details.
00014     
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with this library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA
00019 
00020    If you do not wish to comply with the terms of the LGPL please
00021    contact the author as other terms are available for a fee.
00022     
00023    Zach Laine
00024    whatwasthataddress@gmail.com */
00025    
00029 #ifndef _GG_Cursor_h_
00030 #define _GG_Cursor_h_
00031 
00032 #include <GG/PtRect.h>
00033 
00034 #include <boost/shared_ptr.hpp>
00035 
00036 
00037 namespace GG {
00038 
00039 class Texture;
00040 
00046 class GG_API Cursor
00047 {
00048 public: 
00050     Cursor();          
00051     virtual ~Cursor(); 
00052 
00053  
00055 
00057     virtual void Render(const Pt& pt) = 0;
00059 
00060 private:
00061     friend class boost::serialization::access;
00062     template <class Archive>
00063     void serialize(Archive& ar, const unsigned int version);
00064 };
00065 
00071 class GG_API TextureCursor :
00072     public Cursor
00073 {
00074 public: 
00076 
00079     TextureCursor(const boost::shared_ptr<Texture>& texture, const Pt& hotspot = Pt());
00081  
00083 
00084     const boost::shared_ptr<Texture>& GetTexture() const;
00085 
00087     const Pt& Hotspot() const;
00089  
00091     virtual void Render(const Pt& pt);
00093 
00094 private:
00095     boost::shared_ptr<Texture> m_texture;
00096     Pt                         m_hotspot;
00097 
00098     friend class boost::serialization::access;
00099     template <class Archive>
00100     void serialize(Archive& ar, const unsigned int version);
00101 };
00102 
00103 } // namespace GG
00104 
00105 // template implementations
00106 template <class Archive>
00107 void GG::Cursor::serialize(Archive& ar, const unsigned int version)
00108 {}
00109 
00110 template <class Archive>
00111 void GG::TextureCursor::serialize(Archive& ar, const unsigned int version)
00112 {
00113     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Cursor)
00114         & m_texture
00115         & m_hotspot;
00116 }
00117 
00118 #endif // _GG_Cursor_h_