GG
|
00001 // -*- C++ -*- 00002 /* GG is a GUI for SDL and OpenGL. 00003 Copyright (C) 2003-2008 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_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 00057 class GG_API StaticGraphic : public Control 00058 { 00059 public: 00061 StaticGraphic(X x, Y y, X w, Y h, const boost::shared_ptr<Texture>& texture, Flags<GraphicStyle> style = GRAPHIC_NONE, Flags<WndFlag> flags = Flags<WndFlag>()); 00062 StaticGraphic(X x, Y y, X w, Y h, const SubTexture& subtexture, Flags<GraphicStyle> style = GRAPHIC_NONE, Flags<WndFlag> flags = Flags<WndFlag>()); 00063 00064 00066 00067 Flags<GraphicStyle> Style() const; 00068 00072 Rect RenderedArea() const; 00074 00076 virtual void Render(); 00077 00080 void SetStyle(Flags<GraphicStyle> style); 00081 00082 virtual void DefineAttributes(WndEditor* editor); 00084 00085 protected: 00087 StaticGraphic(); 00088 00089 00090 private: 00091 void Init(const SubTexture& subtexture); 00092 void ValidateStyle(); 00093 00094 SubTexture m_graphic; 00095 Flags<GraphicStyle> m_style; 00096 00097 friend class boost::serialization::access; 00098 template <class Archive> 00099 void serialize(Archive& ar, const unsigned int version); 00100 }; 00101 00102 } // namespace GG 00103 00104 // template implementations 00105 template <class Archive> 00106 void GG::StaticGraphic::serialize(Archive& ar, const unsigned int version) 00107 { 00108 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Control) 00109 & BOOST_SERIALIZATION_NVP(m_graphic) 00110 & BOOST_SERIALIZATION_NVP(m_style); 00111 00112 if (Archive::is_loading::value) 00113 ValidateStyle(); 00114 } 00115 00116 #endif // _GG_StaticGraphic_h_