StaticGraphic.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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 }
00103
00104
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_