StaticGraphic.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /* GG is a GUI for SDL and OpenGL.
00003    Copyright (C) 2003 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@hotmail.com */
00025 
00029 #ifndef _GG_StaticGraphic_h_
00030 #define _GG_StaticGraphic_h_
00031 
00032 #include <GG/Control.h>
00033 #include <GG/Texture.h>
00034 
00035 
00036 namespace GG {
00037 
00039 GG_FLAG_TYPE(GraphicStyle);
00040 extern GG_API const GraphicStyle GRAPHIC_NONE;        
00041 extern GG_API const GraphicStyle GRAPHIC_VCENTER;     
00042 extern GG_API const GraphicStyle GRAPHIC_TOP;         
00043 extern GG_API const GraphicStyle GRAPHIC_BOTTOM;      
00044 extern GG_API const GraphicStyle GRAPHIC_CENTER;      
00045 extern GG_API const GraphicStyle GRAPHIC_LEFT;        
00046 extern GG_API const GraphicStyle GRAPHIC_RIGHT;       
00047 extern GG_API const GraphicStyle GRAPHIC_FITGRAPHIC;  
00048 extern GG_API const GraphicStyle GRAPHIC_SHRINKFIT;   
00049 extern GG_API const GraphicStyle GRAPHIC_PROPSCALE;   
00050 
00051 
00055 class GG_API StaticGraphic : public Control
00056 {
00057 public: 
00059 
00062     StaticGraphic(int x, int y, int w, int h, const boost::shared_ptr<Texture>& texture, Flags<GraphicStyle> style = GRAPHIC_NONE, Flags<WndFlag> flags = Flags<WndFlag>()); 
00063     StaticGraphic(int x, int y, int w, int h, const SubTexture& subtexture, Flags<GraphicStyle> style = GRAPHIC_NONE, Flags<WndFlag> flags = Flags<WndFlag>()); 
00064 
00065  
00067 
00068     Flags<GraphicStyle> Style() const;
00069 
00072     Rect RenderedArea() const;
00074  
00076     virtual void Render();
00077 
00079     void SetStyle(Flags<GraphicStyle> style);
00080 
00081     virtual void DefineAttributes(WndEditor* editor);
00083 
00084 protected: 
00086     StaticGraphic(); 
00087 
00088 
00089 private:
00090     void     Init(const SubTexture& subtexture); 
00091     void     ValidateStyle();   
00092 
00093     SubTexture          m_graphic;
00094     Flags<GraphicStyle> m_style;        
00095 
00096     friend class boost::serialization::access;
00097     template <class Archive>
00098     void serialize(Archive& ar, const unsigned int version);
00099 };
00100 
00101 } // namespace GG
00102 
00103 // template implementations
00104 template <class Archive>
00105 void GG::StaticGraphic::serialize(Archive& ar, const unsigned int version)
00106 {
00107     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Control)
00108         & BOOST_SERIALIZATION_NVP(m_graphic)
00109         & BOOST_SERIALIZATION_NVP(m_style);
00110 
00111     if (Archive::is_loading::value)
00112         ValidateStyle();
00113 }
00114 
00115 #endif // _GG_StaticGraphic_h_

Generated on Wed Mar 26 14:35:42 2008 for GG by  doxygen 1.5.2