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
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 }
00102
00103
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_